summaryrefslogtreecommitdiff
path: root/game/server/tf2/tf_stressentities.cpp
blob: 27e5116add3e538b124215aa69e45c20399f4999 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "test_stressentities.h"
#include "tf_flare.h"
#include "tf_shareddefs.h"
#include "plasmaprojectile.h"


// ------------------------------------------------------------------------------------ //
// Functions to create random entities.
// ------------------------------------------------------------------------------------ //

CBaseEntity* CreateSignalFlare()
{
	CBaseEntity *pLocalPlayer = UTIL_GetLocalPlayer();
	if ( pLocalPlayer )
	{
		return CSignalFlare::Create( GetRandomSpot(), QAngle( 0, 0, 0 ), pLocalPlayer, 3 );
	}
	else
	{
		return NULL;
	}
}


CBaseEntity* CreateResourceChunk()
{
	CBaseEntity *pChunk = MoveToRandomSpot( CreateEntityByName( "resource_chunk" ) );
	if ( pChunk )
	{
		pChunk->Spawn();
	}

	return pChunk;
}


CBaseEntity* CreateResourceBox()
{
	CBaseEntity *pRet = MoveToRandomSpot( CreateEntityByName( "obj_box" ) );
	if ( pRet )
	{
		pRet->Spawn();
	}

	return pRet;
}

CBaseEntity* CreatePlasmaProjectile()
{
	CBaseEntity *pLocalPlayer = UTIL_GetLocalPlayer();
	if ( pLocalPlayer )
	{
		Vector vForward;
		vForward.Random(-1,1);
		VectorNormalize( vForward );

		CBasePlasmaProjectile *pRet = CBasePlasmaProjectile::Create( 
			Vector(0,0,0),
			vForward,
			0,
			pLocalPlayer );

		if ( pRet )
			MoveToRandomSpot( pRet );

		return pRet;
	}

	return NULL;
}

CBaseEntity* CreatePlasmaShot()
{
	CBaseEntity *pEnt = MoveToRandomSpot( CreateEntityByName( "base_plasmaprojectile" ) );
	if ( pEnt )
	{
		CBasePlasmaProjectile *pRet = dynamic_cast< CBasePlasmaProjectile* >( pEnt );
		if ( pRet )
		{
			return pRet;
		}
		else
		{
			UTIL_Remove( pEnt );
		}
	}

	return NULL;
}


REGISTER_STRESS_ENTITY( CreateResourceChunk );
REGISTER_STRESS_ENTITY( CreateResourceBox );
REGISTER_STRESS_ENTITY( CreatePlasmaProjectile );
REGISTER_STRESS_ENTITY( CreatePlasmaShot );
REGISTER_STRESS_ENTITY( CreateSignalFlare );