Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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;
117 m_Weather = g_Game.GetWeather();
118 }
119
120 void EnableDebug(bool pEnabled)
121 {
122 ShowCoefsDbg(pEnabled);
123 }
124
125 protected void ShowCoefsDbg(bool pEnabled)
126 {
128
129 if (pEnabled && m_pPlayer)
130 {
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());
143 DbgUI.Text("Stance: " + GetMovementStanceVisualCoef());
144 DbgUI.Spacer(10);
145
146 DbgUI.Panel("-- Noises", mainPanelSizeX, 2);
147 DbgUI.Text("Noises: ");
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: ");
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
188 }
189
192 {
193 return ProcessNoiseComponents();
194 }
195
198 {
200 }
201
204 {
205 m_PresenceNotifierNoiseEvents.ProcessEvent(pEventType);
206 }
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 {
226 noise = Math.Round(noise * NOISE_LEVEL_MAX);
227 }
228
230 }
231
232
235 {
237 float speedCoef = 1.0;
238
239 m_pPlayer.GetMovementState(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 {
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}
static int StanceToMovementIdxTranslation(HumanMovementState pState)
Translates players speed (idx) and corrects it by current stance used mainly for visibility/audibilit...
Definition dbgui.c:60
int m_iStanceIdx
current command's id
Definition human.c:1156
int m_iMovement
current stance (DayZPlayerConstants.STANCEIDX_ERECT, ...), only if the command has a stance
Definition human.c:1157
Definition enmath.c:7
static float GetNoiseMultiplier(DayZPlayerImplement playerImplement)
static float GetNoiseReduction(Weather weather)
static float GetNoiseMultiplierByPlayerSpeed(DayZPlayerImplement playerImplement)
static float GetNoiseMultiplierByShoes(DayZPlayerImplement playerImplement)
static float GetNoiseMultiplierBySurface(DayZPlayerImplement playerImplement)
Class PluginMessageManager provides some basic Message Distribution mechanics, if you get instance of...
Definition pluginbase.c:2
void ProcessEvent(EPresenceNotifierNoiseEventType pEventType)
static ref map< EPresenceNotifierNoiseEventType, ref PresenceNotifierNoiseEvent > m_PresenceNotifierNotifierEvents
void RegisterEvent(EPresenceNotifierNoiseEventType pEventType, int pValue, float pLength)
Weather controller.
Definition weather.c:168
DayZGame g_Game
Definition dayzgame.c:3942
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
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:808
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
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()
Noise related.
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()
noise component of presence based on player's shoes DEPRECATED
float GetValue()
Definition syncedvalue.c:55