DayZ 1.24
Loading...
Searching...
No Matches
BulletImpactBase.c
Go to the documentation of this file.
2{
3 static const int SURVIVOR_HEAD = 0; // Head component
4 static const int INFECTED_HEAD = 3; // Head component
5 static float DEFAULT_PROJECTILE_WEIGHT = 0.015;
6
7 float MIN_SCALING_PARAM = 0.1;
8
11 float m_Weight; // projectile weight in kg
19 string m_AmmoType;
20
21 static vector INVALID = "0 0 0";
22
23 // Particle Effects
27
28 // Calculations
29 float m_EnterSplashCoef = 0.003;
30 float m_ExitSplashCoef = 0.002;
31 float m_RicochetSplashCoef = 0.002;
33 float m_AngledEnter = 0.40;
34
36 {
37
38 }
39
40 override void OnCheckUpdate()
41 {
42 //DbgUI.Text( m_ammoType );
43 }
44
45 void SetEnterParticle(int id)
46 {
48 }
49
50 void SetExitParticle(int id)
51 {
53 }
54
56 {
58 }
59
60 void SetSingleParticle(int id)
61 {
65 }
66
68 {
70 }
71
87
88 float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
89 {
90 if (m_ImpactType == ImpactTypes.MELEE)
91 return Math.RandomFloat(50, 100);
92
94
96
97 return stopping_force;
98 }
99
101 {
102 // All values represent scale
110
111 if (m_AmmoType == "Bullet_12GaugePellets")
112 {
113 birth_rate *= 0.5;
114 velocity_min *= 2;
115 velocity_max *= 2;
116 }
117
118
119 if (velocity_min < 0.75)
120 velocity_min = 0.75;
121
122 if (size < 0.75)
123 size = 0.75;
124
125 if (lifetime < 0.5)
126 lifetime = 0.5;
127
128 if (lifetime_rnd < 0.5)
129 lifetime_rnd = 0.5;
130
131 if (velocity_max < 1)
132 velocity_max = 1;
133
134 /*Print("===============");
135 Print(velocity_min);
136 Print(velocity_max);
137 Print(size);
138 Print(birth_rate);
139 Print(air_resistance);
140 Print(lifetime);
141 Print(lifetime_rnd);*/
142
143 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
144 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
145 p.ScaleParticleParam(EmitorParam.SIZE, size);
146 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
147 p.ScaleParticleParam(EmitorParam.AIR_RESISTANCE, air_resistance);
148 p.ScaleParticleParam(EmitorParam.AIR_RESISTANCE_RND, air_resistance);
149 p.ScaleParticleParam(EmitorParam.LIFETIME, lifetime);
150 p.ScaleParticleParam(EmitorParam.LIFETIME_RND, lifetime_rnd);
151 }
152
154 {
157 float size = 1 + (outSpeedf * m_ExitSplashCoef);
158 float birth_rate = 1 + (outSpeedf * m_ExitSplashCoef);
159
162
165
168
169 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
170 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
171 p.ScaleParticleParam(EmitorParam.SIZE, size);
172 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
173 }
174
176 {
181
184
187
190
191 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
192 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
193 p.ScaleParticleParam(EmitorParam.SIZE, size);
194 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
195 }
196
218
219 override void Event_OnStarted()
220 {
221 Particle p;
223 float outSpeedf = m_OutSpeed.Length();
224
225 ParticleManager gPM = ParticleManager.GetInstance();
226
227 if (m_ImpactType == ImpactTypes.RICOCHET)
228 {
229 p = gPM.PlayInWorld(m_ParticleRicochet, m_Pos);
230
231 if (p)
232 {
235 p.SetOrientation(particle_orientation);
236
238 }
239 }
240 else
241 {
242 p = gPM.PlayInWorld(m_ParticleEnter, m_Pos);
243
244 if (p)
245 {
246 if (m_SurfNormal != INVALID)
247 {
250 }
251 else
252 {
253 particle_orientation = "0 0 0"; // This vector is in angles
254 }
255
256 p.SetOrientation(particle_orientation);
257
259 }
260
261 if (outSpeedf > 0 && m_SurfNormal != INVALID)
262 {
263 p = gPM.PlayInWorld(m_ParticleExit, m_ExitPos);
264
265 if (p)
266 {
269 p.SetOrientation(particle_orientation);
270
272 }
273 }
274 else
275 {
276 if (m_SurfNormal != INVALID)
277 {
281
283
284 if (dot > m_AngledEnter)
285 {
286 p = gPM.PlayInWorld(m_ParticleRicochet, m_Pos);
287
288 if (p)
289 {
290 particle_orientation = bounce_ori.VectorToAngles();
292 p.SetOrientation(particle_orientation);
293
295 }
296 }
297 }
298 }
299 }
300
301 if (p)
302 SetParticle(p);
303
304
305 // Additional impact particle over long ranges. It shows players where their bullets land
306
307 if (Type() != Hit_MeatBones)
308 {
309 vector camera_pos = GetGame().GetCurrentCameraPosition();
311
312 // Additional size increase by distance from camera
313 float scaling_by_distance = distance * 0.01;
314
315 // Now scale down the above size increase by player's zoom-in value
316 float current_FOV = Camera.GetCurrentFOV();
317 float config_FOV = GetDayZGame().GetUserFOVFromConfig();
320
321 if (scaling_by_distance > 1.1)
322 {
324
327 p_distant.SetOrientation(particle_orientation);
328
329 p_distant.ScaleParticleParam(EmitorParam.SIZE, scaling_by_distance - 0.5);
330 p_distant.ScaleParticleParam(EmitorParam.BIRTH_RATE, scaling_by_distance * 0.1);
331 p_distant.ScaleParticleParam(EmitorParam.BIRTH_RATE_RND, scaling_by_distance * 0.1);
332 p_distant.ScaleParticleParam(EmitorParam.LIFETIME, scaling_by_distance * 0.3);
333 p_distant.ScaleParticleParam(EmitorParam.LIFETIME_RND, scaling_by_distance * 0.3);
334 }
335 }
336 }
337}
DayZGame GetDayZGame()
Definition DayZGame.c:3530
ImpactTypes
string Type
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
void OnEnterAngledCalculations(Particle p)
override void OnCheckUpdate()
static const int INFECTED_HEAD
void SetSingleParticle(int id)
void OnEnterCalculations(Particle p)
void SetExitParticle(int id)
static const int SURVIVOR_HEAD
void SetEnterParticle(int id)
void SetAngledEnterValue(float f)
override void Event_OnStarted()
void EvaluateEffect(Object directHit, int componentIndex, vector pos, int impact_type, vector surfNormal, vector exitPos, vector inSpeed, vector outSpeed, string ammoType)
void OnExitCalculations(Particle p, float outSpeedf)
void OnRicochetCalculations(Particle p, float outspeedf)
void SetRicochetParticle(int id)
static float DEFAULT_PROJECTILE_WEIGHT
Wrapper class for managing particles through SEffectManager.
void SetParticle(Particle p)
Sets the main particle which this Effect will manage.
Definition EnMath.c:7
Legacy way of using particles in the game.
Definition Particle.c:7
static const int IMPACT_DISTANT_DUST
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
proto native float Length()
Returns length of vector (magnitude)
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
proto native CGame GetGame()
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
EmitorParam
Definition EnVisual.c:114