Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
WeaponClass.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_WEAPONCLASS_H
13#define TT_INCLUDE_WEAPONCLASS_H
14#include "WeaponMgr.h"
15#include "MuzzleFlashClass.h"
16#include "ReferencerClass.h"
17#include "Matrix3D.h"
18class ArmedGameObj;
19class ParticleEmitterClass;
20class AudibleSoundClass;
21class PhysicalGameObj;
22typedef enum {
23 WEAPON_HOLD_STYLE_C4 = 0,
24 WEAPON_HOLD_STYLE_NOT_USED,
25 WEAPON_HOLD_STYLE_AT_SHOULDER, // 2
26 WEAPON_HOLD_STYLE_AT_HIP,
27 WEAPON_HOLD_STYLE_LAUNCHER,
28 WEAPON_HOLD_STYLE_HANDGUN,
29 WEAPON_HOLD_STYLE_BEACON,
30 WEAPON_HOLD_STYLE_EMPTY_HANDS,
31 WEAPON_HOLD_STYLE_AT_CHEST,
32 WEAPON_HOLD_STYLE_HANDS_DOWN,
33 NUM_WEAPON_HOLD_STYLES
34} WeaponHoldStyleType;
35
36typedef enum {
37 WEAPON_ANIM_NOT_FIRING,
38 WEAPON_ANIM_FIRING_0,
39 WEAPON_ANIM_FIRING_1
40} WeaponAnimState;
41
42typedef enum {
43 WEAPON_MODEL_UPDATE_WILL_BE_NEEDED,
44 WEAPON_MODEL_UPDATE_IS_NEEDED,
45 WEAPON_MODEL_UPDATE_NOT_NEEDED,
46} WeaponModelUpdateState;
47
48class WeaponClass
49{
50
51public:
52
53 enum {
54 MUZZLE_PRIMARY_0,
55 MUZZLE_PRIMARY_1,
56 MUZZLE_SECONDARY_0,
57 MUZZLE_SECONDARY_1,
58 };
59
60 typedef enum {
61 STATE_IDLE,
62 STATE_READY,
63 STATE_CHARGE,
64 STATE_FIRE_PRIMARY,
65 STATE_FIRE_SECONDARY,
66 STATE_RELOAD,
67 STATE_START_SWITCH,
68 STATE_END_SWITCH,
69 } WeaponStateType;
70
71 WeaponClass( const WeaponDefinitionClass *weapon_def = NULL );
72 ~WeaponClass( void );
73 void Init( const WeaponDefinitionClass *weapon_def );
74 bool Save( ChunkSaveClass & csave );
75 bool Load( ChunkLoadClass & cload );
76 void Set_Model( RenderObjClass *model );
77 void Set_Owner( ArmedGameObj *owner );
78 ArmedGameObj *Get_Owner( void ) { return (ArmedGameObj *)Owner.Get_Ptr(); }
79 void Select( void );
80 void Deselect( void );
81 void Update( void );
82 bool Is_Muzzle_Clear( void );
83 void Compute_Bullet_Start_Point(const Matrix3D & muzzle,Vector3 * set_start_point);
84 void Next_C4_Detonation_Mode( void ); // Take the weapon to the next state (for C4)
85 const WeaponDefinitionClass *Get_Definition( void ) { return Definition; }
86 const char * Get_Name( void ) { return Definition->Get_Name(); }
87 int Get_ID( void ) { return Definition->Get_ID(); }
88 const char * Get_HUD_Icon_Texture_Name( void ) { return Definition->HUDIconTextureName; }
89 const char * Get_Model_Name( void ) { return Definition->Model; }
90 const char * Get_Back_Model_Name( void ){ return Definition->BackModel; }
91 const char * Get_Anim_Name( void ) { return (NextAnimState != WEAPON_ANIM_NOT_FIRING) ? Definition->FireAnim : Definition->IdleAnim; }
92 const char * Get_First_Person_Anim_Name( void ) const { return Definition->FirstPersonAnim; }
93 int Get_Style( void ) { return Definition->Style; }
94 float Get_Key_Number( void ) { return Definition->KeyNumber; }
95 bool Get_Can_Snipe( void ) { return Definition->CanSnipe; }
96 float Get_Rating( void ) { return Definition->Rating; }
97 float Get_Effective_Range( void ){ return PrimaryAmmoDefinition->EffectiveRange; }
98 float Get_Primary_Fire_Rate( void ){ return PrimaryAmmoDefinition->RateOfFire; }
99 const char * Get_First_Person_Model_Name( void ) const { return Definition->FirstPersonModel; }
100 const Vector3& Get_First_Person_Model_Offset( void ) const { return Definition->FirstPersonOffset; }
101 float Get_Recoil_Time( void ) { return Definition->RecoilTime; }
102 float Get_Recoil_Scale( void ) { return Definition->RecoilScale; }
103 void Set_Total_Rounds( int num );
104 SCRIPTS_API int Get_Total_Rounds( void );
105 void Import_Ammo_Info(int16 ammoInfo);
106 int16 Export_Ammo_Info();
107 void Add_Rounds( int num );
108 void Add_Rounds_Client( int num );
109 void Set_Clip_Rounds( int rounds );
110 void Set_Inventory_Rounds( int rounds );
111 void Set_Clip_Rounds_Client( int rounds );
112 void Set_Inventory_Rounds_Client( int rounds );
113 int Get_Clip_Rounds( void ) { return ClipRounds; }
114 int Get_Inventory_Rounds( void ) { return InventoryRounds; }
115 void Do_Reload( void );
116 void Decrement_Rounds( int rounds = 1 );
117 SCRIPTS_API bool Is_Ammo_Maxed( void );
118 bool Is_Loaded( void ) { return (ClipRounds != 0); }
119 bool Is_Reload_OK( void );
120 bool Is_Reload_Needed( void ) { return !Is_Loaded() && Is_Reload_OK(); }
121 SCRIPTS_API float Get_Range( void );
122 bool Is_Model_Update_Needed( void ) { return (UpdateModel == WEAPON_MODEL_UPDATE_IS_NEEDED); }
123 void Reset_Model_Update( void ) { UpdateModel = WEAPON_MODEL_UPDATE_NOT_NEEDED; CurrentAnimState = (WeaponAnimState)-1; }
124 bool Is_Anim_Update_Needed( void ) { return ( NextAnimState != CurrentAnimState ); }
125 void Reset_Anim_Update( void ) { CurrentAnimState = NextAnimState; }
126 WeaponAnimState Get_Anim_State( void ) { return CurrentAnimState; }
127 int Get_Total_Rounds_Fired( void ) { return TotalRoundsFired; }
128 void Display_Targeting( void );
129 void Set_Target( const Vector3 &target) { Target = target; }
130 const Vector3 &Get_Target( void ) { return Target; }
131 void Set_Target_Object( PhysicalGameObj * obj );
132 PhysicalGameObj * Get_Target_Object( PhysicalGameObj * obj );
133 WeaponStateType Get_State( void ) { return State; }
134 bool Is_Firing( void ) { return DidFire; }
135 bool Is_Reloading( void ) { return (State == STATE_RELOAD); }
136 bool Is_Switching( void ) { return (State == STATE_START_SWITCH) || (State == STATE_END_SWITCH); }
137 void Force_Reload( void );
138 void Set_Safety( bool saftey ) { SafetySet = saftey; }
139 bool Is_Safety_Set( void ) { return SafetySet; }
140 void Set_Primary_Triggered( bool triggered );
141 void Set_Secondary_Triggered( bool triggered );
142 bool Is_Triggered( void ) { return IsSecondaryTriggered || IsPrimaryTriggered; }
143 void Init_Muzzle_Flash( RenderObjClass * robj ) { MuzzleFlash.Init( robj ); }
144 void Update_Muzzle_Flash( bool flashA0, bool flashA1, bool flashB0, bool flashB1 ) { MuzzleFlash.Update( flashA0, flashA1, flashB0, flashB1 ); }
145 bool Does_Weapon_Exist( void ) { return WeaponExists; }
146 void Set_Weapon_Exists( bool exists ) { WeaponExists = exists; }
147 PhysicalGameObj * Cast_Weapon( const Vector3 & target );
148 bool Cast_Weapon_Down_Muzzle( Vector3 & hit_pos );
149 void Make_Shell_Eject( const Matrix3D & tm );
150 void Stop_Firing_Sound( void );
151 void Clear_Firing_Sound() {FiringSound = 0;}
152 void Set_Did_Fire(bool fire) {DidFire = fire;}
153 void Set_State( WeaponStateType new_state );
154
155 //new
156 SCRIPTS_API float Get_Targeting_Range(void);
157 bool Tilt_Gun_While_Reloading(){return tiltGunWhileReloading && Definition->DoTiltWhileReloading;}
158 float Get_Charge_Time();
159private:
160 void Fire_C4( const AmmoDefinitionClass *ammo_def );
161 bool Fire_Beacon( const AmmoDefinitionClass *ammo_def );
162 void Fire_Bullet( const AmmoDefinitionClass *ammo_def, bool primary );
163 void clientReloadingSync();
164 void cleintReloadAmmoSync();
165 void sendReloadNetworkCall(int reloadingObjectId,int originatingClientId);
166 void sendClientAmmoAcrossNetwork(int originalPlayerId,int reloadingObjectId,int weaponId,int clipRounds,int backpackRounds);
167
168 const WeaponDefinitionClass* Definition; // 0000
169 ReferencerClass Owner; // 0004
170 RenderObjClass *Model; // 0014
171 int C4DetonationMode; // 0018
172public:
173 const AmmoDefinitionClass *PrimaryAmmoDefinition; // 001C
174 const AmmoDefinitionClass *SecondaryAmmoDefinition; // 0020
175private:
176 safe_int ClipRounds; // 0024
177 safe_int InventoryRounds; // 0028
178 safe_float BurstDelayTimer; // 002C
179 safe_int BurstCount; // 0030
180 float BulletBumpTime; // 0034
181 bool WeaponExists; // 0038
182 WeaponStateType State; // 003C
183 float StateTimer; // 0040
184 bool DidFire; // 0044
185 bool LastFrameIsPrimaryTriggered; // 0045
186 bool LastFrameIsSecondaryTriggered; // 0046
187 bool IsPrimaryTriggered; // 0047
188 bool IsSecondaryTriggered; // 0048
189 int TotalRoundsFired; // 004C
190 bool SafetySet; // 0050
191 bool LockTriggers; // 0051
192 float EmptySoundTimer; // 0054
193 WeaponAnimState NextAnimState; // 0058
194 WeaponAnimState CurrentAnimState; // 005C
195 WeaponModelUpdateState UpdateModel; // 0060
196 Vector3 Target; // 0064
197 ReferencerClass TargetObject; // 0070
198 SimpleVecClass<ParticleEmitterClass*> ContinuousEmitters; // 0080
199 AudibleSoundClass *ContinuousSound; // 008C
200 AudibleSoundClass *FiringSound; // 0090
201 int FiringSoundDefID; // 0094
202 const Matrix3D & Get_Muzzle(int index = MUZZLE_PRIMARY_0);
203 void Do_Fire(bool primary);
204 void Update_State( float dtime );
205 void Do_Firing_Effects( void );
206 void Do_Continuous_Effects( bool enable );
207 MuzzleFlashClass MuzzleFlash; // 0098
208 void Ignore_Owner( void );
209 void Unignore_Owner( void );
210 AudibleSoundClass *GlobalFiringSound;
211 bool tiltGunWhileReloading;
212public:
213 static void Set_Ammo_By_WeaponId_No_Networking(GameObject *obj,int weaponId,int clipBullets,int inventoryRounds);
214 float Get_State_Timer( void ) { return StateTimer; }
215}; // 00AC
216
217#endif