Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
dayzplayerimplementswimming.c
Go to the documentation of this file.
1
2
class
DayZPlayerImplementSwimming
3
{
4
5
DayZPlayer
m_pPlayer
;
6
SHumanCommandSwimSettings
m_pSettings
;
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
9
void
DayZPlayerImplementSwimming
(
DayZPlayer
pPlayer)
10
{
11
m_pPlayer
= pPlayer;
12
m_pSettings
= pPlayer.GetDayZPlayerType().CommandSwimSettingsW();
13
}
14
15
float
GetWaterDepth
()
16
{
17
vector
pp =
m_pPlayer
.PhysicsGetPositionWS();
18
vector
wl =
HumanCommandSwim
.WaterLevelCheck(
m_pPlayer
, pp);
19
20
return
wl[0];
21
}
22
23
float
GetCharacterDepth
()
24
{
25
vector
pp =
m_pPlayer
.PhysicsGetPositionWS();
26
vector
wl =
HumanCommandSwim
.WaterLevelCheck(
m_pPlayer
, pp);
27
28
return
wl[1];
29
}
30
31
bool
CheckSwimmingStart
(out
vector
waterLevel)
32
{
33
return
DayZPlayerUtils
.CheckWaterLevel(
m_pPlayer
,waterLevel) ==
EWaterLevels
.LEVEL_SWIM_START;
34
}
35
37
bool
HandleSwimming
(
int
pCurrentCommandID,
HumanCommandMove
pCMove,
HumanMovementState
pState)
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;
48
if
(
CheckSwimmingStart
(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]);
59
m_pPlayer
.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
{
65
pCMove.
ForceStanceUp
(
DayZPlayerConstants
.STANCEIDX_ERECT);
66
}
67
else
68
{
69
m_pPlayer
.StartCommand_Swim();
70
m_bWasSwimming
=
true
;
71
return
true
;
72
}
73
}
74
else
if
(wl[1] >
m_pSettings
.m_fToCrouchLevel && (pState.
m_iStanceIdx
==
DayZPlayerConstants
.STANCEIDX_PRONE || pState.
m_iStanceIdx
==
DayZPlayerConstants
.STANCEIDX_RAISEDPRONE))
75
{
76
if
(
DayZPlayerUtils
.PlayerCanChangeStance(
m_pPlayer
,
DayZPlayerConstants
.STANCEIDX_CROUCH) )
77
{
78
pCMove.
ForceStanceUp
(
DayZPlayerConstants
.STANCEIDX_CROUCH);
79
}
80
else
81
{
82
m_pPlayer
.StartCommand_Swim();
83
m_bWasSwimming
=
true
;
84
return
true
;
85
}
86
}
87
}
88
89
// not handled
90
return
false
;
91
}
92
else
// if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_SWIM)
93
{
94
if
(
GetWaterDepth
() <
m_pSettings
.m_fWaterLevelOut)
95
{
96
if
(
DayZPlayerUtils
.PlayerCanChangeStance(
m_pPlayer
,
DayZPlayerConstants
.STANCEIDX_ERECT,
true
))
97
{
98
HumanCommandSwim
hcs =
m_pPlayer
.GetCommand_Swim();
99
hcs.StopSwimming();
100
m_bWasSwimming
=
false
;
101
return
true
;
102
}
103
}
104
106
m_bWasSwimming
=
true
;
107
return
true
;
108
}
109
}
110
}
DayZPlayer
Definition
dayzplayerimplement.c:87
DayZPlayerImplementSwimming::GetCharacterDepth
float GetCharacterDepth()
Definition
dayzplayerimplementswimming.c:23
DayZPlayerImplementSwimming::HandleSwimming
bool HandleSwimming(int pCurrentCommandID, HumanCommandMove pCMove, HumanMovementState pState)
ha
Definition
dayzplayerimplementswimming.c:37
DayZPlayerImplementSwimming::GetWaterDepth
float GetWaterDepth()
Definition
dayzplayerimplementswimming.c:15
DayZPlayerImplementSwimming::DayZPlayerImplementSwimming
void DayZPlayerImplementSwimming(DayZPlayer pPlayer)
Definition
dayzplayerimplementswimming.c:9
DayZPlayerImplementSwimming::m_pPlayer
DayZPlayer m_pPlayer
Definition
dayzplayerimplementswimming.c:5
DayZPlayerImplementSwimming::m_bWasSwimming
bool m_bWasSwimming
Definition
dayzplayerimplementswimming.c:7
DayZPlayerImplementSwimming::CheckSwimmingStart
bool CheckSwimmingStart(out vector waterLevel)
Definition
dayzplayerimplementswimming.c:31
DayZPlayerImplementSwimming::m_pSettings
SHumanCommandSwimSettings m_pSettings
Definition
dayzplayerimplementswimming.c:6
HumanCommandMove
Definition
human.c:434
HumanCommandMove::SetCurrentWaterLevel
proto native void SetCurrentWaterLevel(float value)
sets water level (depth)
HumanCommandMove::ForceStanceUp
proto native void ForceStanceUp(int pStanceIdx)
pStanceIds is one of STANCEIDX_ERECT,STANCEIDX_CROUCH this forces to stand up to required stance
HumanMovementState
Definition
human.c:1154
HumanMovementState::m_iStanceIdx
int m_iStanceIdx
current command's id
Definition
human.c:1156
SHumanCommandSwimSettings
Definition
humansettings.c:46
vector
Definition
enconvert.c:119
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:602
DayZPlayerUtils
void DayZPlayerUtils()
cannot be instantiated
Definition
dayzplayerutils.c:465
EWaterLevels
EWaterLevels
Definition
ewaterlevels.c:2
HumanCommandSwim
class HumanCommandLadder HumanCommandSwim()
Definition
human.c:673
Games
Dayz
scripts
4_world
entities
dayzplayerimplementswimming.c
Generated by
1.17.0