summaryrefslogtreecommitdiff
path: root/game/shared/tf/entity_halloween_pickup.cpp
blob: 4ada8f17e248ad4ad7d19ccb782277db97098269 (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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: CTF HealthKit.
//
//=============================================================================//
#include "cbase.h"
#include "entity_halloween_pickup.h"

#ifdef GAME_DLL
#include "items.h"
#include "tf_gamerules.h"
#include "tf_player.h"
#include "tf_team.h"
#include "engine/IEngineSound.h"
#include "entity_halloween_pickup.h"
#include "tf_fx.h"
#include "tf_logic_halloween_2014.h"
#endif // GAME_DLL

#ifdef CLIENT_DLL
#include "c_tf_player.h"
#endif 

#include "tf_shareddefs.h"
#include "tf_duckleaderboard.h"


#define TF_HALLOWEEN_PICKUP_RETURN_DELAY	10

#ifdef GAME_DLL
IMPLEMENT_AUTO_LIST( IHalloweenGiftSpawnAutoList );
#endif // GAME_DLL

//=============================================================================
//
// CTF Halloween Pickup defines.

IMPLEMENT_NETWORKCLASS_ALIASED( HalloweenPickup, DT_CHalloweenPickup )

BEGIN_NETWORK_TABLE( CHalloweenPickup, DT_CHalloweenPickup )
END_NETWORK_TABLE()

BEGIN_DATADESC( CHalloweenPickup )
	DEFINE_KEYFIELD( m_iszSound, FIELD_STRING, "pickup_sound" ),
	DEFINE_KEYFIELD( m_iszParticle, FIELD_STRING, "pickup_particle" ),

#ifdef GAME_DLL
	DEFINE_OUTPUT( m_OnRedPickup, "OnRedPickup" ),
	DEFINE_OUTPUT( m_OnBluePickup, "OnBluePickup" ),
#endif
END_DATADESC();
										 
LINK_ENTITY_TO_CLASS( tf_halloween_pickup, CHalloweenPickup );

// ************************************************************************************
BEGIN_DATADESC( CBonusDuckPickup )
//	DEFINE_KEYFIELD( m_iszSound, FIELD_STRING, "pickup_sound" ),
//	DEFINE_KEYFIELD( m_iszParticle, FIELD_STRING, "pickup_particle" ),
END_DATADESC();

IMPLEMENT_NETWORKCLASS_ALIASED( BonusDuckPickup, DT_CBonusDuckPickup )

BEGIN_NETWORK_TABLE( CBonusDuckPickup, DT_CBonusDuckPickup )
#ifdef GAME_DLL
	SendPropBool( SENDINFO( m_bSpecial ) ),
#else
	RecvPropBool( RECVINFO( m_bSpecial ) ),
#endif
END_NETWORK_TABLE()

LINK_ENTITY_TO_CLASS( tf_bonus_duck_pickup, CBonusDuckPickup );
// ************************************************************************************
#ifdef GAME_DLL
LINK_ENTITY_TO_CLASS( tf_halloween_gift_spawn_location, CHalloweenGiftSpawnLocation );
#endif
// ************************************************************************************
IMPLEMENT_NETWORKCLASS_ALIASED( HalloweenGiftPickup, DT_CHalloweenGiftPickup )

BEGIN_NETWORK_TABLE( CHalloweenGiftPickup, DT_CHalloweenGiftPickup )
#ifdef CLIENT_DLL
RecvPropEHandle( RECVINFO( m_hTargetPlayer ) ),
#else
SendPropEHandle( SENDINFO( m_hTargetPlayer ) ),
#endif
END_NETWORK_TABLE()

BEGIN_DATADESC( CHalloweenGiftPickup )
END_DATADESC();

LINK_ENTITY_TO_CLASS( tf_halloween_gift_pickup, CHalloweenGiftPickup );
// ************************************************************************************

// ************************************************************************************


ConVar tf_halloween_gift_lifetime( "tf_halloween_gift_lifetime", "240", FCVAR_CHEAT | FCVAR_REPLICATED );

#ifdef STAGING_ONLY
ConVar tf_halloween_gift_soul_value( "tf_halloween_gift_soul_value", "10", FCVAR_CHEAT | FCVAR_REPLICATED );
#endif

//=============================================================================
//
// CTF Halloween Pickup functions.
//

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CHalloweenPickup::CHalloweenPickup()
{
#ifdef GAME_DLL
	ChangeTeam( TEAM_UNASSIGNED );
#endif

	m_iszSound = MAKE_STRING( "Halloween.Quack" );
	m_iszParticle = MAKE_STRING( "halloween_explosion" );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CHalloweenPickup::~CHalloweenPickup()
{
}

//-----------------------------------------------------------------------------
// Purpose: Precache function for the pickup
//-----------------------------------------------------------------------------
void CHalloweenPickup::Precache( void )
{
	// We deliberately allow late precaches here
	bool bAllowPrecache = CBaseEntity::IsPrecacheAllowed();
	CBaseEntity::SetAllowPrecache( true );
	PrecacheScriptSound( TF_HALLOWEEN_PICKUP_DEFAULT_SOUND );
	if ( m_iszSound != NULL_STRING )
	{
		PrecacheScriptSound( STRING( m_iszSound ) );
	}
	if ( m_iszParticle != NULL_STRING )
	{
		PrecacheParticleSystem( STRING( m_iszParticle ) );
	}
	BaseClass::Precache();
	CBaseEntity::SetAllowPrecache( bAllowPrecache );
}

#ifdef GAME_DLL
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CHalloweenPickup::UpdateTransmitState()
{
	return SetTransmitState( FL_EDICT_ALWAYS );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CHalloweenPickup::ShouldTransmit( const CCheckTransmitInfo *pInfo )
{
	return FL_EDICT_ALWAYS;
}

//-----------------------------------------------------------------------------
// Purpose: MyTouch function for the pickup
//-----------------------------------------------------------------------------
bool CHalloweenPickup::MyTouch( CBasePlayer *pPlayer )
{
	bool bSuccess = false;

	if ( ValidTouch( pPlayer ) )
	{
		bSuccess = true;

		switch( pPlayer->GetTeamNumber() )
		{
		case TF_TEAM_BLUE:
			m_OnBluePickup.FireOutput( this, this );
			break;
		case TF_TEAM_RED:
			m_OnRedPickup.FireOutput( this, this );
			break;
		}

		Vector vecOrigin = GetAbsOrigin() + Vector( 0, 0, 32 );
		CPVSFilter filter( vecOrigin );
		if ( m_iszSound != NULL_STRING )
		{
			EmitSound( filter, entindex(), STRING( m_iszSound ) );
		}
		else
		{
			EmitSound( filter, entindex(), TF_HALLOWEEN_PICKUP_DEFAULT_SOUND );
		}

		if ( m_iszParticle != NULL_STRING )
		{
			TE_TFParticleEffect( filter, 0.0, STRING( m_iszParticle ), vecOrigin, vec3_angle );
		}

		// Increment score directly during 2014 halloween
		if ( CTFMinigameLogic::GetMinigameLogic() && CTFMinigameLogic::GetMinigameLogic()->GetActiveMinigame() )
		{
			inputdata_t inputdata;

			inputdata.pActivator = NULL;
			inputdata.pCaller = NULL;
			inputdata.value.SetInt( 1 );
			inputdata.nOutputID = 0;

			if ( pPlayer->GetTeamNumber() == TF_TEAM_RED )
			{
				CTFMinigameLogic::GetMinigameLogic()->GetActiveMinigame()->InputScoreTeamRed( inputdata );
			}
			else
			{
				CTFMinigameLogic::GetMinigameLogic()->GetActiveMinigame()->InputScoreTeamBlue( inputdata );
			}
		}

		if ( TFGameRules() && TFGameRules()->IsHalloweenScenario( CTFGameRules::HALLOWEEN_SCENARIO_DOOMSDAY ) )
		{
			CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
			if ( pTFPlayer )
			{
				pTFPlayer->AwardAchievement( ACHIEVEMENT_TF_HALLOWEEN_DOOMSDAY_COLLECT_DUCKS );

				IGameEvent *pEvent = gameeventmanager->CreateEvent( "halloween_duck_collected" );
				if ( pEvent )
				{
					pEvent->SetInt( "collector", pTFPlayer->GetUserID() );
					gameeventmanager->FireEvent( pEvent, true );
				}
			}
		}
	}

	return bSuccess;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CHalloweenPickup::ValidTouch( CBasePlayer *pPlayer )
{
	CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
	if ( pTFPlayer && pTFPlayer->m_Shared.InCond( TF_COND_HALLOWEEN_GHOST_MODE ) )
		return false;

	return BaseClass::ValidTouch( pPlayer );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
float CHalloweenPickup::GetRespawnDelay( void )
{
	return TF_HALLOWEEN_PICKUP_RETURN_DELAY;
}

//-----------------------------------------------------------------------------
// Purpose: Do everything that our base does, but don't change our origin
//-----------------------------------------------------------------------------
CBaseEntity* CHalloweenPickup::Respawn( void )
{
	SetTouch( NULL );
	AddEffects( EF_NODRAW );

	VPhysicsDestroyObject();

	SetMoveType( MOVETYPE_NONE );
	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_TRIGGER );

	m_bRespawning = true;

	//UTIL_SetOrigin( this, g_pGameRules->VecItemRespawnSpot( this ) );// blip to whereever you should respawn.
	SetAbsAngles( g_pGameRules->VecItemRespawnAngles( this ) );// set the angles.

#if !defined( TF_DLL )
	UTIL_DropToFloor( this, MASK_SOLID );
#endif

	RemoveAllDecals(); //remove any decals

	SetThink ( &CItem::Materialize );
	SetNextThink( gpGlobals->curtime + GetRespawnDelay() );
	return this;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHalloweenPickup::ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer )
{
	if ( m_flThrowerTouchTime > 0.f && gpGlobals->curtime < m_flThrowerTouchTime )
	{
		return false;
	}

	return BaseClass::ItemCanBeTouchedByPlayer( pPlayer );
}

#endif // GAME_DLL

// ***********************************************************************************************
ConVar tf_duck_allow_team_pickup( "tf_duck_allow_team_pickup", "1", FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY );
CBonusDuckPickup::CBonusDuckPickup()
{
#ifdef GAME_DLL
	ChangeTeam( TEAM_UNASSIGNED );

	m_iCreatorId = -1;
	m_iVictimId = -1;
	m_iAssisterId = -1;
	m_iFlags = 0;
#else
	pGlowEffect = NULL;
#endif

	m_bSpecial = false;
	m_iszSound = MAKE_STRING( BONUS_DUCK_CREATED_SOUND );
	m_iszParticle = MAKE_STRING( "duck_pickup" );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CBonusDuckPickup::~CBonusDuckPickup()
{
#ifdef GAME_DLL
	m_flLifeTime = 0;
#else
	if ( pGlowEffect )
	{
		ParticleProp()->StopEmission( pGlowEffect );
		pGlowEffect = NULL;
	}
#endif
}

//-----------------------------------------------------------------------------
void CBonusDuckPickup::Precache( void )
{
	// We deliberately allow late precaches here
	bool bAllowPrecache = CBaseEntity::IsPrecacheAllowed();
	CBaseEntity::SetAllowPrecache( true );
	PrecacheParticleSystem( BONUS_DUCK_GLOW );
	PrecacheParticleSystem( BONUS_DUCK_TRAIL_RED );
	PrecacheParticleSystem( BONUS_DUCK_TRAIL_BLUE );
	PrecacheParticleSystem( BONUS_DUCK_TRAIL_SPECIAL_RED );
	PrecacheParticleSystem( BONUS_DUCK_TRAIL_SPECIAL_BLUE );
	PrecacheScriptSound( BONUS_DUCK_CREATED_SOUND );
	BaseClass::Precache();
	CBaseEntity::SetAllowPrecache( bAllowPrecache );
}

#ifdef GAME_DLL
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CBonusDuckPickup::ValidTouch( CBasePlayer *pPlayer )
{
	// Is the item enabled?
	if ( IsDisabled() )
		return false;

	// Only touch a live player.
	if ( !pPlayer || !pPlayer->IsPlayer() || !pPlayer->IsAlive() )
		return false;

	if ( ( GetTeamNumber() >= FIRST_GAME_TEAM ) && ( pPlayer->GetTeamNumber() == GetTeamNumber() ) )
		return false;

	CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
	if ( pTFPlayer && pTFPlayer->m_Shared.InCond( TF_COND_HALLOWEEN_GHOST_MODE ) )
		return false;

	return true;
}
//-----------------------------------------------------------------------------
#define DUCK_BLINK_TIME 3.0f
void CBonusDuckPickup::Spawn( void )
{
	BaseClass::Spawn();
	//SetCycle( RandomFloat(0, 60.0f) );

	//align to the ground so we're not standing on end
	QAngle angle = vec3_angle;
	// rotate randomly in yaw
	angle[1] = random->RandomFloat( 0, 360 );
	SetAbsAngles( angle );

	float flLifeTime = GetLifeTime();
	m_flKillTime = gpGlobals->curtime + flLifeTime;
	m_nBlinkCount = 0;
	SetContextThink( &CBonusDuckPickup::BlinkThink,  gpGlobals->curtime + flLifeTime - DUCK_BLINK_TIME, "BonusDuckBlinkThink" );
	SetContextThink( &CBonusDuckPickup::UpdateCollisionBounds, gpGlobals->curtime + 2.0f, "UpdateCollisionBoundsThink" );
}
//-----------------------------------------------------------------------------
bool CBonusDuckPickup::MyTouch( CBasePlayer *pPlayer )
{
	bool bSuccess = false;

	if ( tf_duck_allow_team_pickup.GetBool() || ValidTouch( pPlayer ) )
	{
		bSuccess = true;

		Vector vecOrigin = GetAbsOrigin();
		CPVSFilter pvsFilter( vecOrigin );
		if ( m_iszSound != NULL_STRING )
		{
			EmitSound( pvsFilter, entindex(), STRING( m_iszSound ) );
		}
		else
		{
			EmitSound( pvsFilter, entindex(), TF_HALLOWEEN_PICKUP_DEFAULT_SOUND );
		}

		if ( m_iszParticle != NULL_STRING )
		{
			TE_TFParticleEffect( pvsFilter, 0.0, STRING( m_iszParticle ), vecOrigin, vec3_angle );
		}

		if ( m_bSpecial )
		{
			CSingleUserRecipientFilter userfilter( pPlayer );
			UserMessageBegin( userfilter, "BonusDucks" );
			WRITE_BYTE( pPlayer->entindex() );
			WRITE_BYTE( true );
			MessageEnd();
		}

		// Notify User that they picked up a EOTL duck if the holiday is active
		if ( pPlayer && TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_EOTL ) && !TFGameRules()->HaveCheatsBeenEnabledDuringLevel() )
		{
			int iFlags = m_iFlags;
			if ( m_bSpecial )
			{
				iFlags |= DUCK_FLAG_BONUS;
			}

			// Send Message to Toucher and Creator if Creator is same team as toucher
			// Tell your team you picked up a duck
			// IsCreated, ID of Creator, ID of Victim, Count, IsGolden

			// Message to Toucher
			{
				CSingleUserRecipientFilter userfilter( pPlayer );
				UserMessageBegin( userfilter, "EOTLDuckEvent" );
				WRITE_BYTE( false );
				WRITE_BYTE( m_iCreatorId );
				WRITE_BYTE( m_iVictimId );
				WRITE_BYTE( pPlayer->entindex() );
				WRITE_BYTE( GetTeamNumber() );
				WRITE_BYTE( 1 );
				WRITE_BYTE( iFlags );
				MessageEnd();
			}

			// Notify Creator
			if ( m_iCreatorId != pPlayer->entindex() )
			{
				CBasePlayer *pCreator = UTIL_PlayerByIndex( m_iCreatorId );
				if ( pCreator && pCreator->InSameTeam( pPlayer ) )
				{
					CSingleUserRecipientFilter userfilter( pCreator );
					UserMessageBegin( userfilter, "EOTLDuckEvent" );
					WRITE_BYTE( false );
					WRITE_BYTE( m_iCreatorId );
					WRITE_BYTE( m_iVictimId );
					WRITE_BYTE( pPlayer->entindex() );
					WRITE_BYTE( GetTeamNumber() );
					WRITE_BYTE( 1 );
					WRITE_BYTE( iFlags );
					MessageEnd();
				}
			}

			// Notify Assister someone picked up their duck as well
			if ( m_iAssisterId != -1 && m_iAssisterId != pPlayer->entindex() )
			{
				CBasePlayer *pAssister = UTIL_PlayerByIndex( m_iAssisterId );
				if ( pAssister && pAssister->InSameTeam( pPlayer ) )
				{
					CSingleUserRecipientFilter userfilter( pAssister );
					UserMessageBegin( userfilter, "EOTLDuckEvent" );
					WRITE_BYTE( false );
					WRITE_BYTE( m_iAssisterId );
					WRITE_BYTE( m_iVictimId );
					WRITE_BYTE( pPlayer->entindex() );
					WRITE_BYTE( GetTeamNumber() );
					WRITE_BYTE( 1 );
					WRITE_BYTE( iFlags );
					MessageEnd();
				}
			}
		}
	}

	return bSuccess;
}
//-----------------------------------------------------------------------------
void CBonusDuckPickup::DropSingleInstance( Vector &vecLaunchVel, CBaseCombatCharacter *pThrower, float flThrowerTouchDelay, float flResetTime /*= 0.1f*/ )
{
	// Remove ourselves after some time
	SetContextThink( &CBonusDuckPickup::NotifyFadeOut, gpGlobals->curtime + GetLifeTime(), "CBonusDuckPreRemoveThink" );

	BaseClass::DropSingleInstance( vecLaunchVel, pThrower, flThrowerTouchDelay, flResetTime );
}
//-----------------------------------------------------------------------------
void CBonusDuckPickup::NotifyFadeOut( void )
{
	//// Notify User that they picked up a EOTL duck if the holiday is active
	//if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_EOTL ) )
	//{
	//	int iFlags = 0;
	//	if ( m_bSpecial )
	//	{
	//		iFlags |= DUCK_FLAG_BONUS;
	//	}
	//	// Tell your team you picked up a duck
	//	// IsCreated, ID of Creator, ID of Victim, Count, IsGolden
	//	CTeamRecipientFilter userfilter( GetTeamNumber(), true );
	//	UserMessageBegin( userfilter, "EOTLDuckEvent" );
	//		WRITE_BYTE( false );
	//		WRITE_BYTE( m_iCreatorId );
	//		WRITE_BYTE( m_iVictimId );
	//		WRITE_BYTE( 0 );
	//		WRITE_BYTE( GetTeamNumber() );
	//		WRITE_BYTE( 1 );
	//		WRITE_BYTE( iFlags );
	//	MessageEnd();
	//}
}
//-----------------------------------------------------------------------------
void CBonusDuckPickup::UpdateCollisionBounds()
{
	CollisionProp()->SetCollisionBounds( Vector( -50, -50, -50 ), Vector( 50, 50, 50 ) );
}
//-----------------------------------------------------------------------------
void CBonusDuckPickup::BlinkThink()
{
	float flTimeToKill = m_flKillTime - gpGlobals->curtime;
	float flNextBlink = RemapValClamped( flTimeToKill, DUCK_BLINK_TIME, 0.f, 0.3f, 0.05f );

	SetContextThink( &CBonusDuckPickup::BlinkThink, gpGlobals->curtime + flNextBlink, "BonusDuckBlinkThink" );

	SetRenderMode( kRenderTransAlpha );

	++m_nBlinkCount;
	if ( m_nBlinkCount % 2 == 0 )
	{
		SetRenderColorA( 50 );
	}
	else
	{
		SetRenderColorA( 255 );
	}
}
#else

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBonusDuckPickup::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );

	if ( updateType == DATA_UPDATE_CREATED )
	{
		if ( !IsDormant() )
		{

			if ( pGlowEffect )
			{
				ParticleProp()->StopEmission( pGlowEffect );
				pGlowEffect = NULL;
			}

			if ( m_bSpecial )
			{
				pGlowEffect = ParticleProp()->Create( BONUS_DUCK_GLOW, PATTACH_ABSORIGIN_FOLLOW, 0, Vector( 0, 0, 10 ) );

				// these are fire and forget
				ParticleProp()->Create( ( GetTeamNumber() == TF_TEAM_RED ) ? BONUS_DUCK_TRAIL_SPECIAL_RED : BONUS_DUCK_TRAIL_SPECIAL_BLUE, PATTACH_ABSORIGIN_FOLLOW );
			}
			else
			{
				// these are fire and forget
				ParticleProp()->Create( ( GetTeamNumber() == TF_TEAM_RED ) ? BONUS_DUCK_TRAIL_RED : BONUS_DUCK_TRAIL_BLUE, PATTACH_ABSORIGIN_FOLLOW );
			}

			CPVSFilter filter( GetAbsOrigin() );
			EmitSound( filter, entindex(), BONUS_DUCK_CREATED_SOUND );
		}
	}
}

#endif // GAME_DLL


//-----------------------------------------------------------------------------
// Purpose: Halloween Gift Spawn
//-----------------------------------------------------------------------------
#ifdef GAME_DLL
CHalloweenGiftSpawnLocation::CHalloweenGiftSpawnLocation()
{
}
#endif
//-----------------------------------------------------------------------------
CHalloweenGiftPickup::CHalloweenGiftPickup()
{
	m_hTargetPlayer = NULL;
#ifdef CLIENT_DLL
	m_pPreviousTargetPlayer = NULL;
#endif
}
//-----------------------------------------------------------------------------
void CHalloweenGiftPickup::Precache( void )
{
	BaseClass::Precache();

	PrecacheScriptSound( "sf15.Merasmus.Gargoyle.Spawn" );
	PrecacheScriptSound( "sf15.Merasmus.Gargoyle.Gone" );
	PrecacheScriptSound( "sf15.Merasmus.Gargoyle.Got" );
}

//------------------------------------------------------------------------
void CHalloweenGiftPickup::Spawn( void )
{
	BaseClass::Spawn();
#ifdef GAME_DLL
	// Set a timer
	SetContextThink( &CHalloweenGiftPickup::DespawnGift, gpGlobals->curtime + tf_halloween_gift_lifetime.GetInt(), "DespawnGift" );
	AddSpawnFlags( SF_NORESPAWN );
#endif // CLIENT_DLL
}

#ifdef GAME_DLL
//------------------------------------------------------------------------
// Despawn (and notify client) and then remove
//------------------------------------------------------------------------
void CHalloweenGiftPickup::DespawnGift()
{
	SetTargetPlayer( NULL );
	SetContextThink( &CHalloweenGiftPickup::RemoveGift, gpGlobals->curtime + 1.0, "RemoveGift" );
}
//------------------------------------------------------------------------
void CHalloweenGiftPickup::RemoveGift()
{
	UTIL_Remove( this );
}

//------------------------------------------------------------------------
void CHalloweenGiftPickup::SetTargetPlayer( CTFPlayer *pTarget )
{
	m_hTargetPlayer = pTarget; 
}
//------------------------------------------------------------------------
bool CHalloweenGiftPickup::ValidTouch( CBasePlayer *pPlayer )
{
	CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
	if ( pTFPlayer && pTFPlayer != m_hTargetPlayer.Get() )
		return false;

	return true;
}
//------------------------------------------------------------------------
bool CHalloweenGiftPickup::MyTouch( CBasePlayer *pPlayer )
{
	CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
	if ( pTFPlayer && pTFPlayer != m_hTargetPlayer.Get() )
		return false;

	// TODO: Give contract points

	// Visual effects
	Vector vecOrigin = GetAbsOrigin();
	CPVSFilter filter( vecOrigin );

	TE_TFParticleEffect( filter, 0.0, "duck_collect_green", vecOrigin, vec3_angle );

	// Sound effects
	CSingleUserRecipientFilter touchingFilter( pPlayer );
	EmitSound( touchingFilter, entindex(), "Halloween.PumpkinPickup" );
	EmitSound( touchingFilter, entindex(), "sf15.Merasmus.Gargoyle.Got" );

	// Give souls to the collecting player
#ifdef STAGING_ONLY
	for( int i=0; i<tf_halloween_gift_soul_value.GetInt(); ++i )
#else
	for( int i=0; i<10; ++i )
#endif // STAGING_ONLY
	{
		TFGameRules()->DropHalloweenSoulPack( 1, vecOrigin, pPlayer, TEAM_SPECTATOR );
	}

	// Achievement
	if ( TFGameRules() && TFGameRules()->IsHalloweenScenario( CTFGameRules::HALLOWEEN_SCENARIO_MANN_MANOR ) )
	{
		pTFPlayer->AwardAchievement( ACHIEVEMENT_TF_HALLOWEEN_COLLECT_GOODY_BAG );
	}
	return true;
}

#endif // GAME_DLL

#ifdef CLIENT_DLL
//-----------------------------------------------------------------------------
void CHalloweenGiftPickup::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );

	if ( updateType == DATA_UPDATE_DATATABLE_CHANGED )
	{
		C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
		if ( pLocalPlayer )
		{
			// Gift Added
			if ( m_hTargetPlayer.Get() != NULL && m_pPreviousTargetPlayer == NULL && m_hTargetPlayer.Get() == pLocalPlayer  )
			{
				// Notification
				CEconNotification *pNotification = new CEconNotification();
				pNotification->SetText( "#TF_HalloweenItem_SoulAppeared" );
				pNotification->SetLifetime( 5.0f );
				pNotification->SetSoundFilename( "ui/halloween_loot_spawn.wav" );
				NotificationQueue_Add( pNotification );
				pLocalPlayer->EmitSound( "sf15.Merasmus.Gargoyle.Spawn" );
			}
			// Gift Despawned
			if ( m_hTargetPlayer.Get() == NULL && m_pPreviousTargetPlayer != NULL && m_pPreviousTargetPlayer == pLocalPlayer )
			{
				// Notification
				CEconNotification *pNotification = new CEconNotification();
				pNotification->SetText( "#TF_HalloweenItem_SoulDisappeared" );
				pNotification->SetLifetime( 5.0f );
				pNotification->SetSoundFilename( "ui/halloween_loot_found.wav" );
				NotificationQueue_Add( pNotification );
				pLocalPlayer->EmitSound( "sf15.Merasmus.Gargoyle.Gone" );
			}

			m_pPreviousTargetPlayer = m_hTargetPlayer.Get();
		}
	}

}
//------------------------------------------------------------------------
bool CHalloweenGiftPickup::ShouldDraw()
{
	CTFPlayer *pOwner = m_hTargetPlayer.Get();
	if ( pOwner != C_TFPlayer::GetLocalTFPlayer() )
		return false;

	return BaseClass::ShouldDraw();
}
#endif