mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
Added most recent version of unmodified HL2 SDK for Episode 1 engine
This commit is contained in:
62
dlls/testfunctions.cpp
Normal file
62
dlls/testfunctions.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "convar.h"
|
||||
#include "tier0/dbg.h"
|
||||
#include "player.h"
|
||||
#include "world.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
void Test_CreateEntity()
|
||||
{
|
||||
if ( engine->Cmd_Argc() < 2 )
|
||||
{
|
||||
Error( "Test_CreateEntity: requires entity classname argument." );
|
||||
}
|
||||
|
||||
const char *pClassName = engine->Cmd_Argv( 1 );
|
||||
|
||||
if ( !CreateEntityByName( pClassName ) )
|
||||
{
|
||||
Error( "Test_CreateEntity( %s ) failed.", pClassName );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Test_RandomPlayerPosition()
|
||||
{
|
||||
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
|
||||
CWorld *pWorld = GetWorldEntity();
|
||||
if ( !pPlayer )
|
||||
{
|
||||
Error( "Test_RandomPlayerPosition: no local player entity." );
|
||||
}
|
||||
else if ( !pWorld )
|
||||
{
|
||||
Error( "Test_RandomPlayerPosition: no world entity." );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vector vMin, vMax;
|
||||
pWorld->GetWorldBounds( vMin, vMax );
|
||||
|
||||
Vector vecOrigin;
|
||||
vecOrigin.x = RandomFloat( vMin.x, vMax.x );
|
||||
vecOrigin.y = RandomFloat( vMin.y, vMax.y );
|
||||
vecOrigin.z = RandomFloat( vMin.z, vMax.z );
|
||||
pPlayer->ForceOrigin( vecOrigin );
|
||||
}
|
||||
|
||||
|
||||
ConCommand cc_Test_CreateEntity( "Test_CreateEntity", Test_CreateEntity, 0, FCVAR_CHEAT );
|
||||
ConCommand cc_Test_RandomPlayerPosition( "Test_RandomPlayerPosition", Test_RandomPlayerPosition, 0, FCVAR_CHEAT );
|
||||
|
||||
|
Reference in New Issue
Block a user