humanstate.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/humanstate.h $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 2/13/02 5:58p $*
  29. * *
  30. * $Revision:: 48 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef HUMANSTATE_H
  36. #define HUMANSTATE_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef VECTOR3_H
  41. #include "vector3.h"
  42. #endif
  43. #ifndef MATRIX3D_H
  44. #include "matrix3D.h"
  45. #endif
  46. class HumanAnimControlClass;
  47. class HumanPhysClass;
  48. class WeaponClass;
  49. class ChunkSaveClass;
  50. class ChunkLoadClass;
  51. class HumanLoiterGlobalSettingsDef;
  52. class StringClass;
  53. class HumanAnimOverrideDef;
  54. class HumanLoiterGlobalSettingsDef;
  55. //#define CORPSE_PERSIST_TIME 10.0f // Need different numbers for single and mp
  56. #define CORPSE_PERSIST_TIME 2.0f
  57. /*
  58. ** Human State
  59. */
  60. class HumanStateClass {
  61. public:
  62. typedef enum {
  63. // Interruptable states
  64. UPRIGHT,
  65. LAND,
  66. ANIMATION,
  67. WOUNDED,
  68. LOITER,
  69. // Uninterruptable states
  70. AIRBORNE,
  71. DIVE,
  72. DEATH,
  73. LADDER,
  74. IN_VEHICLE,
  75. TRANSITION,
  76. TRANSITION_COMPLETE,
  77. DESTROY,
  78. DEBUG_FLY,
  79. ON_FIRE,
  80. ON_CHEM,
  81. ON_ELECTRIC,
  82. ON_CNC_FIRE,
  83. ON_CNC_CHEM,
  84. LOCKED_ANIMATION,
  85. HIGHEST_HUMAN_STATE = LOCKED_ANIMATION
  86. } HumanStateType;
  87. typedef enum {
  88. CROUCHED_FLAG = 1 << 0,
  89. SNIPING_FLAG = 1 << 1,
  90. HIGHEST_HUMAN_STATE_FLAGS = (1 << 2) - 1
  91. } HumanStateFlagsType;
  92. typedef enum {
  93. SUB_STATE_FORWARD = 1 << 0,
  94. SUB_STATE_BACKWARD = 1 << 1,
  95. SUB_STATE_UP = 1 << 2,
  96. SUB_STATE_DOWN = 1 << 3,
  97. SUB_STATE_LEFT = 1 << 4,
  98. SUB_STATE_RIGHT = 1 << 5,
  99. SUB_STATE_TURN_LEFT = 1 << 6,
  100. SUB_STATE_TURN_RIGHT = 1 << 7,
  101. SUB_STATE_SLOW = 1 << 8,
  102. HIGHEST_HUMAN_SUB_STATE = (1 << 9) - 1
  103. } HumanSubStateType;
  104. typedef enum {
  105. HEAD_FROM_BEHIND,
  106. HEAD_FROM_FRONT,
  107. TORSO_FROM_BEHIND,
  108. TORSO_FROM_FRONT,
  109. LEFT_ARM_FROM_BEHIND,
  110. LEFT_ARM_FROM_FRONT,
  111. RIGHT_ARM_FROM_BEHIND,
  112. RIGHT_ARM_FROM_FRONT,
  113. LEFT_LEG_FROM_BEHIND,
  114. LEFT_LEG_FROM_FRONT,
  115. RIGHT_LEG_FROM_BEHIND,
  116. RIGHT_LEG_FROM_FRONT,
  117. GROIN,
  118. OUCH_FIRE,
  119. OUCH_CHEM,
  120. OUCH_ELECTRIC,
  121. OUCH_SUPER_FIRE,
  122. } HumanOuchType;
  123. HumanStateClass( void );
  124. ~HumanStateClass( void );
  125. void Init( HumanPhysClass * human_phys );
  126. void Reset(void);
  127. void Set_Anim_Control( HumanAnimControlClass * anim_control );
  128. void Set_Human_Anim_Override( const char * name );
  129. void Set_Human_Anim_Override( int def_id );
  130. void Set_Human_Loiter_Collection( int def_id );
  131. bool Save( ChunkSaveClass & csave );
  132. bool Load( ChunkLoadClass & cload );
  133. void Set_State( HumanStateType state, int sub_state = 0 );
  134. HumanStateType Get_State( void ) { return State; }
  135. const char * Get_State_Name( void );
  136. bool Is_State_Interruptable( void );
  137. void Set_Sub_State( int sub_state );
  138. int Get_Sub_State( void ) { return SubState; }
  139. bool Is_Sub_State_Adjustable( void );
  140. float Get_State_Timer( void ) { return StateTimer; }
  141. void Set_State_Timer( float timer ) { StateTimer = timer; }
  142. void Toggle_State_Flag( int flag ) { StateFlags ^= flag; }
  143. bool Get_State_Flag( int flag ) { return (StateFlags & flag) != 0; }
  144. void Drop_Weapon( void ) { WeaponHoldTimer = 0.001f; }
  145. void Raise_Weapon( void ) { WeaponHoldTimer = 10; }
  146. void Start_Transition_Animation( const char * anim_name, bool blend = true );
  147. void Start_Scripted_Animation( const char * anim_name, bool blend = true, bool looping = true );
  148. void Stop_Scripted_Animation( void );
  149. void Force_Animation( const char * anim_name, bool blend = true );
  150. void Set_Turn_Velocity( float vel ) { TurnVelocity = vel; }
  151. void Update_Weapon( WeaponClass * weapon, bool new_weapon );
  152. void Update_Aiming( float tilt, float facing );
  153. void Update_State( void );
  154. void Post_Think( void );
  155. void Update_Animation( void );
  156. bool Is_Locked( void ) { return StateLocked; }
  157. bool Get_Leg_Mode( void );
  158. int Get_Ouch_Type( const Vector3 & direction, const char * collision_box_name );
  159. static void Set_Precision(void);
  160. void Reset_Loiter_Delay( void );
  161. void Set_Loiters_Allowed( bool allowed ) { LoitersAllowed = allowed; }
  162. void Get_Information( StringClass & string );
  163. private:
  164. bool StateLocked;
  165. HumanStateType State;
  166. float StateTimer;
  167. int StateFlags;
  168. int SubState;
  169. int WeaponHoldStyle; // How is he holding his weapon?
  170. float WeaponHoldTimer; // How long until we lower the weapon?
  171. bool LoitersAllowed;
  172. float LoiterDelay;
  173. float AimingTilt;
  174. float AimingTurn;
  175. HumanPhysClass * HumanPhys; // Our local copy // Physical Object for Human
  176. HumanAnimControlClass * AnimControl; // Our local copy // Animation Control for Human Model
  177. float TurnVelocity;
  178. float LegRotation;
  179. Matrix3D JumpTM;
  180. float RecoilTimer; // remaining recoil time.
  181. float RecoilScale; // scale factor on the recoil motion.
  182. bool NoAnimBlend;
  183. bool WeaponFired;
  184. HumanAnimOverrideDef * HumanAnimOverride;
  185. HumanLoiterGlobalSettingsDef * HumanLoiterCollection;
  186. static const char * Get_Wound_Anim( int ouch_type );
  187. static const char * Get_Death_Anim( int ouch_type );
  188. void Update_Recoil(WeaponClass * weapon);
  189. // Jumping code
  190. void Begin_Jump( void );
  191. void Complete_Jump( void );
  192. };
  193. #endif // HUMANSTATE_H