Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actiondetachfromtarget.c
Go to the documentation of this file.
1
class
ActionDetachFromTarget
:
ActionInteractBase
2
{
3
4
override
void
CreateConditionComponents
()
5
{
6
m_ConditionItem
=
new
CCINone
;
7
m_ConditionTarget
=
new
CCTCursor
;
8
}
9
10
void
ActionDetachFromTarget
()
11
{
12
m_Text
=
"#take_to_hands"
;
13
}
14
15
override
typename
GetInputType
()
16
{
17
return
ContinuousInteractActionInput
;
18
}
19
20
override
ActionData
CreateActionData
()
21
{
22
DetachActionData
action_data =
new
DetachActionData
;
23
return
action_data;
24
}
25
26
int
FindSlotIdToDetach
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item)
27
{
28
EntityAI
target_entity =
EntityAI
.Cast(target.GetObject());
29
30
if
( player && target_entity )
31
{
32
array<string>
selections =
new
array<string>
();
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
{
39
int
target_slot_id =
InventorySlots
.
GetSlotIdFromString
( selections[i] );
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
}
50
return
InventorySlots
.
INVALID
;
51
}
52
53
override
bool
SetupAction
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item, out
ActionData
action_data,
Param
extra_data = NULL)
54
{
55
int
attSlotId =
InventorySlots
.
INVALID
;
56
if
(!
g_Game
.IsDedicatedServer() )
57
{
58
attSlotId =
FindSlotIdToDetach
(player, target, item);
59
}
60
61
if
( super.SetupAction( player, target, item, action_data, extra_data))
62
{
63
if
(!
g_Game
.IsDedicatedServer())
64
{
65
if
(attSlotId !=
InventorySlots
.
INVALID
)
66
{
67
DetachActionData
action_data_a =
DetachActionData
.Cast(action_data);
68
action_data_a.
m_AttSlot
= attSlotId;
69
return
true
;
70
}
71
return
false
;
72
}
73
return
true
;
74
}
75
return
false
;
76
}
77
78
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item )
79
{
80
if
(
g_Game
.IsMultiplayer() &&
g_Game
.IsServer() )
return
true
;
81
82
return
FindSlotIdToDetach
(player, target, item) !=
InventorySlots
.
INVALID
;
83
}
84
85
override
Object
GetDisplayInteractObject
(
PlayerBase
player,
ActionTarget
target)
86
{
87
int
target_slot_id =
FindSlotIdToDetach
(player, target, null);
88
EntityAI
target_entity =
EntityAI
.Cast( target.GetObject() );
89
90
if
(target_slot_id !=
InventorySlots
.
INVALID
)
91
{
92
return
target_entity.GetInventory().FindAttachment(target_slot_id);
93
}
94
return
null;
95
}
96
97
override
void
OnExecute
(
ActionData
action_data)
98
{
99
if
(
g_Game
.IsDedicatedServer())
100
{
101
ClearActionJuncture
(action_data);
102
return
;
103
}
104
105
Process
(action_data);
106
}
107
108
void
Process
(
ActionData
action_data )
109
{
110
ClearInventoryReservationEx
(action_data);
111
112
DetachActionData
action_data_a =
DetachActionData
.Cast(action_data);
113
EntityAI
target_entity =
EntityAI
.Cast( action_data_a.m_Target.GetObject() );
114
115
ItemBase
attachment =
ItemBase
.Cast(target_entity.GetInventory().FindAttachment(action_data_a.
m_AttSlot
));
116
117
if
(attachment)
118
{
119
float
stackable = attachment.GetTargetQuantityMax();
120
if
( stackable == 0 || stackable >= attachment.GetQuantity() )
121
{
122
//take to hands
123
action_data.m_Player.PredictiveTakeEntityToHands( attachment );
124
}
125
else
if
( stackable != 0 && stackable < attachment.GetQuantity() )
126
{
127
//split and take to hands
128
attachment.SplitIntoStackMaxHandsClient( action_data.m_Player );
129
}
130
}
131
}
132
}
133
134
class
ActionDetachFromTarget_SpecificSlot:
ActionDetachFromTarget
135
{
136
string
m_slotToDetach
;
137
138
override
int
FindSlotIdToDetach
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item)
139
{
140
EntityAI
target_entity =
EntityAI
.Cast(target.GetObject());
141
142
if
( player && target_entity )
143
{
144
array<string>
selections =
new
array<string>
();
145
target_entity.GetActionComponentNameList( target.GetComponentIndex(),selections );
146
147
if
( target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0 )
148
{
149
for
(
int
i = 0; i < selections.Count(); i++ )
150
{
151
if
( selections[i] ==
m_slotToDetach
)
152
{
153
int
target_slot_id =
InventorySlots
.
GetSlotIdFromString
( selections[i] );
154
EntityAI
att = target_entity.GetInventory().FindAttachment(target_slot_id);
155
156
if
( att && player.GetInventory().CanAddEntityIntoHands(att) )
157
{
158
if
( att.CanDetachAttachment( target_entity ) && target_entity.CanReleaseAttachment( att ) )
159
return
target_slot_id;
160
}
161
}
162
}
163
}
164
}
165
return
InventorySlots
.
INVALID
;
166
}
167
}
168
169
class
ActionDetachFromTarget_SpecificSlotsCategory
:
ActionDetachFromTarget
170
{
171
string
m_slotsToDetach
;
172
173
override
int
FindSlotIdToDetach
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item)
174
{
175
EntityAI
target_entity =
EntityAI
.Cast(target.GetObject());
176
177
if
( player && target_entity )
178
{
179
array<string>
selections =
new
array<string>
();
180
target_entity.GetActionComponentNameList( target.GetComponentIndex(),selections );
181
182
if
( target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0 )
183
{
184
for
(
int
i = 0; i < selections.Count(); i++ )
185
{
186
if
(selections[i].Contains(
m_slotsToDetach
))
187
{
188
int
target_slot_id =
InventorySlots
.
GetSlotIdFromString
( selections[i] );
189
EntityAI
att = target_entity.GetInventory().FindAttachment(target_slot_id);
190
191
if
( att && player.GetInventory().CanAddEntityIntoHands(att) )
192
{
193
if
( att.CanDetachAttachment( target_entity ) && target_entity.CanReleaseAttachment( att ) )
194
return
target_slot_id;
195
}
196
}
197
}
198
}
199
}
200
return
InventorySlots
.
INVALID
;
201
}
202
}
203
204
205
class
ActionDetachFromTarget_SpecificSlot_WoodenLogs
: ActionDetachFromTarget_SpecificSlot
206
{
207
void
ActionDetachFromTarget_SpecificSlot_WoodenLogs
()
208
{
209
m_slotToDetach
=
"truck_01_woodenlogs"
;
210
}
211
}
212
213
class
ActionDetachFromTarget_SpecificSlot_WoodenPlanks
: ActionDetachFromTarget_SpecificSlot
214
{
215
void
ActionDetachFromTarget_SpecificSlot_WoodenPlanks
()
216
{
217
m_slotToDetach
=
"truck_01_woodenplanks"
;
218
}
219
}
220
221
class
ActionDetachFromTarget_SpecificSlot_MetalSheets
: ActionDetachFromTarget_SpecificSlot
222
{
223
void
ActionDetachFromTarget_SpecificSlot_MetalSheets
()
224
{
225
m_slotToDetach
=
"truck_01_metalsheets"
;
226
}
227
}
228
229
class
ActionDetachFromTarget_SpecificSlotsCategory_Barrel
:
ActionDetachFromTarget_SpecificSlotsCategory
230
{
231
void
ActionDetachFromTarget_SpecificSlotsCategory_Barrel
()
232
{
233
m_slotsToDetach
=
"truck_01_barrel"
;
234
}
235
}
236
237
class
ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate
:
ActionDetachFromTarget_SpecificSlotsCategory
238
{
239
void
ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate
()
240
{
241
m_slotsToDetach
=
"truck_01_woodencrate"
;
242
}
243
}
ActionData
ActionBase ActionData
Definition
actionbase.c:30
ActionDetachFromTarget_SpecificSlot_MetalSheets
ActionDetachFromTarget_SpecificSlot_WoodenPlanks ActionDetachFromTarget_SpecificSlot ActionDetachFromTarget_SpecificSlot_MetalSheets()
Definition
actiondetachfromtarget.c:223
m_slotsToDetach
string m_slotsToDetach
Definition
actiondetachfromtarget.c:208
ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate
ActionDetachFromTarget_SpecificSlotsCategory_Barrel ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate()
Definition
actiondetachfromtarget.c:239
FindSlotIdToDetach
override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiondetachfromtarget.c:138
ActionDetachFromTarget_SpecificSlot_WoodenLogs
ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget ActionDetachFromTarget_SpecificSlot_WoodenLogs()
Definition
actiondetachfromtarget.c:207
m_slotToDetach
ActionDetachFromTarget m_slotToDetach
ActionTarget
class ActionTargets ActionTarget
ActionBase::m_Text
string m_Text
Definition
actionbase.c:64
ActionBase::m_ConditionItem
ref CCIBase m_ConditionItem
Definition
actionbase.c:70
ActionBase::m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition
actionbase.c:71
ActionBase::ClearInventoryReservationEx
void ClearInventoryReservationEx(ActionData action_data)
Definition
actionbase.c:1040
ActionBase::ClearActionJuncture
void ClearActionJuncture(ActionData action_data)
Definition
actionbase.c:1104
ActionDetachFromTarget_SpecificSlot_WoodenPlanks::ActionDetachFromTarget_SpecificSlot_WoodenPlanks
void ActionDetachFromTarget_SpecificSlot_WoodenPlanks()
Definition
actiondetachfromtarget.c:215
ActionDetachFromTarget_SpecificSlotsCategory_Barrel::ActionDetachFromTarget_SpecificSlotsCategory_Barrel
void ActionDetachFromTarget_SpecificSlotsCategory_Barrel()
Definition
actiondetachfromtarget.c:231
ActionDetachFromTarget_SpecificSlotsCategory
Definition
actiondetachfromtarget.c:170
ActionDetachFromTarget_SpecificSlotsCategory::m_slotsToDetach
string m_slotsToDetach
Definition
actiondetachfromtarget.c:171
ActionDetachFromTarget_SpecificSlotsCategory::FindSlotIdToDetach
override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiondetachfromtarget.c:173
ActionDetachFromTarget
Definition
actiondetachfromtarget.c:2
ActionDetachFromTarget::FindSlotIdToDetach
int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiondetachfromtarget.c:26
ActionDetachFromTarget::ActionDetachFromTarget
void ActionDetachFromTarget()
Definition
actiondetachfromtarget.c:10
ActionDetachFromTarget::CreateActionData
override ActionData CreateActionData()
Definition
actiondetachfromtarget.c:20
ActionDetachFromTarget::CreateConditionComponents
override void CreateConditionComponents()
Definition
actiondetachfromtarget.c:4
ActionDetachFromTarget::GetDisplayInteractObject
override Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
Definition
actiondetachfromtarget.c:85
ActionDetachFromTarget::OnExecute
override void OnExecute(ActionData action_data)
Definition
actiondetachfromtarget.c:97
ActionDetachFromTarget::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiondetachfromtarget.c:78
ActionDetachFromTarget::GetInputType
override GetInputType()
Definition
actiondetachfromtarget.c:15
ActionDetachFromTarget::SetupAction
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition
actiondetachfromtarget.c:53
ActionDetachFromTarget::Process
void Process(ActionData action_data)
Definition
actiondetachfromtarget.c:108
ActionInteractBase::ActionInteractBase
void ActionInteractBase()
Definition
actioninteractbase.c:43
CCINone
Definition
ccinone.c:2
CCTCursor
Definition
cctcursor.c:2
ContinuousInteractActionInput
Definition
actioninput.c:523
DetachActionData
Definition
actiondetach.c:2
DetachActionData::m_AttSlot
int m_AttSlot
Definition
actiondetach.c:3
EntityAI
Definition
inventoryitem.c:2
InventorySlots
provides access to slot configuration
Definition
inventoryslots.c:6
InventorySlots::GetSlotIdFromString
static proto native int GetSlotIdFromString(string slot_name)
InventorySlots::INVALID
const int INVALID
Invalid slot (-1).
Definition
inventoryslots.c:17
ItemBase
Definition
inventoryitem.c:742
Object
Definition
objecttyped.c:2
Param
Base Param Class with no parameters.
Definition
param.c:12
PlayerBase
Definition
playerbaseclient.c:2
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
Process
void Process()
Definition
effectmanager.c:743
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
interact
actiondetachfromtarget.c
Generated by
1.17.0