3 static const int SURVIVOR_HEAD = 0;
4 static const int INFECTED_HEAD = 3;
5 static float DEFAULT_PROJECTILE_WEIGHT = 0.015;
7 float MIN_SCALING_PARAM = 0.1;
10 float m_StoppingForce;
21 static vector INVALID =
"0 0 0";
24 int m_ParticleEnter = -1;
25 int m_ParticleExit = -1;
26 int m_ParticleRicochet = -1;
29 float m_EnterSplashCoef = 0.003;
30 float m_ExitSplashCoef = 0.002;
31 float m_RicochetSplashCoef = 0.002;
32 float m_EnterAngledSplashCoef = 0.01;
33 float m_AngledEnter = 0.40;
40 override void OnCheckUpdate()
45 void SetEnterParticle(
int id)
50 void SetExitParticle(
int id)
55 void SetRicochetParticle(
int id)
57 m_ParticleRicochet = id;
60 void SetSingleParticle(
int id)
64 SetRicochetParticle(
id);
67 void SetAngledEnterValue(
float f)
78 m_SurfNormal = surfNormal;
83 m_Weight =
GetGame().ConfigGetFloat(
"CfgAmmo " + ammoType +
" weight");
85 m_StoppingForce = CalculateStoppingForce(
m_InSpeed.Length(),
m_OutSpeed.Length(), ammoType, m_Weight);
88 float CalculateStoppingForce(
float in_speedf,
float out_speedf,
string ammoType,
float weight)
92 return Math.RandomFloat(50, 100);
95 float projectile_weight_coef = weight / DEFAULT_PROJECTILE_WEIGHT;
97 float stopping_force = (in_speedf - out_speedf) * projectile_weight_coef;
99 return stopping_force;
102 void OnEnterCalculations(
Particle p )
105 float velocity_min = (m_StoppingForce * m_EnterSplashCoef);
106 float velocity_max = (m_StoppingForce * m_EnterSplashCoef);
107 float size = (m_StoppingForce * m_EnterSplashCoef);
108 float birth_rate = (m_StoppingForce * m_EnterSplashCoef);
109 float air_resistance = velocity_min;
110 float lifetime = (m_StoppingForce * m_EnterSplashCoef);
111 float lifetime_rnd = (m_StoppingForce * m_EnterSplashCoef);
121 if (velocity_min < 0.75)
130 if (lifetime_rnd < 0.5)
133 if (velocity_max < 1)
145 p.ScaleParticleParam(
EmitorParam.VELOCITY, velocity_min);
146 p.ScaleParticleParam(
EmitorParam.VELOCITY_RND, velocity_max);
148 p.ScaleParticleParam(
EmitorParam.BIRTH_RATE, birth_rate);
149 p.ScaleParticleParam(
EmitorParam.AIR_RESISTANCE, air_resistance);
150 p.ScaleParticleParam(
EmitorParam.AIR_RESISTANCE_RND, air_resistance);
151 p.ScaleParticleParam(
EmitorParam.LIFETIME, lifetime);
152 p.ScaleParticleParam(
EmitorParam.LIFETIME_RND, lifetime_rnd);
155 void OnExitCalculations(
Particle p,
float outSpeedf)
157 float velocity_min = 1 + (outSpeedf * m_ExitSplashCoef);
158 float velocity_max = 1 + (outSpeedf * m_ExitSplashCoef);
159 float size = 1 + ( outSpeedf * m_ExitSplashCoef);
160 float birth_rate = 1 + (outSpeedf * m_ExitSplashCoef);
162 if (velocity_min < MIN_SCALING_PARAM)
163 velocity_min = MIN_SCALING_PARAM;
165 if (size < MIN_SCALING_PARAM)
166 size = MIN_SCALING_PARAM;
168 if (birth_rate < MIN_SCALING_PARAM)
169 birth_rate = MIN_SCALING_PARAM;
171 p.ScaleParticleParam(
EmitorParam.VELOCITY, velocity_min);
172 p.ScaleParticleParam(
EmitorParam.VELOCITY_RND, velocity_max);
174 p.ScaleParticleParam(
EmitorParam.BIRTH_RATE, birth_rate);
177 void OnRicochetCalculations(
Particle p,
float outspeedf)
179 float velocity_min = MIN_SCALING_PARAM + (m_StoppingForce * m_RicochetSplashCoef);
180 float velocity_max = MIN_SCALING_PARAM + (m_StoppingForce * m_RicochetSplashCoef);
181 float size = MIN_SCALING_PARAM + ( m_StoppingForce * m_RicochetSplashCoef);
182 float birth_rate = MIN_SCALING_PARAM + (m_StoppingForce * m_RicochetSplashCoef);
184 if (velocity_min < MIN_SCALING_PARAM)
185 velocity_min = MIN_SCALING_PARAM;
187 if (size < MIN_SCALING_PARAM)
188 size = MIN_SCALING_PARAM;
190 if (birth_rate < MIN_SCALING_PARAM)
191 birth_rate = MIN_SCALING_PARAM;
193 p.ScaleParticleParam(
EmitorParam.VELOCITY, velocity_min);
194 p.ScaleParticleParam(
EmitorParam.VELOCITY_RND, velocity_max);
196 p.ScaleParticleParam(
EmitorParam.BIRTH_RATE, birth_rate);
199 void OnEnterAngledCalculations(
Particle p)
201 float velocity_min = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterAngledSplashCoef);
202 float velocity_max = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterAngledSplashCoef);
203 float size = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterAngledSplashCoef);
204 float birth_rate = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterAngledSplashCoef);
206 if (velocity_min < MIN_SCALING_PARAM)
207 velocity_min = MIN_SCALING_PARAM;
209 if (size < MIN_SCALING_PARAM)
210 size = MIN_SCALING_PARAM;
212 if (birth_rate < MIN_SCALING_PARAM)
213 birth_rate = MIN_SCALING_PARAM;
215 p.ScaleParticleParam(
EmitorParam.VELOCITY, velocity_min);
216 p.ScaleParticleParam(
EmitorParam.VELOCITY_RND, velocity_max);
218 p.ScaleParticleParam(
EmitorParam.BIRTH_RATE, birth_rate);
221 override void Event_OnStarted()
224 vector particle_orientation;
231 p = gPM.PlayInWorld(m_ParticleRicochet,
m_Pos);
235 particle_orientation =
m_OutSpeed.VectorToAngles();
236 particle_orientation = particle_orientation +
"0 -90 0";
237 p.SetOrientation(particle_orientation);
239 OnRicochetCalculations(p, outSpeedf);
244 p = gPM.PlayInWorld(m_ParticleEnter,
m_Pos );
250 particle_orientation = m_SurfNormal.VectorToAngles();
251 particle_orientation = particle_orientation +
"0 270 0";
255 particle_orientation =
"0 0 0";
258 p.SetOrientation(particle_orientation);
260 OnEnterCalculations(p);
263 if (outSpeedf > 0 && m_SurfNormal !=
INVALID)
265 p = gPM.PlayInWorld(m_ParticleExit, m_ExitPos);
269 particle_orientation =
m_OutSpeed.VectorToAngles();
270 particle_orientation = particle_orientation +
"0 -90 0";
271 p.SetOrientation(particle_orientation);
273 OnExitCalculations(p, outSpeedf);
280 vector surfNormalN = m_SurfNormal.Normalized();
282 vector bounce_ori = surfNormalN + inSpeedN;
284 float dot =
vector.Dot(bounce_ori, surfNormalN);
286 if ( dot > m_AngledEnter )
288 p = gPM.PlayInWorld(m_ParticleRicochet,
m_Pos);
292 particle_orientation = bounce_ori.VectorToAngles();
293 particle_orientation = particle_orientation +
"0 -90 0";
294 p.SetOrientation(particle_orientation);
296 OnEnterAngledCalculations(p);
314 float distance =
vector.Distance(camera_pos,
m_Pos);
317 float scaling_by_distance = distance * 0.01;
320 float current_FOV =
Camera.GetCurrentFOV();
321 float config_FOV =
GetDayZGame().GetUserFOVFromConfig();
322 float FOV_scale = current_FOV / config_FOV;
323 scaling_by_distance = 1 + scaling_by_distance * FOV_scale;
325 if (scaling_by_distance > 1.1)
329 particle_orientation = m_SurfNormal.VectorToAngles();
330 particle_orientation[1] = particle_orientation[1] + 270;
331 p_distant.SetOrientation(particle_orientation);
333 p_distant.ScaleParticleParam(
EmitorParam.SIZE, scaling_by_distance - 0.5);
334 p_distant.ScaleParticleParam(
EmitorParam.BIRTH_RATE, scaling_by_distance * 0.1);
335 p_distant.ScaleParticleParam(
EmitorParam.BIRTH_RATE_RND, scaling_by_distance * 0.1);
336 p_distant.ScaleParticleParam(
EmitorParam.LIFETIME, scaling_by_distance * 0.3);
337 p_distant.ScaleParticleParam(
EmitorParam.LIFETIME_RND, scaling_by_distance * 0.3);