Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actiontakeitem.c
Go to the documentation of this file.
1
/*class ActionTakeItemReciveData : ActionReciveData
2
{
3
ref InventoryLocation m_InventoryLocation;
4
}*/
5
6
class
ActionTakeItem
:
ActionInteractBase
7
{
8
string
m_ItemName
=
""
;
9
10
void
ActionTakeItem
()
11
{
12
m_CommandUID
=
DayZPlayerConstants
.CMD_ACTIONMOD_PICKUP_INVENTORY;
13
m_CommandUIDProne
=
DayZPlayerConstants
.CMD_ACTIONFB_PICKUP_INVENTORY;
14
m_Text
=
"#take"
;
15
}
16
17
override
void
CreateConditionComponents
()
18
{
19
m_ConditionItem
=
new
CCINone
;
20
m_ConditionTarget
=
new
CCTObject
(
UAMaxDistances
.
DEFAULT
);
21
}
22
23
override
bool
HasProneException
()
24
{
25
return
true
;
26
}
27
28
override
bool
ActionConditionContinue
(
ActionData
action_data )
29
{
30
return
true
;
31
}
32
33
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item )
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
42
if
( tgt_entity && (!tgt_parent ||
BaseBuildingBase
.Cast(tgt_parent)) )
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
}
54
55
override
bool
CanBeUsedOnBack
()
56
{
57
return
true
;
58
}
59
60
/*override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
61
{
62
super.WriteToContext(ctx, action_data);
63
InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
64
il.WriteToContext(ctx);
65
}
66
67
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
68
{
69
if(!action_recive_data)
70
{
71
action_recive_data = new ActionTakeItemReciveData;
72
}
73
74
if(super.ReadFromContext(ctx, action_recive_data))
75
{
76
ActionTakeItemReciveData recive_data_ti = ActionTakeItemReciveData.Cast(action_recive_data);
77
recive_data_ti.m_InventoryLocation = new InventoryLocation;
78
if(recive_data_ti.m_InventoryLocation.ReadFromContext(ctx))
79
{
80
return true;
81
}
82
}
83
84
return false;
85
}
86
87
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
88
{
89
super.HandleReciveData(action_recive_data, action_data);
90
ActionTakeItemReciveData recive_data_ti = ActionTakeItemReciveData.Cast(action_recive_data);
91
action_data.m_ReservedInventoryLocations.Insert(recive_data_ti.m_InventoryLocation);
92
} */
93
94
95
96
override
bool
InventoryReservation
(
ActionData
action_data)
97
{
98
bool
success =
true
;
99
100
InventoryLocation
il =
new
InventoryLocation
;
101
102
ItemBase
targetItem;
103
if
(
ItemBase
.CastTo(targetItem, action_data.m_Target.GetObject()) )
104
{
105
action_data.m_Player.GetInventory().FindFreeLocationFor( targetItem ,
FindInventoryLocationType
.ANY, il );
106
if
( action_data.m_Player.GetInventory().HasInventoryReservation( targetItem, il) )
107
{
108
success =
false
;
109
}
110
else
111
{
112
action_data.m_Player.GetInventory().AddInventoryReservationEx( targetItem, il,
GameInventory
.
c_InventoryReservationTimeoutMS
);
113
}
114
}
115
116
if
( success )
117
{
118
if
( il )
119
action_data.m_ReservedInventoryLocations.Insert(il);
120
}
121
122
return
success;
123
}
124
125
override
void
OnExecute
(
ActionData
action_data)
126
{
127
if
(
g_Game
.IsDedicatedServer())
128
{
129
ClearActionJuncture
(action_data);
130
return
;
131
}
132
133
//Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
134
ItemBase
ntarget =
ItemBase
.Cast(action_data.m_Target.GetObject());
135
InventoryLocation
il = action_data.m_ReservedInventoryLocations.Get(0);
136
InventoryLocation
targetInventoryLocation =
new
InventoryLocation
;
137
ntarget.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
138
139
ClearInventoryReservationEx
(action_data);
140
141
//SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
142
143
float
stackable = ntarget.GetTargetQuantityMax(il.
GetSlot
());
144
145
if
( stackable == 0 || stackable >= ntarget.GetQuantity() )
146
{
147
action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
148
}
149
else
150
{
151
ClearInventoryReservationEx
(action_data);
152
ntarget.SplitIntoStackMaxToInventoryLocationClient( il );
153
}
154
155
//action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
156
}
157
};
ActionData
ActionBase ActionData
Definition
actionbase.c:30
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
ActionInteractBase::ActionInteractBase
void ActionInteractBase()
Definition
actioninteractbase.c:43
ActionTakeItem::CanBeUsedOnBack
override bool CanBeUsedOnBack()
Definition
actiontakeitem.c:55
ActionTakeItem::ActionConditionContinue
override bool ActionConditionContinue(ActionData action_data)
Definition
actiontakeitem.c:28
ActionTakeItem::ActionTakeItem
void ActionTakeItem()
Definition
actiontakeitem.c:10
ActionTakeItem::CreateConditionComponents
override void CreateConditionComponents()
Definition
actiontakeitem.c:17
ActionTakeItem::InventoryReservation
override bool InventoryReservation(ActionData action_data)
Definition
actiontakeitem.c:96
ActionTakeItem::OnExecute
override void OnExecute(ActionData action_data)
Definition
actiontakeitem.c:125
ActionTakeItem::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiontakeitem.c:33
ActionTakeItem::m_ItemName
string m_ItemName
Definition
actiontakeitem.c:8
ActionTakeItem::HasProneException
override bool HasProneException()
Definition
actiontakeitem.c:23
AnimatedActionBase::m_CommandUIDProne
int m_CommandUIDProne
Definition
animatedactionbase.c:144
AnimatedActionBase::m_CommandUID
int m_CommandUID
Definition
animatedactionbase.c:143
BaseBuildingBase
Definition
fence.c:2
CCINone
Definition
ccinone.c:2
CCTObject
Definition
cctobject.c:2
EntityAI
Definition
inventoryitem.c:2
GameInventory
script counterpart to engine's class Inventory
Definition
inventory.c:81
GameInventory::c_InventoryReservationTimeoutMS
const int c_InventoryReservationTimeoutMS
reservations
Definition
inventory.c:714
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
InventoryLocation::GetSlot
proto native int GetSlot()
returns slot id if current type is Attachment
ItemBase
Definition
inventoryitem.c:742
ItemBase::IsTakeable
override bool IsTakeable()
Definition
basebuildingbase.c:1008
ItemBase::CanDetachAttachment
override bool CanDetachAttachment(EntityAI parent)
Definition
gardenlime.c:42
PlayerBase
Definition
playerbaseclient.c:2
UAMaxDistances
Definition
actionconstants.c:110
UAMaxDistances::DEFAULT
const float DEFAULT
Definition
actionconstants.c:112
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:602
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition
inventorylocation.c:18
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
interact
actiontakeitem.c
Generated by
1.17.0