Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
dayzplayerimplementjumpclimb.c
Go to the documentation of this file.
1class DayZPlayerImplementJumpClimb
2{
3 bool m_bIsJumpInProgress;
4
5 private DayZPlayerImplement m_Player;
6 private bool m_bWasClimb;
7
8 void DayZPlayerImplementJumpClimb(DayZPlayerImplement pPlayer)
9 {
10 m_Player = pPlayer;
11 }
12
14 bool WasSuccessful()
15 {
16 return m_bIsJumpInProgress || m_bWasClimb;
17 }
18
20 void JumpOrClimb()
21 {
23 m_bWasClimb = false;
24
26 if (m_Player.IsInFullbodyDamageAnimation())
27 return;
28
29 SHumanCommandClimbSettings hcls = m_Player.GetDayZPlayerType().CommandClimbSettingsW();
30
31 if (m_Player.m_MovementState.m_iMovement != DayZPlayerConstants.MOVEMENTIDX_IDLE)
32 hcls.m_fFwMaxDistance = 2.5;
33 else
34 hcls.m_fFwMaxDistance = 1.2;
35
36 if (m_Player.m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_SWIM)
37 hcls.m_fBackwardsCheckDist = 0.35;
38 else
39 hcls.m_fBackwardsCheckDist = 0;
40
41 SHumanCommandClimbResult climbRes = new SHumanCommandClimbResult();
42
43 HumanCommandClimb.DoPerformClimbTest(m_Player, climbRes, 0);
44 if (climbRes.m_bIsClimb || climbRes.m_bIsClimbOver)
45 {
46 int climbType = GetClimbType(climbRes.m_fClimbHeight);
47 if (!m_Player.CanClimb(climbType, climbRes))
48 return;
49
50 if (Climb(climbRes))
51 {
52 if (climbType == 1)
53 m_Player.DepleteStamina(EStaminaModifiers.VAULT);
54 else if (climbType == 2)
55 m_Player.DepleteStamina(EStaminaModifiers.CLIMB);
56
57 return;
58 }
59 }
60
61 if (m_Player.CanJump())
62 {
63 Jump();
64 m_Player.DepleteStamina(EStaminaModifiers.JUMP);
65 }
66 }
67
68 void CheckAndFinishJump(int pLandType = 0)
69 {
70 if ( m_bIsJumpInProgress )
71 {
72 m_bIsJumpInProgress = false;
73 m_Player.OnJumpEnd(pLandType);
74 }
75 }
76
77 private bool Climb(SHumanCommandClimbResult pClimbRes)
78 {
79 int climbType = GetClimbType(pClimbRes.m_fClimbHeight);
80 if (climbType != -1)
81 {
82 m_Player.StartCommand_Climb(pClimbRes, climbType);
83 m_Player.StopHandEvent();
84
85 m_bWasClimb = true;
86 }
87
88 return climbType != -1;
89 }
90
91 private void Jump()
92 {
93 m_bIsJumpInProgress = true;
94 m_Player.SetFallYDiff(m_Player.PhysicsGetPositionWS()[1]);
95
96 m_Player.OnJumpStart();
97 m_Player.StartCommand_Fall(2.6);
98 m_Player.StopHandEvent();
99 }
100
101 private int GetClimbType(float pHeight)
102 {
103 int climbType = -1;
104 if (pHeight < 1.1)
105 climbType = 0;
106 else if (pHeight >= 1.1 && pHeight < 1.7)
107 climbType = 1;
108 else if (pHeight >= 1.7 && pHeight < 2.75)
109 climbType = 2;
110
111 return climbType;
112 }
113}
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
EStaminaModifiers