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.

162 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VEHICLE_APC_H
  8. #define VEHICLE_APC_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vehicle_base.h"
  13. #include "smoke_trail.h"
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Four wheel physics vehicle server vehicle with weaponry
  16. //-----------------------------------------------------------------------------
  17. class CAPCFourWheelServerVehicle : public CFourWheelServerVehicle
  18. {
  19. typedef CFourWheelServerVehicle BaseClass;
  20. // IServerVehicle
  21. public:
  22. bool NPC_HasPrimaryWeapon( void ) { return true; }
  23. void NPC_AimPrimaryWeapon( Vector vecTarget );
  24. bool NPC_HasSecondaryWeapon( void ) { return true; }
  25. void NPC_AimSecondaryWeapon( Vector vecTarget );
  26. // Weaponry
  27. void Weapon_PrimaryRanges( float *flMinRange, float *flMaxRange );
  28. void Weapon_SecondaryRanges( float *flMinRange, float *flMaxRange );
  29. float Weapon_PrimaryCanFireAt( void ); // Return the time at which this vehicle's primary weapon can fire again
  30. float Weapon_SecondaryCanFireAt( void ); // Return the time at which this vehicle's secondary weapon can fire again
  31. };
  32. //-----------------------------------------------------------------------------
  33. // A driveable vehicle with a gun that shoots wherever the driver looks.
  34. //-----------------------------------------------------------------------------
  35. class CPropAPC : public CPropVehicleDriveable
  36. {
  37. DECLARE_CLASS( CPropAPC, CPropVehicleDriveable );
  38. public:
  39. // CBaseEntity
  40. virtual void Precache( void );
  41. void Think( void );
  42. virtual void Spawn(void);
  43. virtual void Activate();
  44. virtual void UpdateOnRemove( void );
  45. virtual void OnRestore( void );
  46. // CPropVehicle
  47. virtual void CreateServerVehicle( void );
  48. virtual void DriveVehicle( float flFrameTime, CUserCmd *ucmd, int iButtonsDown, int iButtonsReleased );
  49. virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData );
  50. virtual Class_T ClassifyPassenger( CBaseCombatCharacter *pPassenger, Class_T defaultClassification );
  51. virtual int OnTakeDamage( const CTakeDamageInfo &info );
  52. virtual float PassengerDamageModifier( const CTakeDamageInfo &info );
  53. // Weaponry
  54. const Vector &GetPrimaryGunOrigin( void );
  55. void AimPrimaryWeapon( const Vector &vecForward );
  56. void AimSecondaryWeaponAt( CBaseEntity *pTarget );
  57. float PrimaryWeaponFireTime( void ) { return m_flMachineGunTime; }
  58. float SecondaryWeaponFireTime( void ) { return m_flRocketTime; }
  59. float MaxAttackRange() const;
  60. bool IsInPrimaryFiringCone() const { return m_bInFiringCone; }
  61. // Muzzle flashes
  62. const char *GetTracerType( void ) ;
  63. void DoImpactEffect( trace_t &tr, int nDamageType );
  64. void DoMuzzleFlash( void );
  65. virtual Vector EyePosition( ); // position of eyes
  66. Vector BodyTarget( const Vector &posSrc, bool bNoisy );
  67. virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  68. private:
  69. enum
  70. {
  71. MAX_SMOKE_TRAILS = 4,
  72. MAX_EXPLOSIONS = 4,
  73. };
  74. // Should we trigger a damage effect?
  75. bool ShouldTriggerDamageEffect( int nPrevHealth, int nEffectCount ) const;
  76. // Add a smoke trail since we've taken more damage
  77. void AddSmokeTrail( const Vector &vecPos );
  78. // Creates the breakable husk of an attack chopper
  79. void CreateChopperHusk();
  80. // Pow!
  81. void ExplodeAndThrowChunk( const Vector &vecExplosionPos );
  82. void Event_Killed( const CTakeDamageInfo &info );
  83. // Purpose:
  84. void GetRocketShootPosition( Vector *pPosition );
  85. void FireMachineGun( void );
  86. void FireRocket( void );
  87. // Death volley
  88. void FireDying( );
  89. // Create a corpse
  90. void CreateCorpse( );
  91. // Blows da shizzle up
  92. void InputDestroy( inputdata_t &inputdata );
  93. void InputFireMissileAt( inputdata_t &inputdata );
  94. void CreateAPCLaserDot( void );
  95. virtual bool ShouldAttractAutoAim( CBaseEntity *pAimingEnt );
  96. private:
  97. // Danger sounds made by the APC
  98. float m_flDangerSoundTime;
  99. // handbrake after the fact to keep vehicles from rolling
  100. float m_flHandbrakeTime;
  101. bool m_bInitialHandbrake;
  102. // Damage effects
  103. int m_nSmokeTrailCount;
  104. // Machine gun attacks
  105. int m_nMachineGunMuzzleAttachment;
  106. int m_nMachineGunBaseAttachment;
  107. float m_flMachineGunTime;
  108. int m_iMachineGunBurstLeft;
  109. Vector m_vecBarrelPos;
  110. bool m_bInFiringCone;
  111. // Rocket attacks
  112. EHANDLE m_hLaserDot;
  113. EHANDLE m_hRocketTarget;
  114. int m_iRocketSalvoLeft;
  115. float m_flRocketTime;
  116. int m_nRocketAttachment;
  117. int m_nRocketSide;
  118. EHANDLE m_hSpecificRocketTarget;
  119. string_t m_strMissileHint;
  120. COutputEvent m_OnDeath;
  121. COutputEvent m_OnFiredMissile;
  122. COutputEvent m_OnDamaged;
  123. COutputEvent m_OnDamagedByPlayer;
  124. DECLARE_DATADESC();
  125. };
  126. #endif // VEHICLE_APC_H