aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/server/testfunctions.cpp
blob: c949a1da6a38ea75ee3d691283d2892b95dfc537 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//========= Copyright 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( const CCommand &args )
{
	if ( args.ArgC() < 2 )
	{
		Error( "Test_CreateEntity: requires entity classname argument." );
	}

	const char *pClassName = args[ 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 );