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