DayZ 1.24
Loading...
Searching...
No Matches
DayZPlayerImplementSwimming.c
Go to the documentation of this file.
1
3{
4
7 bool m_bWasSwimming = false; // important for shallow water, so we know if we should get back into swimming when other fullbody command (like damage) finished
8
10 {
12 m_pSettings = pPlayer.GetDayZPlayerType().CommandSwimSettingsW();
13 }
14
16 {
17 vector pp = m_pPlayer.GetPosition();
18 vector wl = HumanCommandSwim.WaterLevelCheck(m_pPlayer, pp);
19
20 return wl[0];
21 }
22
24 {
25 vector pp = m_pPlayer.GetPosition();
26 vector wl = HumanCommandSwim.WaterLevelCheck(m_pPlayer, pp);
27
28 return wl[1];
29 }
30
32 {
33 return DayZPlayerUtils.CheckWaterLevel(m_pPlayer, waterLevel) == EWaterLevels.LEVEL_SWIM_START;
34 }
35
38 {
39 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE)
40 return false;
41
42 m_bWasSwimming = false;
43
45 if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_SWIM)
46 {
47 vector wl;
49 {
50 m_pPlayer.StartCommand_Swim();
51 m_bWasSwimming = true;
52 return true;
53 }
54
56 if ((pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE) && (pCMove != null))
57 {
58 pCMove.SetCurrentWaterLevel(wl[1]);
60
61 if (wl[1] > m_pSettings.m_fToErectLevel && pState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_ERECT && pState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDERECT)
62 {
63 if (DayZPlayerUtils.PlayerCanChangeStance(m_pPlayer, DayZPlayerConstants.STANCEIDX_ERECT))
64 pCMove.ForceStanceUp(DayZPlayerConstants.STANCEIDX_ERECT);
65 else
66 {
67 m_pPlayer.StartCommand_Swim();
68 m_bWasSwimming = true;
69 return true;
70 }
71 }
72 else if (wl[1] > m_pSettings.m_fToCrouchLevel && (pState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || pState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE))
73 {
74 if (DayZPlayerUtils.PlayerCanChangeStance(m_pPlayer, DayZPlayerConstants.STANCEIDX_CROUCH))
75 pCMove.ForceStanceUp(DayZPlayerConstants.STANCEIDX_CROUCH);
76 else
77 {
78 m_pPlayer.StartCommand_Swim();
79 m_bWasSwimming = true;
80 return true;
81 }
82 }
83 }
84
85 // not handled
86 return false;
87 }
88 else // if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_SWIM)
89 {
91 {
92 if (DayZPlayerUtils.PlayerCanChangeStance(m_pPlayer, DayZPlayerConstants.STANCEIDX_ERECT, true))
93 {
94 HumanCommandSwim hcs = m_pPlayer.GetCommand_Swim();
95 hcs.StopSwimming();
96 m_bWasSwimming = false;
97 return true;
98 }
99 }
100
102 m_bWasSwimming = true;
103 return true;
104 }
105 }
106}
void DayZPlayerUtils()
cannot be instantiated
EWaterLevels
Definition EWaterLevels.c:2
override void SetCurrentWaterLevel(float pWaterLevel)
bool HandleSwimming(int pCurrentCommandID, HumanCommandMove pCMove, HumanMovementState pState)
ha
void DayZPlayerImplementSwimming(DayZPlayer pPlayer)
bool CheckSwimmingStart(out vector waterLevel)
SHumanCommandSwimSettings m_pSettings
float m_fWaterLevelOut
what water level causes to stop swimming (1.2m)
float m_fToCrouchLevel
when to crouch
float m_fToErectLevel
when to stand
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
class HumanCommandLadder HumanCommandSwim()
Definition human.c:669