DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
DayZPlayerImplementThrowing.c
Go to the documentation of this file.
2{
4 {
5 m_Player = pPlayer;
7
9 }
10
11 void HandleThrowing(HumanInputController pHic, HumanCommandWeapons pHcw, EntityAI pEntityInHands, float pDt)
12 {
13 if ( !pEntityInHands && !m_bThrowingAnimationPlaying )
14 {
16 {
18 pHcw.SetThrowingMode(false);
19 }
20
21 return;
22 }
23
26
29 {
30 ResetState();
31
32 pHcw.SetActionProgressParams(0, 0);
34 }
35
38 {
40
41 if ( !CanContinueThrowingEx(pHic, pEntityInHands) )
42 {
44 ResetState();
45
46 pHcw.SetActionProgressParams(0, 0);
47 pHcw.SetThrowingMode(false);
48
49 return;
50 }
51
53 if ( pHcw.WasItemLeaveHandsEvent() )
54 {
55 float lr = pHcw.GetBaseAimingAngleLR();
56 float ud = pHcw.GetBaseAimingAngleUD();
57 vector aimOrientation = m_Player.GetOrientation();
58 aimOrientation[0] = aimOrientation[0] + lr;
59
60 //add 5 deg
61 aimOrientation[1] = aimOrientation[1] + ud + 5;
62
63
64 m_Player.GetHumanInventory().ThrowEntity(pEntityInHands, aimOrientation.AnglesToVector(), c_fThrowingForceMin + m_fThrowingForce01 * (c_fThrowingForceMax - c_fThrowingForceMin));
65 return;
66 }
67
70 {
71 if ( pHic.IsAttackButton() )
72 {
75
77 if ( m_fThrowingForce01 > 1.0 )
79
81 }
82 else
83 {
85 {
87
88 int throwType = 1;
89
90 HumanItemBehaviorCfg itemCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
91 itemCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
92 if ( itemCfg )
93 {
94 switch ( itemCfg.m_iType )
95 {
96 case ItemBehaviorType.TWOHANDED:
97 case ItemBehaviorType.POLEARMS:
98 throwType = 2;
99 break;
100 case ItemBehaviorType.FIREARMS:
101 throwType = 3;
102 }
103 }
104
105 pHcw.ThrowItem(throwType);
107 }
108 }
109 }
110 }
111 else
112 {
113 ResetState();
114 }
115 }
116
118 {
120 m_bThrowingInProgress = false;
122 }
123
124 void SetThrowingModeEnabled(bool enable)
125 {
126 if (enable != m_bThrowingModeEnabled)
127 {
128 m_Player.OnThrowingModeChange(enable);
129 }
130 m_bThrowingModeEnabled = enable;
131 }
132
134 {
136 }
137
140 {
142 }
143
146 {
148 }
149
151 {
152 // don't change mode in raise
153 if( pHic.IsWeaponRaised() )
154 return false;
155
156 // check if it's not a heavy item
157 HumanItemBehaviorCfg itemCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
158 if( itemCfg && itemCfg.m_iType == ItemBehaviorType.HEAVY )
159 return false;
160
161/* HumanMovementState movementState = new HumanMovementState();
162 m_Player.GetMovementState(movementState);
163 if( movementState.IsInProne() )
164 return false;*/
165
166 PlayerBase playerPB = PlayerBase.Cast(m_Player);
167 if( playerPB )
168 {
169 if( playerPB.GetEmoteManager().IsEmotePlaying() )
170 return false;
171
172 if( playerPB.GetActionManager().GetRunningAction() != NULL )
173 return false;
174
175 if( playerPB.IsRestrained() || playerPB.IsItemsToDelete())
176 return false;
177
178 if( playerPB.GetDayZPlayerInventory().IsProcessing() )
179 return false;
180
181 if( playerPB.GetWeaponManager().IsRunning() )
182 return false;
183 }
184
185 return true;
186 }
187
189 {
190 HumanItemBehaviorCfg itemInHandsCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
191 bool boo = false;
192 UAInterface input_interface = m_Player.GetInputInterface();
193 if(input_interface && input_interface.SyncedPress("UAGear"))
194 {
195 boo = true;
196 }
197 if( boo || pHic.IsWeaponRaised() || (itemInHandsCfg && itemInHandsCfg.m_iType == ItemBehaviorType.HEAVY) )
198 {
199 return false;
200 }
201 return true;
202 }
203
205 {
206 if ( pEntityInHands == null )
207 return false;
208
209 return CanContinueThrowing(pHic);
210 }
211
216 private float m_fThrowingForce01;
217
218 private const float c_fThrowingForceMin = 20.0;
219 private const float c_fThrowingForceMax = 90.0;
220 private const float c_fThrowingForceCoef = 1.0;
221}
bool IsThrowingInProgress()
Throwing wind-up only (button hold)
void DayZPlayerImplementThrowing(DayZPlayer pPlayer)
bool IsThrowingAnimationPlaying()
Throwing animation after button release.
bool CanContinueThrowing(HumanInputController pHic)
void HandleThrowing(HumanInputController pHic, HumanCommandWeapons pHcw, EntityAI pEntityInHands, float pDt)
bool CanChangeThrowingStance(HumanInputController pHic)
bool CanContinueThrowingEx(HumanInputController pHic, EntityAI pEntityInHands)
proto native bool WasItemLeaveHandsEvent()
proto native void ThrowItem(int throwType)
proto native void SetActionProgressParams(float pStart, float pEnd)
sets start and end animation position - f.e. for reload clip action
proto native void SetThrowingMode(bool pState)
proto native bool IsThrowingMode()
proto native float GetBaseAimingAngleUD()
returns base aiming angle UD - without sway/offsets/...
proto native float GetBaseAimingAngleLR()
returns base aiming angle LR - without sway/offsets/...
proto native bool IsAttackButton()
returns true if 'UAFire' button is pressed (== true for multiple ticks). Synced.
proto native bool IsThrowingModeChange()
returns true if change of throwing mode has been requested
proto native bool IsWeaponRaised()
returns true if weapon is raised
proto native bool SyncedPress(string action, bool check_focus=true)
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.