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.

169 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_WEAPON_BUILDER_H
  8. #define TF_WEAPON_BUILDER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tf_weaponbase.h"
  13. class CBaseObject;
  14. //=========================================================
  15. // Builder Weapon
  16. //=========================================================
  17. class CTFWeaponBuilder : public CTFWeaponBase
  18. {
  19. DECLARE_CLASS( CTFWeaponBuilder, CTFWeaponBase );
  20. public:
  21. CTFWeaponBuilder();
  22. ~CTFWeaponBuilder();
  23. DECLARE_SERVERCLASS();
  24. virtual void SetSubType( int iSubType );
  25. virtual void SetObjectMode( int iMode ) { m_iObjectMode = iMode; }
  26. virtual void Precache( void );
  27. virtual bool CanDeploy( void );
  28. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
  29. virtual void ItemPostFrame( void );
  30. virtual void PrimaryAttack( void );
  31. virtual void SecondaryAttack( void );
  32. virtual void WeaponIdle( void );
  33. virtual bool Deploy( void );
  34. virtual Activity GetDrawActivity( void );
  35. virtual const char *GetViewModel( int iViewModel ) const;
  36. virtual const char *GetWorldModel( void ) const;
  37. virtual bool AllowsAutoSwitchTo( void ) const;
  38. virtual int GetType( void ) { return m_iObjectType; }
  39. virtual Activity TranslateViewmodelHandActivity( Activity actBase );
  40. void SetCurrentState( int iState );
  41. void SwitchOwnersWeaponToLast();
  42. // Placement
  43. void StartPlacement( void );
  44. void StopPlacement( void );
  45. void UpdatePlacementState( void ); // do a check for valid placement
  46. bool IsValidPlacement( void ); // is this a valid placement pos?
  47. // Building
  48. void StartBuilding( void );
  49. // Special P Sapper (Wheatley) Item
  50. void WheatleySapperIdle( CTFPlayer *pOwner );
  51. bool IsWheatleySapper( void );
  52. void WheatleyReset( bool bResetIntro = false );
  53. void SetWheatleyState( int iNewState );
  54. float WheatleyEmitSound( const char *snd , bool bEmitToAll = false, bool bNoRepeats = false );
  55. bool IsWheatleyTalking( void );
  56. void WheatleyDamage( void );
  57. int GetWheatleyIdleWait();
  58. // Selection
  59. bool HasAmmo( void );
  60. int GetSlot( void ) const;
  61. int GetPosition( void ) const;
  62. const char *GetPrintName( void ) const;
  63. bool CanBuildObjectType( int iObjectType );
  64. void SetObjectTypeAsBuildable( int iObjectType );
  65. virtual int GetWeaponID( void ) const { return TF_WEAPON_BUILDER; }
  66. virtual void WeaponReset( void );
  67. virtual float InternalGetEffectBarRechargeTime( void ) { return 15.0; }
  68. virtual int GetEffectBarAmmo( void ) { return TF_AMMO_GRENADES2; }
  69. public:
  70. CNetworkVar( int, m_iBuildState );
  71. CNetworkVar( unsigned int, m_iObjectType );
  72. CNetworkVar( unsigned int, m_iObjectMode );
  73. CNetworkVar( bool, m_bRoboSapper );
  74. CNetworkVar( float, m_flWheatleyTalkingUntil );
  75. CNetworkArray( bool, m_aBuildableObjectTypes, OBJ_LAST );
  76. CNetworkHandle( CBaseObject, m_hObjectBeingBuilt );
  77. int m_iValidBuildPoseParam;
  78. float m_flNextDenySound;
  79. // P Sapper (Wheatley)
  80. float m_flNextVoicePakIdleStartTime;
  81. KeyValues *m_pkvWavList;
  82. int m_iSapState;
  83. float m_flWheatleyLastDamage;
  84. float m_flWheatleyLastDeploy;
  85. float m_flWheatleyLastHolster;
  86. int m_iWheatleyVOSequenceOffset;
  87. bool m_bWheatleyIntroPlayed;
  88. EHANDLE m_hLastSappedBuilding;
  89. Vector m_vLastKnownSapPos;
  90. private:
  91. bool m_bAttack3Down;
  92. };
  93. // P Sapper (Wheatley) States
  94. enum
  95. {
  96. TF_PSAPSTATE_IDLE = 0,
  97. TF_PSAPSTATE_WAITINGHACK,
  98. TF_PSAPSTATE_WAITINGHACKPW,
  99. TF_PSAPSTATE_WAITINGHACKED,
  100. TF_PSAPSTATE_WAITINGFOLLOWUP,
  101. TF_PSAPSTATE_SPECIALIDLE_KNIFE,
  102. TF_PSAPSTATE_SPECIALIDLE_HARMLESS,
  103. TF_PSAPSTATE_SPECIALIDLE_HACK,
  104. TF_PSAPSTATE_INTRO,
  105. };
  106. //-----------------------------------------------------------------------------
  107. // Purpose:
  108. //-----------------------------------------------------------------------------
  109. class CTFWeaponSapper : public CTFWeaponBuilder, public ITFChargeUpWeapon
  110. {
  111. public:
  112. DECLARE_CLASS( CTFWeaponSapper, CTFWeaponBuilder );
  113. DECLARE_SERVERCLASS();
  114. //DECLARE_PREDICTABLE();
  115. CTFWeaponSapper();
  116. virtual void ItemPostFrame( void );
  117. // ITFChargeUpWeapon
  118. virtual bool CanCharge( void ) { return GetChargeMaxTime() > 0; }
  119. virtual float GetChargeBeginTime( void ) { return m_flChargeBeginTime; }
  120. virtual float GetChargeMaxTime( void ) { float flChargeTime = 0; CALL_ATTRIB_HOOK_FLOAT( flChargeTime, sapper_deploy_time ); return flChargeTime; };
  121. virtual const char *GetViewModel( int iViewModel ) const;
  122. virtual const char *GetWorldModel( void ) const;
  123. virtual Activity TranslateViewmodelHandActivity( Activity actBase );
  124. private:
  125. //float m_flChargeBeginTime;
  126. bool m_bAttackDown;
  127. CNetworkVar( float, m_flChargeBeginTime );
  128. };
  129. #define WHEATLEY_IDLE_WAIT_SECS_MIN 10.0
  130. #define WHEATLEY_IDLE_WAIT_SECS_MAX 20.0
  131. #endif // TF_WEAPON_BUILDER_H