DayZ 1.24
Loading...
Searching...
No Matches
ActionDetach.c
Go to the documentation of this file.
5
7{
8 string m_ItemName = "";
9
11 {
12 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
13 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HANDS;
14 m_Text = "#take_to_hands";
15 }
16
22
23 override bool HasProneException()
24 {
25 return true;
26 }
27
28 override typename GetInputType()
29 {
31 }
32
33 override bool HasProgress()
34 {
35 return false;
36 }
37
38 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
39 {
40 ItemBase tgt_item = ItemBase.Cast(target.GetObject());
41 EntityAI tgt_parent = EntityAI.Cast(target.GetParent());
42 EntityAI tgt_entity = EntityAI.Cast(target.GetObject());
43
44 if (!tgt_item || !tgt_entity || !tgt_parent)
45 return false;
46
47 if (!tgt_parent || !tgt_item.IsItemBase() || !tgt_item.IsTakeable() || tgt_item.IsBeingPlaced())
48 return false;
49
50 if (player.GetCommand_Vehicle())
51 return false;
52
53 if (player.GetInventory().CanAddEntityIntoHands(tgt_entity)) //&& !player.GetInventory().CanAddEntityIntoInventory(tgt_entity) )
54 {
55 if (tgt_entity.GetHierarchyRootPlayer() != player)
56 {
57 if (tgt_entity.CanDetachAttachment(tgt_parent) && tgt_parent.CanReleaseAttachment(tgt_entity))
58 return true;
59 }
60 }
61
62 return false;
63 }
64
66 {
67 if (GetGame().IsMultiplayer())
68 return;
69
70 ActionManagerClient am = ActionManagerClient.Cast(action_data.m_Player.GetActionManager());
71 am.UnlockInventory(action_data);
72
73 EntityAI ntarget = EntityAI.Cast(action_data.m_Target.GetObject());
74 action_data.m_Player.PredictiveTakeEntityToHands(ntarget);
75
76 }
77
79 {
80 ActionManagerClient am = ActionManagerClient.Cast(action_data.m_Player.GetActionManager());
81 am.UnlockInventory(action_data);
82
83 EntityAI ntarget = EntityAI.Cast(action_data.m_Target.GetObject());
84 action_data.m_Player.PredictiveTakeEntityToHands(ntarget);
85 }
86
88 {
89 EntityAI target = EntityAI.Cast(action_data.m_Target.GetObject());
91 if (!target)
92 return;
93
94 if (target.IsHeavyBehaviour())
95 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HEAVY, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_ERECT));
96 else
97 {
98 if (action_data.m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT))
99 Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS, GetCallbackClassTypename()));
100 else
101 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HANDS, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_PRONE));
102 }
103 callback.SetActionData(action_data);
104 callback.InitActionComponent();
105 action_data.m_Callback = callback;
106 }
107};
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
bool HasProgress()
For UI: hiding of progress bar.
Definition ActionBase.c:216
void ActionDetach()
DetachActionData m_ItemName
override void CreateConditionComponents()
void CreateAndSetupActionCallback(ActionData action_data)
override bool HasProneException()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
void OnExecuteServer(ActionData action_data)
void OnExecuteClient(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.