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

Private Member Functions

void ActionTakeItem ()
 
override void CreateConditionComponents ()
 
override bool HasProneException ()
 
override bool ActionConditionContinue (ActionData action_data)
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override bool CanBeUsedOnBack ()
 
override bool InventoryReservation (ActionData action_data)
 
override void OnExecuteServer (ActionData action_data)
 
override void OnExecuteClient (ActionData action_data)
 

Private Attributes

string m_ItemName = ""
 

Detailed Description

Definition at line 6 of file ActionTakeItem.c.

Constructor & Destructor Documentation

◆ ActionTakeItem()

void ActionTakeItem::ActionTakeItem ( )
inlineprivate

Definition at line 10 of file ActionTakeItem.c.

11 {
12 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_INVENTORY;
13 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_INVENTORY;
14 m_Text = "#take";
15 }
string m_Text
Definition ActionBase.c:49
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

References AnimatedActionBase::m_CommandUID, AnimatedActionBase::m_CommandUIDProne, and m_Text.

Member Function Documentation

◆ ActionCondition()

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

Definition at line 33 of file ActionTakeItem.c.

34 {
35 ItemBase tgt_item = ItemBase.Cast(target.GetObject());
36 if (tgt_item && !tgt_item.IsTakeable()) return false;
37 if (tgt_item && tgt_item.IsBeingPlaced()) return false;
38
39 EntityAI tgt_parent = EntityAI.Cast(target.GetParent());
40 EntityAI tgt_entity = EntityAI.Cast(target.GetObject());
41
43 {
44 if (tgt_entity && tgt_entity.IsItemBase() && player.GetInventory().CanAddEntityIntoInventory(tgt_entity) && tgt_entity.GetHierarchyRootPlayer() != player)
45 {
46 if (tgt_parent && (!tgt_item.CanDetachAttachment(tgt_parent) || !tgt_parent.CanReleaseAttachment(tgt_item)))
47 return false;
48
49 return true;
50 }
51 }
52 return false;
53 }

◆ ActionConditionContinue()

override bool ActionTakeItem::ActionConditionContinue ( ActionData action_data)
inlineprivate

Definition at line 28 of file ActionTakeItem.c.

29 {
30 return true;
31 }

◆ CanBeUsedOnBack()

override bool ActionTakeItem::CanBeUsedOnBack ( )
inlineprivate

Definition at line 55 of file ActionTakeItem.c.

56 {
57 return true;
58 }

◆ CreateConditionComponents()

override void ActionTakeItem::CreateConditionComponents ( )
inlineprivate

Definition at line 17 of file ActionTakeItem.c.

18 {
21 }
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.

◆ HasProneException()

override bool ActionTakeItem::HasProneException ( )
inlineprivate

Definition at line 23 of file ActionTakeItem.c.

24 {
25 return true;
26 }

◆ InventoryReservation()

override bool ActionTakeItem::InventoryReservation ( ActionData action_data)
inlineprivate

Definition at line 95 of file ActionTakeItem.c.

96 {
97 bool success = true;
98
100
102 if (ItemBase.CastTo(targetItem, action_data.m_Target.GetObject()))
103 {
104 action_data.m_Player.GetInventory().FindFreeLocationFor(targetItem, FindInventoryLocationType.ANY, il);
105 if (action_data.m_Player.GetInventory().HasInventoryReservation(targetItem, il))
106 success = false;
107 else
108 action_data.m_Player.GetInventory().AddInventoryReservationEx(targetItem, il, GameInventory.c_InventoryReservationTimeoutMS);
109 }
110
111 if (success)
112 {
113 if (il)
114 action_data.m_ReservedInventoryLocations.Insert(il);
115 }
116
117 return success;
118 }
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 ActionTakeItem::OnExecuteClient ( ActionData action_data)
inlineprivate

Definition at line 146 of file ActionTakeItem.c.

147 {
148 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
149 ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
150 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
152 ntarget.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
153
154 //SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
155 //action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
156 float stackable = ntarget.GetTargetQuantityMax(il.GetSlot());
157
158 if (stackable == 0 || stackable >= ntarget.GetQuantity())
159 action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
160 else
161 ntarget.SplitIntoStackMaxToInventoryLocationClient(il);
162 }

◆ OnExecuteServer()

override void ActionTakeItem::OnExecuteServer ( ActionData action_data)
inlineprivate

Definition at line 120 of file ActionTakeItem.c.

121 {
122 if (GetGame().IsMultiplayer())
123 return;
124
125 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
126 ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
127 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
129 ntarget.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
130
131 //SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
132
133 float stackable = ntarget.GetTargetQuantityMax(il.GetSlot());
134
135 if (stackable == 0 || stackable >= ntarget.GetQuantity())
136 action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
137 else
138 {
140 ntarget.SplitIntoStackMaxToInventoryLocationClient(il);
141 }
142
143 //action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
144 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
proto native CGame GetGame()

References ClearInventoryReservationEx(), and GetGame().

Member Data Documentation

◆ m_ItemName

string ActionTakeItem::m_ItemName = ""
private

Definition at line 8 of file ActionTakeItem.c.


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