Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actiontakearrow.c
Go to the documentation of this file.
1
class
ActionTakeArrow
:
ActionTakeItem
2
{
3
void
ActionTakeArrow
()
4
{
5
m_CommandUID
=
DayZPlayerConstants
.CMD_ACTIONMOD_PICKUP_HANDS;
6
m_Text
=
"#take"
;
7
}
8
9
override
void
CreateConditionComponents
()
10
{
11
m_ConditionItem
=
new
CCINone
();
12
m_ConditionTarget
=
new
CCTObject
(
UAMaxDistances
.
DEFAULT
);
13
}
14
15
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item)
16
{
17
EntityAI
targetEntity =
EntityAI
.Cast(target.GetObject());
18
if
(!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
19
return
false
;
20
21
ArrowManagerBase
arrowManager = targetEntity.GetArrowManager();
22
if
(arrowManager)
23
{
24
ItemBase
arrow =
ItemBase
.Cast(arrowManager.
GetFirstArrow
());
25
if
(arrow)
26
{
27
if
(player.GetInventory().CanAddEntityIntoInventory(arrow))
28
return
true
;
29
}
30
}
31
32
return
false
;
33
}
34
35
override
Object
GetDisplayInteractObject
(
PlayerBase
player,
ActionTarget
target)
36
{
37
EntityAI
targetEntity =
EntityAI
.Cast(target.GetObject());
38
if
(!targetEntity || (targetEntity && targetEntity.IsManagingArrows() && !targetEntity.IsDamageDestroyed()))
39
return
null;
40
41
ArrowManagerBase
arrowManager = targetEntity.GetArrowManager();
42
if
(arrowManager)
43
{
44
return
arrowManager.
GetFirstArrow
();
45
}
46
47
return
null;
48
}
49
50
override
bool
CanBeUsedOnBack
()
51
{
52
return
false
;
53
}
54
55
override
bool
InventoryReservation
(
ActionData
action_data)
56
{
57
bool
success =
true
;
58
59
InventoryLocation
il =
new
InventoryLocation
();
60
61
EntityAI
targetEntity;
62
if
(
EntityAI
.CastTo(targetEntity, action_data.m_Target.GetObject()))
63
{
64
ArrowManagerBase
arrowManager = targetEntity.GetArrowManager();
65
if
(arrowManager)
66
{
67
ItemBase
targetArrow =
ItemBase
.Cast(arrowManager.
GetFirstArrow
());
68
if
(targetArrow)
69
{
70
action_data.m_Player.GetInventory().FindFreeLocationFor(targetArrow ,
FindInventoryLocationType
.ANY, il);
71
if
(action_data.m_Player.GetInventory().HasInventoryReservation(targetArrow, il))
72
{
73
success =
false
;
74
}
75
else
76
{
77
action_data.m_Player.GetInventory().AddInventoryReservationEx(targetArrow, il,
GameInventory
.
c_InventoryReservationTimeoutMS
);
78
}
79
}
80
}
81
}
82
83
if
(success)
84
{
85
if
(il)
86
action_data.m_ReservedInventoryLocations.Insert(il);
87
}
88
89
return
success;
90
}
91
92
93
override
void
OnExecute
(
ActionData
action_data)
94
{
95
if
(
g_Game
.IsDedicatedServer())
96
{
97
ClearActionJuncture
(action_data);
98
return
;
99
}
100
101
InventoryLocation
il = action_data.m_ReservedInventoryLocations.Get(0);
102
103
ClearInventoryReservationEx
(action_data);
104
105
ItemBase
arrow =
ItemBase
.Cast(il.
GetItem
());
106
InventoryLocation
arrowInventoryLocation =
new
InventoryLocation
;
107
arrow.GetInventory().GetCurrentInventoryLocation(arrowInventoryLocation);
108
109
float
stackable = arrow.GetTargetQuantityMax(il.
GetSlot
());
110
111
if
( stackable == 0 || stackable >= arrow.GetQuantity() )
112
{
113
action_data.m_Player.PredictiveTakeToDst(arrowInventoryLocation, il);
114
}
115
else
116
{
117
arrow.SplitIntoStackMaxToInventoryLocationClient( il );
118
}
119
}
120
}
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
ActionTakeArrow::ActionTakeArrow
void ActionTakeArrow()
Definition
actiontakearrow.c:3
ActionTakeArrow::CanBeUsedOnBack
override bool CanBeUsedOnBack()
Definition
actiontakearrow.c:50
ActionTakeArrow::CreateConditionComponents
override void CreateConditionComponents()
Definition
actiontakearrow.c:9
ActionTakeArrow::InventoryReservation
override bool InventoryReservation(ActionData action_data)
Definition
actiontakearrow.c:55
ActionTakeArrow::GetDisplayInteractObject
override Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
Definition
actiontakearrow.c:35
ActionTakeArrow::OnExecute
override void OnExecute(ActionData action_data)
Definition
actiontakearrow.c:93
ActionTakeArrow::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiontakearrow.c:15
ActionTakeItem::ActionTakeItem
void ActionTakeItem()
Definition
actiontakeitem.c:10
AnimatedActionBase::m_CommandUID
int m_CommandUID
Definition
animatedactionbase.c:143
ArrowManagerBase
Definition
arrowmanagerbase.c:2
ArrowManagerBase::GetFirstArrow
EntityAI GetFirstArrow()
Definition
arrowmanagerbase.c:82
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
InventoryLocation::GetItem
proto native EntityAI GetItem()
returns item of current inventory location
ItemBase
Definition
inventoryitem.c:742
Object
Definition
objecttyped.c:2
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
actiontakearrow.c
Generated by
1.17.0