DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Hit_MeatBones.c
См. документацию.
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
72 float groundHeight = g_Game.SurfaceY(pos[0], pos[2]);
73 if (groundHeight > start_pos[1])
74 return;
75
76 float power = m_StoppingForce;
77 float upscale = 1;
78 float rnd_offset = 0.5;
79 float rnd_offset_2 = rnd_offset * 0.5;
80
81 while (power > 200)
82 {
83 pos = pos + ( speed_vector * 0.001 );
84 pos = pos + Vector( rnd_offset_2 - Math.RandomFloat( 0, rnd_offset ), 0, rnd_offset_2 - Math.RandomFloat( 0, rnd_offset ) );
85 pos[1] = g_Game.SurfaceY(pos[0], pos[2]);
86
87 EffectParticle eff = new BloodSplatter();
88 eff.SetAutodestroy(true);
90
91 Particle blood = eff.GetParticle(); // TO DO: Handle particle changes inside the Effect instance itself! Not here!
92
93 vector ori = g_Game.GetSurfaceOrientation(pos[0], pos[2]);
94
95 blood.SetOrientation(ori);
96 blood.ScaleParticleParam(EmitorParam.SIZE, upscale);
97
98 Particle blood_chunks = ParticleManager.GetInstance().PlayInWorld(ParticleList.BLOOD_SURFACE_CHUNKS, pos);
99 blood_chunks.SetOrientation(ori);
100
101 power = power * decay_coef;
102 upscale = upscale + Math.RandomFloat(0.1, 1);
103
105 }
106 }
107
109 {
110 // Commented out due to age rating process :(
111
112 /*
113 if (m_OutSpeed.Length() > 0)
114 {
115 Object projected_surface;
116 vector hit_pos;
117 vector hit_normal;
118 float hit_fraction;
119 DayZPhysics.RayCastBullet(m_ExitPos, m_ExitPos + m_OutSpeed, PhxInteractionLayers.BUILDING, m_Object, projected_surface, hit_pos, hit_normal, hit_fraction);
120
121 hit_normal = hit_normal.VectorToAngles();
122 hit_normal[1] = hit_normal[1] + 90;
123
124 EffectParticle eff = new BloodSplatter();
125 eff.SetAutodestroy(true);
126 SEffectManager.PlayInWorld(eff, hit_pos);
127 Particle blood = eff.GetParticle();
128 blood.SetOrientation(hit_normal);
129 }
130 */
131 }
132
133 override void OnEnterCalculations( Particle p )
134 {
135 // Calculate particle's size based on bullet's speed
136 float velocity_min = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterSplashCoef);
137 float velocity_max = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterSplashCoef);
139 float birth_rate = MIN_SCALING_PARAM + (m_StoppingForce * m_EnterSplashCoef/2);
140
141 if ( m_AmmoType == "Bullet_12GaugePellets" )
142 {
143 birth_rate *= 0.5;
144 velocity_min *= 2;
145 velocity_max *= 2;
146 }
147
148 // Additional size increase by distance from camera
149 vector camera_pos = g_Game.GetCurrentCameraPosition();
150 float distance = vector.Distance(camera_pos, m_Pos);
151 float scaling_by_distance = (distance*1.2) * m_ScalingByDistance;
152
153 // Now scale down the above size increase by player's zoom-in value
154 float current_FOV = Camera.GetCurrentFOV();
155 float config_FOV = GetDayZGame().GetUserFOVFromConfig();
156 float FOV_scale = current_FOV / config_FOV;
157 scaling_by_distance = scaling_by_distance * FOV_scale;
158
159 if (scaling_by_distance > 5)
160 scaling_by_distance = 5;
161
162 size = size + scaling_by_distance;
163 velocity_min = velocity_min + scaling_by_distance;
164 velocity_max = velocity_max + scaling_by_distance;
165
166 if (velocity_min < MIN_SCALING_PARAM)
167 velocity_min = MIN_SCALING_PARAM;
168
169 if (velocity_max < MIN_SCALING_PARAM * 2)
170 velocity_max = MIN_SCALING_PARAM * 2;
171
172 if (size < MIN_SCALING_PARAM)
173 size = MIN_SCALING_PARAM;
174
175 if (birth_rate < MIN_SCALING_PARAM)
176 birth_rate = MIN_SCALING_PARAM;
177
178 p.ScaleParticleParam(EmitorParam.VELOCITY, velocity_min);
179 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_max);
180 p.ScaleParticleParam(EmitorParam.SIZE, size);
181 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate);
182 }
183
184 override void OnExitCalculations(Particle p, float outSpeedf)
185 {
186 float velocity_rnd = outSpeedf * m_ExitSplashCoef;
187 float birth_rate_rnd_def = outSpeedf * m_ExitSplashCoef;
188 float size = outSpeedf * m_ExitSplashCoef;
189
190 if (velocity_rnd < MIN_SCALING_PARAM)
191 velocity_rnd = MIN_SCALING_PARAM;
192
193 if (size < MIN_SCALING_PARAM)
194 size = MIN_SCALING_PARAM;
195
196 if (size > 1)
197 size = 1;
198
199 if (birth_rate_rnd_def < MIN_SCALING_PARAM)
200 birth_rate_rnd_def = MIN_SCALING_PARAM;
201
202 p.ScaleParticleParam(EmitorParam.VELOCITY_RND, velocity_rnd);
203 p.ScaleParticleParam(EmitorParam.BIRTH_RATE, birth_rate_rnd_def);
204 p.ScaleParticleParam(EmitorParam.SIZE, size);
205 }
206}
DayZGame g_Game
Определения DayZGame.c:4074
DayZGame GetDayZGame()
Определения DayZGame.c:4076
string ammoType
Определения DustKickupEffects.c:24
ImpactTypes
Определения ImpactEffects.c:2
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
Определения BloodSplatter.c:2
Определения Camera.c:85
int m_ImpactType
Определения BulletImpactBase.c:12
string m_AmmoType
Определения BulletImpactBase.c:19
vector m_OutSpeed
Определения BulletImpactBase.c:18
void SetExitParticle(int id)
Определения BulletImpactBase.c:50
vector m_ExitPos
Определения BulletImpactBase.c:16
void SetEnterParticle(int id)
Определения BulletImpactBase.c:45
float m_StoppingForce
Определения BulletImpactBase.c:10
float m_EnterSplashCoef
Определения BulletImpactBase.c:29
float m_AngledEnter
Определения BulletImpactBase.c:33
void EffBulletImpactBase()
Определения BulletImpactBase.c:35
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 MIN_SCALING_PARAM
Определения BulletImpactBase.c:7
vector m_Pos
Определения BulletImpactBase.c:14
vector m_InSpeed
Определения BulletImpactBase.c:17
Particle GetParticle()
Gets the main particle which this Effect is managing.
Определения EffectParticle.c:166
void EffectParticle()
ctor
Определения EffectParticle.c:36
override void Event_OnStarted()
Определения Hit_MeatBones.c:51
override void OnEnterCalculations(Particle p)
Определения Hit_MeatBones.c:133
void BloodSplatGround(vector start_pos, vector speed_vector, float decay_coef)
Определения Hit_MeatBones.c:68
float m_ScalingByDistance
Определения Hit_MeatBones.c:3
void BloodSplatWall()
Определения Hit_MeatBones.c:108
override void OnExitCalculations(Particle p, float outSpeedf)
Определения Hit_MeatBones.c:184
override float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
Определения Hit_MeatBones.c:19
void Hit_MeatBones()
Определения Hit_MeatBones.c:5
Определения EnMath.c:7
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_MEATBONES_ENTER
Определения ParticleList.c:251
static const int BLOOD_SURFACE_CHUNKS
Определения ParticleList.c:158
static const int IMPACT_MEATBONES_RICOCHET
Определения ParticleList.c:252
static const int IMPACT_MEATBONES_EXIT
Определения ParticleList.c:253
Определения ParticleList.c:12
static int PlayInWorld(notnull Effect eff, vector pos)
Play an Effect.
Определения EffectManager.c:47
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:119
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
Определения EnVisual.c:114
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473