diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/tf/halloween/spell/tf_spell_pickup.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/tf/halloween/spell/tf_spell_pickup.cpp')
| -rw-r--r-- | game/server/tf/halloween/spell/tf_spell_pickup.cpp | 111 |
1 files changed, 111 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(); +} |