Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
hit_meatbones.c
Go to the documentation of this file.
2{
4
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] = g_Game.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 = g_Game.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 = g_Game.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}
static float DEFAULT_PROJECTILE_WEIGHT
void SetExitParticle(int id)
void SetRicochetParticle(int id)
void SetEnterParticle(int id)
void EffectParticle()
ctor
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:697
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.
DayZGame g_Game
Definition dayzgame.c:3942
DayZGame GetDayZGame()
Definition dayzgame.c:3944
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
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
ImpactTypes
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).