Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actionremoveseed.c
Go to the documentation of this file.
1
class
ActionRemoveSeed
:
ActionInteractBase
2
{
3
SeedBase
m_Seed
;
4
5
void
ActionRemoveSeed
()
6
{
7
m_Text
=
"#take"
;
8
}
9
10
override
typename
GetInputType
()
11
{
12
return
ContinuousInteractActionInput
;
13
}
14
15
override
void
CreateConditionComponents
()
16
{
17
m_ConditionItem
=
new
CCINone
;
18
m_ConditionTarget
=
new
CCTCursor
(
UAMaxDistances
.
SMALL
);
19
}
20
21
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item )
22
{
23
if
( player.GetCommand_Vehicle() )
24
return
false
;
25
26
GardenBase
garden_base;
27
if
(
Class
.
CastTo
( garden_base, target.GetObject() ) )
28
{
29
Slot slot;
30
31
array<string>
selections =
new
array<string>
;
32
garden_base.GetActionComponentNameList( target.GetComponentIndex(), selections );
33
string
selection;
34
35
for
(
int
s = 0; s < selections.Count(); s++)
36
{
37
selection = selections[s];
38
slot = garden_base.GetSlotBySelection( selection );
39
if
( slot )
40
break
;
41
}
42
43
//Can only remove seed if slot is not watered to prevent VME
44
if
( slot && slot.GetSeed() )
45
{
46
if
( slot.GetWateredState() != eWateredState.DRY)
47
return
false
;
48
49
m_Seed
=
SeedBase
.Cast( slot.GetSeed() );
50
51
if
(
m_Seed
)
52
{
53
if
( player.GetInventory().CanAddEntityIntoInventory(
m_Seed
) &&
m_Seed
.GetHierarchyRootPlayer() != player )
54
return
true
;
55
else
56
return
player.GetInventory().CanAddEntityIntoHands(
m_Seed
);
57
}
58
}
59
}
60
return
false
;
61
}
62
63
override
bool
InventoryReservation
(
ActionData
action_data)
64
{
65
bool
success =
true
;
66
67
InventoryLocation
il =
new
InventoryLocation
;
68
69
if
(
m_Seed
)
70
{
71
action_data.m_Player.GetInventory().FindFreeLocationFor(
m_Seed
,
FindInventoryLocationType
.ANY, il );
72
if
( action_data.m_Player.GetInventory().HasInventoryReservation(
m_Seed
, il ) )
73
{
74
success =
false
;
75
}
76
else
77
{
78
action_data.m_Player.GetInventory().AddInventoryReservationEx(
m_Seed
, il,
GameInventory
.
c_InventoryReservationTimeoutMS
);
79
}
80
}
81
82
if
( success )
83
{
84
if
( il )
85
action_data.m_ReservedInventoryLocations.Insert( il );
86
}
87
88
return
success;
89
}
90
91
override
void
OnExecuteClient
(
ActionData
action_data)
92
{
93
super.OnExecuteClient(action_data);
94
95
PlayerBase
player = action_data.m_Player;
96
float
stackable;
97
InventoryLocation
il;
98
99
//We place in inventory
100
if
( !player.GetInventory().CanAddEntityIntoHands(
m_Seed
) )
101
{
102
il = action_data.m_ReservedInventoryLocations.Get( 0 );
103
InventoryLocation
targetInventoryLocation =
new
InventoryLocation
;
104
m_Seed
.GetInventory().GetCurrentInventoryLocation( targetInventoryLocation );
105
106
stackable =
m_Seed
.GetTargetQuantityMax( il.
GetSlot
() );
107
108
ClearInventoryReservationEx
(action_data);
109
if
( stackable == 0 || stackable >=
m_Seed
.GetQuantity() )
110
{
111
player.PredictiveTakeToDst( targetInventoryLocation, il );
112
}
113
else
114
{
115
m_Seed
.SplitIntoStackMaxToInventoryLocationClient( il );
116
}
117
}
118
else
119
{
120
//We place in hands
121
ClearInventoryReservationEx
(action_data);
122
stackable =
m_Seed
.GetTargetQuantityMax( -1 );
123
124
if
( stackable == 0 || stackable >=
m_Seed
.GetQuantity() )
125
{
126
action_data.m_Player.PredictiveTakeEntityToHands(
m_Seed
);
127
}
128
else
129
{
130
il =
new
InventoryLocation
;
131
il.
SetHands
( action_data.m_Player,
m_Seed
);
132
m_Seed
.SplitIntoStackMaxToInventoryLocationClient( il );
133
}
134
}
135
}
136
};
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
ActionInteractBase::ActionInteractBase
void ActionInteractBase()
Definition
actioninteractbase.c:43
ActionRemoveSeed::m_Seed
SeedBase m_Seed
Definition
actionremoveseed.c:3
ActionRemoveSeed::CreateConditionComponents
override void CreateConditionComponents()
Definition
actionremoveseed.c:15
ActionRemoveSeed::InventoryReservation
override bool InventoryReservation(ActionData action_data)
Definition
actionremoveseed.c:63
ActionRemoveSeed::OnExecuteClient
override void OnExecuteClient(ActionData action_data)
Definition
actionremoveseed.c:91
ActionRemoveSeed::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionremoveseed.c:21
ActionRemoveSeed::GetInputType
override GetInputType()
Definition
actionremoveseed.c:10
ActionRemoveSeed::ActionRemoveSeed
void ActionRemoveSeed()
Definition
actionremoveseed.c:5
CCINone
Definition
ccinone.c:2
CCTCursor
Definition
cctcursor.c:2
Class
Super root of all classes in Enforce script.
Definition
enscript.c:11
ContinuousInteractActionInput
Definition
actioninput.c:523
GameInventory
script counterpart to engine's class Inventory
Definition
inventory.c:81
GameInventory::c_InventoryReservationTimeoutMS
const int c_InventoryReservationTimeoutMS
reservations
Definition
inventory.c:714
GardenBase
Definition
gardenplot.c:2
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
InventoryLocation::GetSlot
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation::SetHands
proto native void SetHands(notnull EntityAI parent, EntityAI e)
ItemBase
Definition
inventoryitem.c:742
PlayerBase
Definition
playerbaseclient.c:2
SeedBase
Definition
cultivation.c:53
UAMaxDistances
Definition
actionconstants.c:110
UAMaxDistances::SMALL
const float SMALL
Definition
actionconstants.c:111
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
Class::CastTo
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition
inventorylocation.c:18
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
interact
actionremoveseed.c
Generated by
1.17.0