Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
pluginpresencenotifier.c
Go to the documentation of this file.
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
43
44 void RegisterEvent(EPresenceNotifierNoiseEventType pEventType, int pValue, float pLength)
45 {
47 m_PresenceNotifierNotifierEvents.Insert(pEventType, pnne);
48 }
49
51 {
53
54 if (m_CooldownTimer.IsRunning())
55 m_CooldownTimer.Stop();
56
57 m_Value = pnne.GetValue();
58 m_CooldownTimer.Run(pnne.GetTimerLength(), this, "ResetEvent", null);
59 }
60
62 {
63 return m_Value;
64 }
65
66 protected void ResetEvent()
67 {
68 m_Value = 0;
69 }
70}
71
72
74{
76 const int windowPosX = 0;
77 const int windowPosY = 10;
78
79 const int mainPanelSizeX = 200;
80 const int mainPanelSizeY = 1;
81
82 const int margin = 10;
83
85 const int NOISE_LEVEL_MIN = 0;
86 const int NOISE_LEVEL_MAX = 5;
87
89 const int SURFACE_NOISE_LVL0 = 0;
90 const int SURFACE_NOISE_LVL1 = 1;
91 const int SURFACE_NOISE_LVL2 = 2;
92
93 const float SURFACE_LVL2_THRESHOLD = 1.0;
94 const float SURFACE_LVL1_THRESHOLD = 0.5;
95
97 const int LAND_NOISE_LVL1 = 2;
98 const int LAND_NOISE_LVL2 = 3;
99
101
104
106
113
114 void Init(PlayerBase player)
115 {
116 m_pPlayer = player;
118 }
119
120 void EnableDebug(bool pEnabled)
121 {
122 ShowCoefsDbg(pEnabled);
123 }
124
125 protected void ShowCoefsDbg(bool pEnabled)
126 {
127 DbgUI.BeginCleanupScope();
128
129 if (pEnabled && m_pPlayer)
130 {
131 HumanMovementState hms = new HumanMovementState();
132 m_pPlayer.GetMovementState(hms);
133
134 string visualAlertLevel;
135 string noiseAlertLevel;
136
137 DbgUI.Begin("Presence Notifier", windowPosX + 10, windowPosY);
138 DbgUI.Panel("MinimumSize", mainPanelSizeX, mainPanelSizeY);
139
140 DbgUI.Text("Visual: ");
141 DbgUI.Text("Visibility: " + m_pPlayer.GetVisibilityCoef());
142 DbgUI.Text("Speed: " + GetMovementSpeedVisualCoef());
143 DbgUI.Text("Stance: " + GetMovementStanceVisualCoef());
144 DbgUI.Spacer(10);
145
146 DbgUI.Panel("-- Noises", mainPanelSizeX, 2);
147 DbgUI.Text("Noises: ");
148 DbgUI.Text("Speed: " + NoiseAIEvaluate.GetNoiseMultiplierByPlayerSpeed(m_pPlayer));
149 DbgUI.Text("Boots: " + NoiseAIEvaluate.GetNoiseMultiplierByShoes(m_pPlayer));
150 DbgUI.Text("Surface: " + NoiseAIEvaluate.GetNoiseMultiplierBySurface(m_pPlayer) + " [ cfg: " + m_pPlayer.GetSurfaceNoise() + "]");
151 DbgUI.Spacer(10);
152
153 DbgUI.Panel("-- Noise reductions", mainPanelSizeX, 2);
154 DbgUI.Text("Noise reductions: ");
155 DbgUI.Text("Weather: " + NoiseAIEvaluate.GetNoiseReduction(m_Weather));
156 DbgUI.Spacer(10);
157
158 DbgUI.Panel("-- Result", mainPanelSizeX, 2);
159 DbgUI.Text("Result: ");
160 visualAlertLevel = "";
161 for (int iv = 0; iv < GetVisualPresence(); iv++)
162 {
163 visualAlertLevel += "!";
164 }
165 DbgUI.Text("Visual level: " + GetVisualPresence() + " [" + visualAlertLevel + "]");
166
167
168 noiseAlertLevel = "";
169 for (int ia = 0; ia < GetNoisePresence(); ia++)
170 {
171 noiseAlertLevel += "!";
172 }
173
174 DbgUI.Text("Noise level: " + GetNoisePresence() + " [" + noiseAlertLevel + "]");
175
176 DbgUI.End();
177
179 DbgUI.Begin("HumanMovementState", windowPosX + 250, windowPosY);
180 DbgUI.Panel("MinimumSize", mainPanelSizeX, mainPanelSizeY);
181 DbgUI.Text("Command ID: " + hms.m_CommandTypeId);
182 DbgUI.Text("Stance: " + hms.m_iStanceIdx);
183 DbgUI.Text("Movement: " + hms.m_iMovement);
184 DbgUI.End();
185 }
186
187 DbgUI.EndCleanupScope();
188 }
189
192 {
193 return ProcessNoiseComponents();
194 }
195
198 {
200 }
201
207
209 {
210 float visualMean = 0;
211 if (m_pPlayer)
212 {
213 visualMean = (m_pPlayer.GetVisibilityCoef() + GetMovementSpeedVisualCoef() + GetMovementStanceVisualCoef()) / 3;
214 }
215
216 return visualMean;
217 }
218
220 {
221 float noise = 0;
222 float reduction = 0;
223 if (m_pPlayer)
224 {
225 noise = NoiseAIEvaluate.GetNoiseMultiplier(m_pPlayer) * NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather());
226 noise = Math.Round(noise * NOISE_LEVEL_MAX);
227 }
228
229 return Math.Clamp(noise, NOISE_LEVEL_MIN, NOISE_LEVEL_MAX);
230 }
231
232
235 {
236 HumanMovementState hms = new HumanMovementState();
237 float speedCoef = 1.0;
238
239 m_pPlayer.GetMovementState(hms);
240 switch (AITargetCallbacksPlayer.StanceToMovementIdxTranslation(hms))
241 {
242 case DayZPlayerConstants.MOVEMENTIDX_RUN:
243 speedCoef = 0.66;
244 break;
245 case DayZPlayerConstants.MOVEMENTIDX_WALK:
246 speedCoef = 0.33;
247 break;
248 case DayZPlayerConstants.MOVEMENTIDX_IDLE:
249 speedCoef = 0;
250 break;
251 }
252
253 return speedCoef;
254 }
255
257 {
258 HumanMovementState hms = new HumanMovementState();
259 float stanceCoef = 1.0;
260
261 m_pPlayer.GetMovementState(hms);
262 switch (hms.m_iStanceIdx)
263 {
264 case DayZPlayerConstants.STANCEIDX_CROUCH:
265 case DayZPlayerConstants.STANCEIDX_RAISEDCROUCH:
266 stanceCoef = 0.33;
267 break;
268
269 case DayZPlayerConstants.STANCEIDX_PRONE:
270 case DayZPlayerConstants.STANCEIDX_RAISEDPRONE:
271 stanceCoef = 0.11;
272 break;
273 }
274
275 return stanceCoef;
276 }
277
279
280
283 // Not used since 1.12
284
288
291 protected int GetBootsNoiseComponent();
292
295
298}
proto native Weather GetWeather()
Returns weather controller object.
Definition dbgui.c:60
Definition enmath.c:7
Plugin interface for controlling of agent pool system.
Definition pluginbase.c:2
static ref map< EPresenceNotifierNoiseEventType, ref PresenceNotifierNoiseEvent > m_PresenceNotifierNotifierEvents
void RegisterEvent(EPresenceNotifierNoiseEventType pEventType, int pValue, float pLength)
void ProcessEvent(EPresenceNotifierNoiseEventType pEventType)
override Widget Init()
Definition dayzgame.c:127
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
DayZPlayer m_pPlayer
data
Definition dayzplayer.c:135
proto native CGame GetGame()
string m_Value
Definition enentity.c:808
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
const int SURFACE_NOISE_LVL1
void ProcessEvent(EPresenceNotifierNoiseEventType pEventType)
processing of external one-time events (land, fire, etc.)
const int NOISE_LEVEL_MAX
enum EPresenceNotifierNoiseEventType m_TimerLength
void PluginPresenceNotifier()
void PresenceNotifierNoiseEvent(float pValue, float pLength)
const float SURFACE_LVL1_THRESHOLD
void ShowCoefsDbg(bool pEnabled)
float GetMovementSpeedVisualCoef()
Visibility.
int GetExternalNoiseEventsComponent()
DEPRECATED.
const int mainPanelSizeX
int GetSurfaceNoiseComponent()
DEPRECATED.
int GetMovementSpeedNoiseComponent()
float GetMovementStanceVisualCoef()
int ProcessVisualComponents()
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()
Weather m_Weather
const int SURFACE_NOISE_LVL2
const float SURFACE_LVL2_THRESHOLD
const int NOISE_LEVEL_MIN
noise limits
int ProcessNoiseComponents()
void EnableDebug(bool pEnabled)
ref PresenceNotifierNoiseEvents m_PresenceNotifierNoiseEvents
int GetNoisePresence()
returns actual noise presence of player
const int windowPosY
int GetBootsNoiseComponent()
float GetValue()
Definition syncedvalue.c:55