Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionrefueltorch.c
Go to the documentation of this file.
2 {
3  void ActionRefuelTorch()
4  {
5  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ATTACHITEM;
6  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
7  m_Text = "#STR_RefuelTorch0";
8  }
9 
10  override void CreateConditionComponents()
11  {
14  }
15 
16  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
17  {
18  Torch torch;
19  Rag rag;
20  Rag torchRag;
21 
22  if ((Class.CastTo(torch,target.GetObject()) && Class.CastTo(rag,item)) || (Class.CastTo(rag,target.GetObject()) && Class.CastTo(torch,item)))
23  {
24  if (Class.CastTo(torchRag,torch.GetRag()))
25  {
26  int slotId = InventorySlots.INVALID;
28  torchRag.GetInventory().GetCurrentInventoryLocation(lcn);
29  slotId = lcn.GetSlot();
30 
31  return torch.GetInventory().GetSlotLock(slotId) && torch.GetRagQuantity() < torchRag.GetQuantityMax() && torch.IsRagDryEnough(rag);
32  }
33  }
34 
35  return false;
36  }
37 
38  override void OnExecuteServer(ActionData action_data)
39  {
40  Torch torch;
41  Rag rag;
42  Rag torchRag;
43 
44  if ((Class.CastTo(torch,action_data.m_Target.GetObject()) && Class.CastTo(rag,action_data.m_MainItem)) || (Class.CastTo(rag,action_data.m_Target.GetObject()) && Class.CastTo(torch,action_data.m_MainItem)))
45  {
46  Class.CastTo(torchRag,torch.GetRag());
47 
48  int qtyTransfer = torchRag.GetQuantityMax() - torch.GetRagQuantity(); //torch rag capacity
49  qtyTransfer = (int)Math.Clamp(rag.GetQuantity(),0,qtyTransfer);
50  torchRag.AddQuantity(qtyTransfer);
51  rag.AddQuantity(-qtyTransfer);
52  }
53  }
54 };
ItemBase
Definition: inventoryitem.c:730
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionRefuelTorch
Definition: actionrefueltorch.c:1
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CCTNonRuined
Definition: cctnonruined.c:1
int
Param3 int
m_Text
protected string m_Text
Definition: actionbase.c:49
ActionSingleUseBase
Definition: actionsingleusebase.c:41
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
CCINonRuined
Definition: ccinonruined.c:1
Math
Definition: enmath.c:6
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53