DayZ 1.24
Loading...
Searching...
No Matches
ActionRefuelTorch.c
Go to the documentation of this file.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ATTACHITEM;
6 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
7 m_Text = "#STR_RefuelTorch0";
8 }
9
11 {
14 }
15
16 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
17 {
18 Torch torch;
19 Rag rag;
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 {
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
39 {
40 Torch torch;
41 Rag rag;
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};
Param3 int
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void CreateConditionComponents()
override void OnExecuteServer(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
InventoryLocation.
provides access to slot configuration
const int INVALID
Invalid slot (-1)
Definition EnMath.c:7
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.