DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
BulletImpactBase.c
См. документацию.
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 {
47 m_ParticleEnter = id;
48 }
49
50 void SetExitParticle(int id)
51 {
52 m_ParticleExit = id;
53 }
54
56 {
58 }
59
60 void SetSingleParticle(int id)
61 {
65 }
66
67 void SetAngledEnterValue(float f)
68 {
69 m_AngledEnter = f;
70 }
71
72 void EvaluateEffect(Object directHit, int componentIndex, vector pos, int impact_type, vector surfNormal, vector exitPos, vector inSpeed, vector outSpeed, string ammoType)
73 {
74 m_DirectHit = directHit;
75 m_Pos = pos;
76 m_ImpactType = impact_type;
77 m_ComponentIndex = componentIndex;
78 m_SurfNormal = surfNormal;
79 m_ExitPos = exitPos;
80 m_InSpeed = inSpeed;
81 m_OutSpeed = outSpeed;
82 m_AmmoType = ammoType;
83 m_Weight = GetGame().ConfigGetFloat("CfgAmmo " + ammoType + " weight");
84
86 }
87
88 float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
89 {
90 if ( m_ImpactType == ImpactTypes.MELEE )
91 {
92 return Math.RandomFloat(50, 100);
93 }
94
95 float projectile_weight_coef = weight / DEFAULT_PROJECTILE_WEIGHT;
96
97 float stopping_force = (in_speedf - out_speedf) * projectile_weight_coef;
98
99 return stopping_force;
100 }
101
103 {
104 // All values represent scale
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);
112
113 if ( m_AmmoType == "Bullet_12GaugePellets" )
114 {
115 birth_rate *= 0.5;
116 velocity_min *= 2;
117 velocity_max *= 2;
118 }
119
120
121 if (velocity_min < 0.75)
122 velocity_min = 0.75;
123
124 if (size < 0.75)
125 size = 0.75;
126
127 if (lifetime < 0.5)
128 lifetime = 0.5;
129
130 if (lifetime_rnd < 0.5)
131 lifetime_rnd = 0.5;
132
133 if (velocity_max < 1)
134 velocity_max = 1;
135
136 /*Print("===============");
137 Print(velocity_min);
138 Print(velocity_max);
139 Print(size);
140 Print(birth_rate);
141 Print(air_resistance);
142 Print(lifetime);
143 Print(lifetime_rnd);*/
144
145 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
146 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
147 p.ScaleParticleParam(EmitorParam.SIZE, size);
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);
153 }
154
155 void OnExitCalculations(Particle p, float outSpeedf)
156 {
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);
161
162 if (velocity_min < MIN_SCALING_PARAM)
163 velocity_min = MIN_SCALING_PARAM;
164
165 if (size < MIN_SCALING_PARAM)
166 size = MIN_SCALING_PARAM;
167
168 if (birth_rate < MIN_SCALING_PARAM)
169 birth_rate = MIN_SCALING_PARAM;
170
171 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
172 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
173 p.ScaleParticleParam(EmitorParam.SIZE, size);
174 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
175 }
176
177 void OnRicochetCalculations(Particle p, float outspeedf)
178 {
179 float velocity_min = MIN_SCALING_PARAM + (m_StoppingForce * m_RicochetSplashCoef);
180 float velocity_max = MIN_SCALING_PARAM + (m_StoppingForce * m_RicochetSplashCoef);
183
184 if (velocity_min < MIN_SCALING_PARAM)
185 velocity_min = MIN_SCALING_PARAM;
186
187 if (size < MIN_SCALING_PARAM)
188 size = MIN_SCALING_PARAM;
189
190 if (birth_rate < MIN_SCALING_PARAM)
191 birth_rate = MIN_SCALING_PARAM;
192
193 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
194 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
195 p.ScaleParticleParam(EmitorParam.SIZE, size);
196 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
197 }
198
200 {
205
206 if (velocity_min < MIN_SCALING_PARAM)
207 velocity_min = MIN_SCALING_PARAM;
208
209 if (size < MIN_SCALING_PARAM)
210 size = MIN_SCALING_PARAM;
211
212 if (birth_rate < MIN_SCALING_PARAM)
213 birth_rate = MIN_SCALING_PARAM;
214
215 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
216 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
217 p.ScaleParticleParam(EmitorParam.SIZE, size);
218 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
219 }
220
221 override void Event_OnStarted()
222 {
223 Particle p;
224 vector particle_orientation;
225 float outSpeedf = m_OutSpeed.Length();
226
227 ParticleManager gPM = ParticleManager.GetInstance();
228
229 if ( m_ImpactType == ImpactTypes.RICOCHET )
230 {
232
233 if (p)
234 {
235 particle_orientation = m_OutSpeed.VectorToAngles();
236 particle_orientation = particle_orientation + "0 -90 0";
237 p.SetOrientation(particle_orientation);
238
239 OnRicochetCalculations(p, outSpeedf);
240 }
241 }
242 else
243 {
245
246 if (p)
247 {
248 if (m_SurfNormal != INVALID)
249 {
250 particle_orientation = m_SurfNormal.VectorToAngles();
251 particle_orientation = particle_orientation + "0 270 0";
252 }
253 else
254 {
255 particle_orientation = "0 0 0"; // This vector is in angles
256 }
257
258 p.SetOrientation(particle_orientation);
259
261 }
262
263 if (outSpeedf > 0 && m_SurfNormal != INVALID)
264 {
266
267 if (p)
268 {
269 particle_orientation = m_OutSpeed.VectorToAngles();
270 particle_orientation = particle_orientation + "0 -90 0";
271 p.SetOrientation(particle_orientation);
272
273 OnExitCalculations(p, outSpeedf);
274 }
275 }
276 else
277 {
278 if (m_SurfNormal != INVALID)
279 {
280 vector surfNormalN = m_SurfNormal.Normalized();
281 vector inSpeedN = m_InSpeed.Normalized();
282 vector bounce_ori = surfNormalN + inSpeedN;
283
284 float dot = vector.Dot(bounce_ori, surfNormalN);
285
286 if ( dot > m_AngledEnter )
287 {
289
290 if (p)
291 {
292 particle_orientation = bounce_ori.VectorToAngles();
293 particle_orientation = particle_orientation + "0 -90 0";
294 p.SetOrientation(particle_orientation);
295
297 }
298 }
299 }
300 }
301 }
302
303 if (p)
304 {
305 SetParticle(p);
306 }
307
308
309 // Additional impact particle over long ranges. It shows players where their bullets land
310
311 if ( Type() != Hit_MeatBones )
312 {
313 vector camera_pos = GetGame().GetCurrentCameraPosition();
314 float distance = vector.Distance(camera_pos, m_Pos);
315
316 // Additional size increase by distance from camera
317 float scaling_by_distance = distance * 0.01;
318
319 // Now scale down the above size increase by player's zoom-in value
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;
324
325 if (scaling_by_distance > 1.1)
326 {
328
329 particle_orientation = m_SurfNormal.VectorToAngles();
330 particle_orientation[1] = particle_orientation[1] + 270;
331 p_distant.SetOrientation(particle_orientation);
332
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);
338 }
339 }
340 }
341}
DayZGame GetDayZGame()
Определения DayZGame.c:3870
ImpactTypes
Определения ImpactEffects.c:2
string Type
Определения JsonDataContaminatedArea.c:11
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native vector GetCurrentCameraPosition()
Определения Camera.c:85
vector m_SurfNormal
Определения BulletImpactBase.c:15
float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
Определения BulletImpactBase.c:88
int m_ImpactType
Определения BulletImpactBase.c:12
string m_AmmoType
Определения BulletImpactBase.c:19
void OnEnterAngledCalculations(Particle p)
Определения BulletImpactBase.c:199
override void OnCheckUpdate()
Определения BulletImpactBase.c:40
static const int INFECTED_HEAD
Определения BulletImpactBase.c:4
void SetSingleParticle(int id)
Определения BulletImpactBase.c:60
static vector INVALID
Определения BulletImpactBase.c:21
vector m_OutSpeed
Определения BulletImpactBase.c:18
void OnEnterCalculations(Particle p)
Определения BulletImpactBase.c:102
void SetExitParticle(int id)
Определения BulletImpactBase.c:50
vector m_ExitPos
Определения BulletImpactBase.c:16
static const int SURVIVOR_HEAD
Определения BulletImpactBase.c:3
void SetEnterParticle(int id)
Определения BulletImpactBase.c:45
void SetAngledEnterValue(float f)
Определения BulletImpactBase.c:67
int m_ComponentIndex
Определения BulletImpactBase.c:13
float m_StoppingForce
Определения BulletImpactBase.c:10
float m_EnterSplashCoef
Определения BulletImpactBase.c:29
int m_ParticleExit
Определения BulletImpactBase.c:25
override void Event_OnStarted()
Определения BulletImpactBase.c:221
int m_ParticleRicochet
Определения BulletImpactBase.c:26
void EvaluateEffect(Object directHit, int componentIndex, vector pos, int impact_type, vector surfNormal, vector exitPos, vector inSpeed, vector outSpeed, string ammoType)
Определения BulletImpactBase.c:72
void OnExitCalculations(Particle p, float outSpeedf)
Определения BulletImpactBase.c:155
float m_AngledEnter
Определения BulletImpactBase.c:33
int m_ParticleEnter
Определения BulletImpactBase.c:24
void EffBulletImpactBase()
Определения BulletImpactBase.c:35
void OnRicochetCalculations(Particle p, float outspeedf)
Определения BulletImpactBase.c:177
void SetRicochetParticle(int id)
Определения BulletImpactBase.c:55
static float DEFAULT_PROJECTILE_WEIGHT
Определения BulletImpactBase.c:5
float m_ExitSplashCoef
Определения BulletImpactBase.c:30
Object m_DirectHit
Определения BulletImpactBase.c:9
float m_Weight
Определения BulletImpactBase.c:11
float MIN_SCALING_PARAM
Определения BulletImpactBase.c:7
float m_RicochetSplashCoef
Определения BulletImpactBase.c:31
float m_EnterAngledSplashCoef
Определения BulletImpactBase.c:32
vector m_Pos
Определения BulletImpactBase.c:14
vector m_InSpeed
Определения BulletImpactBase.c:17
void SetParticle(Particle p)
Sets the main particle which this Effect will manage.
Определения EffectParticle.c:134
void EffectParticle()
ctor
Определения EffectParticle.c:34
Определения Hit_MeatBones.c:2
Определения EnMath.c:7
Определения ObjectTyped.c:2
static Particle PlayInWorld(int particle_id, vector global_pos)
Creates a particle emitter on the given position and activates it.
Определения Particle.c:174
void ScaleParticleParam(int parameter_id, float coef)
Scales the given parameter on all emitors relatively to their CURRENT value.
Определения Particle.c:697
Legacy way of using particles in the game.
Определения Particle.c:7
static const int IMPACT_DISTANT_DUST
Определения ParticleList.c:199
Определения ParticleList.c:12
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Определения 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.
Определения EnConvert.c:106
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
Определения EnVisual.c:114