DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Hit_MeatBones.c
Go to the documentation of this file.
2{
4
6 {
10
11 m_AngledEnter = 10;
12 m_EnterSplashCoef = 0.002;
13 m_ExitSplashCoef = 0.006;
15
17 }
18
19 override float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
20 {
21 if ( m_ImpactType == ImpactTypes.MELEE )
22 {
23 return 400;
24 }
25
26 float projectile_weight_coef = weight / DEFAULT_PROJECTILE_WEIGHT;
27
28 float stopping_force = in_speedf * projectile_weight_coef;
29
30 if (m_DirectHit)
31 {
32 /*
33 // TO DO: Doesn't work because IsAlive() is false, even when it shouldn't be.
34 if ( m_DirectHit.IsMan() && m_componentIndex == SURVIVOR_HEAD && m_DirectHit.IsAlive() ) // Is the victim a survivor?
35 {
36 stopping_force = stopping_force * 2;
37 }
38 */
39
40 /*
41 // TO DO: Doesn't work. Need to recognize a zombie somehow
42 else if ( m_DirectHit.IsInherited(DayZCreatureAIType) && m_componentIndex == INFECTED_HEAD ) // Is the victim a survivor that's hit in the head?
43 {
44 stopping_force = stopping_force * 2;
45 }*/
46 }
47
48 return stopping_force;
49 }
50
51 override void Event_OnStarted()
52 {
53 super.Event_OnStarted();
54
55 if (m_ImpactType != ImpactTypes.MELEE)
56 {
57 vector in_speed = m_InSpeed * (-1); // Compiler demands to have this variable
58
59 BloodSplatGround( GetPosition(), in_speed , 0.5 );
60
61 if (m_OutSpeed.Length() > 0)
62 {
64 }
65 }
66 }
67
68 void BloodSplatGround( vector start_pos, vector speed_vector, float decay_coef )
69 {
70 vector pos = start_pos;
71 float power = m_StoppingForce;
72 float upscale = 1;
73 float rnd_offset = 0.5;
74 float rnd_offset_2 = rnd_offset * 0.5;
75
76 while (power > 200)
77 {
78 pos = pos + ( speed_vector * 0.001 );
79 pos = pos + Vector( rnd_offset_2 - Math.RandomFloat( 0, rnd_offset ), 0, rnd_offset_2 - Math.RandomFloat( 0, rnd_offset ) );
80 pos[1] = GetGame().SurfaceY(pos[0], pos[2]);
81
82 EffectParticle eff = new BloodSplatter();
83 eff.SetAutodestroy(true);
85
86 Particle blood = eff.GetParticle(); // TO DO: Handle particle changes inside the Effect instance itself! Not here!
87
88 vector ori = GetGame().GetSurfaceOrientation(pos[0], pos[2]);
89
90 blood.SetOrientation(ori);
91 blood.ScaleParticleParam(EmitorParam.SIZE, upscale);
92
93 Particle blood_chunks = ParticleManager.GetInstance().PlayInWorld(ParticleList.BLOOD_SURFACE_CHUNKS, pos);
94 blood_chunks.SetOrientation(ori);
95
96 power = power * decay_coef;
97 upscale = upscale + Math.RandomFloat(0.1, 1);
98
100 }
101 }
102
104 {
105 // Commented out due to age rating process :(
106
107 /*
108 if (m_OutSpeed.Length() > 0)
109 {
110 Object projected_surface;
111 vector hit_pos;
112 vector hit_normal;
113 float hit_fraction;
114 DayZPhysics.RayCastBullet(m_ExitPos, m_ExitPos + m_OutSpeed, PhxInteractionLayers.BUILDING, m_Object, projected_surface, hit_pos, hit_normal, hit_fraction);
115
116 hit_normal = hit_normal.VectorToAngles();
117 hit_normal[1] = hit_normal[1] + 90;
118
119 EffectParticle eff = new BloodSplatter();
120 eff.SetAutodestroy(true);
121 SEffectManager.PlayInWorld(eff, hit_pos);
122 Particle blood = eff.GetParticle();
123 blood.SetOrientation(hit_normal);
124 }
125 */
126 }
127
128 override void OnEnterCalculations( Particle p )
129 {
130 // Calculate particle's size based on bullet's speed
131 float velocity_min = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterSplashCoef);
132 float velocity_max = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterSplashCoef);
134 float birth_rate = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterSplashCoef/2);
135
136 if ( m_AmmoType == "Bullet_12GaugePellets" )
137 {
138 birth_rate *= 0.5;
139 velocity_min *= 2;
140 velocity_max *= 2;
141 }
142
143 // Additional size increase by distance from camera
144 vector camera_pos = GetGame().GetCurrentCameraPosition();
145 float distance = vector.Distance(camera_pos, m_Pos);
146 float scaling_by_distance = (distance*1.2) * m_ScalingByDistance;
147
148 // Now scale down the above size increase by player's zoom-in value
149 float current_FOV = Camera.GetCurrentFOV();
150 float config_FOV = GetDayZGame().GetUserFOVFromConfig();
151 float FOV_scale = current_FOV / config_FOV;
152 scaling_by_distance = scaling_by_distance * FOV_scale;
153
154 if (scaling_by_distance > 5)
155 scaling_by_distance = 5;
156
157 size = size + scaling_by_distance;
158 velocity_min = velocity_min + scaling_by_distance;
159 velocity_max = velocity_max + scaling_by_distance;
160
161 if (velocity_min < MIN_SCALING_PARAM)
162 velocity_min = MIN_SCALING_PARAM;
163
164 if (velocity_max < MIN_SCALING_PARAM * 2)
165 velocity_max = MIN_SCALING_PARAM * 2;
166
167 if (size < MIN_SCALING_PARAM)
168 size = MIN_SCALING_PARAM;
169
170 if (birth_rate < MIN_SCALING_PARAM)
171 birth_rate = MIN_SCALING_PARAM;
172
173 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
174 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
175 p.ScaleParticleParam(EmitorParam.SIZE, size);
176 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
177 }
178
179 override void OnExitCalculations(Particle p, float outSpeedf)
180 {
181 float velocity_rnd = outSpeedf * m_ExitSplashCoef;
182 float birth_rate_rnd_def = outSpeedf * m_ExitSplashCoef;
183 float size = outSpeedf * m_ExitSplashCoef;
184
185 if (velocity_rnd < MIN_SCALING_PARAM)
186 velocity_rnd = MIN_SCALING_PARAM;
187
188 if (size < MIN_SCALING_PARAM)
189 size = MIN_SCALING_PARAM;
190
191 if (size > 1)
192 size = 1;
193
194 if (birth_rate_rnd_def < MIN_SCALING_PARAM)
195 birth_rate_rnd_def = MIN_SCALING_PARAM;
196
197 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_rnd);
198 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate_rnd_def);
199 p.ScaleParticleParam(EmitorParam.SIZE, size);
200 }
201}
DayZGame GetDayZGame()
Definition DayZGame.c:3656
ImpactTypes
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
class JsonUndergroundAreaTriggerData GetPosition
proto native vector GetCurrentCameraPosition()
proto native float SurfaceY(float x, float z)
vector GetSurfaceOrientation(float x, float z)
Returns tilt of the ground on the given position in degrees, so you can use this value to rotate any ...
Definition Game.c:1074
static float DEFAULT_PROJECTILE_WEIGHT
void SetExitParticle(int id)
void SetRicochetParticle(int id)
void SetEnterParticle(int id)
Wrapper class for managing particles through SEffectManager.
Particle GetParticle()
Gets the main particle which this Effect is managing.
override void OnEnterCalculations(Particle p)
void Hit_MeatBones()
override void OnExitCalculations(Particle p, float outSpeedf)
override void Event_OnStarted()
override float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
void BloodSplatWall()
float m_ScalingByDistance
void BloodSplatGround(vector start_pos, vector speed_vector, float decay_coef)
Definition EnMath.c:7
Legacy way of using particles in the game.
Definition Particle.c:7
void ScaleParticleParam(int parameter_id, float coef)
Scales the given parameter on all emitors relatively to their CURRENT value.
Definition Particle.c:687
static const int IMPACT_MEATBONES_EXIT
static const int IMPACT_MEATBONES_RICOCHET
static const int BLOOD_SURFACE_CHUNKS
static const int IMPACT_MEATBONES_ENTER
Manager class for managing Effect (EffectParticle, EffectSound)
static int PlayInWorld(notnull Effect eff, vector pos)
Play an Effect.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native float Length()
Returns length of vector (magnitude)
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
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