Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actiontakehybridattachment.c
Go to the documentation of this file.
1
2
class
ActionTakeHybridAttachment
:
ActionInteractBase
3
{
4
string
m_ItemName
=
""
;
5
6
void
ActionTakeHybridAttachment
()
7
{
8
m_CommandUID
=
DayZPlayerConstants
.CMD_ACTIONMOD_PICKUP_INVENTORY;
9
m_CommandUIDProne
=
DayZPlayerConstants
.CMD_ACTIONFB_PICKUP_INVENTORY;
10
m_Text
=
"#take"
;
11
}
12
13
override
void
CreateConditionComponents
()
14
{
15
m_ConditionItem
=
new
CCINone
;
16
m_ConditionTarget
=
new
CCTCursor
;
17
}
18
19
override
bool
HasProneException
()
20
{
21
return
true
;
22
}
23
24
override
bool
ActionConditionContinue
(
ActionData
action_data )
25
{
26
return
true
;
27
}
28
29
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item )
30
{
31
EntityAI
tgt_entity =
EntityAI
.Cast( target.GetObject() );
32
33
if
( tgt_entity &&
BaseBuildingBase
.Cast(tgt_entity) &&!tgt_entity.IsBeingPlaced() )
34
{
35
string
component_name = tgt_entity.GetActionComponentName( target.GetComponentIndex() );
36
37
/*if (!tgt_entity.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString(component_name)))
38
return false;*/
39
40
ItemBase
attachment =
ItemBase
.Cast(tgt_entity.FindAttachmentBySlotName(component_name));
41
42
if
( attachment && player.GetInventory().CanAddEntityIntoInventory(attachment) && attachment.
IsTakeable
() )
43
{
44
return
true
;
45
}
46
}
47
return
false
;
48
}
49
50
override
bool
CanBeUsedOnBack
()
51
{
52
return
true
;
53
}
54
55
override
bool
InventoryReservation
(
ActionData
action_data)
56
{
57
bool
success =
true
;
58
59
InventoryLocation
il =
new
InventoryLocation
;
60
61
EntityAI
tgt_entity =
EntityAI
.Cast( action_data.m_Target.GetObject() );
62
string
component_name = tgt_entity.GetActionComponentName( action_data.m_Target.GetComponentIndex() );
63
ItemBase
attachment;
64
65
if
( tgt_entity &&
ItemBase
.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)) )
66
{
67
action_data.m_Player.GetInventory().FindFreeLocationFor( attachment ,
FindInventoryLocationType
.ANY, il );
68
if
( action_data.m_Player.GetInventory().HasInventoryReservation( attachment, il) )
69
{
70
success =
false
;
71
}
72
else
73
{
74
action_data.m_Player.GetInventory().AddInventoryReservationEx( attachment, il,
GameInventory
.
c_InventoryReservationTimeoutMS
);
75
}
76
}
77
78
if
( success )
79
{
80
if
( il )
81
action_data.m_ReservedInventoryLocations.Insert(il);
82
}
83
84
return
success;
85
}
86
87
override
void
OnExecute
(
ActionData
action_data )
88
{
89
if
(
g_Game
.IsDedicatedServer())
90
{
91
ClearActionJuncture
(action_data);
92
return
;
93
}
94
95
//Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
96
EntityAI
tgt_entity =
EntityAI
.Cast( action_data.m_Target.GetObject() );
97
string
component_name = tgt_entity.GetActionComponentName( action_data.m_Target.GetComponentIndex() );
98
ItemBase
attachment;
99
100
if
( tgt_entity &&
ItemBase
.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)) )
101
{
102
InventoryLocation
il = action_data.m_ReservedInventoryLocations.Get(0);
103
InventoryLocation
targetInventoryLocation =
new
InventoryLocation
;
104
attachment.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
105
ClearInventoryReservationEx
(action_data);
106
//SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
107
108
float
stackable = attachment.GetTargetQuantityMax(il.
GetSlot
());
109
110
if
( stackable == 0 || stackable >= attachment.GetQuantity() )
111
{
112
action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
113
}
114
else
115
{
116
attachment.SplitIntoStackMaxToInventoryLocationClient( il );
117
}
118
}
119
//action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
120
}
121
};
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
ActionTakeHybridAttachment::CanBeUsedOnBack
override bool CanBeUsedOnBack()
Definition
actiontakehybridattachment.c:50
ActionTakeHybridAttachment::ActionConditionContinue
override bool ActionConditionContinue(ActionData action_data)
Definition
actiontakehybridattachment.c:24
ActionTakeHybridAttachment::CreateConditionComponents
override void CreateConditionComponents()
Definition
actiontakehybridattachment.c:13
ActionTakeHybridAttachment::InventoryReservation
override bool InventoryReservation(ActionData action_data)
Definition
actiontakehybridattachment.c:55
ActionTakeHybridAttachment::OnExecute
override void OnExecute(ActionData action_data)
Definition
actiontakehybridattachment.c:87
ActionTakeHybridAttachment::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiontakehybridattachment.c:29
ActionTakeHybridAttachment::m_ItemName
string m_ItemName
Definition
actiontakehybridattachment.c:4
ActionTakeHybridAttachment::HasProneException
override bool HasProneException()
Definition
actiontakehybridattachment.c:19
ActionTakeHybridAttachment::ActionTakeHybridAttachment
void ActionTakeHybridAttachment()
Definition
actiontakehybridattachment.c:6
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
CCTCursor
Definition
cctcursor.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
PlayerBase
Definition
playerbaseclient.c:2
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
actiontakehybridattachment.c
Generated by
1.17.0