DayZ 1.24
Loading...
Searching...
No Matches
ActionTakeMaterialToHands.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";
8 }
9
15
16 override bool HasProneException()
17 {
18 return true;
19 }
20
22 {
23 ConstructionActionData construction_action_data = player.GetConstructionActionData();
24 EntityAI attachment = construction_action_data.GetActualAttachmentToDetach();
25
26 if (attachment)
27 m_Text = "#take " + attachment.GetDisplayName();
28 }
29
30 override typename GetInputType()
31 {
33 }
34
35 override bool HasProgress()
36 {
37 return false;
38 }
39
40 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
41 {
42 EntityAI target_entity = EntityAI.Cast(target.GetObject());
43 if (target_entity && target_entity.CanUseConstruction())
44 {
46 if (!base_building.IsPlayerInside(player, ""))
47 return false;
48
49 ConstructionActionData construction_action_data = player.GetConstructionActionData();
50 string main_part_name = target_entity.GetActionComponentName(target.GetComponentIndex());
51 //Print(main_part_name);
52
53 if (GetGame().IsMultiplayer() || GetGame().IsServer())
54 construction_action_data.RefreshAttachmentsToDetach(target_entity, main_part_name);
55 EntityAI attachment = construction_action_data.GetActualAttachmentToDetach();
56
57 if (attachment && player.GetInventory().CanAddEntityIntoHands(attachment) && attachment.GetHierarchyRootPlayer() != player)
58 return true;
59 }
60
61 return false;
62 }
63
65 {
66 return true;
67 }
68
73
75 {
76 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
77 ItemBase item_target = ItemBase.Cast(construction_action_data.GetActualAttachmentToDetach());
78 if (item_target)
79 {
80 float stackable = item_target.GetTargetQuantityMax();
81
82 if (stackable == 0 || stackable >= item_target.GetQuantity())
83 {
84 //take to hands
85 action_data.m_Player.PredictiveTakeEntityToHands(item_target);
86 }
87 else if (stackable != 0 && stackable < item_target.GetQuantity())
88 {
89 //split and take to hands
90 item_target.SplitIntoStackMaxHandsClient(action_data.m_Player);
91 }
92 }
93 }
94
96 {
97 if (GetGame().IsMultiplayer())
98 return; // multiplayer handled on client side via OnExecuteClient
99 else
100 OnExecuteImpl(action_data); // single player
101 }
102
104 {
105 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
106 EntityAI target = construction_action_data.GetActualAttachmentToDetach();
107
108 bool heavy_item = false;
110 if (target && target.ConfigIsExisting("heavyItem") && target.ConfigGetBool("heavyItem"))
111 heavy_item = true;
112
113 if (heavy_item)
114 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HEAVY, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_ERECT));
115 else
116 {
117 if (action_data.m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT))
118 Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS, GetCallbackClassTypename()));
119 else
120 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HANDS, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_PRONE));
121 }
122 callback.SetActionData(action_data);
123 callback.InitActionComponent();
124 action_data.m_Callback = callback;
125 }
126}
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
void OnExecuteImpl(ActionData action_data)
override bool CanContinue(ActionData action_data)
override void OnExecuteClient(ActionData action_data)
override void CreateAndSetupActionCallback(ActionData action_data)
override void OnExecuteServer(ActionData action_data)
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
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.