Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
VehicleGameObj.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__VEHICLEGAMEOBJ_H
13#define TT__VEHICLEGAMEOBJ_H
14
15
16
17#include "engine_vector.h"
18#include "SmartGameObj.h"
19#include "PhysClass.h"
20#include "VehicleGameObjDef.h"
21#include "SoldierGameObj.h"
22#ifndef TTLE_EXPORTS
23#include "UndergroundEffectClass.h"
24#endif
25class AudibleSoundClass;
26class VehicleGameObjDef;
27class PersistantSurfaceEmitterClass;
28class PersistantSurfaceSoundClass;
29class VehiclePhysClass;
30class Sound3DClass;
31class TransitionInstanceClass;
32class UndergroundEffectClass;
33
34class VehicleGameObj :
35 public SmartGameObj
36{
37public:
38 VehicleGameObj();
39 virtual ~VehicleGameObj();
40 virtual void Init( void );
41 void Init( const VehicleGameObjDef & definition );
42 const VehicleGameObjDef SCRIPTS_API & Get_Definition( void ) const ;
43 virtual bool Save( ChunkSaveClass & csave );
44 virtual bool Load( ChunkLoadClass & cload );
45 virtual void On_Post_Load( void );
46 virtual const PersistFactoryClass & Get_Factory( void ) const;
47 virtual void Startup( void );
48 VehiclePhysClass * Peek_Vehicle_Phys( void ) const;
49 virtual void Think( void );
50 virtual void Post_Think( void );
51 virtual void Apply_Control( void );
52 virtual int Get_Weapon_Control_Owner(void);
53 virtual bool Set_Targeting( const Vector3 & pos, bool do_tilt = true );
54 virtual bool Use_2D_Aiming( void ) { return Get_Definition().Aim2D; }
55 virtual Matrix3D Get_Look_Transform(void);
56 bool Has_Turret( void) { return TurretBone != 0; }
57 virtual VehicleGameObj * As_VehicleGameObj() { return this; }
58 virtual bool Is_Aircraft( void ) { return Get_Definition().Type == VEHICLE_TYPE_FLYING || Get_Definition().Type == VEHICLE_TYPE_SUB; }
59 virtual bool Is_Turret( void ) { return Get_Definition().Type == VEHICLE_TYPE_TURRET; }
60 virtual int Get_Player_Type(void) const;
61 virtual void Apply_Damage_Extended( const OffenseObjectClass & offense, float scale = 1.0f,
62 const Vector3 & direction = Vector3( 0,0,0 ), const char * collision_box_name = NULL );
63 void Add_Occupant( SoldierGameObj * occupant, int seat_id );
64 SCRIPTS_API void Add_Occupant( SoldierGameObj * occupant );
65 void Remove_Occupant( SoldierGameObj * occupant );
66 bool Contains_Occupant( SoldierGameObj * occupant );
67 int SCRIPTS_API Get_Occupant_Count(void);
68 int Find_Seat( SoldierGameObj * occupant );
69 SoldierGameObj * Get_Driver(void);
70 SoldierGameObj * Get_Gunner(void);
71 SoldierGameObj * Get_Actual_Gunner(void);
72 virtual bool Is_Entry_Permitted(SoldierGameObj * p_soldier);
73 void Passenger_Entering( void );
74 void Passenger_Exiting( void );
75 void Set_Vehicle_Delivered(void);
76 virtual void Export_Creation( BitStreamClass & packet );
77 virtual void Import_Creation( BitStreamClass & packet );
78 virtual void Export_Rare( BitStreamClass &packet );
79 virtual void Import_Rare( BitStreamClass &packet );
80 virtual void Export_Occasional( BitStreamClass &packet );
81 virtual void Import_Occasional( BitStreamClass &packet );
82 virtual void Import_Frequent( BitStreamClass & packet );
83 virtual void Export_Frequent( BitStreamClass & packet );
84 virtual void Import_State_Cs( BitStreamClass & packet );
85 virtual void Export_State_Cs( BitStreamClass & packet );
86 virtual CollisionReactionType Collision_Occurred( const CollisionEventClass & event );
87 const char *Get_Profile( void ) { return Get_Definition().Profile; }
88 void Get_Velocity(Vector3 & vel);
89 void Set_Velocity(Vector3 & vel);
90 virtual void Get_Description( StringClass & description );
91 float Get_Turn_Radius (void) const { return Get_Definition ().TurnRadius; }
92 bool Is_Engine_Enabled (void) const;
93 void Enable_Engine (bool onoff);
94 void Init_Wheel_Effects( void );
95 void Shutdown_Wheel_Effects( void );
96 void Update_Wheel_Effects( void );
97 virtual void Apply_Damage( const OffenseObjectClass & damager, float scale = 1.0f, int alternate_skin = -1 );
98 void Update_Damage_Meshes( void );
99 float Get_Squish_Velocity( void) { return Get_Definition().SquishVelocity; }
100 void Script_Enable_Transitions( bool enable ) { TransitionsEnabled = enable; Create_And_Destroy_Transitions(); }
101 bool Get_Transitions_Enabled ( void ) { return TransitionsEnabled; }
102 static void Set_Precision(void);
103 static bool Toggle_Target_Steering( void );
104 static void Set_Target_Steering( bool onoff );
105 static bool Is_Target_Steering( void );
106 const wchar_t * Get_Vehicle_Name( void );
107 virtual ExpirationReactionType Object_Expired( PhysClass * observed_obj );
108 void Lock_Vehicle( ScriptableGameObj *lockowner, float locktime ) { LockOwner = lockowner, LockTimer = locktime; }
109 bool Is_Locked(void) { return ((LockOwner.Get_Ptr() != NULL) && (LockTimer > 0.0f)); }
110 ScriptableGameObj * Get_Lock_Owner(void) { return LockOwner.Get_Ptr(); }
111#ifndef TTLE_EXPORTS
112 static void Set_Default_Driver_Is_Gunner(bool flag) {DefaultDriverIsGunner = flag;}
113#endif
114 bool Get_Driver_Is_Gunner(void) {return DriverIsGunner;}
115 void Toggle_Driver_Is_Gunner(void) { DriverIsGunner = !DriverIsGunner; }
116 virtual float Get_Stealth_Fade_Distance(void) const;
117 virtual float Get_Filter_Distance(void) const;
118 void Ignore_Occupants( void );
119 void Unignore_Occupants( void );
120 SoldierGameObj *Get_Occupant(int seat) {return SeatOccupants[seat];}
121 void Set_Is_Scripts_Visible(bool b) {visible = b;}
122 bool Get_Is_Scripts_Visible() {return visible;}
123 void Set_Scripts_Last_Team(char c) {LastTeam = c;}
124 void Set_Scripts_Can_Fire(bool b) {CanFire = b;Set_Object_Dirty_Bit(NetworkObjectClass::BIT_FREQUENT,true);}
125 bool Get_Scripts_Can_Fire() { return CanFire; };
126 void Set_Allow_Stealth_While_Empty(bool onoff) { AllowStealthWhileEmpty = onoff; Set_Object_Dirty_Bit(BIT_RARE, true); };
127 bool Get_Allow_Stealth_While_Empty() const { return AllowStealthWhileEmpty; };
128 void Damage_Meshes_Update() { DamageMeshesUpdate = true; DamageMeshesNetworkUpdate = true; Set_Object_Dirty_Bit(NetworkObjectClass::BIT_FREQUENT, true); }
129 void Set_Occupant(int seat, SoldierGameObj *occupant) {SeatOccupants[seat] = occupant;}
130 bool Is_Underground() { return Peek_Physical_Object()->Get_Collision_Group() == UNDERGROUND_COLLISION_GROUP; }
131 SCRIPTS_API void Set_Immovable(bool b);
132 bool Is_Immovable() {return Peek_Physical_Object()->Is_Immovable();}
133 void Set_Lock_Team(int team) {LockTeam = (char)team;Set_Object_Dirty_Bit(BIT_RARE,true);} //0 = nod, 1 = gdi, 2 = both
134 int Get_Lock_Team() {return LockTeam;}
135 void Set_Can_Be_Stolen(bool onoff) { CanBeStolen = onoff; Set_Object_Dirty_Bit(BIT_RARE, true); }
136 bool Can_Be_Stolen() const { return CanBeStolen; }
137 void Set_Owner(SoldierGameObj *obj) {Owner = obj;}
138 void Set_Can_Drive(bool onoff) {CanDrive = onoff; Set_Object_Dirty_Bit(BIT_RARE, true);}
139 bool Can_Drive() {return CanDrive;}
140#ifndef TTLE_EXPORTS
141 void Set_Color(Vector3 &color) {if (UndergroundEffect){UndergroundEffect->Set_Color(color);Set_Object_Dirty_Bit( NetworkObjectClass::BIT_RARE, true );}}
142#endif
143 SoldierGameObj *Get_Owner()
144 {
145 if (Owner.Get_Ptr())
146 {
147 return Owner.Get_Ptr()->As_SoldierGameObj();
148 }
149 else
150 {
151 return NULL;
152 }
153 }
154 bool Scripts_Is_Enemy(DamageableGameObj *obj)
155 {
156 bool enemy = false;
157 if (obj != this && obj != NULL)
158 {
159 int sTeamID1 = LastTeam;
160 if (LastTeam == -2)
161 {
162 sTeamID1 = Get_Player_Type();
163 }
164 int sTeamID2 = obj->Get_Player_Type();
165 if ( sTeamID1 != -2 && sTeamID2 != -2 && sTeamID1 != -4 && sTeamID2 != -4 )
166 {
167 if ( sTeamID1 != -1 && sTeamID2 != -1 )
168 {
169 enemy = sTeamID1 != sTeamID2;
170 }
171 else
172 {
173 enemy = true;
174 }
175 }
176 else
177 {
178 enemy = false;
179 }
180 }
181 return enemy;
182 }
183 bool Scripts_Is_Teammate(const DamageableGameObj* oObject);
184 bool Scripts_Is_Team_Player()
185 {
186 int team = LastTeam;
187 if (LastTeam == -2)
188 {
189 team = Get_Player_Type();
190 }
191 return ((team <= 1) && (team >= 0));
192 }
193#ifndef TTLE_EXPORTS
194 static void Set_Camera_Locked_To_Turret(bool flag) {CameraLockedToTurret = flag;}
195 static bool Get_Camera_Locked_To_Turret(void) {return CameraLockedToTurret;}
196#endif
197protected:
198#ifndef TTLE_EXPORTS
199 static REF_DECL(bool, DefaultDriverIsGunner);
200 static REF_DECL(bool, CameraLockedToTurret);
201#endif
202 Sound3DClass *Sound; //2416
203 int EngineSoundState; //2420
204 AudibleSoundClass *CachedEngineSound; //2424
205 int TurretBone; //2428
206 int BarrelBone; //2432
207 float TurretTurn; //2436
208 float BarrelTilt; //2440
209 float BarrelOffset; //2444
210 bool TransitionsEnabled; //2448
211 bool HasEnterTransitions; //2449
212 bool HasExitTransitions; //2450
213 bool VehicleDelivered; //2451
214 bool DriverIsGunner; //2452
215 bool visible; //2453
216 char LastTeam; //2454
217 bool DamageMeshesUpdate; //2455
218 VectorClass<PersistantSurfaceEmitterClass *> WheelSurfaceEmitters; //2456
219 PersistantSurfaceSoundClass * WheelSurfaceSound; //2472
220 enum {
221 DRIVER_SEAT = 0,
222 GUNNER_SEAT,
223 };
224 VectorClass<SoldierGameObj *> SeatOccupants; //2476
225 int OccupiedSeats; //2492
226 DynamicVectorClass<TransitionInstanceClass *> TransitionInstances; //2496
227 ReferencerClass LockOwner; //2520
228 float LockTimer; //2536
229 bool CanFire;
230 bool AllowStealthWhileEmpty;
231 char LockTeam;
232 bool CanBeStolen;
233 UndergroundEffectClass *UndergroundEffect;
234 ReferencerClass Owner; //Owner for SSGM vehicle locking. When this is set, only this player can enter the vehicle.
235 bool HasUpdatedTargeting;
236 bool CanDrive; //used to identify if it should apply analog control or not, for EMP purposes
237 bool DamageMeshesNetworkUpdate;
238 bool FixedTurretFacing;
239 bool LockedTurretFacing;
240 float DesiredTurretTurn;
241 float DesiredBarrelTilt;
242
243 void Remove_Transitions( TransitionDataClass::StyleType transition_type );
244 void Create_New_Transitions( TransitionDataClass::StyleType transition_type );
245 void Destroy_Transitions( void );
246 void Update_Transitions( void );
247 void Create_And_Destroy_Transitions( void );
248public:
249 void Aquire_Turret_Bones( void );
250 void Release_Turret_Bones( void );
251 void Reset_Sound_Effects( void );
252 void Update_Turret( float weapon_turn, float weapon_tilt );
253protected:
254 void Update_Sound_Effects( void );
255 void Change_Engine_Sound_State( int new_state );
256 void Update_Engine_Sound_Pitch( void );
257 virtual bool Is_Visible();
258public:
259 virtual int Check_If_On_Surface(int surface_type);
260
261 void VehicleGameObj::Set_Fixed_Turret_Facing(bool fixed)
262 {
263 if(!LockedTurretFacing)
264 {
265 FixedTurretFacing = fixed;
266 }
267 }
268
269 void VehicleGameObj::Set_Locked_Turret_Facing(bool locked)
270 {
271 LockedTurretFacing = locked;
272 }
273
274 bool VehicleGameObj::Get_Fixed_Turret_Facing()
275 {
276 return FixedTurretFacing;
277 }
278
279 bool VehicleGameObj::Get_Locked_Turret_Facing()
280 {
281 return LockedTurretFacing;
282 }
283
284 void VehicleGameObj::Set_Desired_Turret_Turn(float angle)
285 {
286 DesiredTurretTurn = angle;
287 }
288
289 void VehicleGameObj::Set_Desired_Barrel_Tilt(float angle)
290 {
291 DesiredBarrelTilt = angle;
292 }
293
294 float VehicleGameObj::Get_Desired_Turret_Turn()
295 {
296 return DesiredTurretTurn;
297 }
298
299 float VehicleGameObj::Get_Desired_Barrel_Tilt()
300 {
301 return DesiredBarrelTilt;
302 }
303
304 float VehicleGameObj::Get_Turret_Turn()
305 {
306 return TurretTurn;
307 }
308
309 float VehicleGameObj::Get_Barrel_Tilt()
310 {
311 return BarrelTilt;
312 }
313
314 void VehicleGameObj::Set_Turret_Turn(float turn)
315 {
316 TurretTurn=turn;
317 }
318
319 void VehicleGameObj::Set_Barrel_Tilt(float tilt)
320 {
321 BarrelTilt=tilt;
322 }
323
324}; // size: 2541
325#endif