DayZ 1.24
Loading...
Searching...
No Matches
ActionAttach.c
Go to the documentation of this file.
2{
4}
5
6
7class ActionAttach : ActionSingleUseBase
8{
9 void ActionAttach()
10 {
11 m_Text = "#attach";
12 }
13
15 {
18 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ATTACHITEM;
19 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
20 }
21
27
29 {
31 if (!GetGame().IsDedicatedServer())
32 {
34 if (target.IsProxy())
35 targetEntity = EntityAI.Cast(target.GetParent());
36 else
37 targetEntity = EntityAI.Cast(target.GetObject());
38
39 if (!targetEntity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il))
40 return false;
41 }
42
43 if (super.SetupAction(player, target, item, action_data, extra_data))
44 {
45#ifndef SERVER
47 action_data_a.m_AttSlot = il.GetSlot();
48#endif
49
50 return true;
51 }
52
53 return false;
54 }
55
56
57 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
58 {
59 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
60 if (targetEntity && item)
61 return targetEntity.GetInventory() && targetEntity.GetInventory().CanAddAttachment(item) && !targetEntity.CanUseConstruction());
62
63 return false;
64 }
65
75
83
85 {
87 if (action_data.m_Target.IsProxy())
88 entity = EntityAI.Cast(action_data.m_Target.GetParent());
89 else
90 entity = EntityAI.Cast(action_data.m_Target.GetObject());
91
92 if (entity && action_data.m_MainItem)
93 action_data.m_Player.PredictiveTakeEntityToTargetAttachmentEx(entity, action_data.m_MainItem, action_data.m_AttSlot);
94 }
95
96 override bool CanBeSetFromInventory()
97 {
98 return false;
99 }
100}
AttachActionData ActionData ActionAttach()
Definition ActionAttach.c:9
void AttachItem(ActionData action_data)
ActionData CreateActionData()
Definition ActionBase.c:191
string m_Text
Definition ActionBase.c:49
bool CanBeSetFromInventory()
Definition ActionBase.c:279
void CreateConditionComponents()
Definition ActionBase.c:196
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition ActionBase.c:126
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition ActionBase.c:350
int m_StanceMask
Definition ActionBase.c:53
override void OnExecuteServer(ActionData action_data)
override void OnExecuteClient(ActionData action_data)
FindInventoryLocationType
flags for searching locations in inventory
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()