Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
bleedingsource.c
Go to the documentation of this file.
6
8{
12 int m_Bit;
13 string m_Bone;
22 float m_MaxTime;
26
27 #ifdef DIAG_DEVELOPER
28 float m_DiagTimeStart; //for debug purposes only
29 #endif
30
31 void BleedingSource(PlayerBase player, int bit, string bone, vector orientation, vector offset,int max_time, float flow_modifier, string particle_name)
32 {
33 //m_Position = position;
34 m_Player = player;
35 m_Bit = bit;
36 m_Bone = bone;
37 m_Orientation = orientation;
38 m_Offset = offset;
39 m_FlowModifier = flow_modifier;
40 m_MaxTime = max_time;
41 m_ParticleName = particle_name;
42
43 //CreateBleedSymptom();
44 if (!g_Game.IsDedicatedServer())
45 {
48
49 }
50 }
51
61
63 {
64 m_Type = type;
65 }
66
68 {
69 return m_Type;
70 }
71
73 {
74 return m_ActiveTime;
75 }
76
77 void SetActiveTime(int time)
78 {
79 m_ActiveTime = time;
80 }
81
82 int GetBit()
83 {
84 return m_Bit;
85 }
86
88 {
89 int boneIdx = m_Player.GetBoneIndexByName(m_Bone);
90 m_BleedingEffect = EffectParticle.Cast(m_ParticleName.ToType().Spawn());
92 {
94 m_BloodParticle = m_BleedingEffect.GetParticle();
95 m_BloodParticle.SetOrientation(m_Orientation);
96 vector pos;
97 pos += m_Offset;
98 m_BloodParticle.SetPosition(pos);
99 float time = Math.RandomFloat01() * 2;
100 //time = time;
101 m_BloodParticle.SetParameter(-1, EmitorParam.CURRENT_TIME, time);
102 //m_BloodParticle.SetParameter(1, EmitorParam.CURRENT_TIME, time);
103
104 m_Player.AddChild(m_BloodParticle, boneIdx);
105 return;
106 }
107 else
108 {
109 Error("bleeding source: failed to spawn the particle: "+m_ParticleName);
110 }
111 }
112
117
118 void OnUpdateServer(float deltatime, float blood_scale, bool no_blood_loss)
119 {
120 m_ActiveTime += deltatime;
121
122 if (m_ActiveTime >= m_MaxTime)
123 {
124 if (m_Player.GetBleedingManagerServer() && !m_DeleteRequested)
125 {
126 m_Player.GetBleedingManagerServer().RequestDeletion(GetBit());//add yourself to a list of sources to be deleted
127 m_DeleteRequested = true;
128 }
129 }
130 if (!no_blood_loss)
131 {
132 float flow = m_FlowModifier;
133 switch (m_Type)
134 {
135 case eBleedingSourceType.NORMAL:
136 {
137 //do nothing
138 break;
139 }
140 case eBleedingSourceType.CONTAMINATED:
141 {
143 }
144 }
145 m_Player.AddHealth("GlobalHealth","Blood", (PlayerConstants.BLEEDING_SOURCE_BLOODLOSS_PER_SEC * blood_scale * deltatime * flow));
146 }
147 }
148
150 {
151 if (m_Player.IsControlledPlayer())
152 {
153 #ifdef DIAG_DEVELOPER
155 {
156 #endif
157 Param4<bool,int,vector,bool> par = new Param4<bool,int,vector,bool>(true,m_Bit,"0 0 0",false);
158 GameplayEffectWidgets_base widgets = g_Game.GetMission().GetEffectWidgets();
159 widgets.AddActiveEffects({EffectWidgetsTypes.BLEEDING_LAYER});
160 widgets.UpdateWidgets(EffectWidgetsTypes.BLEEDING_LAYER,0,par);
161 #ifdef DIAG_DEVELOPER
162 }
163 #endif
164 }
165 }
166
167 void StopSourceBleedingIndication(bool instant = false)
168 {
169 if (m_Player && m_Player.IsControlledPlayer() && g_Game && (!g_Game.IsDedicatedServer()))
170 {
171 Param4<bool,int,vector,bool> par = new Param4<bool,int,vector,bool>(false,m_Bit,"0 0 0",instant);
172 g_Game.GetMission().GetEffectWidgets().UpdateWidgets(EffectWidgetsTypes.BLEEDING_LAYER,0,par);
173 }
174 }
175
177 {
179
180 Particle p = m_BleedingEffect.GetParticle();
181 vector pos = p.GetPosition();
182 m_DebugShape = Debug.DrawSphere(pos, 0.009, COLOR_BLUE, ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER);
183 vector arrow_to = m_BloodParticle.GetOrientation();
184 arrow_to = arrow_to.AnglesToVector();
185 arrow_to = -arrow_to * 0.3;
186 arrow_to = pos + arrow_to;
187
188 m_DebugShape1 = Debug.DrawArrow(pos, arrow_to, 0.1, COLOR_GREEN);
189 }
190
192 {
193 if (m_DebugShape)
194 {
196 }
197
198 if (m_DebugShape1)
199 {
201 }
202 }
203}
void DrawDebugShape()
void SetType(eBleedingSourceType type)
int GetActiveTime()
ref EffectParticle m_BleedingEffect
void BleedingSource(PlayerBase player, int bit, string bone, vector orientation, vector offset, int max_time, float flow_modifier, string particle_name)
int GetBit()
void StartSourceBleedingIndication()
void RemoveParticle()
float m_ActiveTime
float m_FlowModifier
ref Timer m_DebugTick
void RemoveDebugShape()
void CreateParticle()
void OnUpdateServer(float deltatime, float blood_scale, bool no_blood_loss)
string m_Bone
Particle m_BloodParticle
void StopSourceBleedingIndication(bool instant=false)
eBleedingSourceType m_Type
vector m_Orientation
Shape m_DebugShape
bool m_DeleteRequested
void SetActiveTime(int time)
eBleedingSourceType GetType()
eBleedingSourceType
@ CONTAMINATED
float m_MaxTime
int m_Bit
Shape m_DebugShape1
string m_ParticleName
void ~BleedingSource()
map m_Player
Definition debug.c:2
static Shape DrawArrow(vector from, vector to, float size=0.5, int color=0xFFFFFFFF, int flags=0)
Definition debug.c:483
static void RemoveShape(out Shape shape)
Definition debug.c:112
static Shape DrawSphere(vector pos, float size=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
Definition debug.c:382
Wrapper class for managing particles through SEffectManager.
grouped gameplay effect widgets and their handling
override void AddActiveEffects(array< int > effects)
override void UpdateWidgets(int type=-1, float timeSlice=0, Param p=null, int handle=-1)
Usually called in course of an OnFrame update, can be manually called from elsewhere with parameters.
Definition enmath.c:7
Legacy way of using particles in the game.
Definition particle.c:7
static const float BLEEDING_SOURCE_BURN_MODIFIER
static const float BLEEDING_SOURCE_BLOODLOSS_PER_SEC
Manager class for managing Effect (EffectParticle, EffectSound).
static int PlayInWorld(notnull Effect eff, vector pos)
Play an Effect.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
DayZGame g_Game
Definition dayzgame.c:3942
@ NORMAL
vector m_Position
Cached world position.
Definition effect.c:43
const int COLOR_BLUE
Definition constants.c:66
const int COLOR_GREEN
Definition constants.c:65
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
ShapeFlags
Definition endebug.c:126
class DiagMenu Shape
Instance of created debug visualizer.
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition enmath.c:126
EmitorParam
Definition envisual.c:114
vector m_Offset
The direction of the owner in world space.
Definition object.c:15