Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Weapon Base Melee
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPONBASE_MELEE_H
  7. #define TF_WEAPONBASE_MELEE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_shareddefs.h"
  12. #include "tf_weaponbase.h"
  13. #if defined( CLIENT_DLL )
  14. #define CTFWeaponBaseMelee C_TFWeaponBaseMelee
  15. extern ConVar cl_crosshair_file;
  16. #endif
  17. //=============================================================================
  18. //
  19. // Weapon Base Melee Class
  20. //
  21. class CTFWeaponBaseMelee : public CTFWeaponBase
  22. {
  23. public:
  24. DECLARE_CLASS( CTFWeaponBaseMelee, CTFWeaponBase );
  25. DECLARE_NETWORKCLASS();
  26. DECLARE_PREDICTABLE();
  27. #if !defined( CLIENT_DLL )
  28. DECLARE_DATADESC();
  29. #endif
  30. CTFWeaponBaseMelee();
  31. // We say yes to this so the weapon system lets us switch to it.
  32. virtual bool HasPrimaryAmmo() { return true; }
  33. virtual bool CanBeSelected() { return true; }
  34. virtual void Precache();
  35. virtual void ItemPreFrame();
  36. virtual void ItemPostFrame();
  37. virtual void Spawn();
  38. virtual void PrimaryAttack();
  39. virtual void SecondaryAttack();
  40. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
  41. virtual int GetWeaponID( void ) const { return TF_WEAPON_NONE; }
  42. virtual int GetSwingRange( void );
  43. virtual void WeaponReset( void );
  44. virtual bool CanHolster( void ) const;
  45. virtual bool CalcIsAttackCriticalHelper( void );
  46. virtual bool CalcIsAttackCriticalHelperNoCrits( void );
  47. virtual void DoViewModelAnimation( void );
  48. virtual bool DoSwingTrace( trace_t &trace );
  49. virtual void Smack( void );
  50. virtual void DoMeleeDamage( CBaseEntity* ent, trace_t& trace );
  51. virtual void DoMeleeDamage( CBaseEntity* ent, trace_t& trace, float flDamageMod );
  52. virtual float GetMeleeDamage( CBaseEntity *pTarget, int* piDamageType, int* piCustomDamage );
  53. #ifndef CLIENT_DLL
  54. virtual float GetForceScale( void );
  55. virtual int GetDamageCustom( void ) { return TF_DMG_CUSTOM_NONE; }
  56. #endif
  57. // Call when we hit an entity. Use for special weapon effects on hit.
  58. virtual void OnEntityHit( CBaseEntity *pEntity, CTakeDamageInfo *info );
  59. virtual void SendPlayerAnimEvent( CTFPlayer *pPlayer );
  60. bool ConnectedHit( void ) { return m_bConnected; }
  61. virtual char const *GetShootSound( int iIndex ) const;
  62. public:
  63. CTFWeaponInfo *m_pWeaponInfo;
  64. protected:
  65. virtual void Swing( CTFPlayer *pPlayer );
  66. protected:
  67. float m_flSmackTime;
  68. bool m_bConnected;
  69. bool m_bMiniCrit;
  70. #ifdef GAME_DLL
  71. CUtlVector< CHandle< CTFPlayer > > m_potentialVictimVector;
  72. #endif
  73. private:
  74. bool DoSwingTraceInternal( trace_t &trace, bool bCleave, CUtlVector< trace_t >* pTargetTraceVector );
  75. bool OnSwingHit( trace_t &trace );
  76. CTFWeaponBaseMelee( const CTFWeaponBaseMelee & ) {}
  77. };
  78. #endif // TF_WEAPONBASE_MELEE_H