DayZ 1.24
Loading...
Searching...
No Matches
ActionTakeArrow Class Reference
Inheritance diagram for ActionTakeArrow:
[legend]
Collaboration diagram for ActionTakeArrow:
[legend]

Private Member Functions

void ActionTakeArrow ()
 
override void CreateConditionComponents ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override Object GetDisplayInteractObject (PlayerBase player, ActionTarget target)
 
override bool CanBeUsedOnBack ()
 
override bool InventoryReservation (ActionData action_data)
 
override void OnExecuteClient (ActionData action_data)
 
override void OnExecuteServer (ActionData action_data)
 

Detailed Description

Definition at line 11 of file ActionTakeArrow.c.

Constructor & Destructor Documentation

◆ ActionTakeArrow()

void ActionTakeArrow::ActionTakeArrow ( )
inlineprivate

Definition at line 13 of file ActionTakeArrow.c.

14 {
15 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
16 m_Text = "#take";
17 }
string m_Text
Definition ActionBase.c:49
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

References AnimatedActionBase::m_CommandUID, and m_Text.

Member Function Documentation

◆ ActionCondition()

override bool ActionTakeArrow::ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

Definition at line 25 of file ActionTakeArrow.c.

26 {
27 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
28 if (!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
29 return false;
30
31 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
32 if (arrowManager)
33 {
34 ItemBase arrow = ItemBase.Cast(arrowManager.GetFirstArrow());
35 if (arrow)
36 {
37 if (player.GetInventory().CanAddEntityIntoInventory(arrow))
38 return true;
39 }
40 }
41
42 return false;
43 }

◆ CanBeUsedOnBack()

override bool ActionTakeArrow::CanBeUsedOnBack ( )
inlineprivate

Definition at line 58 of file ActionTakeArrow.c.

59 {
60 return false;
61 }

◆ CreateConditionComponents()

override void ActionTakeArrow::CreateConditionComponents ( )
inlineprivate

Definition at line 19 of file ActionTakeArrow.c.

20 {
23 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
const float DEFAULT

References UAMaxDistances::DEFAULT, m_ConditionItem, and m_ConditionTarget.

◆ GetDisplayInteractObject()

override Object ActionTakeArrow::GetDisplayInteractObject ( PlayerBase player,
ActionTarget target )
inlineprivate

Definition at line 45 of file ActionTakeArrow.c.

46 {
47 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
48 if (!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
49 return null;
50
51 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
52 if (arrowManager)
53 return arrowManager.GetFirstArrow();
54
55 return null;
56 }

◆ InventoryReservation()

override bool ActionTakeArrow::InventoryReservation ( ActionData action_data)
inlineprivate

Definition at line 63 of file ActionTakeArrow.c.

64 {
65 bool success = true;
66
68
70 if (EntityAI.CastTo(targetEntity, action_data.m_Target.GetObject()))
71 {
72 ArrowManagerBase arrowManager = targetEntity.GetArrowManager();
73 if (arrowManager)
74 {
75 ItemBase targetArrow = ItemBase.Cast(arrowManager.GetFirstArrow());
76 if (targetArrow)
77 {
78 action_data.m_Player.GetInventory().FindFreeLocationFor(targetArrow, FindInventoryLocationType.ANY, il);
79 if (action_data.m_Player.GetInventory().HasInventoryReservation(targetArrow, il))
80 success = false;
81 else
82 action_data.m_Player.GetInventory().AddInventoryReservationEx(targetArrow, il, GameInventory.c_InventoryReservationTimeoutMS);
83 }
84 }
85 }
86
87 if (success)
88 {
89 if (il)
90 action_data.m_ReservedInventoryLocations.Insert(il);
91 }
92
93 return success;
94 }
FindInventoryLocationType
flags for searching locations in inventory
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
InventoryLocation.

References GameInventory::c_InventoryReservationTimeoutMS.

◆ OnExecuteClient()

override void ActionTakeArrow::OnExecuteClient ( ActionData action_data)
inlineprivate

Definition at line 137 of file ActionTakeArrow.c.

138 {
139
140 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
141
142 ItemBase arrow = ItemBase.Cast(il.GetItem());
144 arrow.GetInventory().GetCurrentInventoryLocation(arrowInventoryLocation);
145
146 float stackable = arrow.GetTargetQuantityMax(il.GetSlot());
147
148 if (stackable == 0 || stackable >= arrow.GetQuantity())
149 action_data.m_Player.PredictiveTakeToDst(arrowInventoryLocation, il);
150 else
151 arrow.SplitIntoStackMaxToInventoryLocationClient(il);
152 }

◆ OnExecuteServer()

override void ActionTakeArrow::OnExecuteServer ( ActionData action_data)
inlineprivate

Definition at line 176 of file ActionTakeArrow.c.

177 {
178 //TakeArrowActionData action_data_ta = TakeArrowActionData.Cast(action_data);
179 //action_data.m_Target.GetObject().RemoveChild(action_data_ta.m_Arrow);
180
181 if (GetGame().IsMultiplayer())
182 return;
183
184 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
185 ItemBase arrow = ItemBase.Cast(il.GetItem());
187 arrow.GetInventory().GetCurrentInventoryLocation(arrowInventoryLocation);
188
189 EntityAI targetEntity = EntityAI.Cast(action_data.m_Target.GetObject());
190 if (targetEntity)
191 targetEntity.RemoveChild(arrow);
192
193 //float ammoMax = arrow.GetAmmoMax();
194
195 //if ( stackable == 0 || ammoMax >= arrow.GetAmmoCount() )
196 //{
197 action_data.m_Player.PredictiveTakeToDst(arrowInventoryLocation, il);
198 /*}
199 else
200 {
201 arrow.SplitIntoStackMaxToInventoryLocationClient( il );
202 }*/
203 }
proto native CGame GetGame()

References GetGame().


The documentation for this class was generated from the following file: