Dayz Explorer 1.28.160049
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 (!GetGame().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 {
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 {
142 flow *= PlayerConstants.BLEEDING_SOURCE_BURN_MODIFIER;
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
154 if (DbgBleedingIndicationStaticInfo.m_DbgEnableBleedingIndication)
155 {
156 #endif
157 Param4<bool,int,vector,bool> par = new Param4<bool,int,vector,bool>(true,m_Bit,"0 0 0",false);
158 GetGame().GetMission().GetEffectWidgets().AddActiveEffects({EffectWidgetsTypes.BLEEDING_LAYER});
159 GetGame().GetMission().GetEffectWidgets().UpdateWidgets(EffectWidgetsTypes.BLEEDING_LAYER,0,par);
160 #ifdef DIAG_DEVELOPER
161 }
162 #endif
163 }
164 }
165
166 void StopSourceBleedingIndication(bool instant = false)
167 {
168 if (m_Player && m_Player.IsControlledPlayer() && GetGame() && (!GetGame().IsDedicatedServer()))
169 {
170 Param4<bool,int,vector,bool> par = new Param4<bool,int,vector,bool>(false,m_Bit,"0 0 0",instant);
171 GetGame().GetMission().GetEffectWidgets().UpdateWidgets(EffectWidgetsTypes.BLEEDING_LAYER,0,par);
172 }
173 }
174
176 {
178
180 vector pos = p.GetPosition();
181 m_DebugShape = Debug.DrawSphere(pos, 0.009, COLOR_BLUE, ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER);
182 vector arrow_to = m_BloodParticle.GetOrientation();
183 arrow_to = arrow_to.AnglesToVector();
184 arrow_to = -arrow_to * 0.3;
185 arrow_to = pos + arrow_to;
186
187 m_DebugShape1 = Debug.DrawArrow(pos, arrow_to, 0.1, COLOR_GREEN);
188 }
189
191 {
192 if (m_DebugShape)
193 {
194 Debug.RemoveShape(m_DebugShape);
195 }
196
197 if (m_DebugShape1)
198 {
199 Debug.RemoveShape(m_DebugShape1);
200 }
201 }
202}
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
@ NORMAL
float m_MaxTime
int m_Bit
Shape m_DebugShape1
string m_ParticleName
void ~BleedingSource()
Definition debug.c:2
Wrapper class for managing particles through SEffectManager.
Particle GetParticle()
Gets the main particle which this Effect is managing.
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.
override void AddActiveEffects(array< int > effects)
Definition enmath.c:7
Legacy way of using particles in the game.
Definition particle.c:7
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.
vector m_Position
Cached world position.
Definition effect.c:43
proto native CGame GetGame()
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
don't call destructor directly. Use Destroy() instead
EmitorParam
Definition envisual.c:114
DayZPlayer m_Player
Definition hand_events.c:42
vector m_Offset
The direction of the owner in world space.
Definition object.c:15