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.

167 lines
5.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef VEHICLE_JEEP_H
  7. #define VEHICLE_JEEP_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vehicle_base.h"
  12. #define JEEP_WHEEL_COUNT 4
  13. struct JeepWaterData_t
  14. {
  15. bool m_bWheelInWater[JEEP_WHEEL_COUNT];
  16. bool m_bWheelWasInWater[JEEP_WHEEL_COUNT];
  17. Vector m_vecWheelContactPoints[JEEP_WHEEL_COUNT];
  18. float m_flNextRippleTime[JEEP_WHEEL_COUNT];
  19. bool m_bBodyInWater;
  20. bool m_bBodyWasInWater;
  21. DECLARE_SIMPLE_DATADESC();
  22. };
  23. //-----------------------------------------------------------------------------
  24. // Purpose:
  25. //-----------------------------------------------------------------------------
  26. class CPropJeep : public CPropVehicleDriveable
  27. {
  28. public:
  29. DECLARE_CLASS( CPropJeep, CPropVehicleDriveable );
  30. DECLARE_SERVERCLASS();
  31. DECLARE_DATADESC();
  32. CPropJeep( void );
  33. // CPropVehicle
  34. virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData );
  35. virtual void DriveVehicle( float flFrameTime, CUserCmd *ucmd, int iButtonsDown, int iButtonsReleased );
  36. virtual void SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
  37. virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  38. virtual void DampenEyePosition( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles );
  39. virtual bool AllowBlockedExit( CBasePlayer *pPlayer, int nRole ) { return false; }
  40. virtual bool CanExitVehicle( CBaseEntity *pEntity );
  41. virtual bool IsVehicleBodyInWater() { return m_WaterData.m_bBodyInWater; }
  42. // Passengers do not directly receive damage from blasts or radiation damage
  43. virtual bool PassengerShouldReceiveDamage( CTakeDamageInfo &info )
  44. {
  45. if ( GetServerVehicle() && GetServerVehicle()->IsPassengerExiting() )
  46. return false;
  47. if ( info.GetDamageType() & DMG_VEHICLE )
  48. return true;
  49. return (info.GetDamageType() & (DMG_RADIATION|DMG_BLAST) ) == 0;
  50. }
  51. // CBaseEntity
  52. void Think(void);
  53. void Precache( void );
  54. void Spawn( void );
  55. void Activate( void );
  56. virtual void CreateServerVehicle( void );
  57. virtual Vector BodyTarget( const Vector &posSrc, bool bNoisy = true );
  58. virtual void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator );
  59. virtual int OnTakeDamage( const CTakeDamageInfo &info );
  60. virtual float PassengerDamageModifier( const CTakeDamageInfo &info );
  61. virtual void EnterVehicle( CBaseCombatCharacter *pPassenger );
  62. virtual void ExitVehicle( int nRole );
  63. void AimGunAt( Vector *endPos, float flInterval );
  64. bool TauCannonHasBeenCutOff( void ) { return m_bGunHasBeenCutOff; }
  65. // NPC Driving
  66. bool NPC_HasPrimaryWeapon( void ) { return true; }
  67. void NPC_AimPrimaryWeapon( Vector vecTarget );
  68. const char *GetTracerType( void ) { return "AR2Tracer"; }
  69. void DoImpactEffect( trace_t &tr, int nDamageType );
  70. bool HeadlightIsOn( void ) { return m_bHeadlightIsOn; }
  71. void HeadlightTurnOn( void ) { m_bHeadlightIsOn = true; }
  72. void HeadlightTurnOff( void ) { m_bHeadlightIsOn = false; }
  73. private:
  74. void FireCannon( void );
  75. void ChargeCannon( void );
  76. void FireChargedCannon( void );
  77. void DrawBeam( const Vector &startPos, const Vector &endPos, float width );
  78. void StopChargeSound( void );
  79. void GetCannonAim( Vector *resultDir );
  80. void InitWaterData( void );
  81. void CheckWaterLevel( void );
  82. void CreateSplash( const Vector &vecPosition );
  83. void CreateRipple( const Vector &vecPosition );
  84. void CreateDangerSounds( void );
  85. void ComputePDControllerCoefficients( float *pCoefficientsOut, float flFrequency, float flDampening, float flDeltaTime );
  86. void DampenForwardMotion( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles, float flFrameTime );
  87. void DampenUpMotion( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles, float flFrameTime );
  88. void JeepSeagullThink( void );
  89. void SpawnPerchedSeagull( void );
  90. void AddSeagullPoop( const Vector &vecOrigin );
  91. void InputShowHudHint( inputdata_t &inputdata );
  92. void InputStartRemoveTauCannon( inputdata_t &inputdata );
  93. void InputFinishRemoveTauCannon( inputdata_t &inputdata );
  94. protected:
  95. virtual void HandleWater( void );
  96. bool CheckWater( void );
  97. bool m_bGunHasBeenCutOff;
  98. float m_flDangerSoundTime;
  99. int m_nBulletType;
  100. bool m_bCannonCharging;
  101. float m_flCannonTime;
  102. float m_flCannonChargeStartTime;
  103. Vector m_vecGunOrigin;
  104. CSoundPatch *m_sndCannonCharge;
  105. int m_nSpinPos;
  106. float m_aimYaw;
  107. float m_aimPitch;
  108. float m_throttleDisableTime;
  109. float m_flAmmoCrateCloseTime;
  110. // handbrake after the fact to keep vehicles from rolling
  111. float m_flHandbrakeTime;
  112. bool m_bInitialHandbrake;
  113. float m_flOverturnedTime;
  114. Vector m_vecLastEyePos;
  115. Vector m_vecLastEyeTarget;
  116. Vector m_vecEyeSpeed;
  117. Vector m_vecTargetSpeed;
  118. JeepWaterData_t m_WaterData;
  119. int m_iNumberOfEntries;
  120. int m_nAmmoType;
  121. // Seagull perching
  122. float m_flPlayerExitedTime; // Time at which the player last left this vehicle
  123. float m_flLastSawPlayerAt; // Time at which we last saw the player
  124. EHANDLE m_hLastPlayerInVehicle;
  125. EHANDLE m_hSeagull;
  126. bool m_bHasPoop;
  127. CNetworkVar( bool, m_bHeadlightIsOn );
  128. };
  129. #endif // VEHICLE_JEEP_H