Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
23  int GetValue()
24  {
25  return m_Value;
26  }
27 }
28 
30 {
31  protected int m_Value;
32 
33  protected static ref map<EPresenceNotifierNoiseEventType, ref PresenceNotifierNoiseEvent> m_PresenceNotifierNotifierEvents;
34  protected ref Timer m_CooldownTimer;
35 
37  {
38  m_Value = 0;
39  m_CooldownTimer = new Timer(CALL_CATEGORY_SYSTEM);
40  m_PresenceNotifierNotifierEvents = new ref map<EPresenceNotifierNoiseEventType, ref PresenceNotifierNoiseEvent>;
41  }
42 
43  void RegisterEvent(EPresenceNotifierNoiseEventType pEventType, int pValue, float pLength)
44  {
45  PresenceNotifierNoiseEvent pnne = new PresenceNotifierNoiseEvent(pValue, pLength);
46  m_PresenceNotifierNotifierEvents.Insert(pEventType, pnne);
47  }
48 
49  void ProcessEvent(EPresenceNotifierNoiseEventType pEventType)
50  {
52 
53  pnne = m_PresenceNotifierNotifierEvents.Get(pEventType);
54 
55  if (m_CooldownTimer.IsRunning())
56  {
57  m_CooldownTimer.Stop();
58  }
59 
60  m_Value = pnne.GetValue();
61  m_CooldownTimer.Run(pnne.GetTimerLength(), this, "ResetEvent", null);
62  }
63 
64  int GetValue()
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  {
129  DbgUI.BeginCleanupScope();
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());
144  DbgUI.Text("Speed: " + GetMovementSpeedVisualCoef());
145  DbgUI.Text("Stance: " + GetMovementStanceVisualCoef());
146  DbgUI.Spacer(10);
147 
148  DbgUI.Panel("-- Noises", mainPanelSizeX, 2);
149  DbgUI.Text("Noises: ");
150  DbgUI.Text("Speed: " + NoiseAIEvaluate.GetNoiseMultiplierByPlayerSpeed(m_pPlayer));
151  DbgUI.Text("Boots: " + NoiseAIEvaluate.GetNoiseMultiplierByShoes(m_pPlayer));
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 
184  DbgUI.EndCleanupScope();
185  }
186 
189  {
190  return ProcessNoiseComponents();
191  }
192 
195  {
196  return ProcessVisualComponents();
197  }
198 
201  {
202  m_PresenceNotifierNoiseEvents.ProcessEvent(pEventType);
203  }
204 
205  protected int ProcessVisualComponents()
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 
216  protected int ProcessNoiseComponents()
217  {
218  float noise = 0;
219  if (m_pPlayer)
220  {
221  noise = NoiseAIEvaluate.GetNoiseMultiplier(m_pPlayer);
222  noise = Math.Round(noise * NOISE_LEVEL_MAX);
223  }
224 
225  return Math.Clamp(noise, NOISE_LEVEL_MIN, NOISE_LEVEL_MAX);
226  }
227 
228 
230  protected float GetMovementSpeedVisualCoef()
231  {
233  float speedCoef = 1.0;
234 
235  m_pPlayer.GetMovementState(hms);
236  switch (AITargetCallbacksPlayer.StanceToMovementIdxTranslation(hms))
237  {
238  case DayZPlayerConstants.MOVEMENTIDX_RUN:
239  speedCoef = 0.66;
240  break;
241  case DayZPlayerConstants.MOVEMENTIDX_WALK:
242  speedCoef = 0.33;
243  break;
244  case DayZPlayerConstants.MOVEMENTIDX_IDLE:
245  speedCoef = 0;
246  break;
247  }
248 
249  return speedCoef;
250  }
251 
252  protected float GetMovementStanceVisualCoef()
253  {
255  float stanceCoef = 1.0;
256 
257  m_pPlayer.GetMovementState(hms);
258  switch (hms.m_iStanceIdx)
259  {
260  case DayZPlayerConstants.STANCEIDX_CROUCH:
261  case DayZPlayerConstants.STANCEIDX_RAISEDCROUCH:
262  stanceCoef = 0.33;
263  break;
264 
265  case DayZPlayerConstants.STANCEIDX_PRONE:
266  case DayZPlayerConstants.STANCEIDX_RAISEDPRONE:
267  stanceCoef = 0.11;
268  break;
269  }
270 
271  return stanceCoef;
272  }
273 
275 
276 
279  // Not used since 1.12
280 
283  protected int GetMovementSpeedNoiseComponent();
284 
287  protected int GetBootsNoiseComponent();
288 
290  protected int GetSurfaceNoiseComponent();
291 
293  protected int GetExternalNoiseEventsComponent();
294 }
PresenceNotifierNoiseEvents
Definition: pluginpresencenotifier.c:29
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
SURFACE_LVL1_THRESHOLD
const float SURFACE_LVL1_THRESHOLD
Definition: pluginpresencenotifier.c:96
Init
void Init(PlayerBase player)
Definition: pluginpresencenotifier.c:117
DbgUI
Definition: dbgui.c:59
ProcessEvent
void ProcessEvent(EPresenceNotifierNoiseEventType pEventType)
processing of external one-time events (land, fire, etc.)
Definition: pluginpresencenotifier.c:200
NOISE_LEVEL_MAX
const int NOISE_LEVEL_MAX
Definition: pluginpresencenotifier.c:88
m_PresenceNotifierNoiseEvents
protected ref PresenceNotifierNoiseEvents m_PresenceNotifierNoiseEvents
Definition: pluginpresencenotifier.c:106
PluginPresenceNotifier
void PluginPresenceNotifier()
Definition: pluginpresencenotifier.c:108
GetMovementStanceVisualCoef
protected float GetMovementStanceVisualCoef()
Definition: pluginpresencenotifier.c:252
EPresenceNotifierNoiseEventType
EPresenceNotifierNoiseEventType
Definition: pluginpresencenotifier.c:1
GetValue
int GetValue()
Definition: pluginpresencenotifier.c:23
PresenceNotifierNoiseEvent
void PresenceNotifierNoiseEvent(float pValue, float pLength)
Definition: pluginpresencenotifier.c:12
m_Value
string m_Value
Definition: enentity.c:5
GetVisualPresence
int GetVisualPresence()
returns actual visibility presence of player
Definition: pluginpresencenotifier.c:194
PluginBase
Definition: pluginadminlog.c:1
GetExternalNoiseEventsComponent
protected int GetExternalNoiseEventsComponent()
DEPRECATED.
SURFACE_NOISE_LVL2
const int SURFACE_NOISE_LVL2
Definition: pluginpresencenotifier.c:93
m_TimerLength
enum EPresenceNotifierNoiseEventType m_TimerLength
m_pPlayer
protected PlayerBase m_pPlayer
Definition: pluginpresencenotifier.c:104
LAND_LIGHT
@ LAND_LIGHT
Definition: pluginpresencenotifier.c:3
HumanMovementState
Definition: human.c:1125
GetMovementSpeedNoiseComponent
protected int GetMovementSpeedNoiseComponent()
NoiseAIEvaluate
Definition: sensesaievaluate.c:1
~PluginPresenceNotifier
void ~PluginPresenceNotifier()
Definition: pluginpresencenotifier.c:115
ProcessNoiseComponents
protected int ProcessNoiseComponents()
Definition: pluginpresencenotifier.c:216
GetNoisePresence
int GetNoisePresence()
returns actual noise presence of player
Definition: pluginpresencenotifier.c:188
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
mainPanelSizeX
const int mainPanelSizeX
Definition: pluginpresencenotifier.c:81
ProcessVisualComponents
protected int ProcessVisualComponents()
Definition: pluginpresencenotifier.c:205
mainPanelSizeY
const int mainPanelSizeY
Definition: pluginpresencenotifier.c:82
margin
const int margin
Definition: pluginpresencenotifier.c:83
SURFACE_NOISE_LVL1
const int SURFACE_NOISE_LVL1
Definition: pluginpresencenotifier.c:92
EnableDebug
void EnableDebug(bool pEnabled)
Definition: pluginpresencenotifier.c:122
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
windowPosX
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
windowPosY
const int windowPosY
Definition: pluginpresencenotifier.c:80
ShowCoefsDbg
protected void ShowCoefsDbg(bool pEnabled)
Definition: pluginpresencenotifier.c:127
LAND_NOISE_LVL1
const int LAND_NOISE_LVL1
land noise
Definition: pluginpresencenotifier.c:99
AITargetCallbacksPlayer
Definition: aitargetcallbacksplayer.c:1
GetSurfaceNoiseComponent
protected int GetSurfaceNoiseComponent()
DEPRECATED.
m_Value
protected int m_Value
Definition: pluginpresencenotifier.c:10
GetTimerLength
float GetTimerLength()
Definition: pluginpresencenotifier.c:18
NOISE_LEVEL_MIN
const int NOISE_LEVEL_MIN
noise limits
Definition: pluginpresencenotifier.c:87
SURFACE_LVL2_THRESHOLD
const float SURFACE_LVL2_THRESHOLD
Definition: pluginpresencenotifier.c:95
LAND_NOISE_LVL2
const int LAND_NOISE_LVL2
Definition: pluginpresencenotifier.c:100
Timer
Definition: dayzplayerimplement.c:62
SURFACE_NOISE_LVL0
const int SURFACE_NOISE_LVL0
noise component from surfaces
Definition: pluginpresencenotifier.c:91
GetMovementSpeedVisualCoef
protected float GetMovementSpeedVisualCoef()
Visibility.
Definition: pluginpresencenotifier.c:230
Math
Definition: enmath.c:6
GetBootsNoiseComponent
protected int GetBootsNoiseComponent()
LAND_HEAVY
@ LAND_HEAVY
Definition: pluginpresencenotifier.c:4