DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
DayZPlayerImplementJumpClimb.c
Go to the documentation of this file.
2{
4 {
5 m_Player = pPlayer;
6 }
7
9 {
10 SHumanCommandClimbSettings hcls = m_Player.GetDayZPlayerType().CommandClimbSettingsW();
11
12 if ( m_Player.m_MovementState.m_iMovement != DayZPlayerConstants.MOVEMENTIDX_IDLE )
13 hcls.m_fFwMaxDistance = 2.5;
14 else
15 hcls.m_fFwMaxDistance = 1.2;
16
17 SHumanCommandClimbResult climbRes = new SHumanCommandClimbResult();
18
20 if ( climbRes.m_bIsClimb || climbRes.m_bIsClimbOver )
21 {
22 int climbType = GetClimbType(climbRes.m_fClimbHeight);
23
24 if ( !m_Player.CanClimb( climbType,climbRes ) )
25 return;
26
27 if ( Climb(climbRes) )
28 {
29 if ( climbType == 1 )
30 m_Player.DepleteStamina(EStaminaModifiers.VAULT);
31 else if ( climbType == 2 )
32 m_Player.DepleteStamina(EStaminaModifiers.CLIMB);
33
34 return;
35 }
36 }
37
38 if ( !m_Player.CanJump() )
39 return;
40
41 Jump();
42 m_Player.DepleteStamina(EStaminaModifiers.JUMP);
43 }
44
45 void CheckAndFinishJump(int pLandType = 0)
46 {
48 {
49 m_bIsJumpInProgress = false;
50 m_Player.OnJumpEnd(pLandType);
51 }
52 }
53
54 private bool Climb(SHumanCommandClimbResult pClimbRes)
55 {
56 int climbType = GetClimbType(pClimbRes.m_fClimbHeight);
57 if( climbType != -1 )
58 {
59 m_Player.StartCommand_Climb(pClimbRes, climbType);
60 m_Player.StopHandEvent();
61 }
62
63 return climbType != -1;
64 }
65
66 private void Jump()
67 {
69 m_Player.SetFallYDiff(m_Player.GetPosition()[1]);
70
71 m_Player.OnJumpStart();
72 m_Player.StartCommand_Fall(2.6);
73 m_Player.StopHandEvent();
74 }
75
76 private int GetClimbType(float pHeight)
77 {
78 int climbType = -1;
79 if( pHeight < 1.1 )
80 climbType = 0;
81 else if( pHeight >= 1.1 && pHeight < 1.7 )
82 climbType = 1;
83 else if( pHeight >= 1.7 && pHeight < 2.75 )
84 climbType = 2;
85
86 return climbType;
87 }
88
89 // Public variable members
90 bool m_bIsJumpInProgress = false;
91
92 // Private variable members
94}
EStaminaModifiers
private bool Climb(SHumanCommandClimbResult pClimbRes)
void DayZPlayerImplementJumpClimb(DayZPlayerImplement pPlayer)
private int GetClimbType(float pHeight)
command itself
Definition human.c:761
proto static native bool DoClimbTest(Human pHuman, SHumanCommandClimbResult pResult, int pDebugDrawLevel)
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
class SHumanCommandSwimSettings SHumanCommandClimbSettings()