Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actionattachwithswich.c
Go to the documentation of this file.
1
class
ActionAttachWithSwitch
:
ActionAttach
2
{
3
void
ActionAttachWithSwitch
()
4
{
5
}
6
7
override
void
CreateConditionComponents
()
8
{
9
m_ConditionItem =
new
CCINonRuined
;
10
m_ConditionTarget =
new
CCTNonRuined
(
UAMaxDistances
.
DEFAULT
);
11
m_CommandUID
=
DayZPlayerConstants
.CMD_ACTIONMOD_ATTACHITEM;
12
m_StanceMask
=
DayZPlayerConstants
.STANCEMASK_ERECT |
DayZPlayerConstants
.STANCEMASK_CROUCH;
13
}
14
15
override
typename
GetInputType
()
16
{
17
return
InventoryOnlyActionInput
;
18
}
19
20
override
bool
CanBePerformedFromInventory
()
21
{
22
return
true
;
23
}
24
25
override
ActionData
CreateActionData
()
26
{
27
AttachActionData
action_data =
new
AttachActionData
;
28
return
action_data;
29
}
30
31
override
bool
SetupAction
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item, out
ActionData
action_data,
Param
extra_data = NULL)
32
{
33
ref
InventoryLocation
il =
new
InventoryLocation
;
34
if
(!
g_Game
.IsDedicatedServer())
35
{
36
EntityAI
target_entity;
37
38
if
( target.IsProxy() )
39
{
40
target_entity =
EntityAI
.Cast( target.GetParent() );
41
}
42
else
43
{
44
target_entity =
EntityAI
.Cast( target.GetObject() );
45
}
46
47
if
(!target_entity.GetInventory().FindFreeLocationFor( item,
FindInventoryLocationType
.ATTACHMENT, il ))
48
return
false
;
49
}
50
51
if
( super.SetupAction( player, target, item, action_data, extra_data))
52
{
53
if
(!
g_Game
.IsDedicatedServer())
54
{
55
AttachActionData
action_data_a =
AttachActionData
.Cast(action_data);
56
action_data_a.
m_AttSlot
= il.GetSlot();
57
}
58
return
true
;
59
}
60
return
false
;
61
}
62
63
64
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item )
65
{
66
EntityAI
target_entity =
EntityAI
.Cast( target.GetObject() );
67
if
( !item.CanSwitchDuringAttach(target_entity) )
68
return
false
;
69
70
if
( target_entity && item )
71
{
72
if
( target_entity.GetInventory() && target_entity.GetInventory().CanAddAttachment( item ) )
73
{
74
return
true
;
75
}
76
}
77
return
false
;
78
}
79
80
override
void
OnExecuteServer
(
ActionData
action_data )
81
{
82
if
(
g_Game
.IsMultiplayer())
83
return
;
84
85
ClearInventoryReservationEx(action_data);
86
AttachActionData
action_data_a =
AttachActionData
.Cast(action_data);
87
EntityAI
target_EAI;
88
89
if
( action_data.m_Target.IsProxy() )
90
{
91
target_EAI =
EntityAI
.Cast( action_data_a.m_Target.GetParent() );
92
}
93
else
94
{
95
target_EAI =
EntityAI
.Cast( action_data_a.m_Target.GetObject() );
96
}
97
98
if
(target_EAI && action_data_a.m_MainItem)
99
{
100
ref
InventoryLocation
il =
new
InventoryLocation
;
101
il.
SetAttachment
( target_EAI, action_data.m_MainItem, action_data_a.
m_AttSlot
);
102
action_data.m_Player.PredictiveForceSwapEntities( target_EAI, action_data.m_MainItem, il );
103
}
104
}
105
106
override
void
OnExecuteClient
(
ActionData
action_data )
107
{
108
ClearInventoryReservationEx(action_data);
109
AttachActionData
action_data_a =
AttachActionData
.Cast(action_data);
110
111
EntityAI
target_EAI;
112
113
if
( action_data.m_Target.IsProxy() )
114
{
115
target_EAI =
EntityAI
.Cast( action_data_a.m_Target.GetParent() );
116
}
117
else
118
{
119
target_EAI =
EntityAI
.Cast( action_data_a.m_Target.GetObject() );
120
}
121
122
if
(target_EAI && action_data_a.m_MainItem)
123
{
124
ref
InventoryLocation
il =
new
InventoryLocation
;
125
il.
SetAttachment
( target_EAI, action_data.m_MainItem, action_data_a.
m_AttSlot
);
126
action_data.m_Player.PredictiveForceSwapEntities( target_EAI, action_data.m_MainItem, il );
127
}
128
}
129
}
ActionAttach
AttachActionData ActionData ActionAttach()
Definition
actionattach.c:9
m_CommandUID
int m_CommandUID
Definition
actionbase.c:31
m_StanceMask
int m_StanceMask
Definition
actionbase.c:33
ActionData
ActionBase ActionData
Definition
actionbase.c:30
ActionTarget
class ActionTargets ActionTarget
ActionAttachWithSwitch::ActionAttachWithSwitch
void ActionAttachWithSwitch()
Definition
actionattachwithswich.c:3
ActionAttachWithSwitch::OnExecuteServer
override void OnExecuteServer(ActionData action_data)
Definition
actionattachwithswich.c:80
ActionAttachWithSwitch::CanBePerformedFromInventory
override bool CanBePerformedFromInventory()
Definition
actionattachwithswich.c:20
ActionAttachWithSwitch::CreateActionData
override ActionData CreateActionData()
Definition
actionattachwithswich.c:25
ActionAttachWithSwitch::CreateConditionComponents
override void CreateConditionComponents()
Definition
actionattachwithswich.c:7
ActionAttachWithSwitch::OnExecuteClient
override void OnExecuteClient(ActionData action_data)
Definition
actionattachwithswich.c:106
ActionAttachWithSwitch::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionattachwithswich.c:64
ActionAttachWithSwitch::GetInputType
override GetInputType()
Definition
actionattachwithswich.c:15
ActionAttachWithSwitch::SetupAction
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition
actionattachwithswich.c:31
AttachActionData
Definition
actionattach.c:2
AttachActionData::m_AttSlot
int m_AttSlot
Definition
actionattach.c:3
CCINonRuined
Definition
ccinonruined.c:2
CCTNonRuined
Definition
cctnonruined.c:2
EntityAI
Definition
inventoryitem.c:2
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
InventoryLocation::SetAttachment
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
InventoryOnlyActionInput
Definition
actioninput.c:940
ItemBase
Definition
inventoryitem.c:742
Param
Base Param Class with no parameters.
Definition
param.c:12
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
singleuse
actionattachwithswich.c
Generated by
1.17.0