DayZ 1.24
Loading...
Searching...
No Matches
ActionDetachFromTarget.c
Go to the documentation of this file.
2{
3
9
11 {
12 m_Text = "#take_to_hands";
13 }
14
15 override typename GetInputType()
16 {
18 }
19
25
27 {
28 EntityAI target_entity = EntityAI.Cast(target.GetObject());
29
30 if (player && target_entity)
31 {
33 target_entity.GetActionComponentNameList(target.GetComponentIndex(), selections);
34
35 if (target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0)
36 {
37 for (int i = 0; i < selections.Count(); i++)
38 {
40 EntityAI att = target_entity.GetInventory().FindAttachment(target_slot_id);
41
42 if (att && player.GetInventory().CanAddEntityIntoHands(att))
43 {
44 if (att.CanDetachAttachment(target_entity) && target_entity.CanReleaseAttachment(att))
45 return target_slot_id;
46 }
47 }
48 }
49 }
51 }
52
54 {
56 if (!GetGame().IsDedicatedServer())
58
59 if (super.SetupAction(player, target, item, action_data, extra_data))
60 {
61 if (!GetGame().IsDedicatedServer())
62 {
64 {
66 action_data_a.m_AttSlot = attSlotId;
67 return true;
68 }
69 return false;
70 }
71 return true;
72 }
73 return false;
74 }
75
76 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
77 {
78 if (GetGame().IsMultiplayer() && GetGame().IsServer()) return true;
79
81 }
82
84 {
86 EntityAI target_entity = EntityAI.Cast(target.GetObject());
87
89 return target_entity.GetInventory().FindAttachment(target_slot_id);
90 return null;
91 }
92
97
99 {
100 if (!GetGame().IsMultiplayer())
102 }
103
105 {
107
109 EntityAI target_entity = EntityAI.Cast(action_data_a.m_Target.GetObject());
110
111 ItemBase attachment = ItemBase.Cast(target_entity.GetInventory().FindAttachment(action_data_a.m_AttSlot));
112
113 if (attachment)
114 {
115 float stackable = attachment.GetTargetQuantityMax();
116 if (stackable == 0 || stackable >= attachment.GetQuantity())
117 {
118 //take to hands
119 action_data.m_Player.PredictiveTakeEntityToHands(attachment);
120 }
121 else if (stackable != 0 && stackable < attachment.GetQuantity())
122 {
123 //split and take to hands
124 attachment.SplitIntoStackMaxHandsClient(action_data.m_Player);
125 }
126 }
127 }
128}
129
130class ActionDetachFromTarget_SpecificSlot: ActionDetachFromTarget
131{
133
135 {
136 EntityAI target_entity = EntityAI.Cast(target.GetObject());
137
138 if (player && target_entity)
139 {
141 target_entity.GetActionComponentNameList(target.GetComponentIndex(), selections);
142
143 if (target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0)
144 {
145 for (int i = 0; i < selections.Count(); i++)
146 {
148 {
150 EntityAI att = target_entity.GetInventory().FindAttachment(target_slot_id);
151
152 if (att && player.GetInventory().CanAddEntityIntoHands(att))
153 {
154 if (att.CanDetachAttachment(target_entity) && target_entity.CanReleaseAttachment(att))
155 return target_slot_id;
156 }
157 }
158 }
159 }
160 }
161 return InventorySlots.INVALID;
162 }
163}
164
166{
168
170 {
171 EntityAI target_entity = EntityAI.Cast(target.GetObject());
172
173 if (player && target_entity)
174 {
176 target_entity.GetActionComponentNameList(target.GetComponentIndex(), selections);
177
178 if (target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0)
179 {
180 for (int i = 0; i < selections.Count(); i++)
181 {
182 if (selections[i].Contains(m_slotsToDetach))
183 {
185 EntityAI att = target_entity.GetInventory().FindAttachment(target_slot_id);
186
187 if (att && player.GetInventory().CanAddEntityIntoHands(att))
188 {
189 if (att.CanDetachAttachment(target_entity) && target_entity.CanReleaseAttachment(att))
190 return target_slot_id;
191 }
192 }
193 }
194 }
195 }
196 return InventorySlots.INVALID;
197 }
198}
199
200
201class ActionDetachFromTarget_SpecificSlot_WoodenLogs: ActionDetachFromTarget_SpecificSlot
202{
205 m_slotToDetach = "truck_01_woodenlogs";
206 }
207}
208
209class ActionDetachFromTarget_SpecificSlot_WoodenPlanks: ActionDetachFromTarget_SpecificSlot
210{
212 {
213 m_slotToDetach = "truck_01_woodenplanks";
214 }
215}
216
217class ActionDetachFromTarget_SpecificSlot_MetalSheets: ActionDetachFromTarget_SpecificSlot
218{
221 m_slotToDetach = "truck_01_metalsheets";
222 }
223}
224
232
234{
237 m_slotsToDetach = "truck_01_woodencrate";
238 }
239}
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
ActionDetachFromTarget_SpecificSlot_WoodenPlanks ActionDetachFromTarget_SpecificSlot ActionDetachFromTarget_SpecificSlot_MetalSheets()
string m_slotsToDetach
ActionDetachFromTarget_SpecificSlotsCategory_Barrel ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate()
override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget ActionDetachFromTarget_SpecificSlot_WoodenLogs()
ActionDetachFromTarget m_slotToDetach
override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
override void OnExecuteServer(ActionData action_data)
override void OnExecuteClient(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override ActionData CreateActionData()
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
override void CreateConditionComponents()
void Process(ActionData action_data)
int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
override Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
provides access to slot configuration
const int INVALID
Invalid slot (-1)
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
proto native CGame GetGame()