DayZ 1.24
Loading...
Searching...
No Matches
WeaponParticlesBase Class Reference
Collaboration diagram for WeaponParticlesBase:
[legend]

Private Member Functions

void WeaponParticlesBase (ItemBase muzzle_owner, string config_OnFire_entry)
 
void OnActivate (ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
 
void OnParticleCreated (ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
 
void OnDeactivate (ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
 
void OnUpdate (ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
 
bool CheckBoltStateCondition (ItemBase weapon)
 
bool CheckHealthCondition (int health_label)
 
bool CheckOverheatingCondition (float overheating_coef)
 
bool CheckRainCondition (float rain_coef)
 
int CheckParticleOverride (string ammoType)
 
vector CheckOrientationOverride (vector local_pos, ItemBase muzzle_owner)
 

Private Attributes

bool m_IlluminateWorld
 
bool m_IgnoreIfSuppressed
 
bool m_OnlyIfBoltIsOpen
 
int m_MuzzleIndex
 
int m_OverrideParticle
 
int m_OnlyWithinHealthLabelMin
 
int m_OnlyWithinHealthLabelMax
 
float m_OnlyWithinOverheatLimitsMin
 
float m_OnlyWithinOverheatLimitsMax
 
float m_OnlyWithinRainLimitsMin
 
float m_OnlyWithinRainLimitsMax
 
string m_OverrideDirectionPoint
 
string m_OnlyIfBulletIs
 
string m_OnlyIfWeaponIs
 
string m_OverridePoint
 
vector m_OverrideDirectionVector
 
vector m_PositionOffset
 
string m_Name
 

Detailed Description

Definition at line 7 of file WeaponParticles.c.

Constructor & Destructor Documentation

◆ WeaponParticlesBase()

void WeaponParticlesBase::WeaponParticlesBase ( ItemBase muzzle_owner,
string config_OnFire_entry )
inlineprivate

Definition at line 33 of file WeaponParticles.c.

34 {
36
37 // ignoreIfSuppressed
38 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
39
40 // onlyIfBoltIsOpen
41 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
42
43 // illuminateWorld
44 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
45
46 m_MuzzleIndex = -1;
47 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
48 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
49
50 // onlyIfWeaponIs
52 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
53
54 // onlyIfBulletIs
56 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
57
58 // onlyWithinHealthLabel[]
60 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
61
62 if (health_limit.Count() == 2)
63 {
66 }
67 else
68 {
69 // Disable this filter
72 }
73
74 // onlyWithinOverheatLimits[]
76 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
77
78 if (overheat_limit.Count() == 2)
79 {
82 }
83 else
84 {
85 // Disable this filter
88 }
89
90 // onlyWithinRainLimits[]
92 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
93
94 if (rain_limit.Count() == 2)
95 {
98 }
99 else
100 {
101 // Disable this filter
104 }
105
106 // overridePoint
107 m_OverridePoint = "";
108 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
109
110 if (m_OverridePoint == "")
111 m_OverridePoint = "Usti hlavne"; // default memory point name
112
113 // overrideParticle
114 string particle_name = "";
115 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
116
117 if (particle_name != "")
119 else
120 {
122 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
124 }
125
126 // overrideDirectionPoint
128 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
129
130 if (m_OverrideDirectionPoint == "")
131 {
132 // overrideDirectionVector
133 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
134
135 if (test_ori != vector.Zero)
137 }
138
139 // positionOffset[]
141 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
142
143 if (v.Count() == 3)
144 {
145 float v1 = v.Get(0);
146 float v2 = v.Get(1);
147 float v3 = v.Get(2);
149 }
150 }
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

References ErrorEx, GetGame(), ParticleList::GetParticleIDByName(), m_IgnoreIfSuppressed, m_IlluminateWorld, m_MuzzleIndex, m_Name, m_OnlyIfBoltIsOpen, m_OnlyIfBulletIs, m_OnlyIfWeaponIs, m_OnlyWithinHealthLabelMax, m_OnlyWithinHealthLabelMin, m_OnlyWithinOverheatLimitsMax, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinRainLimitsMax, m_OnlyWithinRainLimitsMin, m_OverrideDirectionPoint, m_OverrideDirectionVector, m_OverrideParticle, m_OverridePoint, m_PositionOffset, Vector(), and vector::Zero.

Member Function Documentation

◆ CheckBoltStateCondition()

bool WeaponParticlesBase::CheckBoltStateCondition ( ItemBase weapon)
inlineprivate

Definition at line 246 of file WeaponParticles.c.

247 {
249 {
251 WeaponStateBase current_state = wb.GetCurrentState();
252 return current_state.IsBoltOpen();
253 }
254
255 return true;
256 }
represent weapon state base
Definition BulletHide.c:2

References m_OnlyIfBoltIsOpen.

Referenced by OnActivate().

◆ CheckHealthCondition()

bool WeaponParticlesBase::CheckHealthCondition ( int health_label)
inlineprivate

Definition at line 259 of file WeaponParticles.c.

References m_OnlyWithinHealthLabelMax, and m_OnlyWithinHealthLabelMin.

Referenced by OnActivate().

◆ CheckOrientationOverride()

vector WeaponParticlesBase::CheckOrientationOverride ( vector local_pos,
ItemBase muzzle_owner )
inlineprivate

Definition at line 314 of file WeaponParticles.c.

315 {
316 vector particle_ori = "0 0 0";
317 if (m_OverrideDirectionPoint != "")
318 {
319 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
321 particle_ori = target_pos.VectorToAngles();
322 }
323 else
324 {
325 if (m_OverrideDirectionVector != Vector(0, 0, 0))
327
328 if (muzzle_owner.IsInherited(ItemSuppressor))
329 {
330 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
331 }
332 }
333
334 return particle_ori;
335 }
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Definition EnConvert.c:220

References vector::Direction(), m_OverrideDirectionPoint, m_OverrideDirectionVector, and Vector().

Referenced by OnActivate().

◆ CheckOverheatingCondition()

bool WeaponParticlesBase::CheckOverheatingCondition ( float overheating_coef)
inlineprivate

◆ CheckParticleOverride()

int WeaponParticlesBase::CheckParticleOverride ( string ammoType)
inlineprivate

Definition at line 277 of file WeaponParticles.c.

278 {
279 int particle_id = -1;
280
281 string particle_file = "";
282 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
283 if (GetGame().ConfigGetText(cfg_path, particle_file))
285
286 // Config is accessed only once because the data is saved into a map for repeated access.
287
288 if (particle_id > 0 || m_OverrideParticle == -1)
289 {
290 if (particle_file == "")
291 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
292 else
293 {
295
296 if (particle_id == 0)
297 {
298 string devStr;
299#ifdef DEVELOPER
300 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
301#endif
302 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
303 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
304 }
305 }
306 }
307 else
309
310 return particle_id;
311 }
int particle_id

References ErrorEx, GetGame(), ParticleList::GetParticleIDByName(), m_OverrideParticle, and particle_id.

Referenced by OnActivate().

◆ CheckRainCondition()

bool WeaponParticlesBase::CheckRainCondition ( float rain_coef)
inlineprivate

Definition at line 271 of file WeaponParticles.c.

References m_OnlyWithinRainLimitsMax, and m_OnlyWithinRainLimitsMin.

Referenced by OnActivate().

◆ OnActivate()

void WeaponParticlesBase::OnActivate ( ItemBase weapon,
int muzzle_index,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
inlineprivate

Definition at line 158 of file WeaponParticles.c.

159 {
160 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
161 {
162 // Handle effect's parameters
163 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
164 {
166 {
167 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
168 {
169 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
170 {
171 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
172 {
173 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
174 {
175 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
176 {
177 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
178 {
179 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
180 {
181 // Get particle ID
183
185 {
186 // Get position of the particle
187 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
189
190 // Set orientation of the particle
192
193 // Create particle
196 }
197 else
198 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
199
200 // Create light
202 {
203 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
204 int randX = Math.RandomInt(0, 10);
205 if (randX > 8)
206 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
207 else if (randX > 4)
209 else
210 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
211 }
212 }
213 }
214 }
215 }
216 }
217 }
218 }
219 }
220 }
221 }
222 }
void MuzzleFlashLight_1()
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition EnMath.c:7
Legacy way of using particles in the game.
Definition Particle.c:7
static bool IsValidId(int id)
Purely checks for an invalid number, does NOT mean it is actually registered.
static bool m_GunParticlesState
Definition gameplay.c:1478
bool CheckRainCondition(float rain_coef)
bool CheckHealthCondition(int health_label)
vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
bool CheckOverheatingCondition(float overheating_coef)
int CheckParticleOverride(string ammoType)
void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
bool CheckBoltStateCondition(ItemBase weapon)
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].

References CheckBoltStateCondition(), CheckHealthCondition(), CheckOrientationOverride(), CheckOverheatingCondition(), CheckParticleOverride(), CheckRainCondition(), ErrorEx, GetGame(), ParticleList::IsValidId(), PrtTest::m_GunParticlesState, m_IgnoreIfSuppressed, m_IlluminateWorld, m_MuzzleIndex, m_Name, m_OnlyIfBulletIs, m_OnlyIfWeaponIs, m_OverridePoint, m_PositionOffset, MuzzleFlashLight_1(), OnParticleCreated(), particle_id, ParticleManager(), Math::RandomInt(), and Vector().

◆ OnDeactivate()

void WeaponParticlesBase::OnDeactivate ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
inlineprivate

Definition at line 229 of file WeaponParticles.c.

230 {
231
232 }

◆ OnParticleCreated()

void WeaponParticlesBase::OnParticleCreated ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search,
Particle p )
inlineprivate

Definition at line 224 of file WeaponParticles.c.

225 {
226
227 }

Referenced by OnActivate().

◆ OnUpdate()

void WeaponParticlesBase::OnUpdate ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
inlineprivate

Definition at line 234 of file WeaponParticles.c.

235 {
236
237 }

Member Data Documentation

◆ m_IgnoreIfSuppressed

bool WeaponParticlesBase::m_IgnoreIfSuppressed
private

Definition at line 10 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().

◆ m_IlluminateWorld

bool WeaponParticlesBase::m_IlluminateWorld
private

Definition at line 9 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().

◆ m_MuzzleIndex

int WeaponParticlesBase::m_MuzzleIndex
private

Definition at line 12 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().

◆ m_Name

string WeaponParticlesBase::m_Name
private

Definition at line 27 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().

◆ m_OnlyIfBoltIsOpen

bool WeaponParticlesBase::m_OnlyIfBoltIsOpen
private

Definition at line 11 of file WeaponParticles.c.

Referenced by CheckBoltStateCondition(), and WeaponParticlesBase().

◆ m_OnlyIfBulletIs

string WeaponParticlesBase::m_OnlyIfBulletIs
private

Definition at line 21 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().

◆ m_OnlyIfWeaponIs

string WeaponParticlesBase::m_OnlyIfWeaponIs
private

Definition at line 22 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().

◆ m_OnlyWithinHealthLabelMax

int WeaponParticlesBase::m_OnlyWithinHealthLabelMax
private

Definition at line 15 of file WeaponParticles.c.

Referenced by CheckHealthCondition(), and WeaponParticlesBase().

◆ m_OnlyWithinHealthLabelMin

int WeaponParticlesBase::m_OnlyWithinHealthLabelMin
private

Definition at line 14 of file WeaponParticles.c.

Referenced by CheckHealthCondition(), and WeaponParticlesBase().

◆ m_OnlyWithinOverheatLimitsMax

float WeaponParticlesBase::m_OnlyWithinOverheatLimitsMax
private

Definition at line 17 of file WeaponParticles.c.

Referenced by CheckOverheatingCondition(), and WeaponParticlesBase().

◆ m_OnlyWithinOverheatLimitsMin

float WeaponParticlesBase::m_OnlyWithinOverheatLimitsMin
private

Definition at line 16 of file WeaponParticles.c.

Referenced by CheckOverheatingCondition(), and WeaponParticlesBase().

◆ m_OnlyWithinRainLimitsMax

float WeaponParticlesBase::m_OnlyWithinRainLimitsMax
private

Definition at line 19 of file WeaponParticles.c.

Referenced by CheckRainCondition(), and WeaponParticlesBase().

◆ m_OnlyWithinRainLimitsMin

float WeaponParticlesBase::m_OnlyWithinRainLimitsMin
private

Definition at line 18 of file WeaponParticles.c.

Referenced by CheckRainCondition(), and WeaponParticlesBase().

◆ m_OverrideDirectionPoint

string WeaponParticlesBase::m_OverrideDirectionPoint
private

Definition at line 20 of file WeaponParticles.c.

Referenced by CheckOrientationOverride(), and WeaponParticlesBase().

◆ m_OverrideDirectionVector

vector WeaponParticlesBase::m_OverrideDirectionVector
private

Definition at line 24 of file WeaponParticles.c.

Referenced by CheckOrientationOverride(), and WeaponParticlesBase().

◆ m_OverrideParticle

int WeaponParticlesBase::m_OverrideParticle
private

Definition at line 13 of file WeaponParticles.c.

Referenced by CheckParticleOverride(), and WeaponParticlesBase().

◆ m_OverridePoint

string WeaponParticlesBase::m_OverridePoint
private

Definition at line 23 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().

◆ m_PositionOffset

vector WeaponParticlesBase::m_PositionOffset
private

Definition at line 25 of file WeaponParticles.c.

Referenced by OnActivate(), and WeaponParticlesBase().


The documentation for this class was generated from the following file: