Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
hit_meatbones.c
Go to the documentation of this file.
1
class
Hit_MeatBones
:
EffBulletImpactBase
2
{
3
float
m_ScalingByDistance
;
4
5
void
Hit_MeatBones
()
6
{
7
SetEnterParticle
(
ParticleList
.
IMPACT_MEATBONES_ENTER
);
8
SetExitParticle
(
ParticleList
.
IMPACT_MEATBONES_EXIT
);
9
SetRicochetParticle
(
ParticleList
.
IMPACT_MEATBONES_RICOCHET
);
10
11
m_AngledEnter
= 10;
12
m_EnterSplashCoef
= 0.002;
13
m_ExitSplashCoef
= 0.006;
14
m_ScalingByDistance
= 0.05;
15
16
MIN_SCALING_PARAM
= 0.2;
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
{
63
BloodSplatGround
(
m_ExitPos
,
m_OutSpeed
, 0.8 );
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
);
84
SEffectManager
.
PlayInWorld
(eff, pos);
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
99
BloodSplatWall
();
100
}
101
}
102
103
void
BloodSplatWall
()
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
);
133
float
size =
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
}
BloodSplatter
Definition
bloodsplatter.c:2
Camera
Definition
camera.c:85
EffBulletImpactBase::m_EnterSplashCoef
float m_EnterSplashCoef
Definition
bulletimpactbase.c:29
EffBulletImpactBase::m_ImpactType
int m_ImpactType
Definition
bulletimpactbase.c:12
EffBulletImpactBase::DEFAULT_PROJECTILE_WEIGHT
static float DEFAULT_PROJECTILE_WEIGHT
Definition
bulletimpactbase.c:5
EffBulletImpactBase::m_InSpeed
vector m_InSpeed
Definition
bulletimpactbase.c:17
EffBulletImpactBase::MIN_SCALING_PARAM
float MIN_SCALING_PARAM
Definition
bulletimpactbase.c:7
EffBulletImpactBase::m_ExitSplashCoef
float m_ExitSplashCoef
Definition
bulletimpactbase.c:30
EffBulletImpactBase::m_ExitPos
vector m_ExitPos
Definition
bulletimpactbase.c:16
EffBulletImpactBase::m_Pos
vector m_Pos
Definition
bulletimpactbase.c:14
EffBulletImpactBase::EffBulletImpactBase
void EffBulletImpactBase()
Definition
bulletimpactbase.c:35
EffBulletImpactBase::m_OutSpeed
vector m_OutSpeed
Definition
bulletimpactbase.c:18
EffBulletImpactBase::m_AmmoType
string m_AmmoType
Definition
bulletimpactbase.c:19
EffBulletImpactBase::m_AngledEnter
float m_AngledEnter
Definition
bulletimpactbase.c:33
EffBulletImpactBase::SetExitParticle
void SetExitParticle(int id)
Definition
bulletimpactbase.c:50
EffBulletImpactBase::SetRicochetParticle
void SetRicochetParticle(int id)
Definition
bulletimpactbase.c:55
EffBulletImpactBase::m_StoppingForce
float m_StoppingForce
Definition
bulletimpactbase.c:10
EffBulletImpactBase::SetEnterParticle
void SetEnterParticle(int id)
Definition
bulletimpactbase.c:45
EffBulletImpactBase::m_DirectHit
Object m_DirectHit
Definition
bulletimpactbase.c:9
EffectParticle::EffectParticle
void EffectParticle()
ctor
Definition
effectparticle.c:34
EffectParticle::GetParticle
Particle GetParticle()
Gets the main particle which this Effect is managing.
Definition
effectparticle.c:162
Hit_MeatBones::OnEnterCalculations
override void OnEnterCalculations(Particle p)
Definition
hit_meatbones.c:128
Hit_MeatBones::Hit_MeatBones
void Hit_MeatBones()
Definition
hit_meatbones.c:5
Hit_MeatBones::OnExitCalculations
override void OnExitCalculations(Particle p, float outSpeedf)
Definition
hit_meatbones.c:179
Hit_MeatBones::Event_OnStarted
override void Event_OnStarted()
Definition
hit_meatbones.c:51
Hit_MeatBones::CalculateStoppingForce
override float CalculateStoppingForce(float in_speedf, float out_speedf, string ammoType, float weight)
Definition
hit_meatbones.c:19
Hit_MeatBones::BloodSplatWall
void BloodSplatWall()
Definition
hit_meatbones.c:103
Hit_MeatBones::m_ScalingByDistance
float m_ScalingByDistance
Definition
hit_meatbones.c:3
Hit_MeatBones::BloodSplatGround
void BloodSplatGround(vector start_pos, vector speed_vector, float decay_coef)
Definition
hit_meatbones.c:68
Math
Definition
enmath.c:7
Particle
Legacy way of using particles in the game.
Definition
particle.c:7
Particle::ScaleParticleParam
void ScaleParticleParam(int parameter_id, float coef)
Scales the given parameter on all emitors relatively to their CURRENT value.
Definition
particle.c:697
ParticleList
Definition
particlelist.c:12
ParticleList::IMPACT_MEATBONES_EXIT
static const int IMPACT_MEATBONES_EXIT
Definition
particlelist.c:244
ParticleList::IMPACT_MEATBONES_RICOCHET
static const int IMPACT_MEATBONES_RICOCHET
Definition
particlelist.c:243
ParticleList::BLOOD_SURFACE_CHUNKS
static const int BLOOD_SURFACE_CHUNKS
Definition
particlelist.c:149
ParticleList::IMPACT_MEATBONES_ENTER
static const int IMPACT_MEATBONES_ENTER
Definition
particlelist.c:242
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound).
Definition
effectmanager.c:6
SEffectManager::PlayInWorld
static int PlayInWorld(notnull Effect eff, vector pos)
Play an Effect.
Definition
effectmanager.c:47
vector
Definition
enconvert.c:119
vector::Distance
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
GetDayZGame
DayZGame GetDayZGame()
Definition
dayzgame.c:3944
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
Math::RandomFloat
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
EmitorParam
EmitorParam
Definition
envisual.c:114
GetPosition
vector GetPosition()
Get the world position of the Effect.
Definition
effect.c:473
ImpactTypes
ImpactTypes
Definition
impacteffects.c:2
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).
Definition
particlemanager.c:88
Games
Dayz
scripts
3_game
effects
effectparticle
bulletimpactbase
hit_meatbones.c
Generated by
1.17.0