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/shared/tf/tf_weapon_knife.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/shared/tf/tf_weapon_knife.h')
| -rw-r--r-- | game/shared/tf/tf_weapon_knife.h | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/game/shared/tf/tf_weapon_knife.h b/game/shared/tf/tf_weapon_knife.h new file mode 100644 index 0000000..e74cd08 --- /dev/null +++ b/game/shared/tf/tf_weapon_knife.h @@ -0,0 +1,115 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Weapon Knife Class +// +//============================================================================= +#ifndef TF_WEAPON_KNIFE_H +#define TF_WEAPON_KNIFE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "tf_weaponbase_melee.h" + +#ifdef CLIENT_DLL +#define CTFKnife C_TFKnife +#endif + +// Knives use the "set_weapon_mode" attribute to define which type of knife they are +// Keep this enum in sync with the values used for set_weapon_mode. +enum knife_weapontypes_t +{ + KNIFE_STANDARD = 0, + KNIFE_DISGUISE_ONKILL = 1, + KNIFE_MOVEMENT_CLOAK = 2, // The Cloak and Dagger + KNIFE_ICICLE = 3, +}; + +//============================================================================= +// +// Knife class. +// +class CTFKnife : public CTFWeaponBaseMelee +{ +public: + + DECLARE_CLASS( CTFKnife, CTFWeaponBaseMelee ); + DECLARE_NETWORKCLASS(); + DECLARE_PREDICTABLE(); + + CTFKnife(); + virtual void PrimaryAttack( void ) OVERRIDE; + virtual int GetWeaponID( void ) const OVERRIDE { return TF_WEAPON_KNIFE; } + int GetKnifeType( void ) const { int iMode = 0; CALL_ATTRIB_HOOK_INT( iMode, set_weapon_mode ); return iMode; }; + + virtual float GetMeleeDamage( CBaseEntity *pTarget, int* piDamageType, int* piCustomDamage ) OVERRIDE; + + virtual void SendPlayerAnimEvent( CTFPlayer *pPlayer ) OVERRIDE; + + virtual bool CanDeploy( void ) OVERRIDE; + virtual bool Deploy( void ) OVERRIDE; + void BackstabVMThink( void ); + + bool SendWeaponAnim( int iActivity ); + + bool CanPerformBackstabAgainstTarget( CTFPlayer *pTarget ); // "backstab" sometimes means "frontstab" + bool IsBehindAndFacingTarget( CTFPlayer *pTarget ); + bool IsBackstab( void ) { return (m_hBackstabVictim.Get() != NULL); } + void BackstabBlocked( void ); + bool ShouldDisguiseOnBackstab( void ); + void DisguiseOnKill(); + void ProcessDisguiseImpulse(); + + virtual bool CanHolster( void ) const OVERRIDE; + + virtual void ItemPostFrame( void ) OVERRIDE; + virtual void ItemPreFrame( void ) OVERRIDE; + virtual void ItemBusyFrame( void ) OVERRIDE; + virtual void ItemHolsterFrame( void ) OVERRIDE; + + virtual bool CalcIsAttackCriticalHelper( void ) OVERRIDE; + virtual bool CalcIsAttackCriticalHelperNoCrits( void ) OVERRIDE; + virtual bool DoSwingTrace( trace_t &trace ) OVERRIDE; + + virtual void WeaponRegenerate( void ) OVERRIDE; + virtual void WeaponReset( void ) OVERRIDE; + +#ifdef GAME_DLL + virtual void ApplyOnInjuredAttributes( CTFPlayer *pVictim, CTFPlayer *pAttacker, const CTakeDamageInfo &info ) OVERRIDE; // when owner of this weapon is hit + bool DecreaseRegenerationTime( float value, bool bForce ); +#endif + + float GetProgress( void ); + const char* GetEffectLabelText( void ) { return "#TF_KNIFE"; } + +private: + void ResetVars( void ); + +private: + float m_flBlockedTime; + bool m_bAllowHolsterBecauseForced; + CHandle<CTFPlayer> m_hBackstabVictim; + CNetworkVar( bool, m_bReadyToBackstab ); + CNetworkVar( bool, m_bKnifeExists ); + CNetworkVar( float, m_flKnifeRegenerateDuration ); + CNetworkVar( float, m_flKnifeMeltTimestamp ); + + bool m_bWasTaunting; + + CTFKnife( const CTFKnife & ) {} +}; + +inline float CTFKnife::GetProgress( void ) +{ + if ( m_bKnifeExists ) + { + return 1.0f; + } + + float meltedTime = gpGlobals->curtime - m_flKnifeMeltTimestamp; + + return meltedTime / m_flKnifeRegenerateDuration; +} + + +#endif // TF_WEAPON_KNIFE_H |