DayZ 1.24
Loading...
Searching...
No Matches
ActionAttachWithSwich.c
Go to the documentation of this file.
1class ActionAttachWithSwitch: ActionAttach
2{
4 {
5 }
6
8 {
11 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ATTACHITEM;
12 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
13 }
14
15 override typename GetInputType()
16 {
18 }
19
21 {
22 return true;
23 }
24
30
32 {
34 if (!GetGame().IsDedicatedServer())
35 {
37
38 if (target.IsProxy())
39 target_entity = EntityAI.Cast(target.GetParent());
40 else
41 target_entity = EntityAI.Cast(target.GetObject());
42
43 if (!target_entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il))
44 return false;
45 }
46
47 if (super.SetupAction(player, target, item, action_data, extra_data))
48 {
49 if (!GetGame().IsDedicatedServer())
50 {
52 action_data_a.m_AttSlot = il.GetSlot();
53 }
54 return true;
55 }
56 return false;
57 }
58
59
60 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
61 {
62 EntityAI target_entity = EntityAI.Cast(target.GetObject());
63 if (!item.CanSwitchDuringAttach(target_entity))
64 return false;
65
66 if (target_entity && item)
67 {
68 if (target_entity.GetInventory() && target_entity.GetInventory().CanAddAttachment(item))
69 return true;
70 }
71 return false;
72 }
73
75 {
76 if (GetGame().IsMultiplayer())
77 return;
78
82
83 if (action_data.m_Target.IsProxy())
84 target_EAI = EntityAI.Cast(action_data_a.m_Target.GetParent());
85 else
86 target_EAI = EntityAI.Cast(action_data_a.m_Target.GetObject());
87
88 if (target_EAI && action_data_a.m_MainItem)
89 {
91 il.SetAttachment(target_EAI, action_data.m_MainItem, action_data_a.m_AttSlot);
92 action_data.m_Player.PredictiveForceSwapEntities(target_EAI, action_data.m_MainItem, il);
93 }
94 }
95
97 {
100
102
103 if (action_data.m_Target.IsProxy())
104 target_EAI = EntityAI.Cast(action_data_a.m_Target.GetParent());
105 else
106 target_EAI = EntityAI.Cast(action_data_a.m_Target.GetObject());
107
108 if (target_EAI && action_data_a.m_MainItem)
109 {
111 il.SetAttachment(target_EAI, action_data.m_MainItem, action_data_a.m_AttSlot);
112 action_data.m_Player.PredictiveForceSwapEntities(target_EAI, action_data.m_MainItem, il);
113 }
114 }
115}
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
int m_StanceMask
Definition ActionBase.c:53
FindInventoryLocationType
flags for searching locations in inventory
override void OnExecuteClient(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool CanBePerformedFromInventory()
override void CreateConditionComponents()
override void OnExecuteServer(ActionData action_data)
override ActionData CreateActionData()
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
InventoryLocation.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()