summaryrefslogtreecommitdiff
path: root/game/server/tf/entity_rune.cpp
blob: 3018a9ce4f8994634a0bee895eb06a826db95161 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: CTF Rune.
//
//=============================================================================//
#include "cbase.h"
#include "items.h"
#include "tf_gamerules.h"
#include "tf_shareddefs.h"
#include "tf_player.h"
#include "tf_team.h"
#include "engine/IEngineSound.h"
#include "entity_rune.h"
#include "tf_gamestats.h"
#include "func_respawnroom.h"
#include "particle_parse.h"
#include "tf_fx.h"
#include "collisionutils.h"

//=============================================================================
//
// CTF Rune defines.
//

extern ConVar tf_powerup_mode;

#define RUNE_BLINK_CONTEXT "blink_think"

#define TF_RUNE_TEMP_RESPAWN_DELAY 	90.f
#define TF_RUNE_TEMP_UBER_RESPAWN_DELAY 	180.f

// Regular Runes (non temporary) will reposition themselves if they haven't been picked up in time
#define BLINK_TIME 10.f

LINK_ENTITY_TO_CLASS( item_powerup_rune, CTFRune );
LINK_ENTITY_TO_CLASS( item_powerup_rune_temp, CTFRuneTemp );
LINK_ENTITY_TO_CLASS( item_powerup_crit, CTFRuneTempCrit );
LINK_ENTITY_TO_CLASS( item_powerup_uber, CTFRuneTempUber );
LINK_ENTITY_TO_CLASS( info_powerup_spawn, CTFInfoPowerupSpawn );

IMPLEMENT_AUTO_LIST( IInfoPowerupSpawnAutoList );

//=============================================================================
//
// CTF Rune functions.
//

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTFRune::CTFRune()
{
	m_bApplyForce = true;
	m_nRuneType = RUNE_STRENGTH;
	m_nTeam = TEAM_ANY;
	m_bShouldReposition = false;
}

//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
CTFRune::~CTFRune()
{
}

//-----------------------------------------------------------------------------
// Purpose: Spawn powerup rune
//-----------------------------------------------------------------------------
void CTFRune::Spawn( void )
{
	BaseClass::Spawn();

	RemoveSolidFlags( FSOLID_TRIGGER );
	m_bActivateWhenAtRest = true;

	m_vecSpawnDirection.z = 0.7f;
	VectorNormalize( m_vecSpawnDirection );
	SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
	SetSolid( SOLID_BBOX );
	if ( m_bApplyForce )
	{
		SetAbsVelocity( m_vecSpawnDirection * 350.f );
		m_bThrownSingleInstance = true;
	}

	// Reposition if not picked up in time
	m_nBlinkCount = 0;
	m_flKillTime = gpGlobals->curtime + GetRuneRepositionTime() + BLINK_TIME;
	if ( m_bShouldReposition )
	{
		SetContextThink( &CTFRune::BlinkThink, gpGlobals->curtime + GetRuneRepositionTime(), RUNE_BLINK_CONTEXT );
	}
}


//-----------------------------------------------------------------------------
// Purpose: Precache function for the powerup rune
//-----------------------------------------------------------------------------
void CTFRune::Precache( void )
{
	PrecacheScriptSound( "Powerup.PickUpResistance" );
	PrecacheScriptSound( "Powerup.PickUpRegeneration" );
	PrecacheScriptSound( "Powerup.PickUpStrength" );
	PrecacheScriptSound( "Powerup.PickUpHaste" );
	PrecacheScriptSound( "Powerup.PickUpVampire" );
	PrecacheScriptSound( "Powerup.PickUpReflect" );
	PrecacheScriptSound( "Powerup.PickUpPrecision" );
	PrecacheScriptSound( "Powerup.PickUpAgility" );
	PrecacheScriptSound( "Powerup.PickUpKnockout" );
	PrecacheScriptSound( "Powerup.Knockout_Melee_Hit" );
	PrecacheScriptSound( "Powerup.Reflect.Reflect" );
	PrecacheScriptSound( "Powerup.PickUpKing" );
	PrecacheScriptSound( "Powerup.PickUpPlague" ); 
	PrecacheScriptSound( "Powerup.PickUpSupernova" );
	PrecacheScriptSound( "Powerup.PickUpSupernovaActivate" );
	PrecacheScriptSound( "Powerup.PickUpPlagueInfected" );
	PrecacheScriptSound( "Powerup.PickUpPlagueInfectedLoop" );
	PrecacheModel( GetDefaultPowerupModel() ); 
	PrecacheModel( TF_RUNE_STRENGTH );
	PrecacheModel( TF_RUNE_RESIST );
	PrecacheModel( TF_RUNE_REGEN );
	PrecacheModel( TF_RUNE_HASTE );
	PrecacheModel( TF_RUNE_VAMPIRE );
	PrecacheModel( TF_RUNE_REFLECT );
	PrecacheModel( TF_RUNE_PRECISION );
	PrecacheModel( TF_RUNE_AGILITY );
	PrecacheModel( TF_RUNE_KNOCKOUT );
	PrecacheModel( TF_RUNE_KING );
	PrecacheModel( TF_RUNE_PLAGUE );
	PrecacheModel( TF_RUNE_SUPERNOVA );

	// precache all powerup icons
	for ( int i=0; i<RUNE_TYPES_MAX; ++i )
	{
		RuneTypes_t type = RuneTypes_t(i);
		PrecacheParticleSystem( GetPowerupIconName( type, TF_TEAM_RED ) );
		PrecacheParticleSystem( GetPowerupIconName( type, TF_TEAM_BLUE ) );
	}

	PrecacheParticleSystem( "plague_infect_player" ); 
	PrecacheParticleSystem( "plague_healthkit_pickup" );
	PrecacheParticleSystem( "powerup_king_red" );
	PrecacheParticleSystem( "powerup_king_blue" );
	PrecacheParticleSystem( "powerup_supernova_ready" );
	PrecacheParticleSystem( "powerup_supernova_strike_red" );
	PrecacheParticleSystem( "powerup_supernova_strike_blue" );
	PrecacheParticleSystem( "powerup_supernova_explode_red" );
	PrecacheParticleSystem( "powerup_supernova_explode_blue" );
	PrecacheParticleSystem( "powerup_plague_carrier" );

	BaseClass::Precache();
}

//-----------------------------------------------------------------------------
// Purpose: Make sure Powerup Runes that are away from any players at spawn will accept particle attachments
//-----------------------------------------------------------------------------
int CTFRune::UpdateTransmitState()
{
	return SetTransmitState( FL_EDICT_ALWAYS );
}

//-----------------------------------------------------------------------------
// Purpose: Make sure Powerup Runes that are away from any players at spawn will accept particle attachments
//-----------------------------------------------------------------------------
int CTFRune::ShouldTransmit( const CCheckTransmitInfo *pInfo )
{
	return FL_EDICT_ALWAYS;
}


//-----------------------------------------------------------------------------
// Purpose: MyTouch function for the powerup rune
//-----------------------------------------------------------------------------
bool CTFRune::MyTouch( CBasePlayer *pPlayer )
{
	bool bSuccess = ValidTouch( pPlayer );
	if ( bSuccess )
	{
		CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
		if ( !pTFPlayer )
			return false;

		// don't allow different team player to pick up team based rune unless they are a spy disguised as the correct team
		if ( m_nTeam != TEAM_ANY && m_nTeam != pTFPlayer->GetTeamNumber() )
			if ( !pTFPlayer->GetPlayerClass()->IsClass( TF_CLASS_SPY ) || pTFPlayer->m_Shared.GetDisguiseTeam() != m_nTeam )
			{
				return false;
			}

		if ( pTFPlayer->m_Shared.IsStealthed() || 
			pTFPlayer->m_Shared.InCond( TF_COND_STEALTHED_BLINK ) || 
			pTFPlayer->m_Shared.GetPercentInvisible() > 0.25f )
		{
			return false;
		}

		if ( pTFPlayer->m_Shared.IsCarryingRune() )
		{
			ClientPrint( pPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Deny" );
			return false;
		}

		if ( pTFPlayer->IsTaunting() )
		{
			return false;
		}

#ifdef GAME_DLL
		if ( PointInRespawnRoom( pTFPlayer, pTFPlayer->WorldSpaceCenter() ) )
			return false;
#endif
		Assert( m_nRuneType >= 0 && m_nRuneType < RUNE_TYPES_MAX );

		// Order is important because SetSpeed has to occur once SetCarryingRuneType has happened
		pTFPlayer->m_Shared.SetCarryingRuneType( m_nRuneType );
		CPASAttenuationFilter filter( pTFPlayer );

		switch ( m_nRuneType )
		{
		case RUNE_STRENGTH:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Strength" );
			pTFPlayer->EmitSound( "Powerup.PickUpStrength" );
			break;
		case RUNE_RESIST:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Resist" );
			pTFPlayer->EmitSound( "Powerup.PickUpResistance" );
			break;
		case RUNE_REGEN:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Regen" );
			pTFPlayer->EmitSound( "Powerup.PickUpRegeneration" );
			break;
		case RUNE_HASTE:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Haste" );
			pTFPlayer->EmitSound( "Powerup.PickUpHaste" );
			pTFPlayer->TeamFortress_SetSpeed();
			break;
		case RUNE_VAMPIRE:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Vampire" );
			pTFPlayer->EmitSound( "Powerup.PickUpVampire" );
			break;
		case RUNE_REFLECT:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Reflect" );
			pTFPlayer->EmitSound( "Powerup.PickUpReflect" );
			break;
		case RUNE_PRECISION:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Precision" );
			pTFPlayer->EmitSound( "Powerup.PickUpPrecision" );
			break;
		case RUNE_AGILITY:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Agility" );
			pTFPlayer->EmitSound( "Powerup.PickUpAgility" );
			pTFPlayer->TeamFortress_SetSpeed();
			break;
		case RUNE_KNOCKOUT:
		{
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Knockout" );
			pTFPlayer->EmitSound( "Powerup.PickUpKnockout" );

			// Switch to melee to make sure Engies don't have build menus open
			CTFWeaponBase *pMeleeWeapon = dynamic_cast<CTFWeaponBase*>( pTFPlayer->GetEntityForLoadoutSlot( LOADOUT_POSITION_MELEE ) );
			Assert( pMeleeWeapon );
			if ( pMeleeWeapon )
			{
				if ( pTFPlayer->GetActiveTFWeapon() && pTFPlayer->GetActiveTFWeapon()->GetWeaponID() != TF_WEAPON_GRAPPLINGHOOK )
				{
					pTFPlayer->Weapon_Switch( pMeleeWeapon );
				}
				else
				{
					// when the player switch away from the hook, it'll go to the last weapon.
					// force it to be melee weapon
					pTFPlayer->Weapon_SetLast( pMeleeWeapon );
				}
			}

			pTFPlayer->m_Shared.AddCond( TF_COND_CANNOT_SWITCH_FROM_MELEE );
		}
			break;
		case RUNE_KING:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_King" );
			pTFPlayer->EmitSound( "Powerup.PickUpKing" );
			break;
		case RUNE_PLAGUE:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Plague" );
			pTFPlayer->EmitSound( "Powerup.PickUpPlague" );
			break;
		case RUNE_SUPERNOVA:
			ClientPrint( pTFPlayer, HUD_PRINTCENTER, "#TF_Powerup_Pickup_Supernova" );
			pTFPlayer->EmitSound( "Powerup.PickUpSupernova" );
			break;
		}
		UTIL_Remove( this ); //power-up runes don't respawn, only one of them exists in the game
	}

	return bSuccess;
}

//-----------------------------------------------------------------------------
// Purpose: Create an instance of a powerup rune and drop it into the world with a random vector velocity
//-----------------------------------------------------------------------------
CTFRune* CTFRune::CreateRune( const Vector &vecOrigin, RuneTypes_t nType, int nTeam, bool bShouldReposition, bool bApplyForce, Vector vecSpawnDirection /*= vec3_angle*/ )
{
	// Make sure we're passing in a valid rune type
	Assert( nType >= 0 && nType < RUNE_TYPES_MAX );

	CTFRune *pRune = NULL;
	pRune = static_cast< CTFRune* >( CBaseEntity::CreateNoSpawn( "item_powerup_rune", vecOrigin + Vector( 0.f, 0.f, 48.f ), vec3_angle, NULL ) );
	pRune->m_bApplyForce = bApplyForce;
	pRune->m_nRuneType = nType;
	pRune->m_vecSpawnDirection = vecSpawnDirection;
	pRune->m_nTeam = nTeam;
	pRune->m_bShouldReposition = bShouldReposition;

	if ( nTeam == TEAM_ANY )
		pRune->m_nSkin = 0;
	else
		pRune->m_nSkin = nTeam == TF_TEAM_RED ? 1 : 2;

	DispatchSpawn( pRune );

	return pRune;
}

//-----------------------------------------------------------------------------
// Respawn the Powerup Rune in the event of it coming to rest inside a trigger_hurt or respawn room trigger
//-----------------------------------------------------------------------------
void CTFRune::ComeToRest( void )
{
	BaseClass::ComeToRest();

	// See if we've come to rest in a trigger_hurt or a respawn room trigger. If so, immediately reposition the Powerup

	for ( int i = 0; i < ITriggerHurtAutoList::AutoList().Count(); i++ )
	{
		CTriggerHurt *pTrigger = static_cast< CTriggerHurt* >( ITriggerHurtAutoList::AutoList()[i] );
		if ( pTrigger->m_bDisabled )
			continue;

		Vector vecMins, vecMaxs;
		pTrigger->GetCollideable()->WorldSpaceSurroundingBounds( &vecMins, &vecMaxs );
		if ( IsPointInBox( GetCollideable()->GetCollisionOrigin(), vecMins, vecMaxs ) )
		{
			if ( RepositionRune( m_nRuneType, m_nTeam ) )
			{
				UTIL_Remove( this );
			}
			return;
		}
	}
	
	for ( int j = 0; j < IFuncRespawnRoomAutoList::AutoList().Count(); j++ )
	{
		CFuncRespawnRoom *pRespawnRoom = static_cast<CFuncRespawnRoom*>( IFuncRespawnRoomAutoList::AutoList()[j] );
		Vector vecMins, vecMaxs;

		pRespawnRoom->GetCollideable()->WorldSpaceSurroundingBounds( &vecMins, &vecMaxs );
		if ( IsPointInBox( GetCollideable()->GetCollisionOrigin(), vecMins, vecMaxs ) )
		{
			if ( RepositionRune( m_nRuneType, m_nTeam ) )
			{
				UTIL_Remove( this );
			}
			return;
		}
	}
}

//-----------------------------------------------------------------------------
// Purpose: Enter blinking state before removing and respawning this Powerup
//-----------------------------------------------------------------------------
void CTFRune::BlinkThink()
{
	float flTimeToKill = m_flKillTime - gpGlobals->curtime;
	float flNextBlink = RemapValClamped( flTimeToKill, BLINK_TIME, 0.f, 0.5f, 0.1f );

	SetCycle( RandomFloat() );

	SetContextThink( &CTFRune::BlinkThink, gpGlobals->curtime + flNextBlink, RUNE_BLINK_CONTEXT );

	SetRenderMode( kRenderTransAlpha );

	++m_nBlinkCount;
	if ( m_nBlinkCount % 2 == 0 )
	{
		SetRenderColorA( 25 );
	}
	else
	{
		SetRenderColorA( 255 );
	}
	if ( gpGlobals->curtime >= m_flKillTime )
	{
		if ( RepositionRune( m_nRuneType, m_nTeam ) )
		{
			UTIL_Remove( this );
		}
	}
}

//-----------------------------------------------------------------------------
// Purpose: Enter blinking state before removing and respawning this Powerup
//-----------------------------------------------------------------------------
bool CTFRune::RepositionRune( RuneTypes_t nType, int nTeamNumber )
{
	// Powerups will pick a spawn point based on what team color they were when they repositioned. First try your own team color, then neutral, then enemy

	CUtlVector< CTFInfoPowerupSpawn* > vecSpawnPoints;
	if ( nTeamNumber != TEAM_ANY )
	{
		for ( int n = 0; n < IInfoPowerupSpawnAutoList::AutoList().Count(); n++ )
		{
			CTFInfoPowerupSpawn *pSpawnPoint = static_cast<CTFInfoPowerupSpawn*>( IInfoPowerupSpawnAutoList::AutoList()[n] );
			// We want to try to spawn on a point that matches the team color
			if ( !pSpawnPoint->IsDisabled() && !pSpawnPoint->HasRune() && pSpawnPoint->GetTeamNumber() == nTeamNumber )
			{
				vecSpawnPoints.AddToTail( pSpawnPoint );
			}
		}
	}
	if ( nTeamNumber == TEAM_ANY || vecSpawnPoints.Count() < 1 )
	{
		for ( int n = 0; n < IInfoPowerupSpawnAutoList::AutoList().Count(); n++ )
		{
			CTFInfoPowerupSpawn *pSpawnPoint = static_cast<CTFInfoPowerupSpawn*>( IInfoPowerupSpawnAutoList::AutoList()[n] );
			// Don't include disabled info_powerup_spawn positions or ones that already have runes on them
			if ( !pSpawnPoint->IsDisabled() && !pSpawnPoint->HasRune() )
			{
				vecSpawnPoints.AddToTail( pSpawnPoint );
			}
		}
	}

	Assert( vecSpawnPoints.Count() > 0 ); // We need at least one valid info_powerup_spawn position

	if ( vecSpawnPoints.Count() )
	{
		int index = RandomInt( 0, vecSpawnPoints.Count() - 1 );
		CTFInfoPowerupSpawn *pSpawnPoint = vecSpawnPoints[index];
		CTFRune *pNewRune = CreateRune( vecSpawnPoints[index]->GetAbsOrigin(), nType, TEAM_ANY, false, false );
		pSpawnPoint->SetRune( pNewRune );

		return true;
	}

	return false;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------

float CTFRune::GetRuneRepositionTime()
{
	// In freeforall mode, killed players drop enemy team colored powerups. These powerups reposition quicker 
	if ( m_nTeam != TEAM_ANY )
	{
		return 30.f;
	}
	else
	{
		return 60.f;
	}
}



//=============================================================================
//
// CTF Temporary Rune functions.
//
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTFRuneTemp::CTFRuneTemp()
{
	m_nRuneTempType = RUNETYPE_TEMP_NONE;
}

//-----------------------------------------------------------------------------
// Purpose: Precache function for the temporary powerup rune
//-----------------------------------------------------------------------------
void CTFRuneTemp::Precache( void )
{
	PrecacheScriptSound( "Powerup.PickUpTemp.Crit" );
	PrecacheScriptSound( "Powerup.PickUpTemp.Uber" );
	PrecacheModel( TF_RUNE_TEMP_CRIT );
	PrecacheModel( TF_RUNE_TEMP_UBER );

	BaseClass::Precache();
}

//-----------------------------------------------------------------------------
// Purpose: Spawn Temporary powerup rune
//-----------------------------------------------------------------------------
void CTFRuneTemp::Spawn( void )
{
	if ( TFGameRules() && TFGameRules()->IsPowerupMode() )
	{
		BaseClass::Spawn();

		SetMoveType( MOVETYPE_NONE );
		SetSolid( SOLID_BBOX );
	}
}

//-----------------------------------------------------------------------------
// Purpose: MyTouch function for the temporary powerup rune - needed because these respawn, and don't set the condition TF_COND_RUNE
//-----------------------------------------------------------------------------
bool CTFRuneTemp::MyTouch( CBasePlayer *pPlayer )
{
	bool bSuccess = ValidTouch( pPlayer );
	if ( bSuccess )
	{
		CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
		if ( !pTFPlayer )
			return false;

		if ( pTFPlayer->m_Shared.IsStealthed() || pTFPlayer->m_Shared.InCond( TF_COND_STEALTHED_BLINK ) || pTFPlayer->m_Shared.GetPercentInvisible() > 0.25f )
		{
			return false;
		}
		
		if ( pTFPlayer->m_Shared.InCond( TF_COND_RUNE_IMBALANCE ) )
		{
			return false;
		}

		if ( pTFPlayer->IsTaunting() )
		{
			return false;
		}
		
		if ( pTFPlayer->m_Shared.InCond( TF_COND_INVULNERABLE_USER_BUFF ) || pTFPlayer->m_Shared.InCond( TF_COND_CRITBOOSTED_RUNE_TEMP ) )
		{
			return false;
		}

		if ( m_nRuneTempType == RUNETYPE_TEMP_CRIT )
		{
			if ( pTFPlayer->m_Shared.IsCritBoosted() ) // Disallow players who are already crit boosted
			{
				return false;
			}
			else
			{
				pTFPlayer->m_Shared.AddCond( TF_COND_CRITBOOSTED_RUNE_TEMP, 30.f );
				pTFPlayer->EmitSound( "Powerup.PickUpTemp.Crit" );
			}
		}

		if ( m_nRuneTempType == RUNETYPE_TEMP_UBER )
		{
			if ( pTFPlayer->HasTheFlag() || pTFPlayer->m_Shared.IsInvulnerable() ) // Disallow players who have the flag or are already ubercharged
			{
				return false;
			}
			else
			{
				pTFPlayer->m_Shared.AddCond( TF_COND_INVULNERABLE_USER_BUFF, 20.f );
				pTFPlayer->EmitSound( "Powerup.PickUpTemp.Uber" );
			}
		}
	}
	return bSuccess;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
float CTFRuneTemp::GetRespawnDelay( void )
{
	if ( m_nRuneTempType == RUNETYPE_TEMP_UBER )
	{
		return TF_RUNE_TEMP_UBER_RESPAWN_DELAY;
	}
	else
		return TF_RUNE_TEMP_RESPAWN_DELAY;
}

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTFRuneTempCrit::CTFRuneTempCrit()
{
	m_nRuneTempType = RUNETYPE_TEMP_CRIT;
}

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTFRuneTempUber::CTFRuneTempUber()
{
	m_nRuneTempType = RUNETYPE_TEMP_UBER;
}

BEGIN_DATADESC( CTFInfoPowerupSpawn )

	DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "disabled" ),
	DEFINE_KEYFIELD( m_nTeam, FIELD_INTEGER, "team" ),

END_DATADESC()

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTFInfoPowerupSpawn::CTFInfoPowerupSpawn()
{
	m_bDisabled = false;
	m_nTeam = TEAM_ANY;
}

void CTFInfoPowerupSpawn::Spawn()
{
	BaseClass::Spawn();

	// set baseclass team number
	ChangeTeam( m_nTeam );
}