DayZ 1.24
Loading...
Searching...
No Matches
ActionTakeHybridAttachmentToHands.c
Go to the documentation of this file.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
6 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HANDS;
7 m_Text = "#take_to_hands";
8 }
9
15
16 override bool HasProneException()
17 {
18 return true;
19 }
20
21 override typename GetInputType()
22 {
24 }
25
26 override bool HasProgress()
27 {
28 return false;
29 }
30
31 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
32 {
33 EntityAI tgt_entity = EntityAI.Cast(target.GetObject());
34
35 if (tgt_entity && BaseBuildingBase.Cast(tgt_entity) && !tgt_entity.IsBeingPlaced() /*&& BaseBuildingBase.Cast(tgt_entity).IsPlayerInside(player,"")*/)
36 {
37 string component_name = tgt_entity.GetActionComponentName(target.GetComponentIndex());
38
39 ItemBase attachment = ItemBase.Cast(tgt_entity.FindAttachmentBySlotName(component_name));
40
41 if (attachment && player.GetInventory().CanAddEntityIntoHands(attachment) && attachment.IsTakeable())
42 return true;
43 }
44 return false;
45 }
46
48 {
49 return true;
50 }
51
56
58 {
59 EntityAI tgt_entity = EntityAI.Cast(action_data.m_Target.GetObject());
60 string component_name = tgt_entity.GetActionComponentName(action_data.m_Target.GetComponentIndex());
62
63 if (tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)))
64 {
66 float stackable = attachment.GetTargetQuantityMax(-1);
67
68 if (stackable == 0 || stackable >= attachment.GetQuantity())
69 {
70 //take to hands
71 action_data.m_Player.PredictiveTakeEntityToHands(attachment);
72 }
73 else if (stackable != 0 && stackable < attachment.GetQuantity())
74 {
75 //split and take to hands
76 attachment.SplitIntoStackMaxHandsClient(action_data.m_Player);
77 }
78 }
79 }
80
82 {
83 if (GetGame().IsMultiplayer())
84 return; // multiplayer handled on client side via OnExecuteClient
85 else
86 OnExecuteImpl(action_data); // single player
87 }
88
90 {
91 EntityAI tgt_entity = EntityAI.Cast(action_data.m_Target.GetObject());
92 string component_name = tgt_entity.GetActionComponentName(action_data.m_Target.GetComponentIndex());
94 bool heavy_item = false;
95
96 if (tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)))
97 {
99 if (attachment && attachment.ConfigIsExisting("heavyItem") && attachment.ConfigGetBool("heavyItem"))
100 heavy_item = true;
101 }
102
103 if (heavy_item)
104 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HEAVY, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_ERECT));
105 else
106 {
107 if (action_data.m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT))
108 Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS, GetCallbackClassTypename()));
109 else
110 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HANDS, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_PRONE));
111 }
112 callback.SetActionData(action_data);
113 callback.InitActionComponent();
114 action_data.m_Callback = callback;
115 }
116}
string m_Text
Definition ActionBase.c:49
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
override void CreateAndSetupActionCallback(ActionData action_data)
override bool CanContinue(ActionData action_data)
override void OnExecuteServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override 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.