Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionunrestraintargetempty.c
Go to the documentation of this file.
2 {
3  const float DEFAULT_STRUGGLE_TIME = 2;
4  const float UNRESTRAIN_STRUGGLE_MULTIPLIER = 0.75;//multiplier for the struggle time normally used for the player unrestraining themselves, this allows unrestraining to be bound to the 'StruggleLength' config param
5 
6  override void CreateActionComponent()
7  {
8  float time = DEFAULT_STRUGGLE_TIME;
9  PlayerBase targetPlayer = PlayerBase.Cast(m_ActionData.m_Target.GetObject());
10  EntityAI item_in_hands = targetPlayer.GetItemInHands();
11 
12  if ( item_in_hands.ConfigIsExisting("StruggleLength") )
13  {
14  time = item_in_hands.ConfigGetFloat("StruggleLength") * UNRESTRAIN_STRUGGLE_MULTIPLIER;
15  }
16  #ifdef DEVELOPER
17  if ( m_ActionData.m_Player.IsQuickRestrain() )
18  {
20  }
21  #endif
22 
23  m_ActionData.m_ActionComponent = new CAContinuousTime(time);
24  }
25 };
26 
28 {
30  {
31  m_CallbackClass = ActionUnrestrainTargetHandsCB;
32  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_RESTRAINTARGET;
33  m_FullBody = true;
34  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
35  m_Text = "#unrestrain";
36  }
37 
38  override typename GetInputType()
39  {
41  }
42 
43 
44 
45  override void OnStartServer(ActionData action_data)
46  {
47  action_data.m_Player.TryHideItemInHands(true);
48  }
49 
50  override void OnEndServer(ActionData action_data)
51  {
52  action_data.m_Player.TryHideItemInHands(false);
53  }
54 
55  override void CreateConditionComponents()
56  {
59  }
60 
61  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
62  {
63  PlayerBase targetPlayer = PlayerBase.Cast(target.GetObject());
64  return targetPlayer && targetPlayer.IsRestrained();
65  }
66 
67  override void OnFinishProgressServer( ActionData action_data )
68  {
69  PlayerBase targetPlayer = PlayerBase.Cast(action_data.m_Target.GetObject());
70 
71  if (CanReceiveAction(action_data.m_Target) && targetPlayer.IsRestrained())
72  {
73  EntityAI item_in_hands = targetPlayer.GetItemInHands();
74  targetPlayer.SetRestrained(false);
75  if (item_in_hands)
76  {
77  MiscGameplayFunctions.TransformRestrainItem(item_in_hands, null, action_data.m_Player, targetPlayer);
78  }
79  else
80  {
81  ErrorEx("Failed to obtain item in target player's hands during empty handed unrestraining");
82  }
83  }
84  }
85 
86  override void OnStartClient(ActionData action_data)
87  {
88  action_data.m_Player.TryHideItemInHands(true);
89  }
90 
91  override void OnEndClient( ActionData action_data )
92  {
93  if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(false);
94  }
95 
96 };
ItemBase
Definition: inventoryitem.c:730
CAContinuousTime
Definition: cacontinuoustime.c:1
ContinuousInteractActionInput
Definition: actioninput.c:521
CCINone
Definition: ccinone.c:1
CCTObject
Definition: cctobject.c:1
ActionUnrestrainTargetHands
Definition: actionunrestraintargetempty.c:27
UAMaxDistances
Definition: actionconstants.c:104
ErrorEx
enum ShapeType ErrorEx
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
ActionUnrestrainTargetHandsCB
Definition: actionunrestraintargetempty.c:1
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
DEBUG_QUICK_UNRESTRAIN_TIME
const float DEBUG_QUICK_UNRESTRAIN_TIME
Definition: constants.c:599
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5
CanReceiveAction
bool CanReceiveAction(ActionTarget target)
Definition: actionbase.c:638