Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
10  override void CreateConditionComponents()
11  {
14  }
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  {
43  return true;
44  }
45  }
46  return false;
47  }
48 
49  override bool CanContinue( ActionData action_data )
50  {
51  return true;
52  }
53 
54  override void OnExecuteClient( ActionData action_data )
55  {
56  OnExecuteImpl(action_data);
57  }
58 
59  protected void OnExecuteImpl( ActionData action_data )
60  {
61  EntityAI tgt_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
62  string component_name = tgt_entity.GetActionComponentName( action_data.m_Target.GetComponentIndex() );
63  ItemBase attachment;
64 
65  if ( tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)) )
66  {
67  ClearInventoryReservationEx(action_data);
68  float stackable = attachment.GetTargetQuantityMax(-1);
69 
70  if( stackable == 0 || stackable >= attachment.GetQuantity() )
71  {
72  //take to hands
73  action_data.m_Player.PredictiveTakeEntityToHands( attachment );
74  }
75  else if( stackable != 0 && stackable < attachment.GetQuantity() )
76  {
77  //split and take to hands
78  attachment.SplitIntoStackMaxHandsClient( action_data.m_Player );
79  }
80  }
81  }
82 
83  override void OnExecuteServer( ActionData action_data )
84  {
85  if (GetGame().IsMultiplayer())
86  return; // multiplayer handled on client side via OnExecuteClient
87  else
88  OnExecuteImpl(action_data); // single player
89  }
90 
91  override void CreateAndSetupActionCallback( ActionData action_data )
92  {
93  EntityAI tgt_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
94  string component_name = tgt_entity.GetActionComponentName( action_data.m_Target.GetComponentIndex() );
95  ItemBase attachment;
96  bool heavy_item = false;
97 
98  if ( tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)) )
99  {
100  ActionBaseCB callback;
101  if ( attachment && attachment.ConfigIsExisting("heavyItem") && attachment.ConfigGetBool("heavyItem") )
102  {
103  heavy_item = true;
104  }
105  }
106 
107  if( heavy_item )
108  {
109  Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HEAVY,GetCallbackClassTypename(),DayZPlayerConstants.STANCEMASK_ERECT));
110  }
111  else
112  {
113  if( action_data.m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT) )
114  {
115  Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS,GetCallbackClassTypename()));
116  }
117  else
118  {
119  Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HANDS,GetCallbackClassTypename(),DayZPlayerConstants.STANCEMASK_PRONE));
120  }
121  }
122  callback.SetActionData(action_data);
123  callback.InitActionComponent();
124  action_data.m_Callback = callback;
125  }
126 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
CCINotPresent
Definition: ccinotpresent.c:1
ContinuousInteractActionInput
Definition: actioninput.c:521
ClearInventoryReservationEx
void ClearInventoryReservationEx(ActionData action_data)
Definition: actionbase.c:862
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
BaseBuildingBase
Definition: fence.c:1
CCTCursor
Definition: cctcursor.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
ActionBaseCB
Definition: animatedactionbase.c:1
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
EntityAI
Definition: building.c:5
ActionTakeHybridAttachmentToHands
Definition: actiontakehybridattachmenttohands.c:1