DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
PluginPresenceNotifier.c
Go to the documentation of this file.
2{
5}
6
8{
9 protected float m_TimerLength;
10 protected int m_Value;
11
12 void PresenceNotifierNoiseEvent(float pValue, float pLength)
13 {
14 m_Value = pValue;
15 m_TimerLength = pLength;
16 }
17
19 {
20 return m_TimerLength;
21 }
22
24 {
25 return m_Value;
26 }
27}
28
30{
31 protected int m_Value;
32
34 protected ref Timer m_CooldownTimer;
35
37 {
38 m_Value = 0;
41 }
42
43 void RegisterEvent(EPresenceNotifierNoiseEventType pEventType, int pValue, float pLength)
44 {
46 m_PresenceNotifierNotifierEvents.Insert(pEventType, pnne);
47 }
48
50 {
52
53 pnne = m_PresenceNotifierNotifierEvents.Get(pEventType);
54
55 if (m_CooldownTimer.IsRunning())
56 {
58 }
59
60 m_Value = pnne.GetValue();
61 m_CooldownTimer.Run(pnne.GetTimerLength(), this, "ResetEvent", null);
62 }
63
65 {
66 return m_Value;
67 }
68
69 protected void ResetEvent()
70 {
71 m_Value = 0;
72 }
73}
74
75
77{
79 const int windowPosX = 0;
80 const int windowPosY = 10;
81 const int mainPanelSizeX = 200;
82 const int mainPanelSizeY = 1;
83 const int margin = 10;
84
85
87 const int NOISE_LEVEL_MIN = 0;
88 const int NOISE_LEVEL_MAX = 5;
89
91 const int SURFACE_NOISE_LVL0 = 0;
92 const int SURFACE_NOISE_LVL1 = 1;
93 const int SURFACE_NOISE_LVL2 = 2;
94
95 const float SURFACE_LVL2_THRESHOLD = 1.0;
96 const float SURFACE_LVL1_THRESHOLD = 0.5;
97
99 const int LAND_NOISE_LVL1 = 2;
100 const int LAND_NOISE_LVL2 = 3;
101
103
105
107
109 {
113 }
114
116
117 void Init(PlayerBase player)
118 {
119 m_pPlayer = player;
120 }
121
122 void EnableDebug(bool pEnabled)
123 {
124 ShowCoefsDbg(pEnabled);
125 }
126
127 protected void ShowCoefsDbg(bool pEnabled)
128 {
130
131 if (pEnabled && m_pPlayer)
132 {
134 m_pPlayer.GetMovementState(hms);
135
136 string visualAlertLevel;
137 string noiseAlertLevel;
138
139 DbgUI.Begin("Presence Notifier", windowPosX + 10, windowPosY);
140 DbgUI.Panel("MinimumSize", mainPanelSizeX, mainPanelSizeY);
141
142 DbgUI.Text("Visual: ");
143 DbgUI.Text("Visibility: " + m_pPlayer.GetVisibilityCoef());
145 DbgUI.Text("Stance: " + GetMovementStanceVisualCoef());
146 DbgUI.Spacer(10);
147
148 DbgUI.Panel("-- Noises", mainPanelSizeX, 2);
149 DbgUI.Text("Noises: ");
152 DbgUI.Text("Surface: " + NoiseAIEvaluate.GetNoiseMultiplierBySurface(m_pPlayer) + " [ cfg: " + m_pPlayer.GetSurfaceNoise() + "]");
153 DbgUI.Spacer(10);
154
155 DbgUI.Panel("-- Result", mainPanelSizeX, 2);
156 DbgUI.Text("Result: ");
157 visualAlertLevel = "";
158 for (int iv = 0; iv < GetVisualPresence(); iv++)
159 {
160 visualAlertLevel += "!";
161 }
162 DbgUI.Text("Visual level: " + GetVisualPresence() + " [" + visualAlertLevel + "]");
163
164
165 noiseAlertLevel = "";
166 for (int ia = 0; ia < GetNoisePresence(); ia++)
167 {
168 noiseAlertLevel += "!";
169 }
170
171 DbgUI.Text("Noise level: " + GetNoisePresence() + " [" + noiseAlertLevel + "]");
172
173 DbgUI.End();
174
176 DbgUI.Begin("HumanMovementState", windowPosX + 250, windowPosY);
177 DbgUI.Panel("MinimumSize", mainPanelSizeX, mainPanelSizeY);
178 DbgUI.Text("Command ID: " + hms.m_CommandTypeId);
179 DbgUI.Text("Stance: " + hms.m_iStanceIdx);
180 DbgUI.Text("Movement: " + hms.m_iMovement);
181 DbgUI.End();
182 }
183
185 }
186
189 {
190 return ProcessNoiseComponents();
191 }
192
195 {
197 }
198
201 {
203 }
204
206 {
207 float visualMean = 0;
208 if (m_pPlayer)
209 {
210 visualMean = (m_pPlayer.GetVisibilityCoef() + GetMovementSpeedVisualCoef() + GetMovementStanceVisualCoef()) / 3;
211 }
212
213 return visualMean;
214 }
215
217 {
218 float noise = 0;
219 if (m_pPlayer)
220 {
222 noise = Math.Round(noise * NOISE_LEVEL_MAX);
223 }
224
226 }
227
228
231 {
233 float speedCoef = 1.0;
234
235 m_pPlayer.GetMovementState(hms);
236 //Print(hms.m_iMovement);
238 {
239 case DayZPlayerConstants.MOVEMENTIDX_RUN:
240 speedCoef = 0.66;
241 break;
242 case DayZPlayerConstants.MOVEMENTIDX_WALK:
243 speedCoef = 0.33;
244 break;
245 case DayZPlayerConstants.MOVEMENTIDX_IDLE:
246 speedCoef = 0;
247 break;
248 }
249
250 return speedCoef;
251 }
252
254 {
256 float stanceCoef = 1.0;
257
258 m_pPlayer.GetMovementState(hms);
259 switch (hms.m_iStanceIdx)
260 {
261 case DayZPlayerConstants.STANCEIDX_CROUCH:
262 case DayZPlayerConstants.STANCEIDX_RAISEDCROUCH:
263 stanceCoef = 0.33;
264 break;
265
266 case DayZPlayerConstants.STANCEIDX_PRONE:
267 case DayZPlayerConstants.STANCEIDX_RAISEDPRONE:
268 stanceCoef = 0.11;
269 break;
270 }
271
272 return stanceCoef;
273 }
274
276
277
280 // Not used since 1.12
281
285
288 protected int GetBootsNoiseComponent();
289
292
295}
protected float GetMovementStanceVisualCoef()
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
const int SURFACE_NOISE_LVL1
void ProcessEvent(EPresenceNotifierNoiseEventType pEventType)
processing of external one-time events (land, fire, etc.)
protected int ProcessNoiseComponents()
const int NOISE_LEVEL_MAX
enum EPresenceNotifierNoiseEventType m_TimerLength
void PluginPresenceNotifier()
void PresenceNotifierNoiseEvent(float pValue, float pLength)
protected int ProcessVisualComponents()
const float SURFACE_LVL1_THRESHOLD
const int mainPanelSizeX
protected int GetBootsNoiseComponent()
void ~PluginPresenceNotifier()
int GetVisualPresence()
returns actual visibility presence of player
const int margin
EPresenceNotifierNoiseEventType
const int mainPanelSizeY
const int SURFACE_NOISE_LVL0
noise component from surfaces
const int LAND_NOISE_LVL2
const int LAND_NOISE_LVL1
land noise
float GetTimerLength()
const int SURFACE_NOISE_LVL2
const float SURFACE_LVL2_THRESHOLD
protected float GetMovementSpeedVisualCoef()
Visibility.
const int NOISE_LEVEL_MIN
noise limits
protected void ShowCoefsDbg(bool pEnabled)
void EnableDebug(bool pEnabled)
protected ref PresenceNotifierNoiseEvents m_PresenceNotifierNoiseEvents
protected int GetMovementSpeedNoiseComponent()
protected int GetSurfaceNoiseComponent()
DEPRECATED.
int GetNoisePresence()
returns actual noise presence of player
protected int GetExternalNoiseEventsComponent()
DEPRECATED.
const int windowPosY
float GetValue()
Definition SyncedValue.c:55
static int StanceToMovementIdxTranslation(HumanMovementState pState)
Definition DbgUI.c:60
int m_iStanceIdx
current command's id
Definition human.c:1117
int m_iMovement
current stance (DayZPlayerConstants.STANCEIDX_ERECT, ...), only if the command has a stance
Definition human.c:1118
Definition EnMath.c:7
static float GetNoiseMultiplier(DayZPlayerImplement playerImplement)
static float GetNoiseMultiplierByPlayerSpeed(DayZPlayerImplement playerImplement)
static float GetNoiseMultiplierByShoes(DayZPlayerImplement playerImplement)
static float GetNoiseMultiplierBySurface(DayZPlayerImplement playerImplement)
void ProcessEvent(EPresenceNotifierNoiseEventType pEventType)
static protected ref map< EPresenceNotifierNoiseEventType, ref PresenceNotifierNoiseEvent > m_PresenceNotifierNotifierEvents
void RegisterEvent(EPresenceNotifierNoiseEventType pEventType, int pValue, float pLength)
override void Stop()
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
protected DayZPlayer m_pPlayer
data
Definition dayzplayer.c:135
static proto native void Spacer(int height)
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto void BeginCleanupScope()
static proto native void Text(string label)
static proto native void EndCleanupScope()
static proto native void End()
static proto native void Panel(string label, int width, int height, int color=0xaa555555)
string m_Value
Definition EnEntity.c:806
static proto float Round(float f)
Returns mathematical round of value.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8