DayZ 1.24
Loading...
Searching...
No Matches
ActionTakeArrowToHands.c
Go to the documentation of this file.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
6 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HANDS;
7 m_Text = "#take_to_hands";
8 }
9
15
16 override bool HasProneException()
17 {
18 return true;
19 }
20
21 override typename GetInputType()
22 {
24 }
25
26 override bool HasProgress()
27 {
28 return false;
29 }
30
31 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
32 {
33 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
34 if (!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
35 return false;
36
37 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
38 if (arrowManager)
39 {
40 ItemBase arrow = ItemBase.Cast(arrowManager.GetFirstArrow());
41 if (arrow && !arrow.IsSetForDeletion())
42 {
43 if (player.GetInventory().CanAddEntityIntoHands(arrow))
44 return true;
45 }
46 }
47
48 return false;
49 }
50
52 {
53 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
54 if (!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
55 return null;
56
57 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
58 if (arrowManager)
59 return arrowManager.GetFirstArrow();
60
61 return null;
62 }
63
65 {
66 return true;
67 }
68
70 {
71 bool success = true;
72
74
76 if (EntityAI.CastTo(targetEntity, action_data.m_Target.GetObject()))
77 {
78 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
79 if (arrowManager)
80 {
81 ItemBase targetArrow = ItemBase.Cast(arrowManager.GetFirstArrow());
82 if (targetArrow)
83 {
84 il.SetHands(action_data.m_Player, targetArrow);
85 if (action_data.m_Player.GetInventory().HasInventoryReservation(targetArrow, il))
86 success = false;
87 else
88 action_data.m_Player.GetInventory().AddInventoryReservationEx(targetArrow, il, GameInventory.c_InventoryReservationTimeoutMS);
89 }
90 }
91 }
92
93 if (success)
94 {
95 if (il)
96 action_data.m_ReservedInventoryLocations.Insert(il);
97 }
98
99 return success;
100 }
101
102
104 {
105 if (GetGame().IsMultiplayer() && GetGame().IsServer())
106 return;
107
108 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
109
110 ItemBase arrow = ItemBase.Cast(il.GetItem());
112
113 float stackable = arrow.GetTargetQuantityMax(-1);
114
115 if (stackable == 0 || stackable >= arrow.GetQuantity())
116 action_data.m_Player.PredictiveTakeEntityToHands(arrow);
117 else
118 arrow.SplitIntoStackMaxToInventoryLocationClient(il);
119 }
120
122 {
123 EntityAI target = EntityAI.Cast(action_data.m_Target.GetObject());
124 if (!target)
125 return;
126
128
129 if (target.IsHeavyBehaviour())
130 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HEAVY, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_ERECT));
131 else
132 {
133 if (action_data.m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT))
134 Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(m_CommandUID, GetCallbackClassTypename()));
135 else
136 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(m_CommandUIDProne, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_PRONE));
137 }
138
139 callback.SetActionData(action_data);
140 callback.InitActionComponent();
141 action_data.m_Callback = callback;
142 }
143
144
145 override bool CanBeUsedOnBack()
146 {
147 return true;
148 }
149}
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
override bool InventoryReservation(ActionData action_data)
override Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
override void CreateConditionComponents()
override void OnExecute(ActionData action_data)
override void CreateAndSetupActionCallback(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool CanContinue(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
InventoryLocation.
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.