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";
7 bool m_IsCharged =
false;
9 static float m_ChargeTime = 5;
10 static float m_EnergyNeededToCharge = 20;
12 ref
Timer m_ChargingTimer;
20 m_EnergyNeededToCharge = GetEnergyNeededToCharge();
29 float GetTimeNeededToCharge()
31 string cfg_path =
"CfgVehicles " +
GetType() +
" ";
32 return GetGame().ConfigGetFloat (cfg_path +
"defibChargeTime");
35 float GetEnergyNeededToCharge()
37 string cfg_path =
"CfgVehicles " +
GetType() +
" ";
38 return GetGame().ConfigGetFloat (cfg_path +
"defibEnergyNeededPerCharge");
43 if ( !
GetGame().IsDedicatedServer() )
44 m_ChargingSound =
SEffectManager.PlaySoundOnObject(CHARGING_SOUND,
this, 0, 0.15);
46 float energy_needed = m_EnergyNeededToCharge / m_ChargeTime;
47 GetCompEM().SetEnergyUsage(energy_needed);
52 if ( !m_ChargingTimer.IsRunning() )
54 m_ChargingTimer.Run(m_ChargeTime,
this,
"OnIsCharged", NULL,
false);
60 GetCompEM().SwitchOff();
61 GetCompEM().ResetEnergyUsage();
71 if ( GetCompEM().IsWorking() )
76 m_ChargedAlarm =
SEffectManager.PlaySoundOnObject(CHARGED_AND_READY_SOUND,
this);
77 m_ChargingSound.SoundStop();
79 GetCompEM().ResetEnergyUsage();
84 void StopChargedAlarm()
89 m_ChargedAlarm.SoundStop();
90 m_ChargedAlarm = NULL;
94 void StopChargingSound()
98 m_ChargingSound.SoundStop();
102 void StopChargingTimer()
106 m_ChargingTimer.Stop();
107 m_ChargingTimer = NULL;
136 victim.SetPulseType(!victim.GetPulseType());
137 victim.SetHealth(
"",
"Shock",0);
139 GetCompEM().SwitchOff();