DayZ 1.24
Loading...
Searching...
No Matches
ModifiersManager.c File Reference

Go to the source code of this file.

Classes

class  ModifierDebugObj
 

Enumerations

enum  eModifierSyncIDs {
  MODIFIER_SYNC_WOUND_INFECT_1 = 0x00000001 , MODIFIER_SYNC_WOUND_INFECT_2 = 0x00000002 , MODIFIER_SYNC_CONTAMINATION = 0x00000004 , MODIFIER_SYNC_CONTAMINATION2 = 0x00000008 ,
  MODIFIER_SYNC_ZONE_EXPOSURE = 0x00000010 , MODIFIER_SYNC_DROWNING = 0x00000020 , MODIFIER_SYNC_FEVER = 0x00000040 , LAST_INDEX
}
 
enum  EActivationType { TRIGGER_EVENT_OFF , TRIGGER_EVENT_ON_ACTIVATION , TRIGGER_EVENT_ON_CONNECT }
 

Functions

void ModifiersManager (PlayerBase player)
 
void Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
void SetModifiers (bool enable)
 
int GetStorageVersion ()
 
bool IsModifiersEnable ()
 
void AddModifier (ModifierBase modifier)
 
bool IsModifierActive (eModifiers modifier_id)
 
void OnScheduledTick (float delta_time)
 
void DeactivateAllModifiers ()
 
void ActivateModifier (int modifier_id, bool triggerEvent=EActivationType.TRIGGER_EVENT_ON_ACTIVATION)
 
void DeactivateModifier (int modifier_id, bool triggerEvent=true)
 
void OnStoreSave (ParamsWriteContext ctx)
 
bool OnStoreLoad (ParamsReadContext ctx, int version)
 
ModifierBase GetModifier (int modifier_id)
 
PlayerBase GetPlayer ()
 
void SetModifierLock (int modifier_id, bool state)
 
bool GetModifierLock (int modifier_id)
 
void DbgGetModifiers (array< ref ModifierDebugObj > modifiers)
 
void ResetAll ()
 

Variables

const int DEFAULT_TICK_TIME_ACTIVE = 3
 
const int DEFAULT_TICK_TIME_ACTIVE_SHORT = 1
 
const int DEFAULT_TICK_TIME_INACTIVE = 3
 
const int DEFAULT_TICK_TIME_INACTIVE_LONG = 10
 
class ModifierDebugObj m_Player
 
ref map< int, ref ModifierBasem_ModifierList
 
ref array< ref ModifierBasem_ModifierListArray = new array< ref ModifierBase>
 
ref array< ref Paramm_ParamList
 
bool m_AllowModifierTick = false
 
const int STORAGE_VERSION = 121
 

Enumeration Type Documentation

◆ EActivationType

Enumerator
TRIGGER_EVENT_OFF 
TRIGGER_EVENT_ON_ACTIVATION 
TRIGGER_EVENT_ON_CONNECT 

Definition at line 22 of file ModifiersManager.c.

23{
24
28};
@ TRIGGER_EVENT_ON_CONNECT
@ TRIGGER_EVENT_OFF
@ TRIGGER_EVENT_ON_ACTIVATION

◆ eModifierSyncIDs

Enumerator
MODIFIER_SYNC_WOUND_INFECT_1 
MODIFIER_SYNC_WOUND_INFECT_2 
MODIFIER_SYNC_CONTAMINATION 
MODIFIER_SYNC_CONTAMINATION2 
MODIFIER_SYNC_ZONE_EXPOSURE 
MODIFIER_SYNC_DROWNING 
MODIFIER_SYNC_FEVER 
LAST_INDEX 

Definition at line 2 of file ModifiersManager.c.

3{
4
7 MODIFIER_SYNC_CONTAMINATION = 0x00000004,//stage1
8 MODIFIER_SYNC_CONTAMINATION2 = 0x00000008,//stage2 and stage3 share the same sync id
10 MODIFIER_SYNC_DROWNING = 0x00000020,
11 MODIFIER_SYNC_FEVER = 0x00000040,
12 //0x00000080,
13 //0x00000100,
14 //0x00000200,
15 //0x00000400,
16 //0x00000800,
17 //0x00001000,
19};
@ MODIFIER_SYNC_FEVER
@ MODIFIER_SYNC_CONTAMINATION2
@ MODIFIER_SYNC_WOUND_INFECT_1
@ LAST_INDEX
@ MODIFIER_SYNC_ZONE_EXPOSURE
@ MODIFIER_SYNC_WOUND_INFECT_2
@ MODIFIER_SYNC_DROWNING
@ MODIFIER_SYNC_CONTAMINATION

Function Documentation

◆ ActivateModifier()

void ActivateModifier ( int modifier_id,
bool triggerEvent = EActivationType.TRIGGER_EVENT_ON_ACTIVATION )

Definition at line 210 of file ModifiersManager.c.

211 {
212 m_ModifierList.Get(modifier_id).ActivateRequest(triggerEvent);
213 }
ref map< int, ref ModifierBase > m_ModifierList

References m_ModifierList.

Referenced by OnClick(), OnStoreLoad(), and ResetAll().

◆ AddModifier()

void AddModifier ( ModifierBase modifier)

Definition at line 177 of file ModifiersManager.c.

178 {
179 modifier.InitBase(m_Player, this);
180 int id = modifier.GetModifierID();
181
182 if (id < 1)
183 Error("modifiers ID must be 1 or higher(for debugging reasons)");
184
185 //TODO: add a check for duplicity
186 m_ModifierList.Insert(id, modifier);
188 }
class ModifierDebugObj m_Player
ref array< ref ModifierBase > m_ModifierListArray
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), m_ModifierList, m_ModifierListArray, and m_Player.

Referenced by Init(), and SetModifiers().

◆ DbgGetModifiers()

void DbgGetModifiers ( array< ref ModifierDebugObj > modifiers)

Definition at line 318 of file ModifiersManager.c.

319 {
320 modifiers.Clear();
321 for (int i = 1; i < eModifiers.COUNT; i++)
322 {
323 if (m_ModifierList.Contains(i))
324 {
326 int modifier_id = modifier.GetModifierID();
327 string modifier_name = modifier.GetName();
328 bool active = modifier.IsActive();
329 string debug_text = modifier.GetDebugTextSimple();
330 bool is_locked = modifier.IsLocked();
331
332 if (active && debug_text != "")
333 modifier_name += " | " + debug_text;
335
336 modifiers.Insert(obj);
337 }
338 }
339 }
eModifiers
Definition eModifiers.c:2

References m_ModifierList.

◆ DeactivateAllModifiers()

void DeactivateAllModifiers ( )

Definition at line 204 of file ModifiersManager.c.

205 {
206 for (int i = 0; i < m_ModifierList.Count(); i++)
207 m_ModifierList.GetElement(i).Deactivate();
208 }

References m_ModifierList.

Referenced by ResetAll().

◆ DeactivateModifier()

void DeactivateModifier ( int modifier_id,
bool triggerEvent = true )

Definition at line 215 of file ModifiersManager.c.

216 {
217 m_ModifierList.Get(modifier_id).Deactivate(triggerEvent);
218 }

References m_ModifierList.

Referenced by OnClick().

◆ GetModifier()

ModifierBase GetModifier ( int modifier_id)

Definition at line 297 of file ModifiersManager.c.

298 {
299 return m_ModifierList.Get(modifier_id);
300 }

References m_ModifierList.

Referenced by OnStoreLoad().

◆ GetModifierLock()

bool GetModifierLock ( int modifier_id)

Definition at line 313 of file ModifiersManager.c.

314 {
315 return m_ModifierList.Get(modifier_id).IsLocked();
316 }

References m_ModifierList.

◆ GetPlayer()

PlayerBase GetPlayer ( )

Definition at line 302 of file ModifiersManager.c.

303 {
304 return m_Player;
305 }

References m_Player.

◆ GetStorageVersion()

int GetStorageVersion ( )

Definition at line 167 of file ModifiersManager.c.

168 {
169 return STORAGE_VERSION;
170 }
const int STORAGE_VERSION

References STORAGE_VERSION.

Referenced by ManBase::OnStoreLoad().

◆ Init()

void Init ( )

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

Definition at line 88 of file ModifiersManager.c.

89 {
90#ifdef DEVELOPER
92#endif
94 //AddModifier(new BoneRegen);
95 //AddModifier(new Health);
99 //AddModifier(new Shock);
105 //AddModifier(new Blinded);
106 //AddModifier(new BrokenArms);
107 AddModifier(new BrokenLegsMdfr); // <-- Broken legs are here
115 //AddModifier(new Tremor);
123 AddModifier(new WetMdfr);
145 }
void AddModifier(ModifierBase modifier)
Definition Mask.c:2
Definition Wet.c:2

References AddModifier().

◆ IsModifierActive()

bool IsModifierActive ( eModifiers modifier_id)

Definition at line 190 of file ModifiersManager.c.

191 {
192 return m_ModifierList.Get(modifier_id).IsActive();
193 }

References m_ModifierList.

◆ IsModifiersEnable()

bool IsModifiersEnable ( )

Definition at line 172 of file ModifiersManager.c.

173 {
174 return m_AllowModifierTick;
175 }
bool m_AllowModifierTick

References m_AllowModifierTick.

◆ ModifiersManager()

void ModifiersManager ( PlayerBase player)

Definition at line 79 of file ModifiersManager.c.

80 {
84
85 Init();
86 }
void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
ref array< ref Param > m_ParamList

References Init(), m_ModifierList, m_ParamList, and m_Player.

Referenced by PluginBase::ActivateModifier(), PluginBase::DeactivateModifier(), ManBase::Init(), PluginBase::IsModifierLocked(), PluginBase::LockModifier(), PluginBase::SendRPCMods(), and PluginBase::SendRPCModsDetail().

◆ OnScheduledTick()

void OnScheduledTick ( float delta_time)

Definition at line 195 of file ModifiersManager.c.

196 {
197 if (!m_AllowModifierTick) return;
198
201
202 }
void Tick()

References m_AllowModifierTick, and m_ModifierListArray.

◆ OnStoreLoad()

bool OnStoreLoad ( ParamsReadContext ctx,
int version )

Definition at line 259 of file ModifiersManager.c.

260 {
261 int modifier_count;
262 if (!ctx.Read(modifier_count))
263 return false;
264 //PrintString("Loading modifiers count: "+ modifier_count);
265 for (int i = 0; i < modifier_count; i++)
266 {
267 int modifier_id;
268 if (!ctx.Read(modifier_id))
269 return false;
270 //PrintString( "loading item: "+modifier_id );
271 //int modifier_id = CachedObjectsParams.PARAM1_INT.param1;
273 if (modifier)
274 {
275 if (modifier.IsTrackAttachedTime())
276 {
277 int time;
278 if (!ctx.Read(time)) //get the attached time
279 return false;
280 modifier.SetAttachedTime(time);
281 }
282
283 ActivateModifier(modifier_id, EActivationType.TRIGGER_EVENT_ON_CONNECT);
284 }
285 else
286 Debug.LogError("DB loading: non-existent modifier with id:" + modifier_id.ToString());
287 }
288
289 for (int x = 0; x < m_ParamList.Count(); x++)
290 {
291 if (!m_ParamList.Get(x).Deserializer(ctx))
292 return false;
293 }
294 return true;
295 }
Icon x
ModifierBase GetModifier(int modifier_id)
void ActivateModifier(int modifier_id, bool triggerEvent=EActivationType.TRIGGER_EVENT_ON_ACTIVATION)
EActivationType
Definition Debug.c:14
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Definition Debug.c:341

References ActivateModifier(), GetModifier(), Debug::LogError(), m_ParamList, and x.

Referenced by Weapon::CopyWeaponStateFrom(), and ManBase::OnStoreLoad().

◆ OnStoreSave()

void OnStoreSave ( ParamsWriteContext ctx)

Definition at line 220 of file ModifiersManager.c.

221 {
223
224 int modifier_count;
225 for (int x = 0; x < m_ModifierList.Count(); x++)
226 {
227 ModifierBase mdfr = m_ModifierList.GetElement(x);
228 if (mdfr.IsActive() && mdfr.IsPersistent())
229 {
231 //save the modifier id
232 CachedObjectsArrays.ARRAY_INT.Insert(mdfr.GetModifierID());
233 if (mdfr.IsTrackAttachedTime())
234 {
235 //save the overall attached time
236 CachedObjectsArrays.ARRAY_INT.Insert(mdfr.GetAttachedTime());
237 }
238 }
239 }
240
241 //write the count
242 //CachedObjectsParams.PARAM1_INT.param1 = modifier_count;
243 //PrintString("Saving modifiers count: "+ modifier_count);
244 ctx.Write(modifier_count);
245
246 //write the individual modifiers and respective attached times
247 for (int i = 0; i < CachedObjectsArrays.ARRAY_INT.Count(); i++)
248 {
250 //PrintString( "saving item: "+item );
251 ctx.Write(item);
252 }
253
254 for (int z = 0; z < m_ParamList.Count(); z++)
255 m_ParamList.Get(z).Serialize(ctx);
256
257 }
static ref TIntArray ARRAY_INT

References CachedObjectsArrays::ARRAY_INT, m_ModifierList, m_ParamList, and x.

◆ ResetAll()

void ResetAll ( )

Definition at line 341 of file ModifiersManager.c.

342 {
343 bool hasAreaExposureModifier = IsModifierActive(eModifiers.MDF_AREAEXPOSURE);
345
347
349 ActivateModifier(eModifiers.MDF_AREAEXPOSURE);
350
351 if (hasMaksModifier)
353 }
void DeactivateAllModifiers()
proto native bool IsModifierActive()
is modifier active

References ActivateModifier(), DeactivateAllModifiers(), and IsModifierActive().

◆ SetModifierLock()

void SetModifierLock ( int modifier_id,
bool state )

Definition at line 307 of file ModifiersManager.c.

308 {
309 m_ModifierList.Get(modifier_id).SetLock(state);
310 }

References m_ModifierList.

◆ SetModifiers()

void SetModifiers ( bool enable)

Definition at line 147 of file ModifiersManager.c.

148 {
150 return;
151
153
154#ifdef DIAG_DEVELOPER
155#ifndef SERVER
156 DiagMenu.SetValue(DiagMenuIDs.CHEATS_MODIFIERS, enable);
157#endif
158#endif
159
160 if (!enable)
161 {
162 for (int i = 0; i < m_ModifierList.Count(); i++)
163 m_ModifierList.GetElement(i).ResetLastTickTime();
164 }
165 }
DiagMenuIDs
Definition EDiagMenuIDs.c:2
static proto void SetValue(int id, int value)
Set value at the given script id.

References m_AllowModifierTick, m_ModifierList, and DiagMenu::SetValue().

Variable Documentation

◆ DEFAULT_TICK_TIME_ACTIVE

◆ DEFAULT_TICK_TIME_ACTIVE_SHORT

const int DEFAULT_TICK_TIME_ACTIVE_SHORT = 1

◆ DEFAULT_TICK_TIME_INACTIVE

◆ DEFAULT_TICK_TIME_INACTIVE_LONG

const int DEFAULT_TICK_TIME_INACTIVE_LONG = 10

Definition at line 33 of file ModifiersManager.c.

Referenced by AreaExposureMdfr::Init(), and FatigueMdfr::Init().

◆ m_AllowModifierTick

bool m_AllowModifierTick = false

Definition at line 77 of file ModifiersManager.c.

Referenced by IsModifiersEnable(), OnScheduledTick(), and SetModifiers().

◆ m_ModifierList

◆ m_ModifierListArray

ref array< ref ModifierBase> m_ModifierListArray = new array< ref ModifierBase>

Definition at line 75 of file ModifiersManager.c.

Referenced by AddModifier(), and OnScheduledTick().

◆ m_ParamList

ref array<ref Param> m_ParamList

Definition at line 76 of file ModifiersManager.c.

Referenced by ModifiersManager(), OnStoreLoad(), and OnStoreSave().

◆ m_Player

◆ STORAGE_VERSION

const int STORAGE_VERSION = 121