DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
InventoryActionHandler.c
Go to the documentation of this file.
1
3{
8
10
13
14 const float MIN_DISTANCE_TO_INTERRUPT = 1.0;
15 const int IAH_SINGLE_USE = 1;
16 const int IAH_CONTINUOUS = 2;
17
18
20 {
21 m_player = player;
22 m_isActive = false;
23 m_action = null;
24 m_target = null;
25 m_mainItem = null;
26 m_useItemInHands = false;
27
28 }
29
30 void SetAction(ActionBase action, ItemBase target_item, ItemBase main_item )
31 {
32 Object target_parent = null;
33 if(target_item)
34 {
35 target_parent = target_item.GetHierarchyParent();
36 }
37 ActionTarget at = new ActionTarget(target_item, target_parent, -1, vector.Zero, -1);
38
39 SetAction(action, at, main_item );
40 }
41
42 void SetAction(ActionBase action, ActionTarget target, ItemBase main_item )
43 {
45 Class.CastTo(mngr, m_player.GetActionManager());
46
47 m_action = action;
48 m_target = target;
49 m_mainItem = main_item;
50
51 ItemBase itemInHand = m_player.GetItemInHands();
52 m_useItemInHands = main_item == itemInHand;
53
54 m_actionStartPos = m_player.GetPosition();
55 m_isActive = true;
56
57 //mngr.InjectAction( action, target, main_item );
58 mngr.ForceTarget(m_target.GetObject());
59
61 }
62
64 {
65 return m_isActive;
66 }
67
68 void OnUpdate()
69 {
70
71 if( !m_isActive ) return;
72
73 if( m_player.IsRaised() || m_player.GetCommand_Melee() )
74 {
76 return;
77 }
78
79 if( GetGame().IsInventoryOpen() )
80 {
82 return;
83 }
84
86 {
87 ItemBase handItem = m_player.GetItemInHands();
88
89 if( handItem != m_mainItem )
90 {
92 return;
93 }
94 }
95
97 {
99 return;
100 }
101
102
103 }
104
106 {
107 if( !m_isActive ) return;
108
109 m_isActive = false;
110
112 Class.CastTo(mngr, m_player.GetActionManager());
113
114 mngr.EjectAction(m_action);
115 mngr.ClearForceTarget();
116
117 m_player.GetCraftingManager().ResetInventoryCraft();
118
119 m_action = null;
120 m_target = null;
121 m_mainItem = null;
122 m_useItemInHands = false;
123 }
124}
void ActionBase()
Definition ActionBase.c:73
class ActionTargets ActionTarget
void EjectAction(ActionBase action)
void ForceTarget(Object targetObject)
proto native Mission GetMission()
Super root of all classes in Enforce script.
Definition EnScript.c:11
Client only - manage set up crafting on client.
void SetAction(ActionBase action, ItemBase target_item, ItemBase main_item)
void InventoryActionHandler(PlayerBase player)
void SetAction(ActionBase action, ActionTarget target, ItemBase main_item)
Definition EnMath.c:7
void HideInventory()
Definition gameplay.c:779
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float AbsFloat(float f)
Returns absolute value.