Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
bleedingsource.c
Go to the documentation of this file.
2 {
5 }
6 
7 class BleedingSource
8 {
12  int m_Bit;
13  string m_Bone;
21  float m_ActiveTime;
22  float m_MaxTime;
26 
27  void BleedingSource(PlayerBase player, int bit, string bone, vector orientation, vector offset,int max_time, float flow_modifier, string particle_name)
28  {
29  //m_Position = position;
30  m_Player = player;
31  m_Bit = bit;
32  m_Bone = bone;
33  m_Orientation = orientation;
34  m_Offset = offset;
35  m_FlowModifier = flow_modifier;
36  m_MaxTime = max_time;
37  m_ParticleName = particle_name;
38 
39  //CreateBleedSymptom();
40  if (!GetGame().IsDedicatedServer())
41  {
44 
45  }
46  }
47 
49  {
50  if (m_BloodParticle)
52 
54 
56  }
57 
59  {
60  m_Type = type;
61  }
62 
64  {
65  return m_Type;
66  }
67 
69  {
70  return m_ActiveTime;
71  }
72 
73  void SetActiveTime(int time)
74  {
75  m_ActiveTime = time;
76  }
77 
78  int GetBit()
79  {
80  return m_Bit;
81  }
82 
84  {
85  int boneIdx = m_Player.GetBoneIndexByName(m_Bone);
86  m_BleedingEffect = EffectParticle.Cast(m_ParticleName.ToType().Spawn());
87  if (m_BleedingEffect)
88  {
89  SEffectManager.PlayInWorld( m_BleedingEffect, "0 0 0" );
90  m_BloodParticle = m_BleedingEffect.GetParticle();
91  m_BloodParticle.SetOrientation(m_Orientation);
92  vector pos;
93  pos += m_Offset;
94  m_BloodParticle.SetPosition(pos);
95  float time = Math.RandomFloat01() * 2;
96  //time = time;
97  m_BloodParticle.SetParameter(-1, EmitorParam.CURRENT_TIME, time);
98  //m_BloodParticle.SetParameter(1, EmitorParam.CURRENT_TIME, time);
99 
100  m_Player.AddChild(m_BloodParticle, boneIdx);
101  return;
102  }
103  else
104  {
105  Error("bleeding source: failed to spawn the particle: "+m_ParticleName);
106  }
107  }
108 
110  {
111  SEffectManager.DestroyEffect(m_BleedingEffect);
112  }
113 
114  void OnUpdateServer(float deltatime, float blood_scale, bool no_blood_loss )
115  {
116  m_ActiveTime += deltatime;
117 
118  if (m_ActiveTime >= m_MaxTime)
119  {
120  if (m_Player.GetBleedingManagerServer() && !m_DeleteRequested)
121  {
122  m_Player.GetBleedingManagerServer().RequestDeletion(GetBit());//add yourself to a list of sources to be deleted
123  m_DeleteRequested = true;
124  }
125  }
126  if ( !no_blood_loss )
127  {
128  float flow = m_FlowModifier;
129  switch ( m_Type )
130  {
131  case eBleedingSourceType.NORMAL:
132  {
133  //do nothing
134  break;
135  }
136  case eBleedingSourceType.CONTAMINATED:
137  {
138  flow *= PlayerConstants.BLEEDING_SOURCE_BURN_MODIFIER;
139  }
140  }
141  m_Player.AddHealth("GlobalHealth","Blood", (PlayerConstants.BLEEDING_SOURCE_BLOODLOSS_PER_SEC * blood_scale * deltatime * flow) );
142  }
143  }
144 
146  {
147  if (m_Player.IsControlledPlayer())
148  {
149  #ifdef DIAG_DEVELOPER
150  if (DbgBleedingIndicationStaticInfo.m_DbgEnableBleedingIndication)
151  {
152  #endif
153  Param4<bool,int,vector,bool> par = new Param4<bool,int,vector,bool>(true,m_Bit,"0 0 0",false);
154  GetGame().GetMission().GetEffectWidgets().AddActiveEffects({EffectWidgetsTypes.BLEEDING_LAYER});
155  GetGame().GetMission().GetEffectWidgets().UpdateWidgets(EffectWidgetsTypes.BLEEDING_LAYER,0,par);
156  #ifdef DIAG_DEVELOPER
157  }
158  #endif
159  }
160  }
161 
162  void StopSourceBleedingIndication(bool instant = false)
163  {
164  if ( m_Player && m_Player.IsControlledPlayer() && GetGame() && (!GetGame().IsDedicatedServer()) )
165  {
166  Param4<bool,int,vector,bool> par = new Param4<bool,int,vector,bool>(false,m_Bit,"0 0 0",instant);
167  GetGame().GetMission().GetEffectWidgets().UpdateWidgets(EffectWidgetsTypes.BLEEDING_LAYER,0,par);
168  }
169  }
170 
172  {
174 
175  Particle p = m_BleedingEffect.GetParticle();
176  vector pos = p.GetPosition();
177  m_DebugShape = Debug.DrawSphere(pos, 0.009, COLOR_BLUE, ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER);
178  vector arrow_to = m_BloodParticle.GetOrientation();
179  arrow_to = arrow_to.AnglesToVector();
180  arrow_to = -arrow_to * 0.3;
181  arrow_to = pos + arrow_to;
182 
183  m_DebugShape1 = Debug.DrawArrow(pos, arrow_to, 0.1, COLOR_GREEN);
184  }
185 
187  {
188  if (m_DebugShape)
189  {
190  Debug.RemoveShape(m_DebugShape);
191  }
192 
193  if (m_DebugShape1)
194  {
195  Debug.RemoveShape(m_DebugShape1);
196  }
197  }
198 }
GetGame
proto native CGame GetGame()
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
m_Type
eBleedingSourceType m_Type
Definition: bleedingsource.c:25
DrawDebugShape
void DrawDebugShape()
Definition: bleedingsource.c:171
CONTAMINATED
@ CONTAMINATED
Definition: bleedingsource.c:4
m_Bone
string m_Bone
Definition: bleedingsource.c:13
eBleedingSourceType
eBleedingSourceType
Definition: bleedingsource.c:1
BleedingSource
void BleedingSource(PlayerBase player, int bit, string bone, vector orientation, vector offset, int max_time, float flow_modifier, string particle_name)
Definition: bleedingsource.c:27
m_Offset
vector m_Offset
Definition: bleedingsource.c:19
m_BloodParticle
Particle m_BloodParticle
Definition: bleedingsource.c:10
EmitorParam
EmitorParam
Definition: envisual.c:113
m_DeleteRequested
bool m_DeleteRequested
Definition: bleedingsource.c:24
EffectParticle
Wrapper class for managing particles through SEffectManager.
Definition: effectparticle.c:4
CreateParticle
void CreateParticle()
Definition: bleedingsource.c:83
RemoveParticle
void RemoveParticle()
Definition: bleedingsource.c:109
m_Position
enum eBleedingSourceType m_Position
NORMAL
@ NORMAL
Definition: bleedingsource.c:3
PlayerBase
Definition: playerbaseclient.c:1
PlayerConstants
Definition: playerconstants.c:1
vector
Definition: enconvert.c:105
OnUpdateServer
void OnUpdateServer(float deltatime, float blood_scale, bool no_blood_loss)
Definition: bleedingsource.c:114
StopSourceBleedingIndication
void StopSourceBleedingIndication(bool instant=false)
Definition: bleedingsource.c:162
GetBit
int GetBit()
Definition: bleedingsource.c:78
m_BleedingEffect
ref EffectParticle m_BleedingEffect
Definition: bleedingsource.c:14
m_Player
PlayerBase m_Player
Definition: bleedingsource.c:11
m_Orientation
vector m_Orientation
Definition: bleedingsource.c:15
ShapeFlags
ShapeFlags
Definition: endebug.c:125
DbgBleedingIndicationStaticInfo
static info (non-constants)
Definition: bleedingindicationstaticinfo.c:2
GetActiveTime
int GetActiveTime()
Definition: bleedingsource.c:68
COLOR_GREEN
const int COLOR_GREEN
Definition: constants.c:65
GetType
eBleedingSourceType GetType()
Definition: bleedingsource.c:63
m_ActiveTime
float m_ActiveTime
Definition: bleedingsource.c:21
SetType
void SetType(eBleedingSourceType type)
Definition: bleedingsource.c:58
SetActiveTime
void SetActiveTime(int time)
Definition: bleedingsource.c:73
m_DebugShape
Shape m_DebugShape
Definition: bleedingsource.c:16
StartSourceBleedingIndication
void StartSourceBleedingIndication()
Definition: bleedingsource.c:145
RemoveDebugShape
void RemoveDebugShape()
Definition: bleedingsource.c:186
m_MaxTime
float m_MaxTime
Definition: bleedingsource.c:22
m_FlowModifier
float m_FlowModifier
Definition: bleedingsource.c:20
Debug
Definition: debug.c:13
m_DebugShape1
Shape m_DebugShape1
Definition: bleedingsource.c:17
m_Bit
int m_Bit
Definition: bleedingsource.c:12
Timer
Definition: dayzplayerimplement.c:62
~BleedingSource
void ~BleedingSource()
Definition: bleedingsource.c:48
m_ParticleName
string m_ParticleName
Definition: bleedingsource.c:23
m_DebugTick
ref Timer m_DebugTick
Definition: bleedingsource.c:18
Math
Definition: enmath.c:6
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
COLOR_BLUE
const int COLOR_BLUE
Definition: constants.c:66
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead