Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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 {
17 CancelThrowing(pHic, pHcw);
18 }
19
20 return;
21 }
22
25
28 {
29 ResetState();
30
31 pHcw.SetActionProgressParams(0, 0);
33 }
34
37 {
39
40 if ( !CanContinueThrowingEx(pHic, pEntityInHands) )
41 {
42 CancelThrowing(pHic, pHcw);
43 return;
44 }
45
47 if ( pHcw.WasItemLeaveHandsEvent() )
48 {
49 float lr = pHcw.GetBaseAimingAngleLR();
50 float ud = pHcw.GetBaseAimingAngleUD();
51 vector aimOrientation = m_Player.GetOrientation();
52 aimOrientation[0] = aimOrientation[0] + lr;
53
54 //add 5 deg
55 aimOrientation[1] = aimOrientation[1] + ud + 5;
56
57 //clear inventoy reservation in case item is reserved (e.g. action was executed on this player)
59 pEntityInHands.GetInventory().GetCurrentInventoryLocation(loc);
60 m_Player.GetInventory().ClearInventoryReservationEx(pEntityInHands, loc);
61
62 m_Player.GetHumanInventory().ThrowEntity(pEntityInHands, aimOrientation.AnglesToVector(), c_fThrowingForceMin + m_fThrowingForce01 * (c_fThrowingForceMax - c_fThrowingForceMin));
63 return;
64 }
65
68 {
69 if ( pHic.IsAttackButton() )
70 {
73
75 if ( m_fThrowingForce01 > 1.0 )
77
79 }
80 else
81 {
82 HumanCommandMove hcm = m_Player.GetCommand_Move();
83 bool standingFromBack = hcm && hcm.IsStandingFromBack();
84
86 if (m_bThrowingInProgress && standingFromBack)
87 {
88 CancelThrowing(pHic, pHcw);
89 return;
90 }
91
93 {
95
96 int throwType = 1;
97
98 HumanItemBehaviorCfg itemCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
99 itemCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
100 if ( itemCfg )
101 {
102 switch ( itemCfg.m_iType )
103 {
104 case ItemBehaviorType.TWOHANDED:
105 case ItemBehaviorType.POLEARMS:
106 throwType = 2;
107 break;
108 case ItemBehaviorType.FIREARMS:
109 throwType = 3;
110 }
111 }
112
113 pHcw.ThrowItem(throwType);
115 }
116 }
117 }
118 }
119 else
120 {
121 ResetState();
122 }
123 }
124
126 {
128 ResetState();
129
130 if (pHcw)
131 {
132 pHcw.SetActionProgressParams(0, 0);
133 pHcw.SetThrowingMode(false);
134 }
135
136 if (pHic)
137 {
138 pHic.ResetThrowingMode();
139 }
140 }
141
143 {
145 m_bThrowingInProgress = false;
147 }
148
149 void SetThrowingModeEnabled(bool enable)
150 {
151 if (enable != m_bThrowingModeEnabled)
152 {
153 m_Player.OnThrowingModeChange(enable);
154 }
155 m_bThrowingModeEnabled = enable;
156 }
157
159 {
161 }
162
165 {
167 }
168
174
176 {
177 // basic stance has priority
178 if( pHic.IsStanceChange() )
179 return false;
180
181 // don't change mode in raise
182 if( pHic.IsWeaponRaised() )
183 return false;
184
185 // check if it's not a heavy item
186 HumanItemBehaviorCfg itemCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
187 if( itemCfg && itemCfg.m_iType == ItemBehaviorType.HEAVY )
188 return false;
189
190/* HumanMovementState movementState = new HumanMovementState();
191 m_Player.GetMovementState(movementState);
192 if( movementState.IsInProne() )
193 return false;*/
194
195 PlayerBase playerPB = PlayerBase.Cast(m_Player);
196 if( playerPB )
197 {
198 if( playerPB.GetEmoteManager().IsEmotePlaying() )
199 return false;
200
201 if( playerPB.GetActionManager().GetRunningAction() != NULL )
202 return false;
203
204 if( playerPB.IsRestrained() || playerPB.IsItemsToDelete())
205 return false;
206
207 if( playerPB.GetDayZPlayerInventory().IsProcessing() )
208 return false;
209
210 if( playerPB.GetWeaponManager().IsRunning() )
211 return false;
212 }
213
214 if (!CheckFreeSpace() )
215 return false;
216
217 return true;
218 }
219
221 {
222 HumanItemBehaviorCfg itemInHandsCfg = m_Player.GetItemAccessor().GetItemInHandsBehaviourCfg();
223 HumanCommandMove hcm = m_Player.GetCommand_Move();
224 bool boo = false;
225 UAInterface input_interface = m_Player.GetInputInterface();
226 if(input_interface && input_interface.SyncedPress("UAGear"))
227 {
228 boo = true;
229 }
230
231 if( boo || pHic.IsWeaponRaised() || (m_bThrowingInProgress && hcm && (hcm.IsChangingStance() || hcm.IsStandingFromBack())) || (itemInHandsCfg && itemInHandsCfg.m_iType == ItemBehaviorType.HEAVY) )
232 {
233 return false;
234 }
235
236 if (!CheckFreeSpace() )
237 return false;
238
239 return true;
240 }
241
243 {
244 if ( pEntityInHands == null )
245 return false;
246
247 return CanContinueThrowing(pHic);
248 }
249
251 {
252 return m_Player.CheckFreeSpace(vector.Forward, 0.7, false);
253 }
254
259 private float m_fThrowingForce01;
260
261 private const float c_fThrowingForceMin = 20.0;
262 private const float c_fThrowingForceMax = 90.0;
263 private const float c_fThrowingForceCoef = 1.0;
264}
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)
void CancelThrowing(HumanInputController pHic, HumanCommandWeapons pHcw)
proto native bool IsStandingFromBack()
return true if prone on back is chaning to crounch/stand
proto native bool IsChangingStance()
returns true if character is changing stance
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 IsStanceChange()
stance change button was pressed
proto native bool IsAttackButton()
returns true if 'UAFire' button is pressed (== true for multiple ticks). Synced.
proto native void ResetThrowingMode()
resets Throwing mode
proto native bool IsThrowingModeChange()
returns true if change of throwing mode has been requested
proto native bool IsWeaponRaised()
returns true if weapon is raised
InventoryLocation.
proto native bool SyncedPress(string action, bool check_focus=true)
static const vector Forward
Definition enconvert.c:122
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.