Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
SoldierGameObj.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE__SOLDIERGAMEOBJ_H
13#define TT_INCLUDE__SOLDIERGAMEOBJ_H
14
15#include "DialogueClass.h"
16#include "HumanStateClass.h"
17#include "SmartGameObj.h"
18#include "PhysClass.h"
19#include "ArmorWarheadManager.h"
20#include "TransitionGameObjDef.h"
21class TransitionInstanceClass;
22class RenderObjClass;
23class SimpleAnimControlClass;
24class TransitionCompletionDataStruct
25{
26public:
27 TransitionDataClass::StyleType Type;
28 ReferencerClass Vehicle;
29 bool Save(ChunkSaveClass &csave);
30 bool Load(ChunkLoadClass &cload);
31};
32class TransitionEffectClass;
33class SoldierObserverClass;
34class DynamicSpeechAnimClass;
35class PersistantSurfaceEmitterClass;
36class SoldierGameObjDef;
37class Phys3Class;
38class AudibleSoundClass;
39class SoldierGameObj : public SmartGameObj
40{
41public:
42 SoldierGameObj();
43 virtual ~SoldierGameObj();
44 virtual void Init( void );
45 void Init( const SoldierGameObjDef & definition );
46 void Copy_Settings( const SoldierGameObjDef & definition );
47 void SCRIPTS_API Re_Init( const SoldierGameObjDef & definition );
48 SCRIPTS_API const SoldierGameObjDef & Get_Definition( void ) const ;
49 virtual bool Save( ChunkSaveClass & csave );
50 virtual bool Load( ChunkLoadClass & cload );
51 virtual void On_Post_Load( void );
52 virtual const PersistFactoryClass & Get_Factory( void ) const;
53 HumanPhysClass * Peek_Human_Phys( void ) const;
54 virtual void Think( void );
55 virtual void Post_Think( void );
56 virtual void Set_Control_Owner(int control_owner);
57 virtual void Generate_Control( void );
58 virtual void Apply_Control( void );
59 virtual void Apply_Damage( const OffenseObjectClass & damager, float scale = 1.0f, int alternate_skin = -1 );
60 virtual void Apply_Damage_Extended( const OffenseObjectClass & offense, float scale = 1.0f,
61 const Vector3 & direction = Vector3( 0,0,0 ), const char * collision_box_name = NULL );
62 virtual void Set_Delete_Pending (void);
63
67 virtual void Apply_Damage_IgnoreVehicleCheck( const OffenseObjectClass & damager, float scale = 1.0f, int alternate_skin = -1 );
68
69 virtual void Completely_Damaged( const OffenseObjectClass & damager ) {}
70 virtual CollisionReactionType Collision_Occurred( const CollisionEventClass & event );
71 virtual Vector3 Get_Bullseye_Position( void );
72 virtual bool Is_Turreted( void ) { return false; }
73 virtual bool Set_Targeting( const Vector3 & pos, bool do_tilt = true );
74 float Get_Weapon_Height( void );
75 float Get_Weapon_Length( void );
76 virtual const Matrix3D &Get_Muzzle( int index = 0 );
77 bool Detonate_C4( void ) { return DetonateC4; }
78 virtual void Set_Weapon_Model( const char *model_name );
79 virtual void Set_Weapon_Animation( const char *anim_name );
80 virtual void Start_Transition_Animation( const char * anim_name, TransitionCompletionDataStruct * completion_data );
81 virtual void Set_Animation( const char *animation_name, bool looping = true, float frame_offset = 0.0f );
82 virtual void Set_Blended_Animation( const char *animation_name, bool looping = true, float frame_offset = 0.0f, bool play_backwards = false );
83 void Handle_Legs( void );
84 void Exit_Ladder( void );
85 void Enter_Ladder( bool top );
86 virtual void Import_State_Cs( BitStreamClass & packet );
87 virtual void Export_State_Cs( BitStreamClass & packet );
88 void Interpret_Sc_Position_Data(const Vector3 & sc_position);
89 void Interpret_Sc_State_Data(HumanStateClass::HumanStateType state,
90 int sub_state, LPCSTR trans_name, const Vector3 & velocity, const Vector3 & sc_position);
91 int Tally_Vis_Visible_Soldiers(void);
92 SCRIPTS_API bool Is_In_Elevator(void);
93 virtual void Export_Creation( BitStreamClass &packet );
94 virtual void Import_Creation( BitStreamClass &packet );
95 virtual void Export_Rare( BitStreamClass &packet );
96 virtual void Import_Rare( BitStreamClass &packet );
97 virtual void Export_Occasional( BitStreamClass &packet );
98 virtual void Import_Occasional( BitStreamClass &packet );
99 virtual void Export_Frequent( BitStreamClass & packet );
100 virtual void Import_Frequent( BitStreamClass & packet );
101 bool Is_Dead( void ) { return Get_State() == HumanStateClass::DEATH; }
102 bool Is_Destroyed( void ) { return Get_State() == HumanStateClass::DESTROY; }
103 bool Is_Upright( void ) { return Get_State() == HumanStateClass::UPRIGHT; }
104 bool Is_Wounded( void ) { return Get_State() == HumanStateClass::WOUNDED; }
105 bool In_Transition( void ) { return Get_State() == HumanStateClass::TRANSITION; }
106 bool Is_Airborne( void ) { return Get_State() == HumanStateClass::AIRBORNE; }
107 bool Is_Crouched( void ) { return HumanState.Get_State_Flag( HumanStateClass::CROUCHED_FLAG ); }
108 bool Is_Sniping( void ) { return HumanState.Get_State_Flag( HumanStateClass::SNIPING_FLAG ); }
109 void Set_Is_Sniping() { HumanState.Toggle_State_Flag(HumanStateClass::SNIPING_FLAG); Set_Object_Dirty_Bit(BIT_OCCASIONAL, true); }
110 bool Is_Slow( void ) { return (Get_Sub_State() & HumanStateClass::SUB_STATE_SLOW) != 0; }
111 bool Is_On_Ladder( void ) { return Get_State() == HumanStateClass::LADDER; }
112 bool Is_In_Vehicle( void ) { return Get_State() == HumanStateClass::IN_VEHICLE; }
113 void Reset_Loiter_Delay( void ) { HumanState.Reset_Loiter_Delay(); }
114 virtual void Get_Information( StringClass & string );
115 virtual void Get_Description(StringClass & description);
116 void Toggle_Fly_Mode( void );
117 virtual float Get_Max_Speed( void );
118 virtual void Set_Max_Speed( float speed );
119 virtual float Get_Turn_Rate( void );
120 void Enter_Vehicle( VehicleGameObj * vehicle, const char * anim_name );
121 void Exit_Vehicle( void );
122 void Exit_Destroyed_Vehicle( int seat_num, const Vector3 & vehicle_pos );
123 bool Is_Permitted_To_Enter_Vehicle( void );
124 VehicleGameObj * Get_Vehicle( void ) { return Vehicle; }
125 VehicleGameObj * Get_Profile_Vehicle( void );
126 bool Use_Ladder_View( void );
127 StringClass Get_Animation_Name( void ) { return AnimationName; }
128 HumanStateClass * Get_Human_State( void ) { return &HumanState; }
129 void Set_Model(const char *model_name);
130 virtual SoldierGameObj * As_SoldierGameObj() { return this; };
131 void Get_Velocity(Vector3 & vel);
132 void Set_Velocity(Vector3 & vel);
133 void Give_All_Weapons(void);
134 bool Can_See(SoldierGameObj * p_soldier);
135 void Adjust_Skeleton( float height, float width );
136 void Look_At( const Vector3 & pos, float time ) { HeadLookTarget = pos; HeadLookDuration = time; HeadLookAngle = Vector3(0,0,0); }
137 void Update_Look_At( const Vector3 & pos ) { HeadLookTarget = pos; }
138 void Cancel_Look_At( void ) { HeadLookDuration = 0.001F; }
139 void Look_Random( float time );
140 bool Is_Looking( void ) { return (HeadLookDuration > 0); }
141 virtual Matrix3D Get_Look_Transform(void);
142 void Lock_Facing( PhysicalGameObj * game_obj, bool turn_body );
143 void Innate_Enable( int bits = 0xFFFFFFFF ) { InnateEnableBits |= bits; }
144 void Innate_Disable( int bits = 0xFFFFFFFF ) { InnateEnableBits &= ~bits; }
145 bool Is_Innate_Enabled( int bits = 0xFFFFFFFF ) { return (InnateEnableBits & bits) != 0; }
146 void Say_Dialogue( int dialog_id );
147 static float Say_Dynamic_Dialogue( int text_id, SoldierGameObj *speaker = NULL, AudibleSoundClass **sound_obj_to_return = NULL );
148 void Stop_Current_Speech( void );
149 RenderObjClass * Find_Head_Model( void );
150 void Prepare_Speech_Framework( void );
151 void Enable_Ghost_Collision( bool onoff );
152 bool Is_Soldier_Blocked( const Vector3 &curr_pos );
153 bool Disable_Ghost_Collision();
154 DynamicSpeechAnimClass *Get_Facial_Anim (void) { return SpeechAnim; }
155 void Set_Emot_Icon (const char *model_name, float duration );
156 SoldierObserverClass * Get_Innate_Controller( void );
157 SoldierAIState Get_AI_State( void ) const { return AIState; }
158 void Set_AI_State( SoldierAIState state );
159 void Set_Innate_Observer( SoldierObserverClass * observer ) { InnateObserver = observer; }
160 SoldierObserverClass * Get_Innate_Observer( void ) { return InnateObserver; }
161 void Clear_Innate_Observer( void ) { InnateObserver = NULL; }
162 const char * Get_First_Person_Hands_Model_Name( void );
163 void Perturb_Position(float max_perturb = 5);
164 int Get_Key_Ring( void ) const { return KeyRing; }
165 void Give_Key( int key_number ) { KeyRing |= (1 << key_number); }
166 void Remove_Key( int key_number ) { KeyRing &= ~(1 << key_number); }
167 bool Has_Key( int key_number ) { return ((1 << key_number) & KeyRing) != 0; }
168 virtual bool Wants_Powerups( void )
169 {
170 if (Get_Player_Type() == -4 || Is_Dead() || Is_Destroyed())
171 {
172 return false;
173 }
174 return Is_Human_Controlled();
175 }
176 virtual bool Allow_Special_Damage_State_Lock( void ) { return (Is_Human_Controlled() == false); }
177 virtual bool Is_Visible( void ) { return IsVisible && !Vehicle; }
178 void Set_Is_Visible( bool visible ) { IsVisible = visible; }
179 virtual bool Is_Targetable( void ) const;
180 virtual float Get_Stealth_Fade_Distance(void) const;
181 bool Get_Fly_Mode() {return InFlyMode;}
182 HumanStateClass::HumanStateType Get_State( void ) { return HumanState.Get_State(); }
183 RenderObjClass *Get_Weapon_Render_Model() {return WeaponRenderModel; }
184 void Update_Back_Gun( void );
185 const char * Get_State_Name( void ) { return HumanState.Get_State_Name(); }
186 void Set_Can_Steal_Vehicles(bool onoff) { CanStealVehicles = onoff; Set_Object_Dirty_Bit(BIT_RARE, true); }
187 bool Can_Steal_Vehicles() { return CanStealVehicles; }
188 void Set_Can_Drive_Vehicles(bool onoff) { CanDriveVehicles = onoff; Set_Object_Dirty_Bit(BIT_RARE, true); }
189 bool Can_Drive_Vehicles() { return CanDriveVehicles; }
190 void Set_Block_Action_Key(bool onoff) { BlockActionKey = onoff; Set_Object_Dirty_Bit(BIT_RARE, true); }
191 bool Block_Action_Key() { return BlockActionKey; }
192 void Set_Freeze(bool onoff) {Freeze = onoff; Set_Object_Dirty_Bit(BIT_RARE, true);}
193 bool Is_Frozen() {return Freeze;}
194 void Lock_Collision_Mode(bool lockCollisionGroup,Collision_Group_Type lock);
195 Collision_Group_Type *Get_Locked_Collision_Mode();
196 void Set_Can_Play_Damage_Animations(bool onoff) {CanPlayDamageAnimations = onoff;Set_Object_Dirty_Bit(BIT_RARE, true);}
197 bool Can_Play_Damage_Animations() {return CanPlayDamageAnimations;}
198 void Set_Scale_Across_Network(float scale){NetworkRescale = scale;Set_Object_Dirty_Bit(BIT_RARE, true);}
199 float Get_Scale_Across_Network(){return NetworkRescale;}
200 void Set_Movement_Loiters_Allowed(bool allowed){movementLoitersAllowed = allowed;};
201 bool Get_Movement_Loiter_Allowed(){return movementLoitersAllowed;};
202 bool Get_Use_Stock_Ghost_Behavior(){return useStockGhostBehavior;}
203 void Set_Override_Muzzle_Direction(bool override){OverrideMuzzleDirection = override; Set_Object_Dirty_Bit(BIT_RARE, true);};
204 bool Get_Override_Muzzle_Direction(){return OverrideMuzzleDirection;};
205 void Set_Bot_Tag(const char* tag) { botTag = tag; Set_Object_Dirty_Bit(BIT_RARE, true); }
206 const WideStringClass& Get_Bot_Tag() { return botTag; }
207 bool Is_Bot() { return botTag.Get_Length() > 0; }
208 virtual int Get_Contact_Surface_Type();
209 virtual float Get_Skeleton_Heigth( void );
210 virtual void Set_Skeleton_Height( float height );
211 virtual float Get_Skeleton_Width( void );
212 virtual void Set_Skeleton_Width( float width );
213 virtual void Set_Override_Weapon_Hold_Style(int overrideWeaponHoldStyleId);
214 virtual int Get_Override_Weapon_Hold_Style();
215 virtual void Set_Human_Anim_Override(bool enableHumanAnimOverride);
216 virtual int Get_Human_Anim_Override();
217 virtual void Set_Enable_Foot_Steps(bool enableFootSteps);
218 virtual void Trigger_Smooth_Skeleton_Height_Resize(float targetHeight,float speed);
219 virtual void Trigger_Smooth_Skeleton_Width_Resize(float targetWidth,float speed);
220protected:
221 RenderObjClass * WeaponRenderModel; //2416
222 RenderObjClass * BackWeaponRenderModel; //2420
223 RenderObjClass * BackFlagRenderModel; //2424
224 AnimControlClass * WeaponAnimControl; //2428
225 bool DetonateC4; //2432
226 TransitionCompletionDataStruct * TransitionCompletionData; //2436
227 StringClass AnimationName; //2440
228 VehicleGameObj * Vehicle; //2444
229 HumanStateClass HumanState; //2448
230 float LegFacing; //2576
231 bool SyncLegs; //2580
232 bool LastLegMode; //2581
233 int KeyRing; //2584
234 bool IsUsingGhostCollision; //2588
235 DialogueClass DialogList[DIALOG_MAX]; //2592
236 AudibleSoundClass * CurrentSpeech; //3232
237 float HeadLookDuration; //3236
238 Vector3 HeadRotation; //3240
239 Vector3 HeadLookTarget; //3252
240 Vector3 HeadLookAngle; //3264
241 float HeadLookAngleTimer; //3276
242 int Get_Sub_State( void ) { return HumanState.Get_Sub_State(); }
243 void Update_Locked_Facing( void );
244 void Set_Back_Weapon_Model( const char *model_name );
245 void Set_Back_Flag_Model( const char *model_name, const Vector3 & tint = Vector3(0, 0, 0) );
246 int Get_Ouch_Type( const Vector3 & direction, const char * collision_box_name ) { return HumanState.Get_Ouch_Type( direction, collision_box_name ); }
247 bool Internal_Set_Targeting( const Vector3 & pos, bool do_tilt = true );
248 ArmorWarheadManager::SpecialDamageType SpecialDamageMode; //3280
249 float SpecialDamageTimer; //3284
250 ReferencerClass SpecialDamageDamager; //3288
251 TransitionEffectClass * SpecialDamageEffect; //3304
252 void Set_Special_Damage_Mode( ArmorWarheadManager::SpecialDamageType mode, ArmedGameObj * damager = NULL );
253 TransitionEffectClass * HealingEffect; //3308
254 void Handle_Head_look( void );
255 ReferencerClass FacingObject; //3312
256 bool FacingAllowBodyTurn; //3328
257 int InnateEnableBits; //3332
258 SoldierObserverClass *InnateObserver; //3336
259 SoldierAIState AIState; //3340
260 DynamicSpeechAnimClass *SpeechAnim; //3344
261 float GenerateIdleFacialAnimTimer; //3348
262 RenderObjClass * HeadModel; //3352
263 RenderObjClass * EmotIconModel; //3356
264 float EmotIconTimer; //3360
265 bool InFlyMode; //3364
266 bool IsVisible; //3365
267 bool LadderUpMask; //3366
268 bool LadderDownMask; //3367
269 float ReloadingTilt; //3368
270 bool WeaponChanged; //3372
271 bool CanStealVehicles; // padding
272 bool CanDriveVehicles; // padding
273 PersistantSurfaceEmitterClass * WaterWake; //3376
274 DynamicVectorClass<RenderObjClass*> RenderObjList; //3380
275 bool BlockActionKey;
276 bool Freeze; //used to detect that this soldier is frozen (cant fire, move, jump, climb ladders, etc)
277 void Add_RenderObj( RenderObjClass * obj );
278 RenderObjClass * Find_RenderObj( const char * name );
279 void Reset_RenderObjs( void );
280 void Update_Healing_Effect( void );
281 int head_bone;
282 int neck_bone;
283 bool CanPlayDamageAnimations;
284 float NetworkRescale;
285 float LastScale;
286 bool movementLoitersAllowed;
287 bool useStockGhostBehavior;
288 bool OverrideMuzzleDirection;
289 bool UpdatedTarget;
290 bool DoTilt;
291 float skeletonHeight;
292 float skeletonWidth;
293 float lastSkeletonHeight;
294 float lastSkeletonWidth;
295 int overrideWeaponHoldStyleId;
296 bool enableHumanAnimOverride;
297 WideStringClass botTag;
298 int sight_bone;
299 bool enableFootSteps;
300 float targetSoldierHeight;
301 float targetSoldierWidth;
302 float targetSoldierHeightSpeed;
303 float targetSoldierWidthSpeed;
304 TT_DEPRECATED("Do not use") int Check(void);
305}; // size: 3404
306
307
308#endif