Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiondefibrilatebase.c
Go to the documentation of this file.
2 {
3  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
4  {
5  Defibrillator defib;
6  Class.CastTo(defib, item);
7 
8  return CanDefibrillate(defib);
9  }
10 
11  bool CanDefibrillate(Defibrillator defib)
12  {
13  if ( defib.IsCharged() )
14  {
15  return true;
16  }
17  else
18  {
19  return false;
20  }
21  }
22 
23  void DefibrillateClient(PlayerBase player, Defibrillator defib)
24  {
25  defib.DischargeClient(player);
26  }
27 
28  void DefibrillateServer(PlayerBase player, Defibrillator defib)
29  {
30  if ( defib.IsCharged() )
31  {
32  defib.DischargeServer(player);
33 
34 
35  float regain_energy = player.GetSoftSkillsManager().SubtractSpecialtyBonus( defib.GetEnergyNeededToCharge(), this.GetSpecialtyWeight() );
36  regain_energy = defib.GetEnergyNeededToCharge() - regain_energy;
37 
38  ItemBase battery;
39 
40  if (Class.CastTo(battery, defib.GetCompEM().GetEnergySource()))
41  {
42  battery.GetCompEM().AddEnergy( regain_energy );
43  }
44  else
45  {
46  DPrint("ERROR! Defibrillator has no battery! Defibrillator softskill bonus can't be applied!");
47  }
48  }
49  player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
50  }
51 };
ItemBase
Definition: inventoryitem.c:730
DPrint
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...
ActionDefibrilateBase
Definition: actiondefibrilatebase.c:1
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionContinuousBase
Definition: actioncontinuousbase.c:132
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68