summaryrefslogtreecommitdiff
path: root/game/server/tf/halloween/spell
diff options
context:
space:
mode:
Diffstat (limited to 'game/server/tf/halloween/spell')
-rw-r--r--game/server/tf/halloween/spell/tf_spell_pickup.cpp111
-rw-r--r--game/server/tf/halloween/spell/tf_spell_pickup.h37
2 files changed, 148 insertions, 0 deletions
diff --git a/game/server/tf/halloween/spell/tf_spell_pickup.cpp b/game/server/tf/halloween/spell/tf_spell_pickup.cpp
new file mode 100644
index 0000000..89d274c
--- /dev/null
+++ b/game/server/tf/halloween/spell/tf_spell_pickup.cpp
@@ -0,0 +1,111 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Spell
+//
+//=============================================================================//
+#include "cbase.h"
+
+#include "tf_spell_pickup.h"
+#include "tf_player.h"
+#include "halloween/tf_weapon_spellbook.h"
+#include "tf_gamerules.h"
+
+LINK_ENTITY_TO_CLASS( tf_spell_pickup, CSpellPickup );
+
+BEGIN_DATADESC( CSpellPickup )
+
+ // Keyfields.
+ DEFINE_KEYFIELD( m_nTier, FIELD_INTEGER, "tier" ),
+
+END_DATADESC();
+
+
+//-----------------------------------------------------------------------------
+CSpellPickup::CSpellPickup()
+{
+ m_nTier = 0;
+}
+
+//-----------------------------------------------------------------------------
+void CSpellPickup::Spawn( void )
+{
+ BaseClass::Spawn();
+ m_nSkin = m_nTier;
+}
+
+//-----------------------------------------------------------------------------
+void CSpellPickup::Precache( void )
+{
+ BaseClass::Precache();
+
+ PrecacheScriptSound( "Halloween.spell_pickup" );
+ PrecacheScriptSound( "Halloween.spell_pickup_rare" );
+}
+
+//-----------------------------------------------------------------------------
+bool CSpellPickup::MyTouch( CBasePlayer *pPlayer )
+{
+ CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
+ if ( pTFPlayer )
+ {
+ CTFSpellBook *pSpellBook = dynamic_cast< CTFSpellBook* >( pTFPlayer->GetEntityForLoadoutSlot( LOADOUT_POSITION_ACTION ) );
+ if ( pSpellBook )
+ {
+ pSpellBook->RollNewSpell( m_nTier );
+
+ CSingleUserRecipientFilter filter( pPlayer );
+ const char *pszSoundName = ( m_nTier > 0 ) ? "Halloween.spell_pickup_rare" : "Halloween.spell_pickup";
+ EmitSound( filter, entindex(), pszSoundName );
+ }
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+bool CSpellPickup::ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer )
+{
+ if ( IsDisabled() )
+ return false;
+
+ // Dont let them pick up new spells if they already have a spell unless its a tier 1 spell
+ CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer );
+ if ( pTFPlayer && m_nTier == 0 )
+ {
+ CTFSpellBook *pSpellBook = dynamic_cast< CTFSpellBook* >( pTFPlayer->GetEntityForLoadoutSlot( LOADOUT_POSITION_ACTION ) );
+ if ( !pSpellBook )
+ {
+ // TEMP
+ ClientPrint( pPlayer, HUD_PRINTCENTER, "Equip a SpellBook in your ActionSlot to pick this up.", pPlayer->GetPlayerName() );
+ return false;
+ }
+
+ if ( pSpellBook->HasASpellWithCharges() )
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+const char *CSpellPickup::GetPowerupModel( void )
+{
+ if ( TFGameRules() && TFGameRules()->IsHalloweenScenario( CTFGameRules::HALLOWEEN_SCENARIO_DOOMSDAY ) )
+ {
+ if ( m_nTier == 1 )
+ {
+ return "models/items/crystal_ball_pickup_major.mdl";
+ }
+ return "models/items/crystal_ball_pickup.mdl";
+ }
+
+ if ( m_nTier == 1 )
+ {
+ return "models/props_halloween/hwn_spellbook_upright_major.mdl";
+ }
+
+ return BaseClass::GetPowerupModel();
+}
diff --git a/game/server/tf/halloween/spell/tf_spell_pickup.h b/game/server/tf/halloween/spell/tf_spell_pickup.h
new file mode 100644
index 0000000..1e8c4f2
--- /dev/null
+++ b/game/server/tf/halloween/spell/tf_spell_pickup.h
@@ -0,0 +1,37 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Spell.
+//
+//=============================================================================//
+#ifndef TF_SPELL_PICKUP_H
+#define TF_SPELL_PICKUP_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tf_powerup.h"
+class CSpellPickup : public CTFPowerup
+{
+ DECLARE_CLASS( CSpellPickup, CTFPowerup )
+ DECLARE_DATADESC();
+
+public:
+ CSpellPickup();
+
+ virtual void Spawn( void ) OVERRIDE;
+ virtual void Precache() OVERRIDE;
+
+ virtual bool MyTouch( CBasePlayer *pPlayer ) OVERRIDE;
+ virtual const char *GetPowerupModel( void ) OVERRIDE;
+ virtual const char *GetDefaultPowerupModel( void ) OVERRIDE { return "models/props_halloween/hwn_spellbook_upright.mdl"; }
+ virtual bool ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer ) OVERRIDE;
+
+ void SetTier( int nTier ) { m_nTier = nTier; }
+
+private:
+
+ int m_nTier;
+};
+
+#endif // TF_SPELL_PICKUP_H