DayZ 1.24
Loading...
Searching...
No Matches
Defibrillator.c
Go to the documentation of this file.
1class Defibrillator extends ItemBase
2{
3 static const string CHARGING_SOUND = "defibrillator_charge_SoundSet";
4 static const string CHARGED_AND_READY_SOUND = "defibrillator_ready_SoundSet";
5 static const string SHOCK_SOUND = "defibrillator_shock_SoundSet";
6
7 bool m_IsCharged = false;
8
9 static float m_ChargeTime = 5;
10 static float m_EnergyNeededToCharge = 20;
11
15
17 {
18 // Read all config parameters
19 //m_ChargeTime = GetTimeNeededToCharge();
20 m_EnergyNeededToCharge = GetEnergyNeededToCharge();
21 }
22
24 {
25 SEffectManager.DestroyEffect(m_ChargedAlarm);
26 SEffectManager.DestroyEffect(m_ChargingSound);
27 }
28
30 {
31 string cfg_path = "CfgVehicles " + GetType() + " ";
32 return GetGame().ConfigGetFloat(cfg_path + "defibChargeTime");
33 }
34
36 {
37 string cfg_path = "CfgVehicles " + GetType() + " ";
38 return GetGame().ConfigGetFloat(cfg_path + "defibEnergyNeededPerCharge");
39 }
40
41 override void OnWorkStart()
42 {
43 if (!GetGame().IsDedicatedServer())
44 m_ChargingSound = SEffectManager.PlaySoundOnObject(CHARGING_SOUND, this, 0, 0.15);
45
46 float energy_needed = m_EnergyNeededToCharge / m_ChargeTime;
47 GetCompEM().SetEnergyUsage(energy_needed);
48
49 if (!m_ChargingTimer)
50 m_ChargingTimer = new Timer(CALL_CATEGORY_GAMEPLAY);
51
52 if (!m_ChargingTimer.IsRunning())
53 m_ChargingTimer.Run(m_ChargeTime, this, "OnIsCharged", NULL, false);
54 }
55
56 override void OnWorkStop()
57 {
58 GetCompEM().SwitchOff();
59 GetCompEM().ResetEnergyUsage();
63
64 m_IsCharged = false;
65 }
66
68 {
69 if (GetCompEM().IsWorking())
70 {
71 if (!GetGame().IsMultiplayer() || GetGame().IsClient())
72 {
73 //m_ChargedAlarm = PlaySoundLoop(CHARGED_AND_READY_SOUND, 40);
74 m_ChargedAlarm = SEffectManager.PlaySoundOnObject(CHARGED_AND_READY_SOUND, this);
75 m_ChargingSound.SoundStop();
76 }
77 GetCompEM().ResetEnergyUsage();
78 m_IsCharged = true;
79 }
80 }
81
83 {
84 if (m_ChargedAlarm)
85 {
86 //GetGame().ObjectDelete(m_ChargedAlarm);
87 m_ChargedAlarm.SoundStop();
88 m_ChargedAlarm = NULL;
89 }
90 }
91
93 {
94 if (m_ChargingSound)
95 m_ChargingSound.SoundStop();
96 }
97
99 {
100 if (m_ChargingTimer)
101 {
102 m_ChargingTimer.Stop();
103 m_ChargingTimer = NULL;
104 }
105 }
106
108 {
109 return m_IsCharged;
110 }
111
113 {
114 /*
115 bool has_heart_attack = victim.m_ModifiersManager.IsModifierActive(eModifiers.MDF_HEART_ATTACK);
116
117 if ( has_heart_attack )
118 {
119 victim.m_ModifiersManager.DeactivateModifier ( eModifiers.MDF_HEART_ATTACK );
120 }
121 else
122 {
123 victim.m_ModifiersManager.ActivateModifier ( eModifiers.MDF_HEART_ATTACK );
124 }
125 */
126 /*
127 if (!GetGame().IsMultiplayer() || GetGame().IsClient())
128 {
129 SEffectManager.PlaySoundOnObject(SHOCK_SOUND, this);
130 }*/
131
132 victim.SetPulseType(!victim.GetPulseType());
133 victim.SetHealth("", "Shock", 0);
134
135 GetCompEM().SwitchOff();
136 }
137
139 {
140 SEffectManager.PlaySoundOnObject(SHOCK_SOUND, this);
141 }
142
152}
eBleedingSourceType GetType()
void AddAction(typename actionName)
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
void SoundStop()
Stops sound.
float GetEnergyNeededToCharge()
void ~Defibrillator()
override void OnWorkStart()
void DischargeClient(PlayerBase victim)
void StopChargedAlarm()
override void SetActions()
void DischargeServer(PlayerBase victim)
bool IsCharged()
void OnIsCharged()
EffectSound m_ChargingSound
EffectSound m_ChargedAlarm
ref Timer m_ChargingTimer
override void OnWorkStop()
float GetTimeNeededToCharge()
void StopChargingSound()
void Defibrillator()
void StopChargingTimer()
static float m_ChargeTime
bool m_IsCharged
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySoundOnObject(string sound_set, Object parent_object, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
proto native CGame GetGame()
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10