Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actionplugin.c
Go to the documentation of this file.
1
class
ActionPlugIn
:
ActionSingleUseBase
2
{
3
void
ActionPlugIn
()
4
{
5
m_CommandUID
=
DayZPlayerConstants
.CMD_ACTIONMOD_INTERACTONCE;
6
m_Text
=
"#plug_in"
;
7
}
8
9
override
void
CreateConditionComponents
()
10
{
11
m_ConditionItem
=
new
CCINonRuined
();
12
m_ConditionTarget
=
new
CCTNonRuined
(
UAMaxDistances
.
DEFAULT
);
13
}
14
15
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item)
16
{
17
if
(player.IsPlacingLocal())
18
return
false
;
19
20
ItemBase
targetIB =
ItemBase
.Cast(target.GetObject());
21
22
//Prevent plugging to items in inventory
23
if
(targetIB && targetIB.GetHierarchyRoot() == targetIB && item)
24
{
25
if
(item.HasEnergyManager() && !item.GetCompEM().IsPlugged() && targetIB.HasEnergyManager() && targetIB.GetCompEM().CanReceivePlugFrom(item))
26
{
27
return
true
;
28
}
29
30
ItemBase
attachedDevice =
GetAttachedDevice
(targetIB);
31
//Will only ever affect batteries
32
if
(attachedDevice)
33
{
34
return
attachedDevice.GetCompEM().HasFreeSocket();
35
}
36
}
37
38
return
false
;
39
}
40
41
override
void
OnExecuteServer
(
ActionData
action_data)
42
{
43
ItemBase
targetIB =
ItemBase
.Cast(action_data.m_Target.GetObject());
44
45
if
(targetIB.HasEnergyManager())
46
{
47
ItemBase
attachedDevice =
GetAttachedDevice
(targetIB);
48
if
(attachedDevice)
49
targetIB = attachedDevice;
50
51
action_data.m_MainItem.GetCompEM().PlugThisInto(targetIB);
52
53
if
(!
g_Game
.IsDedicatedServer())
54
{
55
if
(!action_data.m_Player.IsPlacingLocal())
56
{
57
action_data.m_Player.PlacingStartLocal(action_data.m_MainItem);
58
Process
(action_data);
59
}
60
}
61
else
62
{
63
if
(!action_data.m_Player.IsPlacingServer())
64
{
65
action_data.m_Player.PlacingStartServer(action_data.m_MainItem);
66
Process
(action_data);
67
}
68
}
69
}
70
}
71
72
void
Process
(
ActionData
action_data)
73
{
74
ItemBase
targetIB =
ItemBase
.Cast(action_data.m_Target.GetObject());
75
76
targetIB.GetInventory().TakeEntityAsAttachment(
InventoryMode
.LOCAL, action_data.m_MainItem);
77
}
78
79
override
void
OnExecuteClient
(
ActionData
action_data)
80
{
81
if
(!action_data.m_Player.IsPlacingLocal())
82
action_data.m_Player.PlacingStartLocal(action_data.m_MainItem);
83
else
84
Process
(action_data);
85
}
86
87
ItemBase
GetAttachedDevice
(
ItemBase
parent)
88
{
89
if
(parent.IsInherited(
CarBattery
) || parent.IsInherited(
TruckBattery
))
90
{
91
ItemBase
parentAttachment =
ItemBase
.Cast(parent.GetAttachmentByType(MetalWire));
92
if
(!parentAttachment)
93
parentAttachment =
ItemBase
.Cast(parent.GetAttachmentByType(BarbedWire));
94
95
return
parentAttachment;
96
}
97
98
return
null;
99
}
100
};
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition
inventory.c:22
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
ActionPlugIn::GetAttachedDevice
ItemBase GetAttachedDevice(ItemBase parent)
Definition
actionplugin.c:87
ActionPlugIn::OnExecuteServer
override void OnExecuteServer(ActionData action_data)
Definition
actionplugin.c:41
ActionPlugIn::CreateConditionComponents
override void CreateConditionComponents()
Definition
actionplugin.c:9
ActionPlugIn::OnExecuteClient
override void OnExecuteClient(ActionData action_data)
Definition
actionplugin.c:79
ActionPlugIn::ActionPlugIn
void ActionPlugIn()
Definition
actionplugin.c:3
ActionPlugIn::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionplugin.c:15
ActionPlugIn::Process
void Process(ActionData action_data)
Definition
actionplugin.c:72
ActionSingleUseBase::ActionSingleUseBase
void ActionSingleUseBase()
Definition
actionsingleusebase.c:31
AnimatedActionBase::m_CommandUID
int m_CommandUID
Definition
animatedactionbase.c:143
CCINonRuined
Definition
ccinonruined.c:2
CCTNonRuined
Definition
cctnonruined.c:2
CarBattery
Definition
carbattery.c:2
ItemBase
Definition
inventoryitem.c:742
PlayerBase
Definition
playerbaseclient.c:2
TruckBattery
Definition
truckbattery.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
Process
void Process()
Definition
effectmanager.c:743
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
singleuse
actionplugin.c
Generated by
1.17.0