Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
playerbase.c
Go to the documentation of this file.
1 class PlayerBase extends ManBase
2 {
3  const int SIMPLIFIED_SHOCK_CAP = 63;
4  const int SHAKE_LEVEL_MAX = 7;
5  private int m_LifeSpanState;
6  private int m_LastShavedSeconds;
7  private int m_BloodType;
8  private bool m_HasBloodTypeVisible;
9  private bool m_LiquidTendencyDrain; //client-side only - Obsolete
10  private bool m_FlagRaisingTendency;
11  private int m_HasBloodyHandsVisible;
12  private int m_FaceCoveredForShaveLayers = 0; //DEPRECATED
13  protected bool m_HasHeatBuffer;
14  protected bool m_PlayerLoaded;
15  protected bool m_PlayerDisconnectProcessed;
16  protected bool m_ProcessUIWarning;
17  protected int m_LocalRefreshAnimStateIdx;
18  protected int m_RefreshAnimStateIdx;
19  private int m_StoreLoadVersion;
20  const int ACT_STORE_SAVE_VERSION = 4;
21  protected int m_LifespanLevelLocal; //control variable for change calls
22  protected int m_AnimCommandStarting; //signals the command that is about to start the next frame (e.g. Swim, Fall...)
23  EUndergroundPresence m_UndergroundPresence;
24 
25  private PluginPlayerStatus m_ModulePlayerStatus;
26  PluginConfigEmotesProfile m_ConfigEmotesProfile;
27  private PluginLifespan m_ModuleLifespan;
28  protected PluginPresenceNotifier m_PresenceNotifier;
29 
30  protected ref UndergroundHandlerClient m_UndergroundHandler;
32  PluginRecipesManager m_ModuleRecipesManager;
33  ref BleedingSourcesManagerServer m_BleedingManagerServer;
34  ref BleedingSourcesManagerRemote m_BleedingManagerRemote;
35  ref ModifiersManager m_ModifiersManager;
36  ref NotifiersManager m_NotifiersManager;
37  ref protected ActionManagerBase m_ActionManager;
38  //ref PlayerLightManager m_PlayerLightManager;
39  ref PlayerAgentPool m_AgentPool;
40  int m_Agents;
41  ref Environment m_Environment;
42  ref EmoteManager m_EmoteManager;
43  ref SymptomManager m_SymptomManager;
46  ref InjuryAnimationHandler m_InjuryHandler;
47  ref ShockHandler m_ShockHandler; //New shock handler
48  ref SoftSkillsManager m_SoftSkillsManager;
49  ref StanceIndicator m_StanceIndicator;
50  ref TransferValues m_TrasferValues;
51  ref DebugMonitorValues m_DebugMonitorValues;
52  const int OVERLOAD_LIMIT = 30000;
53  float m_CargoLoad;
54  float m_VisibilityCoef;
55  float m_OriginalSlidePoseAngle;
56  int m_SoundEvent;
57  int m_SoundEventParam;
58  int m_FliesIndex;
59  bool m_SoundEventSent;
60  ref Param2<float,float> m_UAProgressParam;
61  ref Param2<int,int> m_UAParam;
62  ref Param3<float,float,bool> m_StaminaParam;
63  ref Param1<string> m_UAParamMessage;
64  ref Param1<float> m_UnconParam;
65  ref Param1<float> m_DeathDarkeningParam;
66  ref DamageDealtEffect m_DamageDealtEffect;
67  ref EffectRadial m_EffectRadial;
68  ref FlashbangEffect m_FlashbangEffect;
69  ref ShockDealtEffect m_ShockDealtEffect;
70  ref EffectParticle m_FliesEff;
71  ref TInputActionMap m_InputActionMap; // Backwards compatibility
72  ref TInputActionMap m_InputActionMapControled;
73  ref TInputActionMap m_InputActionMapAsTarget;
75  //ref CraftingMeta m_CraftingMeta;
76  ref HiddenSelectionsData m_EmptyGloves;
77  ref WeaponManager m_WeaponManager;
78  ref CraftingManager m_CraftingManager;
80  ref InventoryActionHandler m_InventoryActionHandler;
81  ref protected QuickBarBase m_QuickBarBase;
82  ref PlayerSoundManagerServer m_PlayerSoundManagerServer;
83  ref PlayerSoundManagerClient m_PlayerSoundManagerClient;
84  ref HeatComfortAnimHandler m_HCAnimHandler;
85  ref EffectSound m_SoundFliesEffect;
86  bool m_QuickBarHold;
87  bool m_QuickBarFT = false;
88  Hud m_Hud;
89  protected int m_RecipePick;
90  protected bool m_IsHoldingBreath;
91  protected bool m_IsInWater;
92  float m_LastPostFrameTickTime;
93  //AbstractWave m_SaySoundWave;
94  ref Timer m_DeathCheckTimer;
95  bool m_CorpseProcessing;
96  int m_CorpseState;
97  protected int m_CorpseStateLocal;
98 
99  int m_PersistentFlags;
100  int m_StaminaState;
101  float m_UnconsciousTime;
102  int m_ShockSimplified;
103  float m_CurrentShock; //Used to synchronize shock between server and client
104  bool m_IsRestrained;
105  bool m_IsRestrainStarted;
106  bool m_IsRestrainPrelocked;
107  bool m_ImmunityBoosted;
108  bool m_AreHandsLocked; //Currently only used to block quickbar usage after canceling placement
109  float m_UnconsciousVignetteTarget = 2;
110  float m_CameraSwayModifier = 0.2;
111  float m_LastShockHitTime;
112  DayZPlayerCameraBase m_CurrentCamera;
113  int m_BleedingBits;
114  vector m_DirectionToCursor;
115  vector m_DefaultHitPosition;
116  int m_DiseaseCount;
117  int m_HealingsCount;
118  protected bool m_AllowQuickRestrain;
119  protected bool m_AllowQuickFishing;
120  protected int m_Shakes;
121  protected int m_ShakesForced;
122  int m_BreathVapour;
123  int m_HealthLevel;
124  int m_MixedSoundStates;
125  int m_QuickBarBonus = 0;
126  bool m_IsVehicleSeatDriver;
127  float m_UnconsciousEndTime = 0;
128  int m_BleedingSourceCount;
129  Head_Default m_CharactersHead;
130  EPulseType m_PulseType;
131  PlayerBase m_CheckPulseLastTarget;
133  //string m_sOpticsType;
134  bool m_HideHairAnimated;
135  string m_DecayedTexture;
136  protected ref array<EntityAI> m_ItemsToDelete;
137  int m_BrokenLegState = eBrokenLegs.NO_BROKEN_LEGS; //Describe the current leg state, can go bellow 0, cannot be used directly to obtain broken legs state, use GetBrokenLegs() instead
138  int m_LocalBrokenState = eBrokenLegs.NO_BROKEN_LEGS;
139  bool m_BrokenLegsJunctureReceived;
140  ref EffectSound m_BrokenLegSound;
141  const string SOUND_BREAK_LEG = "broken_leg_SoundSet";
142  bool m_CanPlayBrokenLegSound; //Used to check if sound has already been played
143  static bool DEBUG_INVENTORY_ACCESS = false;
144  static ref array<string> m_BleedingSourcesLow; //Stores all LOWER body part bleeding sources
145  static ref array<string> m_BleedingSourcesUp; //Stores all UPPER body part bleeding sources EXCLUDING HEAD
146  float m_UnconRefillModifier = 1;
147  ref protected RandomGeneratorSyncManager m_RGSManager;
148  int m_AntibioticsActive;//ref count for antibiotics activation
149 
150  // CONTAMINATED AREA RELATED
151  bool m_ContaminatedAreaEffectEnabled;
152  const string CONTAMINATED_AREA_AMBIENT = "ContaminatedArea_SoundSet";//obsolete, use EffectTrigger::GetAmbientSoundsetName() instead
153  EffectSound m_AmbientContamination;
154  protected int m_ContaminatedAreaCount;
155  protected int m_EffectAreaCount;
156  protected bool m_InsideEffectArea;
157  protected bool m_InsideEffectAreaPrev;
158  protected EffectTrigger m_CurrentEffectTrigger;
159 
160  static ref array<Man> m_ServerPlayers = new array<Man>;
161  protected bool m_CanDisplayHitEffectPPE;
162 
163  protected string m_CachedPlayerName;//cached from player identity
164  protected string m_CachedPlayerID;//cached from player identity
165 
166 
167  #ifdef DIAG_DEVELOPER
168  int m_IsInsideTrigger;
169  bool m_CanBeTargetedDebug; //server-side only
170  ref array<EntityAI> m_PresetItems = new array<EntityAI>;
171  bool m_PresetSpawned;
172  ref CameraToolsMenuClient m_CameraToolsMenuClient;
173  #endif
174 
175  #ifdef DEVELOPER
176  Transport m_GetInVehicleTransportDebug;
177  #endif
178 
179  #ifdef BOT
180  ref Bot m_Bot;
181  #endif
182 
183  //Temp QuickBar load
184  ref array<ref Param2<EntityAI,int> > m_aQuickBarLoad;
185 
186  //hologram
187  ref Hologram m_HologramServer;
188  ref Hologram m_HologramLocal;
189  vector m_LocalProjectionPosition = "0 0 0 ";
190  vector m_LocalProjectionOrientation = "0 0 0 ";
191 
192  //Sheduler
193  float m_LastTick = -1;
194  int m_AddModifier = -1;
195  //crafting start
196  int m_RecipeID = -1;
197  EntityAI m_Item1;
198  EntityAI m_Item2;
199  bool m_IsCraftingReady;
200  float m_RecipeAnimLength;
201  vector m_CraftingInitialPos;
202  ref array<int> m_Recipes;
203  //crafting end
204  ref SoundParams m_SaySoundParams;
205  ref SoundObjectBuilder m_SaySoundBuilder;
206  ref SoundObject m_SaySoundObject;
207  string m_SaySoundLastSetName;
208  //input control
209  bool m_ActionQBControl;
210 
211  //Action data for base building actions
212  ref ConstructionActionData m_ConstructionActionData;
213  //Action data for fireplace (indoor)
214  vector m_LastFirePoint;
215  float m_LastFirePointRot;
216  int m_LastFirePointIndex;
217 
218  bool ItemToInventory;
219  bool m_IsFighting = false;
220  bool m_IsDrowning;//Set only via the setter SetDrowning
221 
222  // debug monitor
223  int m_DebugMonitorEnabled;
224 
225  //map
226  ActionUnfoldMapCB m_hac;
227  bool m_MapOpen;
228  bool m_MapCloseRequestProcessed; //DEPRECATED
229  protected bool m_MapClosingSyncSent;
230  protected float m_LastMapScale = -1.0;
231  protected vector m_LastMapPos;
232  protected ref MapNavigationBehaviour m_MapNavigationBehaviour;
233 
234  //inventory soft locking
235  protected bool m_InventorySoftLocked; //obsolete, count should be checked instead. Left in here for legacy's sake.
236  protected int m_InventorySoftLockCount = 0;
237  static ref TStringArray m_QBarItems;
238 
239  //Analytics
240  string m_DatabaseID;
241  ref Timer m_AnalyticsTimer;
242 
244  protected bool m_MeleeDebug;
245  //protected bool m_CheckMeleeItem;
246  protected ItemBase m_CheckMeleeItem;
247 
249  protected string m_UALastMessage;
250  protected ref Timer m_UALastMessageTimer;
251 
252  bool m_WorkingNVGHeadset; //Deprecated
253  bool m_LoweredNVGHeadset;
254  protected ref array<int> m_ActiveNVTypes;
255  //bool m_PreviousNVGState;
256  int m_SyncedModifiers;
257  int m_SyncedModifiersPrev;
258  PluginAdminLog m_AdminLog;
259  ref PlayerStomach m_PlayerStomach;
260 
261  protected static Particle m_ContaminatedAroundPlayer;
262  protected static Particle m_ContaminatedAroundPlayerTiny;
263 
264  protected PlayerStat<float> m_StatWater;
265  protected PlayerStat<float> m_StatToxicity;
266  protected PlayerStat<float> m_StatEnergy;
267  protected PlayerStat<float> m_StatHeatComfort;
268  protected PlayerStat<float> m_StatTremor;
269  protected PlayerStat<int> m_StatWet
270  protected PlayerStat<int> m_StatBloodType
271  protected PlayerStat<float> m_StatDiet
272  protected PlayerStat<float> m_StatStamina
273  protected PlayerStat<float> m_StatSpecialty
274  protected PlayerStat<float> m_StatHeatBuffer
275 
277  protected GameplayEffectWidgets_base m_EffectWidgets;
278  protected ref array<int> m_ProcessAddEffectWidgets;
279  protected ref array<int> m_ProcessRemoveEffectWidgets;
280 
281  //postprocess processing
282  protected ref array<int> m_ProcessAddGlassesEffects;
283  protected ref array<int> m_ProcessRemoveGlassesEffects;
284 
285  void PlayerBase()
286  {
287  Init();
288  }
289 
290  void Init()
291  {
292  SetEventMask(EntityEvent.INIT|EntityEvent.POSTFRAME|EntityEvent.FRAME);
293  m_StoreLoadVersion = 0;
294  m_IsCraftingReady = false;
295  m_Recipes = new array<int>;
296  m_LastShavedSeconds = 0;
297  m_BloodType = 0;
298  m_HasBloodTypeVisible = false;
299  m_LifeSpanState = 0;
300  m_LifespanLevelLocal = -1;
301  m_CorpseState = 0;
302  m_CorpseStateLocal = 0;
303  m_HasBloodyHandsVisible = 0;
304  m_PlayerLoaded = false;
305  m_PlayerSelected = false;
306  m_ProcessUIWarning = false;
307  m_FlagRaisingTendency = true;
308  m_LiquidTendencyDrain = false;
309  m_UAParamMessage = new Param1<string>("");
310  m_UnconParam = new Param1<float>(0);
311  m_DeathDarkeningParam = new Param1<float>(0);
312  m_UAParam = new Param2<int,int>(0,0);
313  m_UAProgressParam = new Param2<float,float>(0,0);
314  m_QuickBarBase = new QuickBarBase(this);
315  m_QuickBarBonus = Math.Max(ConfigGetInt("quickBarBonus"), 0);
316  m_CargoLoad = 0;
317  m_VisibilityCoef = 1.0;
318  m_Hud = GetGame().GetMission().GetHud();
319  m_RecipePick = 0;
320  m_ActionQBControl = false;
321  m_QuickBarHold = false;
322  m_HideHairAnimated = true;
323  m_WorkingNVGHeadset = false;
324  m_LoweredNVGHeadset = false;
325  m_AreHandsLocked = false;
326  m_ItemsToDelete = new array<EntityAI>;
327  m_AnimCommandStarting = HumanMoveCommandID.None;
328  m_EmptyGloves = new HiddenSelectionsData(ConfigGetString("emptyGloves"));
329  m_CanDisplayHitEffectPPE = true;
330 
331  #ifdef DIAG_DEVELOPER
332  m_CanBeTargetedDebug = true;
333  //RegisterNetSyncVariableBool("m_CanBeTargetedDebug");
334  #endif
335 
336  m_AnalyticsTimer = new Timer(CALL_CATEGORY_SYSTEM);
337 
338  m_StaminaHandler = new StaminaHandler(this);//current stamina calculation
339  m_InjuryHandler = new InjuryAnimationHandler(this);
340  m_ShockHandler = new ShockHandler(this); //New shock handler
341  m_HCAnimHandler = new HeatComfortAnimHandler(this);
342  m_PlayerStats = new PlayerStats(this);//player stats
344 
345  if (GetGame().IsServer())
346  {
347  m_PlayerStomach = new PlayerStomach(this);
348  m_NotifiersManager = new NotifiersManager(this); // player notifiers
349  m_AgentPool = new PlayerAgentPool(this); // agent pool manager
350  m_BleedingManagerServer = new BleedingSourcesManagerServer(this);
351  m_Environment = new Environment(this);//environment effects on player
352  m_ModifiersManager = new ModifiersManager(this); // player modifiers
353  m_PlayerSoundManagerServer = new PlayerSoundManagerServer(this);
354  m_VirtualHud = new VirtualHud(this);
355 
356  m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
357  }
358 
359  m_SymptomManager = new SymptomManager(this); // state manager
360  m_ModuleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
361 
362  m_TrasferValues = new TransferValues(this);
363  m_EmoteManager = new EmoteManager(this);
364  m_SoftSkillsManager = new SoftSkillsManager(this);//Soft Skills calculation
365 
366  m_WeaponManager = new WeaponManager(this);
367  m_DebugMonitorValues = new DebugMonitorValues(this);
368  m_RGSManager = new RandomGeneratorSyncManager(this);
369 
370  if (!GetGame().IsDedicatedServer())
371  {
372  m_MeleeDebug = false;
373  m_UALastMessage = "";
374  m_UALastMessageTimer = new Timer;
375  m_InventoryActionHandler = new InventoryActionHandler(this);
376  m_BleedingManagerRemote = new BleedingSourcesManagerRemote(this);
377  m_PlayerSoundManagerClient = new PlayerSoundManagerClient(this);
378  m_StanceIndicator = new StanceIndicator(this);
379  m_ActionsInitialize = false;
380  ClientData.AddPlayerBase(this);
381 
382  m_ProcessAddEffectWidgets = new array<int>;
383  m_ProcessRemoveEffectWidgets = new array<int>;
384  m_ActiveNVTypes = new array<int>;
385  m_ProcessAddGlassesEffects = new array<int>;
386  m_ProcessRemoveGlassesEffects = new array<int>;
387  }
388 
389  m_ActionManager = NULL;
390  //m_PlayerLightManager = NULL;
391 
392  m_ConfigEmotesProfile = PluginConfigEmotesProfile.Cast(GetPlugin(PluginConfigEmotesProfile));
393 
394  if (GetDayZGame().IsDebug())
395  {
396  PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed = PluginConfigDebugProfileFixed.Cast(GetPlugin(PluginConfigDebugProfileFixed));
398  PluginDeveloper m_Developer = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
399 
400  PlayerBase player = this;
401 
403  {
404  string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
405  if (player && default_preset != "")
406  {
407  TStringArray preset_array = new TStringArray;
408  m_ConfigDebugProfileFixed.GetPresetItems(default_preset, preset_array);
409 
410  bool is_preset_fixed = true;
411  if (preset_array.Count() == 0)
412  {
413  m_ConfigDebugProfile.GetPresetItems(default_preset, preset_array);
414  is_preset_fixed = false;
415  }
416 
417  if (preset_array.Count() > 0)
418  {
419  m_Developer.ClearInventory(player);
420 
421  for (int i = 0; i < preset_array.Count(); i++)
422  {
423  float health = -1;
424  int quantity = -1;
425  if (is_preset_fixed)
426  {
427  health = m_ConfigDebugProfileFixed.GetItemHealth(default_preset, i);
428  quantity = m_ConfigDebugProfileFixed.GetItemQuantity(default_preset, i);
429  }
430  else
431  {
432  health = m_ConfigDebugProfile.GetItemHealth(default_preset, i);
433  quantity = m_ConfigDebugProfile.GetItemQuantity(default_preset, i);
434  }
435  m_Developer.SpawnEntityInPlayerInventory(player, preset_array.Get(i), health, quantity);
436  }
437  }
438  }
439  }
440  }
441 
442  m_MapNavigationBehaviour = new MapNavigationBehaviour(this);
443 
444  m_ModulePlayerStatus = PluginPlayerStatus.Cast(GetPlugin(PluginPlayerStatus));
445  m_ModuleLifespan = PluginLifespan.Cast(GetPlugin(PluginLifespan));
446 
447  m_BleedingSourcesLow = new array<string>;
448  m_BleedingSourcesLow.Insert("RightToeBase");
449  m_BleedingSourcesLow.Insert("RightFoot");
450  m_BleedingSourcesLow.Insert("LeftToeBase");
451  m_BleedingSourcesLow.Insert("LeftFoot");
452  m_BleedingSourcesLow.Insert("RightUpLegRoll");
453  m_BleedingSourcesLow.Insert("RightUpLeg");
454  m_BleedingSourcesLow.Insert("RightLegRoll");
455  m_BleedingSourcesLow.Insert("RightLeg");
456  m_BleedingSourcesLow.Insert("LeftUpLegRoll");
457  m_BleedingSourcesLow.Insert("LeftUpLeg");
458  m_BleedingSourcesLow.Insert("LeftLegRoll");
459  m_BleedingSourcesLow.Insert("LeftLeg");
460 
461  m_BleedingSourcesUp = new array<string>;
462  m_BleedingSourcesUp.Insert("RightForeArmRoll");
463  m_BleedingSourcesUp.Insert("LeftForeArmRoll");
464  m_BleedingSourcesUp.Insert("RightForeArm");
465  m_BleedingSourcesUp.Insert("RightArmRoll");
466  m_BleedingSourcesUp.Insert("RightArm");
467  m_BleedingSourcesUp.Insert("RightShoulder");
468  m_BleedingSourcesUp.Insert("LeftForeArm");
469  m_BleedingSourcesUp.Insert("LeftArmRoll");
470  m_BleedingSourcesUp.Insert("LeftArm");
471  m_BleedingSourcesUp.Insert("LeftShoulder");
472  m_BleedingSourcesUp.Insert("Spine3");
473  m_BleedingSourcesUp.Insert("Spine2");
474  m_BleedingSourcesUp.Insert("Spine1");
475  m_BleedingSourcesUp.Insert("Spine");
476  m_BleedingSourcesUp.Insert("Pelvis");
477  m_BleedingSourcesUp.Insert("Neck");
478 
479  RegisterNetSyncVariableInt("m_LifeSpanState", LifeSpanState.BEARD_NONE, LifeSpanState.COUNT);
480  RegisterNetSyncVariableInt("m_BloodType", 0, 128);
481  RegisterNetSyncVariableInt("m_ShockSimplified",0, SIMPLIFIED_SHOCK_CAP);
482  RegisterNetSyncVariableInt("m_SoundEvent",0, EPlayerSoundEventID.ENUM_COUNT - 1);
483  RegisterNetSyncVariableInt("m_SoundEventParam", 0, ((EPlayerSoundEventParam.ENUM_COUNT - 1) * 2) - 1);
484  RegisterNetSyncVariableInt("m_StaminaState",0, eStaminaState.COUNT - 1);
485  RegisterNetSyncVariableInt("m_BleedingBits");
486  RegisterNetSyncVariableInt("m_Shakes", 0, SHAKE_LEVEL_MAX);
487  RegisterNetSyncVariableInt("m_BreathVapour", 0, BREATH_VAPOUR_LEVEL_MAX);
488  RegisterNetSyncVariableInt("m_HealthLevel", eInjuryHandlerLevels.PRISTINE, eInjuryHandlerLevels.RUINED);
489  RegisterNetSyncVariableInt("m_MixedSoundStates", 0, eMixedSoundStates.COUNT - 1);
490  RegisterNetSyncVariableInt("m_CorpseState",-PlayerConstants.CORPSE_STATE_DECAYED,PlayerConstants.CORPSE_STATE_DECAYED);//do note the negative min, negative sign denotes a special meaning
491  RegisterNetSyncVariableInt("m_RefreshAnimStateIdx",0,3);
492  RegisterNetSyncVariableInt("m_BrokenLegState", -eBrokenLegs.BROKEN_LEGS_SPLINT, eBrokenLegs.BROKEN_LEGS_SPLINT);
493  RegisterNetSyncVariableInt("m_SyncedModifiers", 0, ((eModifierSyncIDs.LAST_INDEX - 1) * 2) - 1);
494  RegisterNetSyncVariableInt("m_HasBloodyHandsVisible", 0, eBloodyHandsTypes.LAST_INDEX - 1);
495  RegisterNetSyncVariableInt("m_ActionSoundCategoryHash");
496 
497  RegisterNetSyncVariableBool("m_IsUnconscious");
498  RegisterNetSyncVariableBool("m_IsRestrained");
499  RegisterNetSyncVariableBool("m_IsInWater");
500  RegisterNetSyncVariableBool("m_InsideEffectArea");
501 
502  RegisterNetSyncVariableBool("m_HasBloodTypeVisible");
503  //RegisterNetSyncVariableBool("m_LiquidTendencyDrain");
504  RegisterNetSyncVariableBool("m_IsRestrainStarted");
505  RegisterNetSyncVariableBool("m_IsRestrainPrelocked");
506  RegisterNetSyncVariableBool("m_HasHeatBuffer");
507 
508  RegisterNetSyncVariableFloat("m_CurrentShock"); //Register shock synchronized variable
509 
510  m_OriginalSlidePoseAngle = GetSlidePoseAngle();
511 
513  m_DefaultHitPosition = SetDefaultHitPosition(GetDayZPlayerType().GetDefaultHitPositionComponent());
514 
515  m_DecayedTexture = ConfigGetString("decayedTexture");
516  m_FliesIndex = -1;
517  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(this.OnPlayerLoaded);
518  }
519 
520  void IncreaseAntibioticsCount()
521  {
522  m_AntibioticsActive++;
523  }
524 
525  void DecreaseAntibioticsCount()
526  {
527  m_AntibioticsActive--;
528  if (m_AntibioticsActive < 0)
529  {
530  m_AntibioticsActive = 0;
531  Error("DecreaseAntibioticsCount called more times than IncreaseAntibioticsCount (should be equal) - check your code, forcing clamp to 0");
532  }
533  }
534 
535  bool IsAntibioticsActive()
536  {
537  return (m_AntibioticsActive > 0);
538  }
539 
540  void SetSoundCategoryHash(int hash)
541  {
542  m_ActionSoundCategoryHash = hash;
543  SetSynchDirty();
544  }
545 
546 
547  void RequestTriggerEffect(EffectTrigger trigger, int ppeIdx = -1, int aroundId = ParticleList.CONTAMINATED_AREA_GAS_AROUND, int tinyId = ParticleList.CONTAMINATED_AREA_GAS_TINY, string soundset = "", bool partDynaUpdate = false, int newBirthRate = 0, bool forceUpdate = false)
548  {
549  //do note multiple triggers can be calling this method within a single frame depending on the contaminated area setup and dynamic gameplay events(such as gas grenades being deployed)
550 
551  if (!m_InsideEffectArea)
552  return;
553  bool allow = false;
554  if (!m_CurrentEffectTrigger)
555  {
556  allow = true;
557  }
558  else if (trigger == m_CurrentEffectTrigger && forceUpdate)
559  {
560  allow = true;
561  //Print("ON Enabling effect FORCED " + trigger);
562  }
563  else if (trigger.GetEffectsPriority() > m_CurrentEffectTrigger.GetEffectsPriority())
564  {
565  RemoveCurrentEffectTrigger();
566  allow = true;
567  }
568  if (allow)
569  {
570  /*
571  Print("--------------------------------------------------");
572  Print("ON Enabling effect " + trigger);
573  Print("------------> soundset " + soundset);
574  Print("--------------------------------------------------");
575  */
576  m_CurrentEffectTrigger = trigger;
577  SetContaminatedEffectEx( true, ppeIdx, aroundId, tinyId, soundset,partDynaUpdate, newBirthRate );
578  }
579  }
580 
581 
582  void RemoveCurrentEffectTrigger()
583  {
584  if (m_CurrentEffectTrigger)
585  {
586  /*
587  Print("--------------------------------------------------");
588  Print("OFF Disabling effect");
589  Print("--------------------------------------------------");
590  */
591  SetContaminatedEffectEx( false, m_CurrentEffectTrigger.m_PPERequester );
592  m_CurrentEffectTrigger = null;
593  }
594  }
595 
596  void IncreaseContaminatedAreaCount()
597  {
598  if (m_ContaminatedAreaCount == 0)
599  OnContaminatedAreaEnterServer();
600  m_ContaminatedAreaCount++;
601  }
602 
603  void DecreaseContaminatedAreaCount()
604  {
605  m_ContaminatedAreaCount--;
606  if (m_ContaminatedAreaCount <= 0)
607  {
608  m_ContaminatedAreaCount = 0;
609  OnContaminatedAreaExitServer();
610  }
611  }
612  void IncreaseEffectAreaCount()
613  {
614  if (m_EffectAreaCount == 0)
615  {
616  m_InsideEffectArea = true;
617  SetSynchDirty();
618  OnPlayerIsNowInsideEffectAreaBeginServer();
619  }
620  m_EffectAreaCount++;
621  }
622 
623  void DecreaseEffectAreaCount()
624  {
625  m_EffectAreaCount--;
626  if (m_EffectAreaCount <= 0)
627  {
628  m_EffectAreaCount = 0;
629  m_InsideEffectArea = false;
630  SetSynchDirty();
631  OnPlayerIsNowInsideEffectAreaEndServer();
632  }
633  }
634 
635 
636  protected void OnContaminatedAreaEnterServer()
637  {
638  GetModifiersManager().ActivateModifier( eModifiers.MDF_AREAEXPOSURE );
639  //Print("Contaminated ENTERED <------------------------------------------------------------- FINAL");
640  }
641 
642  protected void OnContaminatedAreaExitServer()
643  {
644  GetModifiersManager().DeactivateModifier( eModifiers.MDF_AREAEXPOSURE );
645  //Print("Contaminated LEFT <------------------------------------------------------------- FINAL");
646  }
647 
648  protected void OnPlayerIsNowInsideEffectAreaBeginServer()
649  {
650  //Print("ANY EFFECT AREA ENTERED <------------------------------------------------------------- FINAL");
651  }
652 
653  protected void OnPlayerIsNowInsideEffectAreaEndServer()
654  {
655  //Print("ANY EFFECT AREA LEFT <------------------------------------------------------------- FINAL");
656  }
657 
658  protected void OnPlayerIsNowInsideEffectAreaBeginClient()
659  {
660  //Print("ANY EFFECT AREA ENTERED CLIENT <------------------------------------------------------------- FINAL");
661  }
662 
663  protected void OnPlayerIsNowInsideEffectAreaEndClient()
664  {
665  RemoveCurrentEffectTrigger();
666  //Print("ANY EFFECT AREA LEFT CLIENT <------------------------------------------------------------- FINAL");
667  }
668 
670  ItemBase GetItemOnSlot(string slot_type)
671  {
672  int slot_id = InventorySlots.GetSlotIdFromString(slot_type);
673  EntityAI item_EAI = this.GetInventory().FindAttachment(slot_id);
674  ItemBase item_IB = ItemBase.Cast(item_EAI);
675 
676  if (item_EAI && !item_IB)
677  {
678  string str = "Warning! GetItemOnSlot() >> found item on slot " + slot_type + " can't be cast to ItemBase! Found item is " + item_EAI.GetType() + " and the player is " + GetType() + "!";
679  Error(str);
680  return null;
681  }
682 
683  return item_IB;
684  }
685 
687  ItemBase GetItemOnHead()
688  {
689  return GetItemOnSlot("Headgear");
690  }
691 
692  override int GetQuickBarBonus()
693  {
694  return m_QuickBarBonus;
695  }
696 
697  //--------------------------------------------------------------------------
698  // Inventory overrides
699  //--------------------------------------------------------------------------
700  override bool CanDropEntity (notnull EntityAI item)
701  {
702  if (GetInventory().HasInventoryReservation(item, null))
703  {
704  return false;
705  }
706 
707  if (IsRestrained())
708  {
709  if (GetHumanInventory().GetEntityInHands() == item)
710  return false;
711  }
712 
713  return true;
714  }
715 
716  //--------------------------------------------------------------------------
717  // PLAYER DAMAGE EVENT HANDLING
718  //--------------------------------------------------------------------------
719 
720  int GetBreathVapourLevel()
721  {
722  return m_BreathVapour;
723  }
724 
725  // adds state to and syncs sound states variable which is used to generate sound client-side
726  void UnsetMixedSoundState(eMixedSoundStates state)
727  {
728  int bit_mask_remove = ~state;
729 
730  eMixedSoundStates new_states = m_MixedSoundStates & bit_mask_remove;
731 
732  if (new_states != m_MixedSoundStates)
733  {
734  m_MixedSoundStates = new_states;
735  SetSynchDirty();
736  }
737  }
738 
739  // adds state to and syncs sound states variable which is used to generate sound client-side
740  void SetMixedSoundState(eMixedSoundStates state)
741  {
742  eMixedSoundStates new_states = m_MixedSoundStates | state;
743 
744  if (new_states != m_MixedSoundStates)
745  {
746  m_MixedSoundStates = new_states;
747  SetSynchDirty();
748  }
749  }
750 
751  override bool IsPlayer()
752  {
753  return true;
754  }
755 
756  bool IsBleeding()
757  {
758  return (m_BleedingBits != 0);
759  }
760 
761  void SetBleedingBits(int bits)
762  {
763  if (m_BleedingBits != bits)
764  {
765  if (m_BleedingBits == 0)
766  {
767  OnBleedingBegin();
768  }
769  else if (bits == 0)
770  {
771  OnBleedingEnd();
772  }
773  }
774  m_BleedingBits = bits;
775  SetSynchDirty();
776  }
777 
778  int GetBleedingBits()
779  {
780  return m_BleedingBits;
781  }
782 
783  void IncreaseDiseaseCount()
784  {
785  m_DiseaseCount++;
786  }
787 
788  void DecreaseDiseaseCount()
789  {
790  m_DiseaseCount--;
791  }
792 
793  void IncreaseHealingsCount()
794  {
795  m_HealingsCount++;
796  }
797 
798  void DecreaseHealingsCount()
799  {
800  m_HealingsCount--;
801  }
802 
803 
804  bool HasHealings()
805  {
806  return m_HealingsCount;//0 for no healings, 1+ for healings, gets truncated to 1
807  }
808 
809  bool HasDisease()
810  {
811  return m_DiseaseCount;//0 for no disease, 1+ for disease, gets truncated to 1
812  }
813 
814 
815  EPulseType GetPulseType()
816  {
817  return m_PulseType;
818  }
819 
820  void SetPulseType(EPulseType pulse_type)
821  {
822  m_PulseType = pulse_type;
823  }
824 
825  void QueueAddEffectWidget(array<int> effects)
826  {
827  m_ProcessAddEffectWidgets.InsertArray(effects);
828  }
829 
830  void QueueRemoveEffectWidget(array<int> effects)
831  {
832  m_ProcessRemoveEffectWidgets.InsertArray(effects);
833  }
834 
835  void QueueAddGlassesEffect(int id)
836  {
837  m_ProcessAddGlassesEffects.Insert(id);
838  }
839 
840  void QueueRemoveGlassesEffect(int id)
841  {
842  m_ProcessRemoveGlassesEffects.Insert(id);
843  }
844 
845  DamageDealtEffect GetDamageDealtEffect()
846  {
847  return m_DamageDealtEffect;
848  }
849 
850  override void SpawnDamageDealtEffect()
851  {
852  if (m_DamageDealtEffect)
853  {
854  delete m_DamageDealtEffect;
855  }
856 
857  if (m_CanDisplayHitEffectPPE)
858  {
859  m_DamageDealtEffect = new DamageDealtEffect();
860  }
861  }
862 
863  void SpawnDamageDealtEffect2(Param param1 = null, Param param2 = null)
864  {
865  if (m_EffectRadial)
866  {
867  delete m_EffectRadial;
868  }
869 
870  m_EffectRadial = new EffectRadial(param1,param2);
871  }
872 
873  FlashbangEffect GetFlashbangEffect()
874  {
875  return m_FlashbangEffect;
876  }
877 
878  void SpawnFlashbangEffect(PlayerBase player, bool visual)
879  {
880  if (m_FlashbangEffect)
881  {
882  m_FlashbangEffect.Stop();
883  delete m_FlashbangEffect;
884  }
885 
886  m_FlashbangEffect = new FlashbangEffect(player, visual);
887  }
888 
889  ShockDealtEffect GetShockEffect()
890  {
891  return m_ShockDealtEffect;
892  }
893 
894  void SpawnShockEffect(float intensity_max)
895  {
896  if (m_ShockDealtEffect)
897  {
898  delete m_ShockDealtEffect;
899  }
900 
901  m_ShockDealtEffect = new ShockDealtEffect(intensity_max);
902  }
903 
904  override void EEKilled(Object killer)
905  {
906  //Print(Object.GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " event EEKilled, player has died at STS=" + GetSimulationTimeStamp());
907 
908  if (m_AdminLog)
909  {
910  m_AdminLog.PlayerKilled(this, killer);
911  }
912 
913  if (GetBleedingManagerServer())
914  delete GetBleedingManagerServer();
915 
916  if (GetModifiersManager())
917  GetModifiersManager().DeactivateAllModifiers();
918 
919  // kill character in database
920  if (GetHive())
921  {
922  GetHive().CharacterKill(this);
923  }
924 
925  // disable voice communication
926  GetGame().EnableVoN(this, false);
927  if (!GetGame().IsDedicatedServer())
928  ClientData.RemovePlayerBase(this);
929  GetSymptomManager().OnPlayerKilled();
930 
931  if (GetEconomyProfile() && !m_CorpseProcessing && m_CorpseState == 0 && GetGame().GetMission().InsertCorpse(this))
932  {
933  m_CorpseProcessing = true;
934  //Print("EEKilled - processing corpse");
935  }
936 
937  if (GetGame().IsMultiplayer() && GetGame().IsServer())
938  {
939  if (GetGame().GetMission())
940  {
941  GetGame().GetMission().SyncRespawnModeInfo(GetIdentity());
942  }
943  }
944 
945  super.EEKilled(killer);
946  }
947 
948  override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
949  {
950  super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
951 
952  if (m_AdminLog)
953  {
954  m_AdminLog.PlayerHitBy(damageResult, damageType, this, source, component, dmgZone, ammo);
955  }
956 
957  if (damageResult != null && damageResult.GetDamage(dmgZone, "Shock") > 0)
958  {
959  m_LastShockHitTime = GetGame().GetTime();
960 
961  if (!IsUnconscious())
962  {
963  if (GetGame().ConfigIsExisting("cfgAmmo " + ammo + " unconRefillModifier"))
964  {
965  m_UnconRefillModifier = GetGame().ConfigGetInt("cfgAmmo " + ammo + " unconRefillModifier");
966  }
967  else
968  {
969  m_UnconRefillModifier = 1;
970  }
971  }
972  }
973 
975  if (damageType == DT_EXPLOSION && ammo == "FlashGrenade_Ammo")
976  {
977  GetStaminaHandler().DepleteStamina(EStaminaModifiers.OVERALL_DRAIN);
978  }
979 
980  //new bleeding computation
981  //---------------------------------------
982  if (damageResult != null && GetBleedingManagerServer())
983  {
984  float dmg = damageResult.GetDamage(dmgZone, "Blood");
985  GetBleedingManagerServer().ProcessHit(dmg, source, component, dmgZone, ammo, modelPos);
986  }
987  //---------------------------------------
988 
989  #ifdef DIAG_DEVELOPER
990  if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG))
991  Print("EEHitBy() | " + GetDisplayName() + " hit by " + source.GetDisplayName() + " to " + dmgZone);
992 
993  PluginRemotePlayerDebugServer plugin_remote_server = PluginRemotePlayerDebugServer.Cast(GetPlugin(PluginRemotePlayerDebugServer));
994  if (plugin_remote_server)
995  {
996  plugin_remote_server.OnDamageEvent(this, damageResult);
997  }
998  #endif
999 
1000  if (GetGame().IsDebugMonitor())
1001  m_DebugMonitorValues.SetLastDamage(source.GetDisplayName());
1002 
1003  if (m_ActionManager)
1004  m_ActionManager.Interrupt();
1005 
1006  int transferShockToDamageCoef = g_Game.ConfigGetInt(string.Format("%1 %2 DamageApplied transferShockToDamage", CFG_AMMO, ammo));
1007  if (transferShockToDamageCoef == 1)
1008  {
1009  //Print("PlayerBase | EEHitBy | nonlethal hit");
1010  AddHealth("", "Health", -ConvertNonlethalDamage(damageResult.GetDamage(dmgZone, "Shock"), damageType));
1011  if (dmgZone != "Head")
1012  AddHealth(dmgZone, "Health", -damageResult.GetDamage(dmgZone, "Shock")); //Also deal damage to zone health, no dmg reduction
1013  }
1014 
1015  if (GetGame().IsServer())
1016  {
1017  if (GetHealth("RightLeg", "Health") <= 1 || GetHealth("LeftLeg", "Health") <= 1 || GetHealth("RightFoot", "Health") <= 1 || GetHealth("LeftFoot", "Health") <= 1)
1018  {
1019  if (GetModifiersManager().IsModifierActive(eModifiers.MDF_BROKEN_LEGS))//effectively resets the modifier
1020  {
1021  GetModifiersManager().DeactivateModifier(eModifiers.MDF_BROKEN_LEGS);
1022  }
1023  GetModifiersManager().ActivateModifier(eModifiers.MDF_BROKEN_LEGS);
1024  }
1025 
1026  if (ammo == "Bullet_CupidsBolt" && IsAlive())
1027  {
1028  DamageSystem.ResetAllZones(this);
1029  m_ModifiersManager.ResetAll();
1030  m_ModifiersManager.ActivateModifier(eModifiers.MDF_IMMUNITYBOOST);
1031 
1032  // bleeding sources
1033  if (m_BleedingManagerServer)
1034  m_BleedingManagerServer.RemoveAllSources();
1035 
1036  // Stats
1037  if (GetPlayerStats())
1038  {
1039  int bloodType = GetStatBloodType().Get();
1040  float energyValue = GetStatEnergy().Get();
1041  float waterValue = GetStatWater().Get();
1042  float heatBuffer = GetStatHeatBuffer().Get();
1043  float heatComfort = GetStatHeatComfort().Get();
1044 
1045  GetPlayerStats().ResetAllStats();
1046 
1047  GetStatBloodType().Set(bloodType);
1048  GetStatWater().Set(waterValue);
1049  GetStatEnergy().Set(energyValue);
1050  GetStatHeatBuffer().Set(heatBuffer);
1051  GetStatHeatComfort().Set(heatComfort);
1052  }
1053 
1054  // Agents
1055  if (m_AgentPool)
1056  m_AgentPool.RemoveAllAgents();
1057 
1058  if (m_StaminaHandler)
1059  m_StaminaHandler.SetStamina(GameConstants.STAMINA_MAX);
1060 
1061  // uncon
1062  if (IsUnconscious())
1063  DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, false);
1064  }
1065  }
1066 
1067  m_ShockHandler.CheckValue(true);
1068 
1069  //analytics
1070  GetGame().GetAnalyticsServer().OnEntityHit(source, this);
1071  }
1072 
1073  override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
1074  {
1075  super.EEHitByRemote(damageType, source, component, dmgZone, ammo, modelPos);
1076 
1077  if (m_MeleeFightLogic.IsInBlock())
1078  {
1079  EffectSound sound = SEffectManager.PlaySoundOnObject("BlockingAttack_SoundSet", this);
1080  sound.SetAutodestroy(true);
1081  }
1082  }
1083 
1084  override void EEDelete(EntityAI parent)
1085  {
1086  SEffectManager.DestroyEffect(m_FliesEff);
1087  StopSoundSet(m_SoundFliesEffect);
1088 
1089  if (GetArrowManager())
1090  GetArrowManager().ClearArrows();
1091  }
1092 
1093  override protected float ConvertNonlethalDamage(float damage, DamageType damageType)
1094  {
1095  return damage * GameConstants.NL_DAMAGE_FIREARM_CONVERSION_PLAYERS;
1096  }
1097 
1101  override void OnReceivedHit(ImpactEffectsData hitData)
1102  {
1103  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1104  {
1105  float shakeStrength = Math.InverseLerp(0, 500, hitData.m_InSpeed.Length());
1106  GetCurrentCamera().SpawnCameraShake(shakeStrength);
1107  OnPlayerRecievedHit();
1108  }
1109 
1110  if (hitData.m_AmmoType == "Bullet_CupidsBolt")
1111  Ammo_CupidsBolt.PlayOnHitParticle(hitData.m_Position);
1112 
1113  //ParticleManager.GetInstance().PlayInWorld(ParticleList.BOLT_CUPID_HIT, hitData.m_Position);
1114  }
1115 
1116  // DEPRECATED by method above
1117  override void OnPlayerRecievedHit()
1118  {
1119  #ifndef NO_GUI
1120  if (m_MeleeFightLogic.IsInBlock())
1121  {
1122  EffectSound sound = SEffectManager.PlaySoundOnObject("BlockingAttack_SoundSet", this);
1123  sound.SetAutodestroy(true);
1124  return;
1125  }
1126 
1127  SpawnDamageDealtEffect();
1128  CachedObjectsParams.PARAM2_FLOAT_FLOAT.param1 = 32;
1129  CachedObjectsParams.PARAM2_FLOAT_FLOAT.param2 = 0.3;
1130  SpawnDamageDealtEffect2(CachedObjectsParams.PARAM2_FLOAT_FLOAT);
1131 
1132  CloseMapEx(true);
1133  #endif
1134  }
1135 
1136  void OnPlayerReceiveFlashbangHitStart(bool visual)
1137  {
1138  SpawnFlashbangEffect(this, visual);
1139  }
1140 
1141  void OnPlayerReceiveFlashbangHitEnd() {}
1142 
1143  //--------------------------------------------------------------------------
1145  //--------------------------------------------------------------------------
1146 
1148  override string GetHitComponentForAI()
1149  {
1150  return GetDayZPlayerType().GetHitComponentForAI();
1151  }
1152 
1154  override string GetDefaultHitComponent()
1155  {
1156  return GetDayZPlayerType().GetDefaultHitComponent();
1157  }
1158 
1159  override vector GetDefaultHitPosition()
1160  {
1161  return m_DefaultHitPosition;
1162  }
1163 
1166  {
1167  return GetDayZPlayerType().GetSuitableFinisherHitComponents();
1168  }
1169 
1170  protected vector SetDefaultHitPosition(string pSelection)
1171  {
1172  return GetSelectionPositionMS(pSelection);
1173  }
1174 
1175  //--------------------------------------------------------------------------
1177  void AddPossibleCoverFaceForShave()
1178  {
1179  m_FaceCoveredForShaveLayers++;
1180  }
1182  void RemovePossibleCoverFaceForShave()
1183  {
1184  m_FaceCoveredForShaveLayers--;
1185  }
1186  //--------------------------------------------------------------------------
1187  override void EEItemAttached(EntityAI item, string slot_name)
1188  {
1189  super.EEItemAttached(item, slot_name);
1190 
1191  ItemBase itemIB = ItemBase.Cast(item);
1192  SwitchItemSelectionTexture(item, slot_name);
1193  Param1<PlayerBase> p = new Param1<PlayerBase>(this);
1194  item.SwitchItemSelectionTextureEx(EItemManipulationContext.ATTACHING, p);
1195  m_QuickBarBase.updateSlotsCount();
1196  CalculateVisibilityForAI();
1197  UpdateShoulderProxyVisibility(item, slot_name);
1198 
1199  HideHairSelections(itemIB,true);
1200 
1201  GetGame().GetAnalyticsClient().OnItemAttachedAtPlayer(item, slot_name);
1202  Clothing clothing = Clothing.Cast(item);
1203  if (clothing)
1204  {
1205  if (!GetGame().IsDedicatedServer())
1206  {
1207  if (clothing.GetEffectWidgetTypes())
1208  {
1209  QueueAddEffectWidget(clothing.GetEffectWidgetTypes());
1210  }
1211 
1212  if (clothing.GetGlassesEffectID() > -1)
1213  {
1214  QueueAddGlassesEffect(clothing.GetGlassesEffectID());
1215  }
1216 
1217  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 200, false);//sometimes it takes a while to load in
1218  UpdateCorpseStateVisual();//....but if possible, we don't want a delay
1219  }
1220  else if (GetGame().IsServer())
1221  {
1222  if (clothing.IsGasMask())
1223  {
1224  GetModifiersManager().ActivateModifier(eModifiers.MDF_MASK);
1225  }
1226  }
1227 
1228  clothing.UpdateNVGStatus(this,true);
1229  }
1230 
1231  AdjustBandana(item,slot_name);
1232  }
1233 
1234  override void EEItemDetached(EntityAI item, string slot_name)
1235  {
1236  super.EEItemDetached(item, slot_name);
1237  ItemBase item_base = ItemBase.Cast(item);
1238  SwitchItemSelectionTexture(item, slot_name);
1239  item.SwitchItemSelectionTextureEx(EItemManipulationContext.DETACHING);
1240  m_QuickBarBase.updateSlotsCount();
1241  CalculateVisibilityForAI();
1242 
1243  HideHairSelections(item_base,false);
1244 
1245  Clothing clothing = Clothing.Cast(item);
1246 
1247  if (clothing)
1248  {
1249  if (!GetGame().IsDedicatedServer())
1250  {
1251  if (clothing.GetEffectWidgetTypes())
1252  {
1253  QueueRemoveEffectWidget(clothing.GetEffectWidgetTypes());
1254  }
1255 
1256  if (clothing.GetGlassesEffectID() > -1)
1257  {
1258  QueueRemoveGlassesEffect(clothing.GetGlassesEffectID());
1259  }
1260  }
1261 
1262  if (GetGame().IsServer())
1263  {
1264  if (clothing.IsGasMask())
1265  {
1266  GetModifiersManager().DeactivateModifier(eModifiers.MDF_MASK);
1267  }
1268  }
1269 
1270  clothing.UpdateNVGStatus(this);
1271  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 200, false);//sometimes it takes a while to load in
1272  UpdateCorpseStateVisual();//....but if possible, we don't want a delay
1273  }
1274  }
1275 
1276  void SwitchItemTypeAttach(EntityAI item, string slot)
1277  {
1278  //Print("SwitchItemTypeAttach: " + item.GetType());
1279  if (!GetGame().IsServer())
1280  return;
1281 
1282  /*InventoryLocation invloc = new InventoryLocation;
1283 
1284  item.GetInventory().GetCurrentInventoryLocation(invloc);
1285  //Print(invloc.DumpToString());
1286  if (item.ConfigIsExisting("ChangeIntoOnAttach") && invloc.GetType() != InventoryLocationType.UNKNOWN)
1287  {
1288  string str = item.ChangeIntoOnAttach(slot);
1289  if (str != "")
1290  {
1291  string typestr = item.GetType();
1292  MiscGameplayFunctions.TurnItemIntoItem(ItemBase.Cast(item), str, this);
1293  }
1294  }*/
1295  }
1296 
1297  void SwitchItemTypeDetach(EntityAI item, string slot)
1298  {
1299  //Print("SwitchItemTypeDetach: " + item.GetType());
1300  }
1301 
1302  void UpdateShoulderProxyVisibility(EntityAI item, string slot_name)
1303  {
1304  string slot = slot_name;
1305  bool boo;
1306  boo = item.IsWeapon();
1307 
1308  if (slot == "Melee")
1309  {
1310  SetSimpleHiddenSelectionState(SIMPLE_SELECTION_MELEE_RIFLE,boo);
1311  SetSimpleHiddenSelectionState(SIMPLE_SELECTION_MELEE_MELEE,!boo);
1312  }
1313  else if (slot == "Shoulder")
1314  {
1315  SetSimpleHiddenSelectionState(SIMPLE_SELECTION_SHOULDER_RIFLE,boo);
1316  SetSimpleHiddenSelectionState(SIMPLE_SELECTION_SHOULDER_MELEE,!boo);
1317  }
1318  }
1319 
1320  override void SwitchItemSelectionTexture(EntityAI item, string slot_name)
1321  {
1322  super.SwitchItemSelectionTexture(item,slot_name);
1323 
1324  //shirt + armband
1325  EntityAI armband = FindAttachmentBySlotName("Armband");
1326  if (slot_name == "Body" && armband)
1327  {
1328  Param1<PlayerBase> p = new Param1<PlayerBase>(this);
1329  armband.SwitchItemSelectionTextureEx(EItemManipulationContext.UPDATE,p);
1330  }
1331  }
1332 
1333  void RemoveAllItems()
1334  {
1335  array<EntityAI> itemsArray = new array<EntityAI>;
1336  ItemBase item;
1337  GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER, itemsArray);
1338 
1339  for (int i = 0; i < itemsArray.Count(); i++)
1340  {
1341  Class.CastTo(item, itemsArray.Get(i));
1342  if (item && !item.IsInherited(SurvivorBase)) GetInventory().LocalDestroyEntity(item);
1343  }
1344  }
1345 
1346  bool GetHitPPEEnabled()
1347  {
1348  return m_CanDisplayHitEffectPPE;
1349  }
1350 
1351  void SetHitPPEEnabled(bool enabled)
1352  {
1353  m_CanDisplayHitEffectPPE = enabled;
1354  }
1355 
1356  bool IsMale()
1357  {
1358  if (ConfigGetBool("woman") != 1)
1359  {
1360  return true;
1361  }
1362  return false;
1363  }
1364 
1365  int GetVoiceType()
1366  {
1367  int voice_type = ConfigGetInt("voiceType");
1368 
1369  if (voice_type == 0)
1370  {
1371  voice_type = 1;
1372  }
1373 
1374  return voice_type;
1375  }
1376 
1377  PlayerSoundManagerServer GetPlayerSoundManagerServer()
1378  {
1379  return m_PlayerSoundManagerServer;
1380  }
1381 
1382 
1383  UndergroundHandlerClient GetUndergroundHandler()
1384  {
1385  if (!m_UndergroundHandler && IsAlive())
1386  {
1387  m_UndergroundHandler = new UndergroundHandlerClient(this);
1388  }
1389 
1390  return m_UndergroundHandler;
1391  }
1392 
1393  void KillUndergroundHandler()
1394  {
1395  m_UndergroundHandler = null;
1396  }
1397  // --------------------------------------------------
1398  // User Actions
1399  //---------------------------------------------------
1400  void SetActions(out TInputActionMap InputActionMap)
1401  {
1402  AddAction(ActionOpenDoors, InputActionMap);
1403  AddAction(ActionCloseDoors, InputActionMap);
1404  AddAction(ActionLockedDoors, InputActionMap);
1405  AddAction(ActionEnterLadder, InputActionMap);
1406  AddAction(ActionExitLadder, InputActionMap);
1407 
1408  //-----------CheckIfCanMOveToTarget----------
1409  AddAction(ActionStartEngine, InputActionMap);
1410  AddAction(ActionStopEngine, InputActionMap);
1411  AddAction(ActionSwitchSeats, InputActionMap);
1412  AddAction(ActionOpenCarDoors,InputActionMap);
1413  AddAction(ActionCloseCarDoors,InputActionMap);
1414  AddAction(ActionUncoverHeadSelf, InputActionMap);
1415  AddAction(ActionDrinkPondContinuous, InputActionMap);
1416  AddAction(ActionIgniteFireplaceByAir, InputActionMap);
1417  AddAction(ActionMineBushByHand, InputActionMap);
1418 
1419  AddAction(ActionUngagSelf, InputActionMap);
1420  AddAction(ActionWashHandsWater, InputActionMap);
1421  AddAction(ActionGetOutTransport, InputActionMap);
1422 
1423  AddAction(ActionUnrestrainTargetHands, InputActionMap);
1424  AddAction(ActionTakeArrow, InputActionMap);
1425  AddAction(ActionTakeArrowToHands, InputActionMap);
1426  }
1427 
1428  void SetActions() // Backwards compatibility, not recommended to use
1429  {
1430  }
1431 
1432  void SetActionsRemoteTarget(out TInputActionMap InputActionMap)
1433  {
1434  AddAction(ActionCPR, InputActionMap);
1435  AddAction(ActionUncoverHeadTarget, InputActionMap);
1436  AddAction(ActionUngagTarget, InputActionMap);
1437  AddAction(ActionPullBodyFromTransport, InputActionMap);
1438  AddAction(ActionCheckPulseTarget, InputActionMap);
1439  }
1440 
1441  void SetActionsRemoteTarget() // Backwards compatibility, not recommended to use
1442  {
1443  }
1444 
1445  void InitializeActions()
1446  {
1447  // Backwards compatibility
1448  if (IsControlledPlayer())
1449  {
1451  SetActions();
1452  }
1453  else
1454  {
1456  SetActionsRemoteTarget();
1457  }
1459 
1460  m_InputActionMapControled = new TInputActionMap;
1461  SetActions(m_InputActionMapControled);
1462 
1463  m_InputActionMapAsTarget = new TInputActionMap;
1464  SetActionsRemoteTarget(m_InputActionMapAsTarget);
1465  }
1466 
1467  override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
1468  {
1469  if (!m_ActionsInitialize)
1470  {
1471  m_ActionsInitialize = true;
1473  }
1474 
1475  // Backwards compatibility
1476  array<ActionBase_Basic> bcActions = m_InputActionMap.Get(action_input_type);
1477  if (!bcActions)
1478  {
1479  if (IsControlledPlayer())
1480  actions = m_InputActionMapControled.Get(action_input_type);
1481  else
1482  actions = m_InputActionMapAsTarget.Get(action_input_type);
1483  }
1484  else
1485  {
1486  if (!actions)
1487  actions = new array<ActionBase_Basic>();
1488 
1489  if (IsControlledPlayer())
1490  actions.InsertAll(m_InputActionMapControled.Get(action_input_type));
1491  else
1492  actions.InsertAll(m_InputActionMapAsTarget.Get(action_input_type));
1493 
1494  actions.InsertAll(bcActions);
1495  }
1496  }
1497 
1498  void AddAction(typename actionName, out TInputActionMap InputActionMap)
1499  {
1500  ActionBase action = GetActionManager().GetAction(actionName);
1501 
1502  typename ai = action.GetInputType();
1503  if (!ai)
1504  {
1505  m_ActionsInitialize = false;
1506  return;
1507  }
1508 
1509  ref array<ActionBase_Basic> action_array = InputActionMap.Get(ai);
1510 
1511  if (!action_array)
1512  {
1513  action_array = new array<ActionBase_Basic>;
1514  InputActionMap.Insert(ai, action_array);
1515  }
1516  action_array.Insert(action);
1517  }
1518 
1519  void AddAction(typename actionName) // Backwards compatibility, not recommended to use
1520  {
1521  AddAction(actionName, m_InputActionMap);
1522  }
1523 
1524  void RemoveAction(typename actionName, out TInputActionMap InputActionMap)
1525  {
1526  ActionBase action = GetActionManager().GetAction(actionName);
1527  typename ai = action.GetInputType();
1528  ref array<ActionBase_Basic> action_array = InputActionMap.Get(ai);
1529 
1530  if (action_array)
1531  {
1532  for (int i = 0; i < action_array.Count(); i++)
1533  {
1534  if (action == action_array.Get(i))
1535  {
1536  action_array.Remove(i);
1537  }
1538  }
1539  action_array = new array<ActionBase_Basic>;
1540  InputActionMap.Insert(ai, action_array);
1541  }
1542  action_array.Insert(action);
1543  }
1544 
1545  void RemoveAction(typename actionName) // Backwards compatibility, not recommended to use
1546  {
1547  RemoveAction(actionName, m_InputActionMap);
1548  }
1549 
1550  int GetCurrentRecipe()
1551  {
1552  return m_RecipePick;
1553  }
1554 
1555  void SetNextRecipe()
1556  {
1557  m_RecipePick++;
1558  }
1559 
1560  void SetFirstRecipe()
1561  {
1562  m_RecipePick = 0;
1563  }
1564 
1565  //---------------------------------------------------
1566 
1567 
1569  {
1570  return m_ActionManager;
1571  }
1572 
1573  EmoteManager GetEmoteManager()
1574  {
1575  return m_EmoteManager;
1576  }
1577 
1578  RandomGeneratorSyncManager GetRandomGeneratorSyncManager()
1579  {
1580  return m_RGSManager;
1581  }
1582 
1584  override void OnLadder(float delta_time, HumanMovementState pState)
1585  {
1586  ProcessHandDamage(delta_time, pState);
1587  }
1588 
1589  void ProcessHandDamage(float delta_time, HumanMovementState pState)
1590  {
1591  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
1592  {
1593  if (pState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SLIDE)
1594  {
1595  //Print("sliding down");
1596  EntityAI gloves = GetInventory().FindAttachment(InventorySlots.GLOVES);
1597 
1598  if (gloves && gloves.GetHealthLevel() < 4)
1599  {
1600  gloves.AddHealth("","", PlayerConstants.GLOVES_DAMAGE_SLIDING_LADDER_PER_SEC * delta_time);
1601  return;
1602  }
1603 
1604  if (Math.RandomFloat01() < PlayerConstants.CHANCE_TO_BLEED_SLIDING_LADDER_PER_SEC * delta_time)
1605  {
1606  if (Math.RandomFloat01() < 0.5)
1607  {
1608  if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll"))
1609  {
1610  SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
1611  }
1612  }
1613  else
1614  {
1615  if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightForeArmRoll"))
1616  {
1617  SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
1618  }
1619  }
1620  }
1621 
1622  }
1623  }
1624  }
1625 
1626  override void ProcessFeetDamageServer(int pUserInt)
1627  {
1628  //InventorySlots.HEADGEAR
1629  EntityAI shoes = GetInventory().FindAttachment(InventorySlots.FEET);
1630 
1631  string surface; int liquid;
1632  GetGame().SurfaceUnderObject(this, surface, liquid);
1633  float modifier_surface = Surface.GetParamFloat(surface, "footDamage");
1634 
1635  if (shoes && shoes.GetHealthLevel() < 4)
1636  {
1637  shoes.AddHealth("", "", -1 * modifier_surface * PlayerConstants.SHOES_MOVEMENT_DAMAGE_PER_STEP * (float)PlayerConstants.CHECK_EVERY_N_STEP);
1638 
1639  return;
1640  }
1641 
1642  float rnd = Math.RandomFloat01();
1643  float modifier_movement = GetFeetDamageMoveModifier();
1644  float chance = modifier_movement * modifier_surface * PlayerConstants.BAREFOOT_MOVEMENT_BLEED_MODIFIER * (float)PlayerConstants.CHECK_EVERY_N_STEP;
1645  if (rnd < chance)
1646  {
1647  if (pUserInt % 2 == 0)
1648  {
1649  if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightFoot"))
1650  SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
1651 
1652  }
1653  else
1654  {
1655  if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftFoot"))
1656  SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
1657  }
1658  }
1659  }
1660 
1661  float GetFeetDamageMoveModifier()
1662  {
1663  float modifier;
1664  switch(m_MovementState.m_iMovement)
1665  {
1666  case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
1667  modifier = 1;
1668  break
1669  case DayZPlayerConstants.MOVEMENTIDX_RUN:
1670  modifier = 0.5;
1671  break
1672  case DayZPlayerConstants.MOVEMENTIDX_WALK:
1673  modifier = 0;
1674  break
1675  }
1676  return modifier;
1677  }
1678 
1679  void SetStamina(int value, int range)
1680  {
1682  m_ModulePlayerStatus.SetStamina(value, range);
1683  }
1684 
1685  #ifdef DIAG_DEVELOPER
1686  void SetStaminaDisabled(bool value)
1687  {
1688  if (m_StaminaHandler)
1689  m_StaminaHandler.SetStaminaDisabled(value);
1690  }
1691  #endif
1692 
1693  void SetQuickRestrain(bool enable)
1694  {
1695  m_AllowQuickRestrain = enable;
1696  }
1697 
1698  void SetQuickFishing(bool enable)
1699  {
1700  m_AllowQuickFishing = enable;
1701  }
1702 
1703  bool IsQuickRestrain()
1704  {
1705  return m_AllowQuickRestrain;
1706  }
1707 
1708  bool IsQuickFishing()
1709  {
1710  return m_AllowQuickFishing;
1711  }
1712 
1713  PlayerStats GetPlayerStats()
1714  {
1715  return m_PlayerStats;
1716  }
1717 
1718  CraftingManager GetCraftingManager()
1719  {
1720  return m_CraftingManager;
1721  }
1722 
1723  StaminaHandler GetStaminaHandler()
1724  {
1725  return m_StaminaHandler;
1726  }
1727 
1728  override WeaponManager GetWeaponManager()
1729  {
1730  return m_WeaponManager;
1731  }
1732 
1734  {
1735  return m_ArrowManager;
1736  }
1737 
1738  bool CanBeRestrained()
1739  {
1740  if (IsInVehicle() || IsRaised() || IsSwimming() || IsClimbing() || IsClimbingLadder() || IsRestrained() || !GetWeaponManager() || GetWeaponManager().IsRunning() || !GetActionManager() || GetActionManager().GetRunningAction() != null || IsMapOpen())
1741  {
1742  return false;
1743  }
1744  if (GetThrowing() && GetThrowing().IsThrowingModeEnabled())
1745  {
1746  return false;
1747  }
1748  return true;
1749  }
1750 
1751  void SetRestrainStarted(bool restrain_started)
1752  {
1753  m_IsRestrainStarted = restrain_started;
1754  SetSynchDirty();
1755  }
1756 
1757  bool IsRestrainStarted()
1758  {
1759  return m_IsRestrainStarted;
1760  }
1761 
1762  void SetRestrainPrelocked(bool restrain_prelock)
1763  {
1764  m_IsRestrainPrelocked = restrain_prelock;
1765  SetSynchDirty();
1766  }
1767 
1768  bool IsRestrainPrelocked()
1769  {
1770  return m_IsRestrainPrelocked;
1771  }
1772 
1773  void SetRestrained(bool is_restrained)
1774  {
1775  m_IsRestrained = is_restrained;
1776  SetSynchDirty();
1777  }
1778 
1779  override bool IsRestrained()
1780  {
1781  return m_IsRestrained;
1782  }
1783 
1784  override bool IsInventoryVisible()
1785  {
1786  return true;
1787  }
1788 
1789  bool CanManipulateInventory()
1790  {
1791  if (IsControlledPlayer())
1792  {
1793  return !IsRestrained() && !IsRestrainPrelocked();
1794  }
1795  return true;
1796  }
1797 
1798  override bool CanReleaseAttachment (EntityAI attachment)
1799  {
1800  return super.CanReleaseAttachment(attachment);
1801  }
1802 
1803  override bool CanReleaseCargo (EntityAI cargo)
1804  {
1805  return super.CanReleaseCargo(cargo);
1806  }
1807 
1808  override bool CanReceiveItemIntoCargo(EntityAI item)
1809  {
1810  return super.CanReceiveItemIntoCargo(item);
1811  }
1812 
1813  override bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
1814  {
1815  return super.CanSwapItemInCargo(child_entity, new_entity);
1816  }
1817 
1818  override bool CanReceiveItemIntoHands(EntityAI item_to_hands)
1819  {
1820  if (IsInVehicle())
1821  return false;
1822 
1823  if (!CanPickupHeavyItem(item_to_hands))
1824  return false;
1825 
1826  return super.CanReceiveItemIntoHands(item_to_hands);
1827  }
1828 
1829  override bool CanSaveItemInHands(EntityAI item_in_hands)
1830  {
1831  return super.CanSaveItemInHands(item_in_hands);
1832  }
1833 
1834  override bool CanReleaseFromHands(EntityAI handheld)
1835  {
1836  return super.CanReleaseFromHands(handheld);
1837  }
1838 
1839  int GetCraftingRecipeID()
1840  {
1841  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1842  {
1843  return GetCraftingManager().GetRecipeID();
1844  }
1845  else
1846  {
1847  return m_RecipeID;
1848  }
1849  }
1850 
1851  void SetCraftingRecipeID(int recipeID)
1852  {
1853  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1854  {
1855  GetCraftingManager().SetRecipeID(recipeID);
1856  }
1857  else
1858  {
1859  m_RecipeID = recipeID;
1860  }
1861  }
1862 
1863  // --------------------------------------------------
1864  // Action data for base building actions
1865  //---------------------------------------------------
1866  ConstructionActionData GetConstructionActionData()
1867  {
1868  return m_ConstructionActionData;
1869  }
1870 
1871  void ResetConstructionActionData()
1872  {
1873  if (m_ConstructionActionData)
1874  {
1875  m_ConstructionActionData.ResetActionIndexes();
1876  }
1877  }
1878 
1879  // --------------------------------------------------
1880  // Action data for fireplace (indoor)
1881  //---------------------------------------------------
1882  vector GetLastFirePoint()
1883  {
1884  return m_LastFirePoint;
1885  }
1886  float GetLastFirePointRot()
1887  {
1888  return m_LastFirePointRot;
1889  }
1890  int GetLastFirePointIndex()
1891  {
1892  return m_LastFirePointIndex;
1893  }
1894 
1895  void SetLastFirePoint(vector last_fire_point)
1896  {
1897  m_LastFirePoint = last_fire_point;
1898  }
1899  void SetLastFirePointRot(float last_fire_point_rot)
1900  {
1901  m_LastFirePointRot = last_fire_point_rot;
1902  }
1903  void SetLastFirePointIndex(int last_fire_point_index)
1904  {
1905  m_LastFirePointIndex = last_fire_point_index;
1906  }
1907 
1908  // --------------------------------------------------
1909  // QuickBar
1910  //---------------------------------------------------
1911 
1912  void RemoveQuickBarEntityShortcut(EntityAI entity)
1913  {
1914  int index = m_QuickBarBase.FindEntityIndex(entity);
1915  if (index != -1)
1916  m_QuickBarBase.SetEntityShortcut(entity,-1);
1917  }
1918  //---------------------------------------------------
1919  void SetEnableQuickBarEntityShortcut(EntityAI entity, bool value)
1920  {
1921  int index = m_QuickBarBase.FindEntityIndex(entity);
1922  if (index != -1)
1923  m_QuickBarBase.SetShotcutEnable(index,value);
1924 
1925  }
1926  //---------------------------------------------------
1927  int FindQuickBarEntityIndex(EntityAI entity)
1928  {
1929  int index;
1930  index = m_QuickBarBase.FindEntityIndex(entity);
1931 
1932  if (m_QuickBarBase.GetEntity(index) == NULL)
1933  return -1;
1934 
1935  return index;
1936  }
1937  //---------------------------------------------------
1938 
1939  int GetQuickBarSize()
1940  {
1941  return m_QuickBarBase.GetSize();
1942  }
1943  //---------------------------------------------------
1944  EntityAI GetQuickBarEntity(int index)
1945  {
1946  return m_QuickBarBase.GetEntity(index);
1947  }
1948  //---------------------------------------------------
1949  void UpdateQuickBarEntityVisibility(EntityAI entity)
1950  {
1951  int i = FindQuickBarEntityIndex(entity);
1952  if (i >= 0)
1953  m_QuickBarBase.UpdateShotcutVisibility(i);
1954  }
1955  //---------------------------------------------------
1956  void SetQuickBarEntityShortcut(EntityAI entity, int index, bool force = false)
1957  {
1958  m_QuickBarBase.SetEntityShortcut(entity, index, force);
1959  }
1960  //---------------------------------------------------
1961  void OnQuickbarSetEntityRequest(ParamsReadContext ctx)
1962  {
1963  m_QuickBarBase.OnSetEntityRequest(ctx);
1964  }
1965  //---------------------------------------------------
1966 
1967  // Applies splint on all limbs.
1968  void ApplySplint()
1969  {
1970  float add_health_coef = 0.33;
1971  // The idea is to slightly increase health of broken limb so the player is still limping. Using more splints will help but each time less. 100% recovery can be achieved only through long term healing.
1972  if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
1973  {
1974  AddHealth("LeftLeg", "Health", (GetMaxHealth("LeftLeg", "Health") - GetHealth("LeftLeg", "Health") ) * add_health_coef );
1975  AddHealth("RightLeg", "Health", (GetMaxHealth("RightLeg", "Health") - GetHealth("RightLeg", "Health")) * add_health_coef );
1976  AddHealth("RightFoot", "Health", (GetMaxHealth("RightFoot", "Health") - GetHealth("RightFoot", "Health")) * add_health_coef );
1977  AddHealth("LeftFoot", "Health", (GetMaxHealth("LeftFoot", "Health") - GetHealth("LeftFoot", "Health")) * add_health_coef );
1978  }
1979  }
1980 
1981  void ProcessDrowning(float dT)
1982  {
1983  GetStaminaHandler().DepleteStamina(EStaminaModifiers.DROWN,dT);
1984 
1985  #ifndef SERVER
1986  //PP EFFECTS
1987  PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
1988  req.SetStamina01(GetStaminaHandler().GetStaminaNormalized());
1989  #endif
1990  }
1991 
1992  void SpawnDrowningBubbles()
1993  {
1994  if (!GetDrowningWaterLevelCheck())
1995  return;
1996  float bubbleFrequency = Math.Lerp(PlayerConstants.DROWNING_BUBBLE_FREQUENCY_MIN, PlayerConstants.DROWNING_BUBBLE_FREQUENCY_MAX, GetStaminaHandler().GetSyncedStaminaNormalized());
1997  int boneIdx = GetBoneIndexByName("Head");
1998 
1999  if (boneIdx != -1)
2000  {
2001  Particle p = ParticleManager.GetInstance().PlayInWorld(ParticleList.DROWNING_BUBBLES, "-0.03 0.15 0");
2002  if (p)
2003  AddChild(p, boneIdx);
2004  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SpawnDrowningBubbles, bubbleFrequency);
2005  }
2006  }
2007 
2008  void ProcessHoldBreath(float dT)
2009  {
2010  if (IsTryingHoldBreath() && CanStartConsumingStamina(EStaminaConsumers.HOLD_BREATH))
2011  {
2012  if (!m_IsHoldingBreath)
2013  {
2014  OnHoldBreathStart();
2015  m_IsHoldingBreath = true;
2016  }
2017  }
2018  else if (!IsTryingHoldBreath() || !CanConsumeStamina(EStaminaConsumers.HOLD_BREATH))
2019  {
2020  if (m_IsHoldingBreath) OnHoldBreathEnd();
2021  m_IsHoldingBreath = false;
2022  }
2023  }
2024 
2025  void OnHoldBreathStart()
2026  {
2027  //SendSoundEvent(SoundSetMap.GetSoundSetID("holdBreath_male_Char_SoundSet"));
2028  RequestSoundEventEx(EPlayerSoundEventID.HOLD_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
2029  }
2030 
2031  void OnHoldBreathExhausted()
2032  {
2033  RequestSoundEventEx(EPlayerSoundEventID.EXHAUSTED_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
2034  }
2035 
2036  void OnHoldBreathEnd()
2037  {
2038  //SendSoundEvent(SoundSetMap.GetSoundSetID("releaseBreath_male_Char_SoundSet"));
2039  RequestSoundEventEx(EPlayerSoundEventID.RELEASE_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
2040  }
2041 
2042  override bool IsHoldingBreath()
2043  {
2044  return m_IsHoldingBreath;
2045  }
2046 
2047  override bool IsRefresherSignalingViable()
2048  {
2049  return false;
2050  }
2051 
2052  eMixedSoundStates GetMixedSoundStates()
2053  {
2054  return m_MixedSoundStates;
2055  }
2056 
2057  AbstractWave SaySoundSet(string name)
2058  {
2059  if (m_SaySoundLastSetName != name)
2060  {
2061  m_SaySoundParams = new SoundParams(name);
2062  m_SaySoundBuilder = new SoundObjectBuilder(m_SaySoundParams);
2063 
2064  m_SaySoundLastSetName = name;
2065  }
2066 
2067  m_SaySoundObject = m_SaySoundBuilder.BuildSoundObject();
2068  m_SaySoundObject.SetPosition(GetPosition());
2069  return GetGame().GetSoundScene().Play3D(m_SaySoundObject, m_SaySoundBuilder);
2070  }
2071 
2072  EntityAI FindCargoByBaseType(string searched_item)
2073  {
2074  EntityAI attachment;
2075  string item_name;
2076  int attcount = this.GetInventory().AttachmentCount();
2077 
2078  for (int att = 0; att < attcount; att++)
2079  {
2080  attachment = GetInventory().GetAttachmentFromIndex(att);
2081  if (attachment.IsItemBase())
2082  {
2083  item_name = attachment.GetType();
2084  if (GetGame().IsKindOf(item_name, searched_item))
2085  {
2086  return attachment;
2087  }
2088  }
2089  }
2090  return NULL;
2091  }
2092 
2093  void InitEditor()
2094  {
2095  if (GetGame().IsDebug())
2096  {
2097  if (!GetGame().IsMultiplayer() && GetGame().GetPlayer() && GetGame().GetPlayer().GetID() == this.GetID())
2098  {
2099  PluginSceneManager scene_editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
2100  scene_editor.InitLoad();
2101  }
2102  }
2103  }
2104 
2105  //---------------------------------------------------------------------------------------------------------------------------
2106  void OnPlayerLoaded()
2107  {
2108  InitEditor();
2109 
2110  if (GetGame().IsMultiplayer() || GetGame().IsServer())
2111  {
2112  if (m_ModuleLifespan)
2113  {
2114  m_ModuleLifespan.SynchLifespanVisual(this, m_LifeSpanState, m_HasBloodyHandsVisible, m_HasBloodTypeVisible, m_BloodType);
2115  }
2116  }
2117 
2118  if (IsControlledPlayer())//true only on client for the controlled character
2119  {
2120  if (!m_VirtualHud)
2121  m_VirtualHud = new VirtualHud(this);
2122  if (m_Hud)
2123  {
2124  m_Hud.UpdateBloodName();
2125  PPERequesterBank.GetRequester(PPERequester_DeathDarkening).Stop();
2126  PPERequesterBank.GetRequester(PPERequester_ShockHitReaction).Stop();
2127  PPERequesterBank.GetRequester(PPERequester_UnconEffects).Stop(); //TODO - stop en mass...check if effects do not terminate (spawning inside of contaminated area)?!
2128  GetGame().GetUIManager().CloseAll();
2129  GetGame().GetMission().SetPlayerRespawning(false);
2130  GetGame().GetMission().OnPlayerRespawned(this);
2131 
2132  m_Hud.ShowHudUI(true);
2133  m_Hud.ShowQuickbarUI(true);
2134  m_Hud.UpdateQuickbarGlobalVisibility();
2135  }
2136  m_EffectWidgets = GetGame().GetMission().GetEffectWidgets();
2137  }
2138  if (!GetGame().IsDedicatedServer())
2139  {
2140  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 2000, false);//sometimes it takes a while to load in
2141  m_PlayerSoundEventHandler = new PlayerSoundEventHandler(this);
2142  }
2143  int slot_id = InventorySlots.GetSlotIdFromString("Head");
2144  m_CharactersHead = Head_Default.Cast(GetInventory().FindPlaceholderForSlot(slot_id));
2145  CheckHairClippingOnCharacterLoad();
2146  UpdateHairSelectionVisibility();
2147  PreloadDecayTexture();
2148 
2149  Weapon_Base wpn = Weapon_Base.Cast(GetItemInHands());
2150  if (wpn)
2151  wpn.ValidateAndRepair();
2152  /*
2153  PreloadDecayTexture();
2154  UpdateCorpseStateVisual();
2155  */
2156  m_PlayerLoaded = true;
2157 
2158  //Print("PlayerBase | OnPlayerLoaded()");
2159 
2160  }
2161 
2162  void SetPlayerDisconnected(bool state)
2163  {
2164  m_PlayerDisconnectProcessed = state;
2165  }
2166 
2167  bool IsPlayerDisconnected()
2168  {
2169  return m_PlayerDisconnectProcessed;
2170  }
2171 
2172  // --------------------------------------------------
2173  // Advanced placement
2174  //---------------------------------------------------
2175 
2176  //get hologram
2177  Hologram GetHologramServer()
2178  {
2179  return m_HologramServer;
2180  }
2181 
2182  Hologram GetHologramLocal()
2183  {
2184  return m_HologramLocal;
2185  }
2186 
2187  void PlacingStartServer(ItemBase item)
2188  {
2189  if (item)
2190  {
2191  m_HologramServer = new Hologram(this, GetLocalProjectionPosition(), item);
2192  GetHologramServer().SetProjectionPosition(GetLocalProjectionPosition());
2193  GetHologramServer().SetProjectionOrientation(GetLocalProjectionOrientation());
2194  GetHologramServer().GetProjectionEntity().OnPlacementStarted(this);
2195  GetHologramServer().CheckPowerSource();
2196  GetHologramServer().RefreshVisual();
2197  }
2198  }
2199 
2200  void PlacingStartLocal(ItemBase item)
2201  {
2202  if (GetGame().IsMultiplayer() && GetGame().IsServer())
2203  return;
2204 
2205  if (item)
2206  {
2207  m_HologramLocal = new Hologram(this, GetLocalProjectionPosition(), item);
2208  GetHologramLocal().GetProjectionEntity().OnPlacementStarted(this);
2209  }
2210  }
2211 
2212  void PlacingCancelServer()
2213  {
2214  EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
2215 
2216  if (IsPlacingServer())
2217  {
2218  GetHologramServer().CheckPowerSource();
2219  GetHologramServer().GetParentEntity().OnPlacementCancelled(this);
2220  SetLocalProjectionPosition(vector.Zero);
2221 
2222  delete m_HologramServer;
2223 
2224  return;
2225  }
2226  else if (entityInHands && entityInHands.HasEnergyManager())
2227  {
2228  if (entityInHands.GetCompEM().IsPlugged())
2229  entityInHands.OnPlacementCancelled(this);
2230  }
2231  }
2232 
2233  //Called when item placement is canceled, will prevent quickbar usage until the item the player was placing is back in hands
2234  void LockHandsUntilItemHeld()
2235  {
2236  m_AreHandsLocked = true;
2237  }
2238 
2239  void PlacingCancelLocal()
2240  {
2241  EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
2242  if (entityInHands && entityInHands.HasEnergyManager())
2243  {
2244  if (entityInHands.GetCompEM().IsPlugged())
2245  entityInHands.OnPlacementCancelled(this);
2246  }
2247 
2248  SetLocalProjectionPosition(vector.Zero);
2249 
2250  delete m_HologramLocal;
2251  }
2252 
2253  void PlacingCompleteServer()
2254  {
2255  SetLocalProjectionPosition(vector.Zero);
2256  delete m_HologramServer;
2257  }
2258 
2259  void PlacingCompleteLocal()
2260  {
2261  SetLocalProjectionPosition(vector.Zero);
2262  delete m_HologramLocal;
2263  }
2264 
2265  bool IsPlacingServer()
2266  {
2267  if (m_HologramServer)
2268  return true;
2269 
2270  return false;
2271  }
2272 
2273  bool IsPlacingLocal()
2274  {
2275  if (m_HologramLocal)
2276  return true;
2277 
2278  return false;
2279  }
2280 
2281  void SetDrowning(bool enable)
2282  {
2283  if (enable != m_IsDrowning)
2284  {
2285  if (enable)
2286  OnDrowningStart();
2287  else
2288  OnDrowningEnd();
2289  }
2290 
2291  m_IsDrowning = enable;
2292  }
2293 
2294  void OnDrowningStart()
2295  {
2296  #ifndef SERVER
2297  if (IsControlledPlayer())
2298  {
2299  PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
2300  req.Start();
2301  }
2302  //Particles
2303  SpawnDrowningBubbles();
2304  #endif
2305  }
2306 
2307  void OnDrowningEnd()
2308  {
2309  #ifndef SERVER
2310  if (IsControlledPlayer())
2311  {
2312  PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
2313  req.Stop();
2314  }
2315  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(SpawnDrowningBubbles);
2316  #endif
2317  }
2318 
2319  bool TogglePlacingServer(int userDataType, ParamsReadContext ctx)
2320  {
2321  if (userDataType == INPUT_UDT_ADVANCED_PLACEMENT)
2322  {
2323  PlacingCancelServer();
2324  return true;
2325  }
2326 
2327  return false;
2328  }
2329 
2330  void RequestResetADSSync()
2331  {
2332  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && GetGame().IsMultiplayer())
2333  {
2334  if (ScriptInputUserData.CanStoreInputUserData())
2335  {
2337  ctx.Write(INPUT_UDT_RESET_ADS);
2338  ctx.Send();
2339  }
2340  }
2341  else if (!GetGame().IsMultiplayer())
2342  {
2343  m_ResetADS = true;
2344  }
2345  }
2346 
2348  bool ResetADSPlayerSync(int userDataType, ParamsReadContext ctx)
2349  {
2350  if (userDataType == INPUT_UDT_RESET_ADS)
2351  {
2353  SendSyncJuncture(DayZPlayerSyncJunctures.SJ_ADS_RESET,pCtx);
2354  return true;
2355  }
2356 
2357  return false;
2358  }
2359 
2360  override bool CanPlaceItem(EntityAI item)
2361  {
2362  if (m_UndergroundPresence > EUndergroundPresence.NONE)
2363  {
2364  TStringSet disallowedUndergroundTypes = CfgGameplayHandler.GetDisallowedTypesInUnderground();
2365  foreach (string t: disallowedUndergroundTypes)
2366  {
2367  if (item.IsKindOf(t))
2368  return false;
2369  }
2370  }
2371  return true;
2372  }
2373 
2374  void SetUnderground(EUndergroundPresence presence)
2375  {
2376  m_UndergroundPresence = presence;
2377  }
2378 
2379  void TogglePlacingLocal(ItemBase item = null)
2380  {
2381  if (IsPlacingLocal())
2382  {
2383  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && GetGame().IsMultiplayer())
2384  {
2385  if (ScriptInputUserData.CanStoreInputUserData())
2386  {
2388  ctx.Write(INPUT_UDT_ADVANCED_PLACEMENT);
2389  ctx.Send();
2390  }
2391  }
2392  PlacingCancelLocal();
2393  }
2394  else if (!item)
2395  {
2396  PlacingStartLocal(GetItemInHands());
2397  }
2398  else
2399  {
2400  PlacingStartLocal(item);
2401  }
2402  }
2403 
2404  void SetLocalProjectionPosition(vector local_position)
2405  {
2406  m_LocalProjectionPosition = local_position;
2407  }
2408 
2409  void SetLocalProjectionOrientation(vector local_orientation)
2410  {
2411  m_LocalProjectionOrientation = local_orientation;
2412  }
2413 
2414  vector GetLocalProjectionPosition()
2415  {
2416  return m_LocalProjectionPosition;
2417  }
2418 
2419  vector GetLocalProjectionOrientation()
2420  {
2421  return m_LocalProjectionOrientation;
2422  }
2423 
2425  void AddToEnvironmentTemperature(float pTemperature) {};
2426 
2427  // ------------------------------------------------------------------------
2428 
2430  void SetInWater(bool pState)
2431  {
2432  m_IsInWater = pState;
2433  SetSynchDirty();
2434  }
2435 
2436  bool IsInWater()
2437  {
2438  return m_IsInWater;
2439  }
2440 
2441  // -------------------------------------------------------------------------
2442  void ~PlayerBase()
2443  {
2444  if (GetGame() && (!GetGame().IsDedicatedServer()))
2445  {
2446  ClientData.RemovePlayerBase(this);
2447  SetContaminatedEffectEx(false);
2448  }
2449 
2450  SEffectManager.DestroyEffect(m_FliesEff);
2451  StopSoundSet(m_SoundFliesEffect);
2452  }
2453 
2454  void OnCameraChanged(DayZPlayerCameraBase new_camera)
2455  {
2456  m_CameraSwayModifier = new_camera.GetWeaponSwayModifier();
2457  m_CurrentCamera = new_camera;
2458  }
2459 
2460  DayZPlayerCamera GetCurrentPlayerCamera()
2461  {
2462  return m_CurrentCamera;
2463  }
2464 
2465  bool IsCurrentCameraAimedAtGround()
2466  {
2467  if (!m_CurrentCamera)
2468  return false;
2469 
2470  return m_CurrentCamera.GetCurrentPitch() < PlayerConstants.CAMERA_THRESHOLD_PITCH;
2471  }
2472 
2473  BleedingSourcesManagerServer GetBleedingManagerServer()
2474  {
2475  return m_BleedingManagerServer;
2476  }
2477 
2478  BleedingSourcesManagerRemote GetBleedingManagerRemote()
2479  {
2480  return m_BleedingManagerRemote;
2481  }
2482 
2483  SymptomManager GetSymptomManager()
2484  {
2485  return m_SymptomManager;
2486  }
2488  {
2489  if (!m_VirtualHud)
2490  {
2491  m_VirtualHud = new VirtualHud(this);
2492  }
2493  return m_VirtualHud;
2494  }
2495 
2496  TransferValues GetTransferValues()
2497  {
2498  return m_TrasferValues;
2499  }
2500 
2501  DebugMonitorValues GetDebugMonitorValues()
2502  {
2503  return m_DebugMonitorValues;
2504  }
2505 
2506  // -------------------------------------------------------------------------
2507  /*bool IsCraftingSetUp()
2508  {
2509  return m_IsCraftingReady;
2510  }*/
2511  // -------------------------------------------------------------------------
2512  /*void PerformRecipe()
2513  {*/
2514  /*
2515  Debug.Log("Ingredient1: "+ToString(m_Item1.Ptr().GetType()),"recipes");
2516  Debug.Log("Ingredient2: "+ToString(m_Item2.Ptr().GetType()),"recipes");
2517  */
2518  /*int id = GetCraftingMeta().GetRecipeID();
2519  ItemBase item1 = GetCraftingMeta().GetIngredient1();
2520  ItemBase item2 = GetCraftingMeta().GetIngredient2();
2521 
2522  Debug.Log("PerformRecipe called on player: "+ string.ToString(this),"recipes");
2523 
2524  if (m_ModuleRecipesManager)
2525  {
2526  if (!item1 || !item2)
2527  {
2528  Debug.Log("PerformRecipe: At least one of the object links is now null, not performing the recipe","recipes");
2529  }
2530  else
2531  {
2532 
2533  m_ModuleRecipesManager.PerformRecipeServer(id, item1,item2,this);
2534  }
2535  RequestCraftingDisable();
2536  }
2537  }*/
2538  // -------------------------------------------------------------------------
2539  /*float GetCraftingSetUpDistance()
2540  {
2541  return Math.AbsFloat(vector.Distance(GetCraftingMeta().GetInitPos(), GetPosition()));
2542  }*/
2543  // -------------------------------------------------------------------------
2544 
2545  /*void RequestCraftingSetup(int id, EntityAI item1, EntityAI item2, int craft_type)
2546  {
2547  if (!GetGame().IsDedicatedServer())
2548  {
2549  SetUpCraftingClient(id,item1,item2,craft_type);
2550  SendCraftingMeta();
2551  }
2552 
2553  }*/
2554 
2555  /*void RequestCraftingDisable()
2556  {
2557  if (GetGame().IsServer())
2558  {
2559  SendDisableRequestToClient();
2560  DisableCrafting();
2561  }
2562 
2563  }*/
2564 
2565  /*private void SendDisableRequestToClient()
2566  {
2567  GetGame().RPCSingleParam(this, ERPCs.RPC_CRAFTING_DISABLE, NULL,this);
2568  }*/
2569 
2570  /*private void OnReceiveDisableRequest()
2571  {
2572  DisableCrafting();
2573  }*/
2574 
2575  /*private void SendCraftingMeta()
2576  {
2577  array<ref Param> params = new array<ref Param>;
2578  CraftingMeta cm = GetCraftingMeta();
2579  cm.SerializeValues(params);
2580  GetGame().RPC(this, ERPCs.RPC_CRAFTING_SETUP, params,this);
2581  }*/
2582 
2583  /*private void OnReceiveCraftingMeta(ParamsReadContext ctx)
2584  {
2585  CreateCraftingMeta(0,NULL,NULL,"0 0 0", 0,0);
2586  GetCraftingMeta().DeserializeValuesCtx(ctx);
2587  SetUpCraftingServer();
2588 
2589  }*/
2590  // -------------------------------------------------------------------------
2591  /*private void SetUpCraftingServer()
2592  {
2593  if (GetGame().IsMultiplayer() && GetGame().IsServer())
2594  {
2595  m_IsCraftingReady = true;
2596  m_ModuleRecipesManager.OnCraftingSetUpServer(GetCraftingMeta(), this);
2597  }
2598  }*/
2599 
2600  /*private void SetUpCraftingClient(int id, EntityAI item1, EntityAI item2, int craft_type)
2601  {
2602  if (!GetGame().IsDedicatedServer())
2603  {
2604  m_IsCraftingReady = true;
2605 
2606  float specialty_weight = m_ModuleRecipesManager.GetRecipeSpecialty(id);
2607  float length = m_ModuleRecipesManager.GetRecipeLengthInSecs(id);
2608  CreateCraftingMeta(id, item1, item2, GetPosition(), length, specialty_weight);
2609  m_ModuleRecipesManager.OnCraftingSetUpClient(GetCraftingMeta(), this);
2610  Debug.Log("SetUpCrafting2 called for id: "+ id.ToString()+ " on player: "+ this.ToString(),"recipes");
2611  if (craft_type != AT_WORLD_CRAFT)
2612  {
2613  ActionManagerClient mngr = GetActionManager();
2614  mngr.DisableActions();
2615  ActionTarget actionTarget;
2616  if (item2 == GetItemInHands())
2617  {
2618  actionTarget = new ActionTarget(item1, -1, vector.Zero, -1);
2619  mngr.InjectContinuousAction(craft_type,actionTarget,item2);
2620  }
2621  else
2622  {
2623  actionTarget = new ActionTarget(item2, -1, vector.Zero, -1);
2624  mngr.InjectContinuousAction(craft_type,actionTarget,item1);
2625  }
2626  }
2627  }
2628 
2629  }*/
2630 
2631  // -------------------------------------------------------------------------
2632  /*void DisableCrafting()
2633  {
2634  m_IsCraftingReady = false;
2635  if (!GetGame().IsDedicatedServer())
2636  {
2637  ActionManagerClient mngr = GetActionManager();
2638  if (mngr)
2639  {
2640  mngr.EnableActions();
2641  GetCraftingMeta() = NULL;
2642  }
2643  }
2644  }*/
2645 
2646  //--------------------------------------------------------------------------
2647  void OnScheduledTick(float deltaTime)
2648  {
2649  if (!IsPlayerSelected() || !IsAlive())
2650  return;
2651  if (m_ModifiersManager)
2652  m_ModifiersManager.OnScheduledTick(deltaTime);
2653  if (m_NotifiersManager)
2654  m_NotifiersManager.OnScheduledTick();
2655  if (m_TrasferValues)
2656  m_TrasferValues.OnScheduledTick(deltaTime);
2657  if (m_VirtualHud)
2658  m_VirtualHud.OnScheduledTick();
2659  if (GetBleedingManagerServer())
2660  GetBleedingManagerServer().OnTick(deltaTime);
2661  if (m_Environment)
2662  m_Environment.Update(deltaTime);
2663 
2664  // Check if electric device needs to be unplugged
2665  ItemBase heldItem = GetItemInHands();
2666  if (heldItem && heldItem.HasEnergyManager() && heldItem.GetCompEM().IsPlugged())
2667  {
2668  // Now we know we are working with an electric device which is plugged into a power source.
2669  EntityAI placed_entity = heldItem;
2670 
2671  // Unplug the device when the player is too far from the power source.
2672  placed_entity.GetCompEM().UpdatePlugState();
2673  }
2674  }
2675 
2676  void OnCommandHandlerTick(float delta_time, int pCurrentCommandID)
2677  {
2678  if (!IsAlive())
2679  {
2680  if (!m_DeathSyncSent && m_KillerData)
2681  {
2682  SyncEvents.SendEntityKilled(this, m_KillerData.m_Killer, m_KillerData.m_MurderWeapon, m_KillerData.m_KillerHiTheBrain);
2683  //Print("Sending Death Sync, yay! Headshot by killer = " + m_KillerData.m_KillerHiTheBrain);
2684  //Print("And was he killed by headshot in general? = " + m_KilledByHeadshot);
2685  m_DeathSyncSent = true;
2686  }
2687  return;
2688  }
2689  if (m_DebugMonitorValues)
2690  m_DebugMonitorValues.OnScheduledTick(delta_time);
2691  if (GetSymptomManager())
2692  GetSymptomManager().OnTick(delta_time, pCurrentCommandID, m_MovementState);//needs to stay in command handler tick as it's playing animations
2693  //if (GetBleedingManagerServer()) GetBleedingManagerServer().OnTick(delta_time);
2694 
2696  if (instType == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2697  {
2698  if (m_PlayerSoundEventHandler)
2699  m_PlayerSoundEventHandler.OnTick(delta_time);
2700 
2701  if (m_ProcessRemoveEffectWidgets && m_ProcessRemoveEffectWidgets.Count() > 0)
2702  {
2703  m_EffectWidgets.RemoveActiveEffects(m_ProcessRemoveEffectWidgets);
2704  }
2705 
2706  if (m_ProcessAddEffectWidgets && m_ProcessAddEffectWidgets.Count() > 0)
2707  {
2708  m_EffectWidgets.AddActiveEffects(m_ProcessAddEffectWidgets);
2709  }
2710 
2711  HandleGlassesEffect();
2712 
2713  if (m_ContaminatedAreaEffectEnabled)
2714  ContaminatedParticleAdjustment();
2715 
2716  #ifdef DIAG_DEVELOPER
2717  if (m_WeaponDebug)
2718  {
2719  m_WeaponDebug.OnCommandHandlerUpdate();
2720  }
2721  #endif
2722 
2723  m_ProcessAddEffectWidgets.Clear(); //clears array for remotes as well
2724  m_ProcessRemoveEffectWidgets.Clear(); //clears array for remotes as well
2725  }
2726 
2727  m_AnimCommandStarting = HumanMoveCommandID.None;
2728 
2729  if (CfgGameplayHandler.GetAllowStaminaAffectInertia())
2730  UpdateMovementInertia();
2731  }
2732 
2734  void UpdateMovementInertia()
2735  {
2737  if (hcm)
2738  {
2739  float staminaPercentage = GetStaminaHandler().GetSyncedStaminaNormalized();
2740  hcm.SetTurnSpanSprintModifier(2 - staminaPercentage);
2741  hcm.SetRunSprintFilterModifier((2 - staminaPercentage) * 0.5);
2742  hcm.SetDirectionSprintFilterModifier(2 - staminaPercentage);
2743  }
2744  }
2745 
2746  bool m_ShowDbgUI = true;
2747  int m_DbgListSelection = 0;
2748  float m_DbgSliderValue = 0.0;
2749  ref array<string> m_DbgOptions = {"jedna", "dva", "tri"};
2750 
2751  NotifiersManager GetNotifiersManager()
2752  {
2753  return m_NotifiersManager;
2754  }
2755 
2756  //--------------------------------------------------------------------------
2757  void OnTick()
2758  {
2759  float deltaT = (GetGame().GetTime() - m_LastTick) * 0.001;
2760  if (m_LastTick < 0)
2761  deltaT = 0; //first tick protection
2762 
2763  m_LastTick = GetGame().GetTime();
2764 
2765  OnScheduledTick(deltaT);
2766  }
2767 
2768  // -------------------------------------------------------------------------
2769  override void EEItemIntoHands(EntityAI item)
2770  {
2771  super.EEItemIntoHands(item);
2772 
2773  if (item)
2774  {
2775  MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(item, {Bolt_Base});
2776 
2777  Weapon_Base w;
2778  if (Class.CastTo(w, item))
2779  {
2780  w.ResetWeaponAnimState();
2781 
2783  if (cm)
2784  {
2785  cm.SetMeleeBlock(false);
2786  GetMeleeFightLogic().SetBlock(false);
2787  }
2788  }
2789 
2791  if (item.IsHeavyBehaviour() && IsRaised())
2792  {
2794  if (cm2)
2795  {
2796  cm2.ForceStance(DayZPlayerConstants.STANCEIDX_ERECT);
2797  }
2798  }
2799 
2801  }
2802  }
2803 
2804  override void EEItemOutOfHands(EntityAI item)
2805  {
2806  super.EEItemOutOfHands(item);
2807 
2808  if (IsPlacingLocal())
2809  {
2810  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(TogglePlacingLocal);
2811  }
2812 
2814  }
2815 
2816  PlayerStomach GetStomach()
2817  {
2818  return m_PlayerStomach;
2819  }
2820 
2821  override void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
2822  {
2823  EvaluateDamageHit(pCurrentCommandID);
2824 
2825  // lower implement
2826  super.CommandHandler(pDt,pCurrentCommandID,pCurrentCommandFinished);
2827 
2829 
2830  CheckZeroSoundEvent();
2831  CheckSendSoundEvent();
2832 
2833  ProcessADDModifier();
2834 
2835  if (m_BrokenLegsJunctureReceived)//was there a change in broken legs state ?
2836  {
2837  m_BrokenLegsJunctureReceived = false;
2838  bool initial = m_BrokenLegState < 0;//negative values indicate initial activation
2839 
2840  if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
2841  {
2842  DropHeavyItem();
2843  if (initial)
2844  {
2845  BrokenLegForceProne();
2846  hic.ResetADS();
2847  GetUApi().GetInputByID(UATempRaiseWeapon).Supress();
2848  ExitSights();
2849  }
2850  }
2851  }
2852 
2853  GetDayZPlayerInventory().HandleInventory(pDt);
2854 
2855  if (IsFireWeaponRaised() || m_IsHoldingBreath)
2856  {
2857  ProcessHoldBreath(pDt);
2858  }
2859 
2861 
2862  if (m_AreHandsLocked && GetHumanInventory().GetEntityInHands())
2863  {
2864  m_AreHandsLocked = false;
2865  }
2866 
2867  // freelook camera memory for weapon raycast
2868  if (hic.CameraIsFreeLook() && m_DirectionToCursor == vector.Zero)
2869  {
2870  m_DirectionToCursor = GetGame().GetCurrentCameraDirection();
2871  }
2872  else if (!hic.CameraIsFreeLook() && m_DirectionToCursor != vector.Zero)
2873  {
2874  m_DirectionToCursor = vector.Zero;
2875  }
2876 
2877  if (m_WeaponManager)
2878  {
2879  m_WeaponManager.Update(pDt);
2880  }
2881  if (m_EmoteManager && IsPlayerSelected())
2882  {
2883  m_EmoteManager.Update(pDt);
2884  }
2885  if (m_RGSManager)
2886  {
2887  m_RGSManager.Update();
2888  }
2889  if (m_StanceIndicator)
2890  {
2891  m_StanceIndicator.Update();
2892  }
2893  if (m_StaminaHandler)
2894  {
2895  m_StaminaHandler.Update(pDt, pCurrentCommandID);
2896  }
2897  if (m_InjuryHandler)
2898  {
2899  m_InjuryHandler.Update(pDt);
2900  }
2901  if (m_HCAnimHandler)
2902  {
2903  m_HCAnimHandler.Update(pDt, m_MovementState);
2904  }
2905  if (m_ShockHandler)
2906  {
2907  m_ShockHandler.Update(pDt);
2908  }
2909 
2910  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
2911  {
2912  GetPlayerSoundManagerServer().Update();
2913  ShockRefill(pDt);
2914  FreezeCheck();
2915  }
2916 
2917  GetHumanInventory().Update(pDt);
2918  if (m_IsDrowning)
2919  {
2920  ProcessDrowning(pDt);
2921  }
2922  UpdateDelete();
2923 
2924  HandleDamageHit(pCurrentCommandID);
2925 
2926  if (mngr && hic)
2927  {
2928  mngr.Update(pCurrentCommandID);
2929 
2932 
2933  if (!m_UnconsciousDebug)
2934  {
2936  if (m_ShouldBeUnconscious && m_IsUnconscious)
2937  {
2938  if (hcu)
2939  {
2941  m_Swimming.m_bWasSwimming |= hcu.IsInWater();
2942  }
2943 
2944  if (m_Swimming.m_bWasSwimming)
2945  {
2946  m_LastCommandBeforeUnconscious = DayZPlayerConstants.COMMANDID_SWIM;
2947  }
2948 
2949  OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
2950  }
2952  else if (m_ShouldBeUnconscious)
2953  {
2955  bool isTransitioning = hcv && (hcv.IsGettingIn() || hcv.IsGettingOut() || hcv.IsSwitchSeat());
2956 
2957  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
2958  {
2959  OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
2960 
2961  m_IsUnconscious = true;
2962  OnUnconsciousStart();
2963  }
2967  else if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_DEATH && pCurrentCommandID != DayZPlayerConstants.COMMANDID_FALL && !isTransitioning)
2968  {
2969  m_LastCommandBeforeUnconscious = pCurrentCommandID;
2970 
2971  if (hcv)
2972  {
2973  m_TransportCache = hcv.GetTransport();
2974  }
2975 
2977  m_JumpClimb.CheckAndFinishJump();
2979  SetFallYDiff(GetPosition()[1]);
2980  }
2981  }
2983  else if (m_IsUnconscious)
2984  {
2986  if (hcu && pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
2987  {
2988  OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
2989 
2991  if (m_UnconsciousTime > 2)
2992  {
2993  int wakeUpStance = DayZPlayerConstants.STANCEIDX_PRONE;
2994 
2996  if (m_Swimming.m_bWasSwimming || m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE)
2997  wakeUpStance = -1;
2998 
2999  hcu.WakeUp(wakeUpStance);
3000 
3001  m_IsUnconscious = false;
3002  OnUnconsciousStop(pCurrentCommandID);
3003  }
3004  }
3005  else
3006  {
3008  if (IsAlive())
3009  {
3010  m_IsUnconscious = false;
3011  OnUnconsciousStop(pCurrentCommandID);
3012  }
3013  }
3014  }
3015  }
3016 
3017  // quickbar use
3018  int quickBarSlot = hic.IsQuickBarSlot();
3019  if (quickBarSlot && IsAlive())
3020  {
3021  if (hic.IsQuickBarSingleUse())
3022  {
3023  OnQuickBarSingleUse(quickBarSlot);
3024  //Print("PlayerBase.c IsQuickBarSingleUse - slot: " + quickBarSlot.ToString());
3025  }
3026  if (hic.IsQuickBarContinuousUseStart() && ((!GetGame().IsDedicatedServer()) && !GetGame().GetUIManager().GetMenu()))
3027  {
3028  OnQuickBarContinuousUseStart(quickBarSlot);
3029  //Print("PlayerBase.c IsQuickBarContinuousUseStart - slot: " + quickBarSlot.ToString());
3030  }
3031  if (hic.IsQuickBarContinuousUseEnd() && ((!GetGame().IsDedicatedServer())))
3032  {
3033  OnQuickBarContinuousUseEnd(quickBarSlot);
3034  //Print("PlayerBase.c IsQuickBarContinuousUseEnd - slot: " + quickBarSlot.ToString());
3035  }
3036  }
3037 
3038  /*if ((pCurrentCommandID == DayZPlayerConstants.COMMANDID_ACTION || pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE || pCurrentCommandID == DayZPlayerConstants.COMMANDID_LADDER || pCurrentCommandID == DayZPlayerConstants.COMMANDID_SWIM))
3039  {
3040  mngr.Update(); // checks for suitable action and sets it
3041  }*/
3042  }
3043  if (m_StaminaHandler && hic)
3044  {
3046  if (!CanConsumeStamina(EStaminaConsumers.SPRINT) || !CanSprint())
3047  {
3048  hic.LimitsDisableSprint(true);
3049  }
3050  else
3051  {
3052  hic.LimitsDisableSprint(false);
3053  }
3054  }
3055 
3056  //map closing - feel free to move to different "update" if it does not belong here
3057  if (IsMapOpen())
3058  {
3059  if (!GetGame().IsDedicatedServer())
3060  {
3061  if (!CfgGameplayHandler.GetUse3DMap() && !GetGame().GetUIManager().IsMenuOpen(MENU_MAP))
3062  {
3063  CloseMapEx(false);
3064  }
3065  else if (CfgGameplayHandler.GetUse3DMap())
3066  {
3067  if (IsMapCallbackCancelInput())
3068  {
3069  CloseMapEx(true);
3070  }
3071  else if (IsMapCallbackEndInput())
3072  {
3073  CloseMapEx(false);
3074  }
3075  }
3076  }
3077  }
3078 
3079 
3080 #ifdef BOT
3081  if (m_Bot)
3082  m_Bot.OnUpdate(pDt);
3083 #endif
3084 
3085  if (m_CheckMeleeItem && (!GetGame().IsDedicatedServer()))
3086  {
3087  CheckMeleeItemDamage(m_CheckMeleeItem);
3088  SetCheckMeleeItem();
3089  }
3090 
3091  #ifdef DEVELOPER
3092  TryGetInVehicleDebug();
3093  #endif
3094 
3095  OnCommandHandlerTick(pDt, pCurrentCommandID);
3096  }
3097 
3098  #ifdef DEVELOPER
3099 
3100  void SetGetInVehicleDebug(EntityAI ent)
3101  {
3102  m_GetInVehicleTransportDebug = Transport.Cast(ent);
3103  }
3104 
3105  void TryGetInVehicleDebug()
3106  {
3107  if (m_GetInVehicleTransportDebug)
3108  {
3109  HumanCommandVehicle vehCommand = StartCommand_Vehicle(m_GetInVehicleTransportDebug, 0, 0);
3110  if (vehCommand)
3111  {
3112  vehCommand.SetVehicleType(m_GetInVehicleTransportDebug.GetAnimInstance());
3113  }
3114  m_GetInVehicleTransportDebug = null;
3115  }
3116  }
3117  #endif
3118 
3119  //MAP handling
3121  void CloseMap()
3122  {
3123  CloseMapEx(false);
3124  }
3125 
3126  void CloseMapEx(bool cancelled)
3127  {
3128  if (m_hac && !GetMapClosingSyncSent())
3129  {
3130  if (ScriptInputUserData.CanStoreInputUserData())
3131  {
3132  if (GetGame().IsMultiplayer() && GetGame().IsClient())
3133  {
3134  ActionManagerClient mngr_client;
3135  CastTo(mngr_client, GetActionManager());
3136 
3137  if (cancelled)
3138  {
3139  mngr_client.RequestInterruptAction();
3140  }
3141  else
3142  {
3143  mngr_client.RequestEndAction();
3144  }
3145 
3146  GetGame().GetMission().RemoveActiveInputExcludes({"map"});
3147  GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
3148  }
3149  else if (!GetGame().IsMultiplayer())
3150  {
3151  int command_ID = DayZPlayerConstants.CMD_ACTIONINT_END;
3152  if (cancelled)
3153  {
3154  command_ID = DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT;
3155  }
3156  m_hac.InternalCommand(command_ID);
3157  }
3158  SetMapClosingSyncSet(true);
3159  }
3160  }
3161 
3162  if (!GetGame().IsDedicatedServer())
3163  {
3164  if (GetGame().GetUIManager().IsMenuOpen(MENU_MAP))
3165  {
3166  GetGame().GetUIManager().FindMenu(MENU_MAP).Close();
3167  if (m_Hud)
3168  {
3169  m_Hud.ShowHudPlayer(true);
3170  m_Hud.ShowQuickbarPlayer(true);
3171  }
3172 
3173  GetGame().GetMission().RemoveActiveInputExcludes({"map"});
3174  GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
3175  }
3176  }
3177  }
3178 
3179  void SetMapOpen(bool state)
3180  {
3181  m_MapOpen = state;
3182  }
3183 
3184  bool IsMapOpen()
3185  {
3186  return m_MapOpen;
3187  }
3188 
3189  void SetMapClosingSyncSet(bool state)
3190  {
3191  m_MapClosingSyncSent = state;
3192  }
3193 
3194  bool GetMapClosingSyncSent()
3195  {
3196  return m_MapClosingSyncSent;
3197  }
3198 
3199  bool IsMapCallbackCancelInput()
3200  {
3201  if (IsRaised() || (GetUApi().GetInputByID(UAUIMenu).LocalPress() || GetUApi().GetInputByID(UAGear).LocalPress()))
3202  {
3203  return true;
3204  }
3205 
3206  return false;
3207  }
3208 
3209  bool IsMapCallbackEndInput()
3210  {
3211  if (GetUApi().GetInputByID(UADefaultAction).LocalPress())
3212  {
3213  return true;
3214  }
3215 
3216  return false;
3217  }
3218 
3219  MapNavigationBehaviour GetMapNavigationBehaviour()
3220  {
3221  return m_MapNavigationBehaviour;
3222  }
3223 
3224  void MapNavigationItemInPossession(EntityAI item)
3225  {
3226  if (GetMapNavigationBehaviour())
3227  {
3228  GetMapNavigationBehaviour().OnItemInPlayerPossession(item);
3229  }
3230  }
3231 
3232  void MapNavigationItemNotInPossession(EntityAI item)
3233  {
3234  if (GetMapNavigationBehaviour())
3235  {
3236  GetMapNavigationBehaviour().OnItemNotInPlayerPossession(item);
3237  }
3238  }
3239 
3240  void SetCheckMeleeItem(ItemBase item = null)
3241  {
3242  m_CheckMeleeItem = item;
3243  }
3244 
3245  /*
3246  void AirTemperatureCheck()
3247  {
3248  if (!m_Environment.IsTemperatureSet())
3249  return;
3250  float air_temperature = m_Environment.GetTemperature();
3251  int level = 0;//default
3252  if (MiscGameplayFunctions.IsValueInRange(air_temperature, PlayerConstants.BREATH_VAPOUR_THRESHOLD_HIGH, PlayerConstants.BREATH_VAPOUR_THRESHOLD_LOW))
3253  {
3254  float value = Math.InverseLerp(PlayerConstants.BREATH_VAPOUR_THRESHOLD_LOW, PlayerConstants.BREATH_VAPOUR_THRESHOLD_HIGH,air_temperature);
3255  value = Math.Clamp(value,0,1);
3256  level = Math.Round(Math.Lerp(1,BREATH_VAPOUR_LEVEL_MAX,value));
3257  }
3258  else if (air_temperature < PlayerConstants.BREATH_VAPOUR_THRESHOLD_HIGH)
3259  {
3260  level = BREATH_VAPOUR_LEVEL_MAX;
3261  }
3262  if (level != m_BreathVapour)
3263  {
3264  m_BreathVapour = level;
3265  SetSynchDirty();
3266  }
3267  }
3268  */
3269 
3270  void SetShakesForced(int value)
3271  {
3272  m_ShakesForced = value;
3273  }
3274 
3275  void FreezeCheck()
3276  {
3277  int level;
3278  if (m_ShakesForced > 0)
3279  {
3280  level = m_ShakesForced;
3281  }
3282  else
3283  {
3284  float heat_comfort = GetStatHeatComfort().Get();
3285  if (heat_comfort <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING)
3286  {
3287  float value = Math.InverseLerp(PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING, PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_CRITICAL,heat_comfort);
3288  level = Math.Lerp(1,7,value);
3289  level = Math.Clamp(value,1,7);
3290  /*
3291  value = Math.Clamp(value,0,1);
3292  level = Math.Round(value * SHAKE_LEVEL_MAX);//translate from normalized value to levels
3293  */
3294  }
3295  }
3296  if (level != m_Shakes)
3297  {
3298  m_Shakes = level;
3299  SetSynchDirty();
3300  }
3301  }
3302 
3303  override bool IsLanded(int pCurrentCommandID)
3304  {
3305  if (super.IsLanded(pCurrentCommandID))
3306  {
3307  return true;
3308  }
3309 
3311  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
3312  {
3313  bool wasFalling = m_IsUnconsciousFalling;
3314  m_IsUnconsciousFalling = PhysicsIsFalling(false);
3315  return wasFalling && !m_IsUnconsciousFalling;
3316  }
3317 
3319 
3320  return false;
3321  }
3322 
3323  override bool OnLand(int pCurrentCommandID, FallDamageData fallDamageData)
3324  {
3325  if (super.OnLand(pCurrentCommandID, fallDamageData))
3326  {
3327  return true;
3328  }
3329 
3332 
3333  return false;
3334  }
3335 
3336  override bool IsAlreadyInFallingCommand(int pCurrentCommandID)
3337  {
3338  if (super.IsAlreadyInFallingCommand(pCurrentCommandID))
3339  {
3340  return true;
3341  }
3342 
3345  return pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE;
3346  }
3347 
3348  void OnUnconsciousStart()
3349  {
3350  CloseInventoryMenu();
3351 
3352  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
3353  {
3354  SetInventorySoftLock(true);
3355  if (m_LastCommandBeforeUnconscious != DayZPlayerConstants.COMMANDID_VEHICLE)
3356  {
3357  EntityAI entity_in_hands = GetHumanInventory().GetEntityInHands();
3358  if (entity_in_hands && CanDropEntity(entity_in_hands) && !IsRestrained())
3359  {
3360  DropItem(ItemBase.Cast(entity_in_hands));
3361  }
3362  }
3363  GetGame().GetSoundScene().SetSoundVolume(0,2);
3364  m_EffectWidgets.AddSuspendRequest(EffectWidgetSuspends.UNCON);
3365  }
3366 
3367  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || (!GetGame().IsMultiplayer() && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT))
3368  {
3369  SetSynchDirty();
3370 
3371  if (m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE)
3372  {
3373  if (m_TransportCache)
3374  m_TransportCache.MarkCrewMemberUnconscious(m_TransportCache.CrewMemberIndex(this));
3375  }
3376 
3377  // disable voice communication
3378  GetGame().EnableVoN(this, false);
3379 
3380  if (m_AdminLog)
3381  {
3382  m_AdminLog.UnconStart(this);
3383  }
3384 
3385  // When we fall uncon we force out of block
3386  if (GetMeleeFightLogic())
3387  {
3388  GetMeleeFightLogic().SetBlock(false);
3389  }
3390  }
3391 
3392  SetMasterAttenuation("UnconsciousAttenuation");
3393  }
3394 
3395  void OnUnconsciousStop(int pCurrentCommandID)
3396  {
3397  m_UnconRefillModifier =1;
3398  SetSynchDirty();
3399  m_UnconsciousTime = 0;
3400  m_UnconsciousVignetteTarget = 2;
3401  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
3402  {
3403  if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_DEATH)
3404  {
3405  GetGame().GetSoundScene().SetSoundVolume(g_Game.m_volume_sound,1);
3406  PPERequesterBank.GetRequester(PPERequester_UnconEffects).Stop();
3407  GetGame().GetMission().GetHud().ShowHudUI(true);
3408  GetGame().GetMission().GetHud().ShowQuickbarUI(true);
3409  if (GetGame().GetUIManager().IsDialogVisible())
3410  {
3411  GetGame().GetUIManager().CloseDialog();
3412  }
3413  if (GetGame().GetUIManager().IsMenuOpen(MENU_RESPAWN_DIALOGUE))
3414  {
3415  GetGame().GetUIManager().FindMenu(MENU_RESPAWN_DIALOGUE).Close();
3416  }
3417  }
3418  SetInventorySoftLock(false);
3419  m_EffectWidgets.RemoveSuspendRequest(EffectWidgetSuspends.UNCON);
3420  }
3421  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
3422  {
3423  // enable voice communication
3424  if (IsAlive())
3425  GetGame().EnableVoN(this, true);
3426 
3427  if (m_AdminLog)
3428  {
3429  m_AdminLog.UnconStop(this);
3430  }
3431  }
3432 
3433  SetMasterAttenuation("");
3434  }
3435 
3436  void OnUnconsciousUpdate(float pDt, int last_command)
3437  {
3438  m_UnconsciousTime += pDt;
3439  if (GetGame().IsServer())
3440  {
3441  int shock_simplified = SimplifyShock();
3442 
3443  if (m_ShockSimplified != shock_simplified)
3444  {
3445  m_ShockSimplified = shock_simplified;
3446  SetSynchDirty();
3447  }
3448 
3449  if (m_UnconsciousTime > PlayerConstants.UNCONSCIOUS_IN_WATER_TIME_LIMIT_TO_DEATH && last_command == DayZPlayerConstants.COMMANDID_SWIM)
3450  {
3451  SetHealth("","",-100);
3452  }
3453  }
3454  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
3455  {
3456  GetGame().GetMission().GetHud().ShowHudUI(false);
3457  GetGame().GetMission().GetHud().ShowQuickbarUI(false);
3458  if (GetPulseType() == EPulseType.REGULAR)
3459  {
3460  float shock_simple_normalized = GetSimplifiedShockNormalized();
3461 
3462  float sin = Math.Sin(m_UnconsciousTime * 0.3);
3463  float sin_normalized = (sin + 1) / 2;
3464  if (sin_normalized < 0.05)
3465  {
3466  m_UnconsciousVignetteTarget = (1 - shock_simple_normalized / 3) * 2/*vignette max*/;
3467  }
3468  float vignette = Math.Lerp(2,m_UnconsciousVignetteTarget, sin_normalized);
3469  //PrintString(m_UnconsciousVignetteTarget.ToString());
3470  m_UnconParam.param1 = vignette;
3471  PPERequesterBank.GetRequester(PPERequester_UnconEffects).Start(m_UnconParam);
3472  }
3473  }
3474  }
3475 
3476  int SimplifyShock()
3477  {
3478  int shock = Math.Lerp(0, SIMPLIFIED_SHOCK_CAP, GetHealth("","Shock") / GetMaxHealth("","Shock"));
3479  shock = Math.Clamp(shock, 0, SIMPLIFIED_SHOCK_CAP);
3480  return shock;
3481  }
3482 
3483  float GetSimplifiedShockNormalized()
3484  {
3485  return (m_ShockSimplified / SIMPLIFIED_SHOCK_CAP);
3486  }
3487 
3488  override bool IsUnconscious()
3489  {
3490  return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || m_IsUnconscious;
3491  }
3492 
3493  override bool CanBeTargetedByAI(EntityAI ai)
3494  {
3495  #ifdef DIAG_DEVELOPER
3496  if (!m_CanBeTargetedDebug)
3497  {
3498  return false;
3499  }
3500  #endif
3501 
3502  return super.CanBeTargetedByAI(ai) && !IsUnconscious() && !IsInVehicle();
3503  }
3504 
3505  void GiveShock(float shock)
3506  {
3507  AddHealth("","Shock",shock);
3508  }
3509 
3510 
3511  void OnRestrainStart()
3512  {
3513  CloseInventoryMenu();
3514  GetGame().GetMission().RemoveActiveInputExcludes({"inventory"},true);
3515  GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
3516  }
3517 
3519  void ShockRefill(float pDt);
3520 
3521  //BrokenLegs
3522  // -----------------------
3523 
3524  eBrokenLegs GetBrokenLegs()
3525  {
3526  return Math.AbsInt(m_BrokenLegState);//negative value denotes first time activation
3527  }
3528 
3529  //Server side
3530  void SetBrokenLegs(int stateId)
3531  {
3532  m_BrokenLegState = stateId;
3533 
3534  DayZPlayerSyncJunctures.SendBrokenLegsEx(this, stateId);
3535  eBrokenLegs state = GetBrokenLegs();//m_BrokenLegState can go bellow 0, cannot be used directly
3536 
3537  if (state == eBrokenLegs.NO_BROKEN_LEGS)
3538  {
3539  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
3540  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
3541  }
3542  else if (state == eBrokenLegs.BROKEN_LEGS)
3543  {
3544  SetLegHealth();
3545  }
3546  else if (state == eBrokenLegs.BROKEN_LEGS_SPLINT)
3547  {
3548  // handle splint here
3549  }
3550 
3551  SetSynchDirty();
3552  }
3553 
3554  //Update of state
3555  void UpdateBrokenLegs(int stateId)
3556  {
3557  eBrokenLegs state = GetBrokenLegs();
3558  //Raise broken legs flag and force to prone
3559  if (state != eBrokenLegs.NO_BROKEN_LEGS)
3560  {
3561  if (state == eBrokenLegs.BROKEN_LEGS_SPLINT)
3562  {
3563  if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE)
3564  {
3565  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
3566  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
3567  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask | eInjuryOverrides.BROKEN_LEGS_SPLINT;
3568  }
3569  m_InjuryHandler.CheckValue(false);
3570 
3571  }
3572  else if (state == eBrokenLegs.BROKEN_LEGS)
3573  {
3574 
3575  if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE)
3576  {
3577  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
3578  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
3579  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask | eInjuryOverrides.BROKEN_LEGS;
3580  }
3581 
3582  BrokenLegWalkShock();
3583  m_InjuryHandler.CheckValue(false);
3584 
3585  }
3586  }
3587  else if (state == eBrokenLegs.NO_BROKEN_LEGS)
3588  {
3589  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
3590  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
3591  }
3592 
3593  }
3594 
3595  void BreakLegSound()
3596  {
3597  PlaySoundSet(m_BrokenLegSound, SOUND_BREAK_LEG, 0.1, 0.1);
3598  }
3599  void BrokenLegForceProne(bool forceOverride = false)
3600  {
3601  if (!IsInWater() && !IsSwimming() && !IsClimbingLadder() && !IsInVehicle() && !IsClimbing() && DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_PRONE))
3602  {
3603  if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE && m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
3604  {
3605  EntityAI attachment;
3606  Class.CastTo(attachment, GetItemOnSlot("Splint_Right"));
3607  if (attachment && attachment.GetType() == "Splint_Applied")
3608  {
3609  attachment.Delete();
3610  }
3611 
3612  m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_INITIAL_SHOCK);
3613  m_ShockHandler.CheckValue(true);
3614 
3615 
3616  if (m_ShockHandler.GetCurrentShock() >= 25) //Prevent conflict with unconsciousness by not forcing prone when going uncon (25 shock or less left)
3617  {
3618 
3619  //calcels user action
3621  if (cmd)
3622  {
3623  cmd.Cancel();
3624  }
3625 
3626  StopHandEvent();
3627  //Get command move and verify not null
3628  HumanCommandMove hcm = StartCommand_Move();//not sure why this is here
3629  hcm = GetCommand_Move();
3630  if (hcm)
3631  {
3632  hcm.ForceStance(DayZPlayerConstants.STANCEIDX_PRONE);
3633  }
3634  }
3635  }
3636  }
3637 
3638  m_JumpClimb.CheckAndFinishJump();
3639  }
3640 
3641  //Used to inflict shock when player is walking (only inflicted on Update timer)
3642  void BrokenLegWalkShock()
3643  {
3644  //No need to pursue here if player is prone as the following logic is not applied
3645  if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE && m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
3646  {
3647  float avgLegHealth = GetHealth("RightLeg","") + GetHealth("LeftLeg","") + GetHealth("RightFoot","") + GetHealth("LeftFoot","");
3648  avgLegHealth *= 0.25; //divide by 4 to make the average leg health;
3649 
3650  if (IsSwimming())
3651  {
3652  //swimming other than forward is not detectable in script other than through velocity check
3653  vector v;
3654  PhysicsGetVelocity(v);
3655 
3656  if (v.LengthSq() > 0)
3657  {
3658  m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_SHOCK_SWIM);
3659  }
3660  }
3661  else if (m_MovementState.m_iMovement != 0)
3662  {
3663  if (IsClimbingLadder())
3664  {
3665  MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK);
3666  }
3667  else if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
3668  {
3669  if (m_MovementState.m_iMovement > 1)//only jog and faster
3670  {
3671  MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK);
3672  }
3673  }
3674  else if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
3675  {
3676  //any speed other than idle
3677  MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK * PlayerConstants.BROKEN_CROUCH_MODIFIER, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK * PlayerConstants.BROKEN_CROUCH_MODIFIER, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK * PlayerConstants.BROKEN_CROUCH_MODIFIER);
3678  }
3679  }
3680  else
3681  {
3682  //Here apply shock if player is standing or crouched and STANDING STILL
3683  m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_STAND_SHOCK);
3684  }
3685 
3686  m_ShockHandler.CheckValue(true);
3687  }
3688  }
3689 
3690  //Always use the same thresholds but allow passing of different shock values
3691  void MovingShock(float legHealth, float highShock, float midShock, float lowShock)
3692  {
3693  if (legHealth <= PlayerConstants.BROKEN_LEGS_LOW_HEALTH_THRESHOLD)
3694  {
3695  //Inflict "high shock"
3696  m_ShockHandler.SetShock(highShock);
3697  }
3698  else if (legHealth >= PlayerConstants.BROKEN_LEGS_HIGH_HEALTH_THRESHOLD)
3699  {
3700  //Inflict "low shock"
3701  m_ShockHandler.SetShock(lowShock);
3702  }
3703  else
3704  {
3705  //If neither high nore low, inflict "mid shock"
3706  m_ShockHandler.SetShock(midShock);
3707  }
3708  }
3709 
3710  void DealShock(float dmg)
3711  {
3712  Param1<float> damage = new Param1<float>(0);
3713  damage.param1 = dmg;
3714  GetGame().RPCSingleParam(this, ERPCs.RPC_SHOCK, damage, true, GetIdentity());
3715  }
3716 
3717  //Prevent player from picking up heavy items when legs are broken
3718  override bool CanPickupHeavyItem(notnull EntityAI item)
3719  {
3720  if (item.IsHeavyBehaviour() && (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS || GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS_SPLINT))
3721  return false;
3722 
3723  return super.CanPickupHeavyItem(item);
3724  }
3725 
3726  //Set all leg zones' health to 0 in order to limit emergent behaviour and prevent confusion as to how broken legs really work
3727  void SetLegHealth()
3728  {
3729  SetHealth("RightLeg", "", 0);
3730  SetHealth("RightFoot", "", 0);
3731  SetHealth("LeftLeg", "", 0);
3732  SetHealth("LeftFoot", "", 0);
3733  }
3734 
3735  void DropHeavyItem()
3736  {
3737  ItemBase itemInHands = GetItemInHands();
3738  if (itemInHands && itemInHands.IsHeavyBehaviour())
3739  DropItem(itemInHands);
3740  }
3741 
3742  bool IsWearingSplint()
3743  {
3744  EntityAI attachment;
3745  Class.CastTo(attachment, GetItemOnSlot("Splint_Right"));
3746  if (attachment && attachment.GetType() == "Splint_Applied")
3747  {
3748  return true;
3749  }
3750  return false;
3751  }
3752 
3753  // -----------------------
3754 
3755 
3756  override void OnCommandSwimStart()
3757  {
3758  ItemBase itemInHands = GetItemInHands();
3759  if (itemInHands)
3760  {
3761  if (itemInHands.IsHeavyBehaviour())
3762  {
3763  TryHideItemInHands(false);
3764  DropHeavyItem();
3765  }
3766  else
3767  {
3768  TryHideItemInHands(true);
3769  }
3770  itemInHands.OnItemInHandsPlayerSwimStart(this);
3771  }
3772  m_AnimCommandStarting = HumanMoveCommandID.CommandSwim;
3773 
3774  if (GetInventory())
3775  GetInventory().LockInventory(LOCK_FROM_SCRIPT);
3776 
3777  CloseInventoryMenu();
3778  GetDayZGame().GetBacklit().OnSwimmingStart();
3779 
3780  AbortWeaponEvent();
3781  GetWeaponManager().DelayedRefreshAnimationState(10);
3782  RequestHandAnimationStateRefresh();
3783 
3784  GetGame().GetMission().AddActiveInputExcludes({"swimming"});
3785  }
3786 
3787  override void OnCommandSwimFinish()
3788  {
3789  TryHideItemInHands(false, true);
3790 
3791  if (GetInventory())
3792  GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
3793 
3794  GetDayZGame().GetBacklit().OnSwimmingStop();
3795 
3796  GetWeaponManager().RefreshAnimationState();
3797 
3798  GetGame().GetMission().RemoveActiveInputExcludes({"swimming"});
3799  }
3800 
3801  override void OnCommandLadderStart()
3802  {
3803  m_AnimCommandStarting = HumanMoveCommandID.CommandLadder;
3804  TryHideItemInHands(true);
3805 
3806  if (GetInventory())
3807  GetInventory().LockInventory(LOCK_FROM_SCRIPT);
3808 
3809  CloseInventoryMenu();
3810 
3811  GetGame().GetMission().AddActiveInputExcludes({"ladderclimbing"});
3812  }
3813 
3814  override void OnCommandLadderFinish()
3815  {
3816  TryHideItemInHands(false, true);
3817 
3818  if (GetInventory())
3819  GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
3820 
3821  GetGame().GetMission().RemoveActiveInputExcludes({"ladderclimbing"});
3822  }
3823 
3824  override void OnCommandFallStart()
3825  {
3826  m_AnimCommandStarting = HumanMoveCommandID.CommandFall;
3827 
3828  if (GetInventory())
3829  GetInventory().LockInventory(LOCK_FROM_SCRIPT);
3830 
3831  CloseInventoryMenu();
3832 
3833  AbortWeaponEvent();
3834  GetWeaponManager().DelayedRefreshAnimationState(10);
3835  RequestHandAnimationStateRefresh();
3836  }
3837 
3838  override void OnCommandFallFinish()
3839  {
3840  if (GetInventory())
3841  GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
3842 
3843  GetWeaponManager().RefreshAnimationState();
3844  }
3845 
3846  override void OnCommandClimbStart()
3847  {
3848  m_AnimCommandStarting = HumanMoveCommandID.CommandClimb;
3849 
3850  if (GetInventory())
3851  GetInventory().LockInventory(LOCK_FROM_SCRIPT);
3852 
3853  CloseInventoryMenu();
3854 
3855  AbortWeaponEvent();
3856  GetWeaponManager().DelayedRefreshAnimationState(10);
3857  RequestHandAnimationStateRefresh();
3858  }
3859 
3860  override void OnCommandClimbFinish()
3861  {
3862  if (GetInventory())
3863  GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
3864 
3865  GetWeaponManager().RefreshAnimationState();
3866  }
3867 
3868  override void OnCommandVehicleStart()
3869  {
3870  m_AnimCommandStarting = HumanMoveCommandID.CommandVehicle;
3871 
3872  if (GetInventory())
3873  GetInventory().LockInventory(LOCK_FROM_SCRIPT);
3874 
3875  CloseInventoryMenu();
3876 
3877  ItemBase itemInHand = GetItemInHands();
3878  EntityAI itemOnHead = FindAttachmentBySlotName("Headgear");
3879 
3880  if (itemInHand && itemInHand.GetCompEM())
3881  itemInHand.GetCompEM().SwitchOff();
3882 
3883  TryHideItemInHands(true);
3884 
3885  if (itemOnHead && itemOnHead.GetCompEM())
3886  itemOnHead.GetCompEM().SwitchOff();
3887 
3889  if (hcv && hcv.GetVehicleSeat() == DayZPlayerConstants.VEHICLESEAT_DRIVER)
3890  OnVehicleSeatDriverEnter();
3891 
3892  GetGame().GetMission().AddActiveInputExcludes({"vehicledriving"});
3893  }
3894 
3895  override void OnCommandVehicleFinish()
3896  {
3897  if (GetInventory())
3898  GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
3899 
3900  TryHideItemInHands(false, true);
3901 
3902  if (m_IsVehicleSeatDriver)
3903  OnVehicleSeatDriverLeft();
3904 
3905  GetGame().GetMission().RemoveActiveInputExcludes({"vehicledriving"});
3906  }
3907 
3908  override void OnCommandMelee2Start()
3909  {
3910  m_AnimCommandStarting = HumanMoveCommandID.CommandMelee2;
3911  m_IsFighting = true;
3912 
3913  AbortWeaponEvent();
3914  GetWeaponManager().DelayedRefreshAnimationState(10);
3915  RequestHandAnimationStateRefresh();
3916  }
3917 
3918  override void OnCommandMelee2Finish()
3919  {
3920  RunFightBlendTimer();
3921 
3922  GetWeaponManager().RefreshAnimationState();
3923 
3924  }
3925 
3926  override void OnCommandDeathStart()
3927  {
3928  m_AnimCommandStarting = HumanMoveCommandID.CommandDeath;
3929 
3930  AbortWeaponEvent();
3931  GetWeaponManager().DelayedRefreshAnimationState(10);
3932  RequestHandAnimationStateRefresh();
3933  }
3934 
3935  override void OnJumpStart()
3936  {
3937  m_ActionManager.OnJumpStart();
3938 
3939  AbortWeaponEvent();
3940  GetWeaponManager().DelayedRefreshAnimationState(10);
3941  RequestHandAnimationStateRefresh();
3942  CloseMapEx(true);
3943  }
3944 
3945  override void OnJumpEnd(int pLandType = 0)
3946  {
3947  if (m_PresenceNotifier)
3948  {
3949  switch (pLandType)
3950  {
3951  case HumanCommandFall.LANDTYPE_NONE:
3952  case HumanCommandFall.LANDTYPE_LIGHT:
3953  m_PresenceNotifier.ProcessEvent(EPresenceNotifierNoiseEventType.LAND_LIGHT);
3954  break;
3955  case HumanCommandFall.LANDTYPE_MEDIUM:
3956  case HumanCommandFall.LANDTYPE_HEAVY:
3957  m_PresenceNotifier.ProcessEvent(EPresenceNotifierNoiseEventType.LAND_HEAVY);
3958  break;
3959  }
3960  }
3961 
3962  GetWeaponManager().RefreshAnimationState();
3963  }
3964 
3965  bool IsStance(int stance, int stanceMask)
3966  {
3967  return ((1 << stance) & stanceMask) != 0;
3968  }
3969 
3970  override void OnStanceChange(int previousStance, int newStance)
3971  {
3972  int prone = DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE;
3973  int notProne = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_RAISEDERECT | DayZPlayerConstants.STANCEMASK_RAISEDCROUCH;
3974 
3975  if (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_PRONE) && IsStance(newStance, DayZPlayerConstants.STANCEMASK_ERECT))
3976  m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_FROM_PRONE;
3977 
3978  if (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_PRONE) && IsStance(previousStance, DayZPlayerConstants.STANCEMASK_CROUCH) || (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_CROUCH) && IsStance(newStance, DayZPlayerConstants.STANCEMASK_ERECT)))
3979  m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_FROM_CROUCH;
3980 
3981  if ((IsStance(previousStance, prone) && IsStance(newStance, notProne)) || (IsStance(previousStance, notProne) && IsStance(newStance, prone)))
3982  {
3983  AbortWeaponEvent();
3984  GetWeaponManager().RefreshAnimationState();
3985  }
3986  }
3987 
3988  override bool CanChangeStance(int previousStance, int newStance)
3989  {
3990  // Check if the player is playing a throwing animation
3991  if (GetThrowing().IsThrowingAnimationPlaying())
3992  {
3993  return false;
3994  }
3995 
3996  // don't allow base stance change, only raised hands change
3997  if (IsRolling())
3998  {
3999  if (Math.AbsInt(previousStance - newStance) == 3)
4000  return true;
4001 
4002  return false;
4003  }
4004 
4005  // Check if the player is going to crouch or raised crouch
4006  if (newStance == DayZPlayerConstants.STANCEIDX_CROUCH || newStance == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
4007  {
4008  return GetCurrentWaterLevel() <= GetDayZPlayerType().CommandSwimSettingsW().m_fToErectLevel;
4009  }
4010 
4011  // Check if the player is going to prone
4012  if (newStance == DayZPlayerConstants.STANCEIDX_PRONE || newStance == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
4013  {
4014  return GetCurrentWaterLevel() <= GetDayZPlayerType().CommandSwimSettingsW().m_fToCrouchLevel;
4015  }
4016 
4017  // The player can change stance if none of the conditions above are met
4018  return true;
4019  }
4020 
4021 
4022  override void OnCommandMoveStart()
4023  {
4024  if (GetGame().IsServer())
4025  {
4026  //In case player changes stance through a different command, we refresh the anim overrides
4027  int prone = DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE;
4028  if (!IsPlayerInStance(prone))
4029  {
4030  m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
4031  ForceUpdateInjuredState();
4032  }
4033  }
4034  }
4035 
4036  override bool CanRoll()
4037  {
4038  if (!CanConsumeStamina(EStaminaConsumers.ROLL))
4039  return false;
4040 
4041  if (IsInFBEmoteState() || m_EmoteManager.m_MenuEmote)
4042  {
4043  return false;
4044  }
4045 
4046  return IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE) && GetCommand_Move() && !GetCommand_Move().IsOnBack();
4047  }
4048 
4049  override void OnRollStart(bool isToTheRight)
4050  {
4051  DepleteStamina(EStaminaModifiers.ROLL);
4052 
4053  if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
4054  m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_ROLL_SHOCK);
4055  }
4056 
4057  override void OnRollFinish()
4058  {
4059  }
4060 
4061  void OnJumpOutVehicleFinish(float carSpeed)
4062  {
4063  string surfaceType;
4064  int liquidType;
4065  GetGame().SurfaceUnderObject(this, surfaceType, liquidType);
4066  }
4067 
4068  void OnVehicleSwitchSeat(int seatIndex)
4069  {
4070  if (seatIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
4071  {
4072  OnVehicleSeatDriverEnter();
4073  }
4074  else
4075  {
4076  OnVehicleSeatDriverLeft();
4077  }
4078  }
4079 
4080  void OnVehicleSeatDriverEnter()
4081  {
4082  m_IsVehicleSeatDriver = true;
4083  if (m_Hud)
4084  m_Hud.ShowVehicleInfo();
4085  }
4086 
4087  void OnVehicleSeatDriverLeft()
4088  {
4089  m_IsVehicleSeatDriver = false;
4090  if (m_Hud)
4091  m_Hud.HideVehicleInfo();
4092  }
4093 
4094  override void OnThrowingModeChange(bool change_to_enabled)
4095  {
4096  if (change_to_enabled)
4097  {
4098  PlacingCancelLocal();
4099  PlacingCancelServer();
4100  }
4101  }
4102 
4103  override void EOnFrame(IEntity other, float timeSlice)
4104  {
4105  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
4106  {
4107  #ifndef NO_GUI
4108  m_Hud.Update(timeSlice);
4109  m_Hud.ToggleHeatBufferPlusSign(m_HasHeatBuffer);
4110 
4111  if (IsControlledPlayer() && m_EffectWidgets && m_EffectWidgets.IsAnyEffectRunning())
4112  {
4113  m_EffectWidgets.Update(timeSlice);
4114  }
4115  #endif
4116 
4117  if (m_UndergroundHandler)
4118  m_UndergroundHandler.Tick(timeSlice);
4119  }
4120  }
4121 
4122  override void EOnPostFrame(IEntity other, int extra)
4123  {
4124  float delta_time = (GetGame().GetTime() - m_LastPostFrameTickTime) / 1000;
4125  m_LastPostFrameTickTime = GetGame().GetTime();
4126  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
4127  {
4128  if (GetDamageDealtEffect())
4129  {
4130  if (IsAlive())
4131  GetDamageDealtEffect().Update(delta_time);
4132  else
4133  delete GetDamageDealtEffect();
4134  }
4135 
4136  if (m_EffectRadial)
4137  {
4138  if (IsAlive())
4139  {
4140  m_EffectRadial.Update(delta_time);
4141  }
4142  else
4143  m_EffectRadial = null;
4144  }
4145 
4146 
4147  if (GetFlashbangEffect())
4148  {
4149  if (IsAlive())
4150  {
4151  GetFlashbangEffect().Update(delta_time);
4152  }
4153  else
4154  {
4155  GetFlashbangEffect().Stop();
4156  delete GetFlashbangEffect();
4157  }
4158  }
4159 
4160  if (GetShockEffect())
4161  {
4162  if (IsAlive())
4163  GetShockEffect().Update(delta_time);
4164  else
4165  delete GetShockEffect();
4166  }
4167 
4168  m_InventoryActionHandler.OnUpdate();
4169  }
4170 
4171  #ifdef DIAG_DEVELOPER
4172  DiagOnPostFrame(other, extra);
4173  #endif
4174  }
4175 
4176 #ifdef DIAG_DEVELOPER
4177  protected void DiagOnPostFrame(IEntity other, int extra)
4178  {
4179  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
4180  {
4181  if (m_WeaponDebug)
4182  {
4183  m_WeaponDebug.OnPostFrameUpdate();
4184  }
4185 
4186  if (GetBleedingManagerRemote())
4187  {
4188  GetBleedingManagerRemote().OnUpdate();
4189  }
4190 
4191  if (m_MeleeCombat)
4192  {
4193  if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG))
4194  {
4195  m_MeleeDebug = true;
4196  m_MeleeCombat.Debug(GetItemInHands(), m_MeleeCombat.GetHitType());
4197  }
4198  else if (!DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG) && m_MeleeDebug)
4199  {
4200  m_MeleeDebug = false;
4201  m_MeleeCombat.Debug(GetItemInHands(), m_MeleeCombat.GetHitType());
4202  }
4203  }
4204 
4205  if (DiagMenu.GetBool(DiagMenuIDs.SOUNDS_ITEM_IMPACT_SOUNDS))
4206  InventoryItem.DrawImpacts();
4207 
4208  if (GetPluginManager())
4209  {
4210  PluginDrawCheckerboard drawCheckerboard = PluginDrawCheckerboard.Cast(GetPluginManager().GetPluginByType(PluginDrawCheckerboard));
4211  if (drawCheckerboard && !drawCheckerboard.IsActive())
4212  {
4213  drawCheckerboard.ShowWidgets(DiagMenu.GetBool(DiagMenuIDs.MISC_DRAW_CHECKERBOARD));
4214  }
4215  }
4216 
4217  if (m_PresenceNotifier)
4218  {
4219  m_PresenceNotifier.EnableDebug(DiagMenu.GetBool(DiagMenuIDs.MISC_PRESENCE_NOTIFIER_DBG));
4220  }
4221 
4222  if (DiagMenu.GetBool(DiagMenuIDs.TRIGGER_PLAYER_DEBUG))
4223  {
4224  vector minmax[2];
4225  GetCollisionBox(minmax);
4226 
4227  int color = COLOR_RED_A;
4228  if (m_IsInsideTrigger)
4229  color = COLOR_GREEN_A;
4230 
4231  Shape dbgShape = Debug.DrawBoxEx(minmax[0], minmax[1], color, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE|ShapeFlags.ONCE);
4232 
4233  vector mat[4];
4234  GetTransform(mat);
4235  dbgShape.CreateMatrix(mat);
4236  dbgShape.SetMatrix(mat);
4237  }
4238  }
4239 
4240  if (m_Environment && m_Environment.m_Debug)
4241  {
4242  #ifdef SERVER
4243  EnvDebugData envDebugData = m_Environment.GetEnvDebugData();
4244  GetGame().RPCSingleParam(this, ERPCs.DIAG_MISC_ENVIRONMENT_DEBUG_DATA, envDebugData, false, GetIdentity());
4245  #else
4246  m_Environment.ShowEnvDebugPlayerInfo(DiagMenu.GetBool(DiagMenuIDs.MISC_ENVIRONMENT_DEBUG));
4247  #endif
4248  }
4249 
4250  if (m_FallDamage && m_FallDamage.m_Debug)
4251  {
4252  #ifdef SERVER
4253  FallDamageDebugData fallDamageDebugData = m_FallDamage.GetFallDamageDebugData();
4254  GetGame().RPCSingleParam(this, ERPCs.DIAG_MISC_FALLDAMAGE_DEBUG_DATA, fallDamageDebugData, false, GetIdentity());
4255  #else
4256  m_FallDamage.ShowFallDamageDebugInfo(DiagMenu.GetBool(DiagMenuIDs.MISC_FALLDAMAGE_DEBUG));
4257  #endif
4258  }
4259  }
4260 
4261  override void OnEnterTrigger(ScriptedEntity trigger)
4262  {
4263  super.OnEnterTrigger(trigger);
4264 
4265  ++m_IsInsideTrigger;
4266  }
4267 
4268  override void OnLeaveTrigger(ScriptedEntity trigger)
4269  {
4270  super.OnLeaveTrigger(trigger);
4271 
4272  --m_IsInsideTrigger;
4273  }
4274 #endif
4275 
4276  void StaminaHUDNotifier(bool show)
4277  {
4278  if (m_Hud)
4279  m_Hud.SetStaminaBarVisibility(show);
4280  }
4281 
4282  override void DepleteStamina(EStaminaModifiers modifier, float dT = -1)
4283  {
4284  if (GetStaminaHandler())
4285  GetStaminaHandler().DepleteStamina(modifier,dT);
4286  }
4287 
4288  override bool CanConsumeStamina(EStaminaConsumers consumer)
4289  {
4290  if (!GetStaminaHandler()) return false;
4291 
4292  bool val = (GetStaminaHandler().HasEnoughStaminaFor(consumer) /*&& !IsOverloaded()*/ && !IsRestrained() && !IsInFBEmoteState());
4293 
4294  if (!val)
4295  StaminaHUDNotifier(false);
4296 
4297  return val;
4298  }
4299 
4300  override bool CanStartConsumingStamina(EStaminaConsumers consumer)
4301  {
4302  if (!GetStaminaHandler()) return false;
4303 
4304  bool val = (GetStaminaHandler().HasEnoughStaminaToStart(consumer) && !IsRestrained() && !IsInFBEmoteState());
4305 
4306  if (!val)
4307  StaminaHUDNotifier(false);
4308 
4309  return val;
4310  }
4311 
4313  bool HasStaminaRemaining()
4314  {
4315  if (!GetStaminaHandler())
4316  return false;
4317 
4318  return GetStaminaHandler().GetStamina() > 0;
4319  }
4320 
4321  override bool CanClimb(int climbType, SHumanCommandClimbResult climbRes)
4322  {
4323  if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
4324  {
4325  return false;
4326  }
4327 
4328  if (climbType == 1 && !CanConsumeStamina(EStaminaConsumers.VAULT))
4329  return false;
4330 
4331  if (climbType == 2 && (!CanConsumeStamina(EStaminaConsumers.CLIMB) || GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS))
4332  return false;
4333 
4334  if (climbType > 0 && m_InjuryHandler && m_InjuryHandler.GetInjuryAnimValue() >= InjuryAnimValues.LVL3)
4335  return false;
4336 
4337  return super.CanClimb(climbType,climbRes);
4338  }
4339 
4340  override bool CanJump()
4341  {
4342  if (GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS)
4343  {
4344  return false;
4345  }
4346 
4347  if (!CanConsumeStamina(EStaminaConsumers.JUMP))
4348  return false;
4349 
4351  if (m_InjuryHandler && m_InjuryHandler.GetInjuryAnimValue() >= InjuryAnimValues.LVL3)
4352  return false;
4353 
4354  if (IsInFBEmoteState() || m_EmoteManager.m_MenuEmote)
4355  {
4356  return false;
4357  }
4358 
4359  return super.CanJump();
4360  }
4361 
4362  bool IsJumpInProgress()
4363  {
4364  return m_JumpClimb.m_bIsJumpInProgress;
4365  }
4366 
4367  bool IsTargetInActiveRefresherRange(EntityAI target)
4368  {
4369  array<vector> temp = new array<vector>;
4370  temp = GetGame().GetMission().GetActiveRefresherLocations();
4371  int count = temp.Count();
4372  if (count > 0)
4373  {
4374  vector pos = target.GetPosition();
4375  for (int i = 0; i < count; i++)
4376  {
4377  if (vector.Distance(pos,temp.Get(i)) < GameConstants.REFRESHER_RADIUS)
4378  return true;
4379  }
4380 
4381  return false;
4382  }
4383  else
4384  {
4385  return false;
4386  }
4387  }
4388 
4389  void RequestHandAnimationStateRefresh()
4390  {
4391  if ((GetGame().IsMultiplayer() && GetGame().IsServer()))
4392  {
4393  m_RefreshAnimStateIdx++;
4394  if (m_RefreshAnimStateIdx > 3)
4395  m_RefreshAnimStateIdx = 0;
4396  SetSynchDirty();
4397  }
4398  }
4399 
4400  void RefreshHandAnimationState(int delay = 0)
4401  {
4402  if (delay == 0)
4403  {
4404  GetItemAccessor().OnItemInHandsChanged(true);
4405  GetItemAccessor().ResetWeaponInHands();
4406  }
4407  else
4408  {
4409  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(RefreshHandAnimationState,delay,false,0);
4410  }
4411  }
4412 
4413  // -------------------------------------------------------------------------
4414  // USER ACTIONS
4415  // -------------------------------------------------------------------------
4416 
4417  bool IsFacingTarget(Object target)
4418  {
4419  vector pdir = GetDirection();
4420  vector ptv = target.GetPosition() - GetPosition();
4421  pdir.Normalize();
4422  ptv.Normalize();
4423 
4424  if (Math.AbsFloat(pdir[0]-ptv[0]) < 0.5 && Math.AbsFloat(pdir[2]-ptv[2]) < 0.5)
4425  {
4426  return true;
4427  }
4428  return false;
4429  }
4430 
4431  //---------------------------------------------------------
4432  void OnQuickBarSingleUse(int slotClicked)
4433  {
4434  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
4435  return;
4436 
4437  if (m_AreHandsLocked)
4438  return; //Player is in the short window of time after interrupting placement of an item and before getting it back in hands
4439 
4440  if (GetInventory().IsInventoryLocked() || IsEmotePlaying())
4441  return;
4442 
4443  if (GetThrowing().IsThrowingModeEnabled() || GetThrowing().IsThrowingAnimationPlaying())
4444  return;
4445 
4446  if (IsRaised() || GetCommand_Melee() || IsSwimming() || IsClimbingLadder() || IsClimbing() || IsRestrained() || IsRestrainPrelocked())
4447  return;
4448 
4449  if (GetDayZPlayerInventory().IsProcessing() || IsItemsToDelete())
4450  return;
4451 
4452  if (GetActionManager().GetRunningAction() != null)
4453  return;
4454 
4455  if (GetWeaponManager() && GetWeaponManager().IsRunning())
4456  return;
4457 
4458  if (!ScriptInputUserData.CanStoreInputUserData())
4459  return;
4460 
4461  //TODO MW change locking method
4462  //if (GetDayZPlayerInventory().HasLockedHands())
4463  // return;
4464 
4465  EntityAI quickBarEntity = GetQuickBarEntity(slotClicked - 1);//GetEntityInQuickBar(slotClicked - 1);
4466 
4467  if (!quickBarEntity)
4468  return;
4469 
4470  Magazine mag;
4471  Weapon_Base wpn;
4472 
4473  if (Class.CastTo(mag, quickBarEntity) && Class.CastTo(wpn, mag.GetHierarchyParent()))
4474  return;
4475 
4476  EntityAI inHandEntity = GetHumanInventory().GetEntityInHands();
4477 
4478  if (!GetDayZPlayerInventory().IsIdle())
4479  return; // player is already performing some animation
4480 
4481  InventoryLocation handInventoryLocation = new InventoryLocation;
4482  handInventoryLocation.SetHands(this,quickBarEntity);
4483  if (this.GetInventory().HasInventoryReservation(quickBarEntity, handInventoryLocation))
4484  return;
4485 
4486  if (inHandEntity == quickBarEntity)
4487  {
4488  if (GetHumanInventory().CanRemoveEntityInHands())
4489  {
4490  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Stash - PredictiveMoveItemFromHandsToInventory HND=" + Object.GetDebugName(inHandEntity));
4491  PredictiveMoveItemFromHandsToInventory();
4492  }
4493  }
4494  else
4495  {
4496  InventoryLocation invLocQBItem = new InventoryLocation;
4497  quickBarEntity.GetInventory().GetCurrentInventoryLocation(invLocQBItem);
4498  if (GetInventory().HasInventoryReservation(quickBarEntity,invLocQBItem))
4499  return;
4500 
4501  if (inHandEntity)
4502  {
4503  InventoryLocation Reserved_Item_il = new InventoryLocation;
4504 
4505  InventoryLocation inHandEntityFSwapDst = new InventoryLocation;
4506  inHandEntity.GetInventory().GetCurrentInventoryLocation(inHandEntityFSwapDst);
4507 
4508  int index = GetHumanInventory().FindUserReservedLocationIndex(inHandEntity);
4509  if (index >= 0)
4510  GetHumanInventory().GetUserReservedLocation(index, Reserved_Item_il);
4511 
4512  if (Reserved_Item_il)
4513  inHandEntityFSwapDst.CopyLocationFrom(Reserved_Item_il, true);
4514 
4515  if (index < 0 && GameInventory.CanSwapEntitiesEx(quickBarEntity, inHandEntity))
4516  {
4517  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] PredictiveSwapEntities QB=" + Object.GetDebugName(quickBarEntity) + " HND=" + Object.GetDebugName(inHandEntity));
4518  PredictiveSwapEntities(quickBarEntity, inHandEntity);
4519  }
4520  else if (GameInventory.CanForceSwapEntitiesEx(quickBarEntity, handInventoryLocation, inHandEntity, inHandEntityFSwapDst))
4521  {
4522  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Swap - PredictiveForceSwapEntities HND=" + Object.GetDebugName(inHandEntity) + " QB=" + Object.GetDebugName(quickBarEntity) + " fswap_dst=" + InventoryLocation.DumpToStringNullSafe(inHandEntityFSwapDst));
4523  PredictiveForceSwapEntities(quickBarEntity, inHandEntity, inHandEntityFSwapDst);
4524  }
4525  }
4526  else
4527  {
4528  if (GetInventory().HasInventoryReservation(quickBarEntity,handInventoryLocation))
4529  return;
4530 
4531  if (GetInventory().CanAddEntityIntoHands(quickBarEntity))
4532  {
4533  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Stash - PredictiveTakeEntityToHands QB=" + Object.GetDebugName(quickBarEntity));
4534  PredictiveTakeEntityToHands(quickBarEntity);
4535  }
4536  }
4537  }
4538  }
4539  //---------------------------------------------------------
4540  void OnQuickBarContinuousUseStart(int slotClicked)
4541  {
4542  if (GetInventory().IsInventoryLocked())
4543  return;
4544 
4545  if (IsSwimming() || IsClimbingLadder() || GetCommand_Melee() || IsClimbing() || IsRestrained() || IsRestrainPrelocked())
4546  return;
4547 
4548  ItemBase quickBarItem = ItemBase.Cast(GetQuickBarEntity(slotClicked - 1));
4549 
4550  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
4551  {
4552  ItemBase itemInHands = ItemBase.Cast(GetHumanInventory().GetEntityInHands());
4553 
4554  if (itemInHands != quickBarItem)
4555  {
4557 
4558  if (amc.CanPerformActionFromQuickbar(itemInHands, quickBarItem))
4559  {
4560  amc.PerformActionFromQuickbar(itemInHands, quickBarItem);
4561  }
4562  else
4563  {
4564  if (IsRaised() || GetCommand_Melee())
4565  return;
4566 
4567  amc.ForceTarget(quickBarItem);
4568  m_QuickBarFT = true;
4569  }
4570  }
4571  }
4572  m_QuickBarHold = true;
4573  }
4574  //---------------------------------------------------------
4575  void OnQuickBarContinuousUseEnd(int slotClicked)
4576  {
4577  if (m_QuickBarHold)
4578  {
4579  if ( GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
4580  {
4582 
4583  if (m_ActionQBControl)
4584  {
4585  ActionBase action = am.GetRunningAction();
4586  if (action)
4587  {
4588  if (!action.GetInput().IsActive())
4589  {
4590  am.EndActionInput();
4591  }
4592 
4593  }
4594  }
4595 
4596  if (m_QuickBarFT)
4597  {
4598  am.ClearForceTarget();
4599  m_QuickBarFT = false;
4600  }
4601  }
4602  }
4603  m_QuickBarHold = false;
4604  }
4605  void SetActionEndInput(ActionBase action)
4606  {
4607  m_ActionQBControl = !action.GetInput().IsActive();
4608  }
4609 
4610  bool IsQBControl()
4611  {
4612  return m_ActionQBControl;
4613  }
4614  void ResetActionEndInput()
4615  {
4616  m_ActionQBControl = false;
4617  }
4618 
4619  //---------------------------------------------------------
4620  // RADIAL QUICKBAR AND RELOAD ACTIONS
4621  //---------------------------------------------------------
4622  //the same functionality as normal quick bar slot key press
4623  void RadialQuickBarSingleUse(int slotClicked)
4624  {
4625  OnQuickBarSingleUse(slotClicked);
4626  }
4627 
4628  //removed the need for holding down quick bar slot key
4629  void RadialQuickBarCombine(int slotClicked)
4630  {
4631  EntityAI quickBarEntity = GetQuickBarEntity(slotClicked - 1);
4632  EntityAI entity_in_hands = GetHumanInventory().GetEntityInHands();
4633 
4634  ReloadWeapon(entity_in_hands, quickBarEntity);
4635  }
4636 
4637  //removed the need for holding down quick bar slot key
4638  void QuickReloadWeapon(EntityAI weapon)
4639  {
4640  EntityAI magazine = GetMagazineToReload(weapon);
4641  ReloadWeapon(weapon, magazine);
4642  }
4643 
4644  //Reload weapon with given magazine
4645  void ReloadWeapon(EntityAI weapon, EntityAI magazine)
4646  {
4647  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
4648  {
4649  ActionManagerClient mngr_client;
4650  CastTo(mngr_client, GetActionManager());
4651 
4652  if (mngr_client && FirearmActionLoadMultiBulletRadial.Cast(mngr_client.GetRunningAction()))
4653  {
4654  mngr_client.Interrupt();
4655  }
4656  else if (GetHumanInventory().GetEntityInHands()!= magazine)
4657  {
4658  Weapon_Base wpn;
4659  Magazine mag;
4660  Class.CastTo(wpn, weapon);
4661  Class.CastTo(mag, magazine);
4662  if (GetWeaponManager().CanUnjam(wpn))
4663  {
4664  GetWeaponManager().Unjam();
4665  }
4666  else if (GetWeaponManager().CanAttachMagazine(wpn, mag))
4667  {
4668  GetWeaponManager().AttachMagazine(mag);
4669  }
4670  else if (GetWeaponManager().CanSwapMagazine(wpn, mag))
4671  {
4672  GetWeaponManager().SwapMagazine(mag);
4673  }
4674  else if (GetWeaponManager().CanLoadBullet(wpn, mag))
4675  {
4676  //GetWeaponManager().LoadMultiBullet(mag);
4677 
4678  ActionTarget atrg = new ActionTarget(mag, this, -1, vector.Zero, -1.0);
4679  if (mngr_client && !mngr_client.GetRunningAction() && mngr_client.GetAction(FirearmActionLoadMultiBulletRadial).Can(this, atrg, wpn))
4680  mngr_client.PerformActionStart(mngr_client.GetAction(FirearmActionLoadMultiBulletRadial), atrg, wpn);
4681  }
4682  }
4683  }
4684  }
4685 
4686  //returns compatible magazine from player inventory with highest ammo count
4687  EntityAI GetMagazineToReload(EntityAI weapon)
4688  {
4689  Weapon_Base weapon_base = Weapon_Base.Cast(weapon);
4690  WeaponManager weapon_manager = GetWeaponManager();
4691  EntityAI magazine_to_reload;
4692 
4693  EntityAI ammo_magazine; //magazine
4694  int last_ammo_magazine_count;
4695  int ammo_magazine_count;
4696 
4697  EntityAI ammo_pile; //ammo pile
4698  int last_ammo_pile_count;
4699  int ammo_pile_count;
4700 
4701  //Get all magazines in (player) inventory
4702  for (int att_i = 0; att_i < GetInventory().AttachmentCount(); ++att_i)
4703  {
4704  EntityAI attachment = GetInventory().GetAttachmentFromIndex(att_i);
4705  ref CargoBase attachment_cargo = attachment.GetInventory().GetCargo();
4706 
4707  if (attachment_cargo)
4708  {
4709  for (int cgo_i = 0; cgo_i < attachment_cargo.GetItemCount(); ++cgo_i)
4710  {
4711  EntityAI cargo_item = attachment_cargo.GetItem(cgo_i);
4712 
4713  //check for proper magazine
4714  if (cargo_item.IsMagazine())
4715  {
4716  Magazine magazine = Magazine.Cast(cargo_item);
4717  ammo_pile_count = magazine.GetAmmoCount();
4718 
4719  //magazines (get magazine with max ammo count)
4720  if (weapon_manager.CanAttachMagazine(weapon_base, magazine) || weapon_manager.CanSwapMagazine(weapon_base, magazine))
4721  {
4722  if (ammo_pile_count > 0)
4723  {
4724  if (last_ammo_magazine_count == 0)
4725  {
4726  ammo_magazine = magazine;
4727  last_ammo_magazine_count = ammo_pile_count;
4728  }
4729  else
4730  {
4731  if (last_ammo_magazine_count < ammo_pile_count)
4732  {
4733  ammo_magazine = magazine;
4734  last_ammo_magazine_count = ammo_pile_count;
4735  }
4736  }
4737  }
4738  }
4739  //bullets (get ammo pile with min ammo count)
4740  else if (weapon_manager.CanLoadBullet(weapon_base, magazine))
4741  {
4742  if (ammo_pile_count > 0)
4743  {
4744  if (last_ammo_pile_count == 0)
4745  {
4746  ammo_pile = magazine;
4747  last_ammo_pile_count = ammo_pile_count;
4748  }
4749  else
4750  {
4751  if (last_ammo_pile_count > ammo_pile_count)
4752  {
4753  ammo_pile = magazine;
4754  last_ammo_pile_count = ammo_pile_count;
4755  }
4756  }
4757  }
4758  }
4759  }
4760  }
4761  }
4762  }
4763 
4764  //prioritize magazine
4765  if (ammo_magazine)
4766  {
4767  return ammo_magazine;
4768  }
4769 
4770  return ammo_pile;
4771  }
4772  //---------------------------------------------------------
4773 
4774 
4775  //---------------------------------------------------------
4776  void OnSpawnedFromConsole()
4777  {
4778  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
4779  {
4780  GetGame().GetMission().AddDummyPlayerToScheduler(this);
4781  OnSelectPlayer();
4782  }
4783  }
4784 
4785  //---------------------------------------------------------
4786  //Obsolete
4787  bool GetLiquidTendencyDrain()
4788  {
4789  return m_LiquidTendencyDrain;
4790  }
4791  //---------------------------------------------------------
4792  //Obsolete
4793  void SetLiquidTendencyDrain(bool state)
4794  {
4795  m_LiquidTendencyDrain = state;
4796  }
4797 
4798  //---------------------------------------------------------
4800  bool GetFlagTendencyRaise()
4801  {
4802  return m_FlagRaisingTendency;
4803  }
4804  //---------------------------------------------------------
4806  void SetFlagTendencyRaise(bool state)
4807  {
4808  m_FlagRaisingTendency = state;
4809  }
4810 
4811  override SoundOnVehicle PlaySound(string sound_name, float range, bool create_local = false)
4812  {
4813  return BetaSound.SaySound(this, sound_name, range, false);
4814  }
4815 
4816  float GetPlayerLoad()
4817  {
4818  return GetWeightEx();
4819  }
4820 
4821  bool IsOverloaded()
4822  {
4823  return GetWeightEx() >= OVERLOAD_LIMIT;
4824  }
4825 
4826  void SetPlayerLoad(float load)//Deprecated
4827  {
4828  m_CargoLoad = load;
4829  //Print("m_CargoLoad: " + m_CargoLoad);
4830  //Log(ToString(this) + "'s load weight is " + ftoa(m_CargoLoad) + " g.", LogTemplates.TEMPLATE_PLAYER_WEIGHT);
4831  }
4832 
4833  //Deprecated, will be overrid by other method calls (in order to ensure stamina calculation is properly set)
4834  void AddPlayerLoad(float addedload)//Deprecated
4835  {
4836  float newload = GetPlayerLoad() + addedload;
4837  SetPlayerLoad(newload);
4838 
4839  // Do not need -> Log is in SetPlayerLoad
4840  //PrintString(ToString(this) + "'s load weight is " + ToString(m_CargoLoad) + " g.");
4841  }
4842 
4843  bool IsItemInInventory(EntityAI entity)
4844  {
4845  return GetInventory().HasEntityInInventory(entity);
4846  }
4847 
4848  override bool NeedInventoryJunctureFromServer(notnull EntityAI item, EntityAI currParent, EntityAI newParent)
4849  {
4850  if (GetGame().IsMultiplayer())
4851  {
4853  switch (t)
4854  {
4855  case DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER:
4856  return false;
4857  case DayZPlayerInstanceType.INSTANCETYPE_CLIENT:
4858  case DayZPlayerInstanceType.INSTANCETYPE_SERVER:
4859  case DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER:
4860  case DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE:
4861  case DayZPlayerInstanceType.INSTANCETYPE_REMOTE:
4862  return true; // Might help mitigate "megabugged" (desync)
4863 
4864  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " NeedInventoryJunctureFromServer item=" + Object.GetDebugName(item) + " currPar=" + currParent + " newPar=" + newParent);
4865 
4866  bool i_owned = GetHumanInventory().HasEntityInInventory(item);
4867 
4868  bool cp_owned = false;
4869  if (currParent)
4870  cp_owned = GetHumanInventory().HasEntityInInventory(currParent);
4871 
4872  bool np_owned = false;
4873  if (newParent)
4874  np_owned = GetHumanInventory().HasEntityInInventory(newParent);
4875 
4876  bool all_owned = i_owned && cp_owned && (np_owned || (newParent == null));
4877  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " NeedInventoryJunctureFromServer=" + !all_owned + " i_pwn=" + i_owned + " cp_pwn=" + cp_owned + " np_pwn=" + np_owned);
4878 
4879  return !all_owned;
4880  default:
4881  Error("[syncinv] unsupported instance type t=" + t);
4882  break;
4883  }
4884  }
4885  return false;
4886  }
4887 
4888 
4889  override protected float GetWeightSpecialized(bool forceRecalc = false)
4890  {
4891  float totalWeight = super.GetWeightSpecialized(forceRecalc);
4892 
4893  ItemBase itemHands = GetItemInHands();
4894  if (itemHands) // adds weight of item carried in hands
4895  {
4896  totalWeight += itemHands.GetWeightEx(forceRecalc);
4897  }
4898  #ifdef DEVELOPER
4899  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
4900  {
4901  float itemInHandsWeight = totalWeight - super.GetWeightSpecialized(forceRecalc);
4902  WeightDebugData dta = WeightDebug.GetWeightDebug(this);
4903  dta.SetCalcDetails("TMan: " + (super.GetWeightSpecialized(forceRecalc)+ itemInHandsWeight) +"(contents weight[includes item in hands])");
4904  }
4905  #endif
4906  return totalWeight;
4907  }
4908 
4909  void CalculateVisibilityForAI()
4910  {
4911  const int VISIBILITY_SLOTS_COUNT = 10;
4912 
4913  int attcount = GetInventory().AttachmentCount();
4914  float sumVisibility = 0;
4915  float countVisibility = 0;
4916  float visibilityMean = 0;
4917 
4918  if (attcount > 0)
4919  {
4920  for (int att = 0; att < attcount; att++)
4921  {
4922  EntityAI attachment = GetInventory().GetAttachmentFromIndex(att);
4923  if (attachment.IsClothing())
4924  {
4925  ClothingBase clothing;
4926  Class.CastTo(clothing, attachment);
4927  sumVisibility += clothing.GetItemVisibility();
4928  countVisibility++;
4929  }
4930  }
4931 
4932  visibilityMean = (sumVisibility + (VISIBILITY_SLOTS_COUNT - countVisibility)) / VISIBILITY_SLOTS_COUNT;
4933  SetVisibilityCoef(visibilityMean);
4934  }
4935  else
4936  {
4937  visibilityMean = 1;
4938  SetVisibilityCoef(visibilityMean);
4939  }
4940  }
4941 
4942  void SetVisibilityCoef(float pVisibility)
4943  {
4944  m_VisibilityCoef = pVisibility;
4945  }
4946 
4947  float GetVisibilityCoef()
4948  {
4949  return m_VisibilityCoef;
4950  }
4951 
4952 
4953  int GetShakeLevel()
4954  {
4955  return m_Shakes;
4956  }
4957 
4958 
4959  EStatLevels GetStatLevelHealth()
4960  {
4961  float health = GetHealth("","");
4962  return GetStatLevel(health, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH);
4963  }
4964 
4965  EStatLevels GetStatLevelToxicity()
4966  {
4967  float toxicity = GetStatToxicity().Get();
4968  return GetStatLevel(toxicity, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH);
4969  }
4970 
4971  EStatLevels GetStatLevelBlood()
4972  {
4973  float blood = GetHealth("","Blood");
4974  return GetStatLevel(blood, PlayerConstants.SL_BLOOD_CRITICAL, PlayerConstants.SL_BLOOD_LOW, PlayerConstants.SL_BLOOD_NORMAL, PlayerConstants.SL_BLOOD_HIGH);
4975  }
4976 
4977  EStatLevels GetStatLevelEnergy()
4978  {
4979  float energy = GetStatEnergy().Get();
4980  return GetStatLevel(energy, PlayerConstants.SL_ENERGY_CRITICAL, PlayerConstants.SL_ENERGY_LOW, PlayerConstants.SL_ENERGY_NORMAL, PlayerConstants.SL_ENERGY_HIGH);
4981  }
4982 
4983  EStatLevels GetStatLevelWater()
4984  {
4985  float water = GetStatWater().Get();
4986  return GetStatLevel(water, PlayerConstants.SL_WATER_CRITICAL, PlayerConstants.SL_WATER_LOW, PlayerConstants.SL_WATER_NORMAL, PlayerConstants.SL_WATER_HIGH);
4987  }
4988 
4990  /*
4991  EStatLevels GetImmunityLevel()
4992  {
4993  float immunity = GetImmunity();
4994 
4995  EStatLevels level;
4996  if (immunity > PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_HIGH)
4997  {
4998  level = EStatLevels.GREAT;
4999  }
5000  else if (immunity > PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_NORMAL)
5001  {
5002  level = EStatLevels.HIGH;
5003  }
5004  else if (immunity > PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_LOW)
5005  {
5006  level = EStatLevels.MEDIUM;
5007  }
5008  else if (immunity > PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_CRITICAL)
5009  {
5010  level = EStatLevels.LOW;
5011  }
5012  else
5013  {
5014  level = EStatLevels.CRITICAL;
5015  }
5016 
5017  if (m_ImmunityBoosted && level != EStatLevels.GREAT)
5018  {
5019  level--;
5020  }
5021  return level;
5022  }
5023  */
5024 
5025  EStatLevels GetImmunityLevel()
5026  {
5027  float immunity = GetImmunity();
5028  if (m_ImmunityBoosted)
5029  return EStatLevels.GREAT;
5030  return GetStatLevel(immunity, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_CRITICAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_LOW, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_NORMAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_HIGH);
5031  }
5032 
5033  //-------------------------------------
5034  float GetBordersImmunity()
5035  {
5036  float immunity = GetImmunity();
5037  float immmunity_max = 1;
5038  return GetStatLevelBorders(immunity, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_CRITICAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_LOW, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_NORMAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_HIGH, immmunity_max);
5039  }
5040 
5041 
5042  float GetStatBordersHealth()
5043  {
5044  float health = GetHealth("","");
5045  float health_max = GetMaxHealth("","");
5046  return GetStatLevelBorders(health, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH, health_max);
5047  }
5048 
5049  float GetStatBordersToxicity()
5050  {
5051  float toxicity = GetStatToxicity().Get();
5052  float toxicity_max = GetStatToxicity().GetMax();
5053  return GetStatLevelBorders(toxicity, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH, toxicity_max);
5054  }
5055 
5056  float GetStatBordersBlood()
5057  {
5058  float blood = GetHealth("","Blood");
5059  float blood_max = GetMaxHealth("","Blood");
5060  return GetStatLevelBorders(blood, PlayerConstants.SL_BLOOD_CRITICAL, PlayerConstants.SL_BLOOD_LOW, PlayerConstants.SL_BLOOD_NORMAL, PlayerConstants.SL_BLOOD_HIGH, blood_max);
5061  }
5062 
5063  float GetStatBordersEnergy()
5064  {
5065  float energy = GetStatEnergy().Get();
5066  float energy_max = GetStatEnergy().GetMax();
5067  return GetStatLevelBorders(energy, PlayerConstants.SL_ENERGY_CRITICAL, PlayerConstants.SL_ENERGY_LOW, PlayerConstants.SL_ENERGY_NORMAL, PlayerConstants.SL_ENERGY_HIGH, energy_max);
5068  }
5069 
5070  float GetStatBordersWater()
5071  {
5072  float water = GetStatWater().Get();
5073  float water_max = GetStatWater().GetMax();
5074  return GetStatLevelBorders(water, PlayerConstants.SL_WATER_CRITICAL, PlayerConstants.SL_WATER_LOW, PlayerConstants.SL_WATER_NORMAL, PlayerConstants.SL_WATER_HIGH, water_max);
5075  }
5076 
5077  //------------------------------------
5078 
5079  float GetStatLevelBorders(float stat_value, float critical, float low, float normal, float high, float max)
5080  {
5081  if (stat_value <= critical)
5082  {
5083  return Math.InverseLerp(0, critical, stat_value);
5084  }
5085  if (stat_value <= low)
5086  {
5087  return Math.InverseLerp(critical, low, stat_value);
5088  }
5089  if (stat_value <= normal)
5090  {
5091  return Math.InverseLerp(low, normal, stat_value);
5092  }
5093  if (stat_value <= high)
5094  {
5095  return Math.InverseLerp(normal, high, stat_value);
5096  }
5097  return Math.InverseLerp(high, max, stat_value);
5098  }
5099 
5100  EStatLevels GetStatLevel(float stat_value, float critical, float low, float normal, float high)
5101  {
5102  if (stat_value <= critical)
5103  {
5104  return EStatLevels.CRITICAL;
5105  }
5106  if (stat_value <= low)
5107  {
5108  return EStatLevels.LOW;
5109  }
5110  if (stat_value <= normal)
5111  {
5112  return EStatLevels.MEDIUM;
5113  }
5114  if (stat_value <= high)
5115  {
5116  return EStatLevels.HIGH;
5117  }
5118  return EStatLevels.GREAT;
5119  }
5120 
5121  void SetImmunityBoosted(bool boosted)
5122  {
5123  m_ImmunityBoosted = boosted;
5124  }
5125 
5126 
5127 
5129  float GetImmunity()
5130  {
5131  float immunity;
5132  if (GetPlayerStats())
5133  {
5134  float max_health = GetMaxHealth("GlobalHealth", "Health") + 0.01;//addition to prevent divisioin by zero in case of some messup
5135  float max_blood = GetMaxHealth("GlobalHealth", "Blood") + 0.01;//addition to prevent divisioin by zero in case of some messup
5136  float energy_normalized = GetStatEnergy().Get() / PlayerConstants.SL_ENERGY_MAX;
5137  float water_normalized = GetStatWater().Get() / PlayerConstants.SL_WATER_MAX;
5138  float health_normalized = GetHealth("GlobalHealth", "Health") / max_health;
5139  float blood_normalized = GetHealth("GlobalHealth", "Blood") / max_blood;
5140  immunity = energy_normalized + water_normalized + health_normalized + blood_normalized;
5141  immunity = immunity / 4;//avg
5142  immunity = Math.Clamp(immunity,0,1);
5143  }
5144  return immunity;
5145  }
5146 
5147  bool IsSprinting()
5148  {
5149  return m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENT_SPRINT);
5150  }
5151 
5152  bool CanSprint()
5153  {
5154  ItemBase item = GetItemInHands();
5155  if (IsRaised() || (item && item.IsHeavyBehaviour()))
5156  return false;
5157 
5158  if (item && GetThrowing() && GetThrowing().IsThrowingModeEnabled())
5159  return false;
5160 
5161  if (GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS)
5162  return false;
5163 
5164  return true;
5165  }
5166 
5167  bool IsInProne()
5168  {
5169  return m_MovementState.IsInProne();
5170  }
5171 
5172  bool IsInRasedProne()
5173  {
5174  return m_MovementState.IsInRaisedProne();
5175  }
5176 
5177  bool IsLeaning()
5178  {
5179  return m_MovementState.IsLeaning();
5180  }
5181 
5182  bool IsRolling()
5183  {
5184  return GetCommand_Move() && GetCommand_Move().IsInRoll());
5185  }
5186 
5187  /*
5188  override bool IsRaised()
5189  {
5190  //GetMovementState(m_MovementState);
5191  return m_MovementState.IsRaised();
5192  }
5193  */
5194 
5195 
5196 
5197  bool IsClimbing()
5198  {
5199  return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_CLIMB;
5200  }
5201 
5202  bool IsFalling()
5203  {
5204  return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_FALL;
5205  }
5206  override bool IsFighting()
5207  {
5208  return m_IsFighting;
5209  }
5210 
5211  bool IsEmotePlaying()
5212  {
5213  if (m_EmoteManager)
5214  {
5215  return m_EmoteManager.IsEmotePlaying();
5216  }
5217  else
5218  {
5219  return false;
5220  }
5221  }
5222 
5223  override bool IsIgnoredByConstruction()
5224  {
5225  return IsRuined();
5226  }
5227 
5232  bool AnimCommandCheck(HumanMoveCommandID mask)
5233  {
5234  return m_AnimCommandStarting & mask;
5235  }
5236 
5237  void RunFightBlendTimer()
5238  {
5239  if (!m_FightEndBlendTimer)
5240  m_FightEndBlendTimer = new Timer();
5241  if (!m_FightEndBlendTimer.IsRunning())
5242  {
5243  m_FightEndBlendTimer.Run(PlayerConstants.MELEE2_MOVEMENT_BLEND_DELAY,this,"EndFighting");
5244  }
5245  }
5246 
5247  void EndFighting()
5248  {
5249  m_IsFighting = false;
5250  }
5251 
5252  bool CheckMeleeItemDamage(ItemBase item)
5253  {
5254  //on-hit drop of melee weapons
5255  //bayonets & buttstocks
5256  if (item && item.GetHierarchyParent() && item.GetHierarchyParent().IsWeapon() && item.IsRuined()/*&& item.FindAttachmentBySlotName()*/)
5257  {
5258  PlayAttachmentDropSound();
5259  return DropItem(item);
5260  }
5261  //handheld items themselves
5262  if (item && item == GetItemInHands() && item.IsRuined())
5263  {
5264  return PredictiveDropEntity(item);
5265  }
5266  return false;
5267  }
5268 
5269  void PlayAttachmentDropSound()
5270  {
5271  //TODO
5272  }
5273 
5274  // -------------------------------------------------------------------------
5275  override void RPC(int rpc_type, array<ref Param> params, bool guaranteed, PlayerIdentity recipient = NULL)
5276  {
5277  super.RPC(rpc_type, params, guaranteed, recipient);
5278  }
5279 
5280  // -------------------------------------------------------------------------
5281  override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
5282  {
5283  super.OnRPC(sender, rpc_type, ctx);
5284 
5285  switch (rpc_type)
5286  {
5287  #ifndef SERVER
5288 
5289  case ERPCs.RPC_SYNC_DISPLAY_STATUS:
5290  if (GetVirtualHud())
5291  {
5292  GetVirtualHud().OnRPC(ctx);
5293  }
5294  break;
5295 
5296  case ERPCs.RPC_PLAYER_SYMPTOM_ON:
5297  if (GetSymptomManager())
5298  {
5299  GetSymptomManager().OnRPC(ERPCs.RPC_PLAYER_SYMPTOM_ON, ctx);
5300  }
5301  break;
5302 
5303  case ERPCs.RPC_PLAYER_SYMPTOM_OFF:
5304  if (GetSymptomManager())
5305  {
5306  GetSymptomManager().OnRPC(ERPCs.RPC_PLAYER_SYMPTOM_OFF, ctx);
5307  }
5308  break;
5309 
5310  case ERPCs.RPC_DAMAGE_VALUE_SYNC:
5311  if (m_TrasferValues)
5312  m_TrasferValues.OnRPC(ctx);
5313  break;
5314 
5315  case ERPCs.RPC_USER_ACTION_MESSAGE:
5316  if (!GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
5317  {
5318  break;
5319  }
5320  if (ctx.Read(m_UAParamMessage))
5321  {
5322  string actiontext = m_UAParamMessage.param1;
5323  MessageAction(actiontext);
5324  }
5325  break;
5326 
5327  case ERPCs.RPC_SOFT_SKILLS_SPECIALTY_SYNC:
5328  ref Param1<float> p_synch = new Param1<float>(0);
5329  ctx.Read(p_synch);
5330  float specialty_level = p_synch.param1;
5331  GetSoftSkillsManager().SetSpecialtyLevel(specialty_level);
5332  break;
5333 
5334  case ERPCs.RPC_SOFT_SKILLS_STATS_SYNC:
5335  ref Param5<float, float, float, float, bool> p_debug_synch = new Param5<float, float ,float, float, bool>(0, 0, 0, 0, false);
5336  ctx.Read(p_debug_synch);
5337  float general_bonus_before = p_debug_synch.param1;
5338  float general_bonus_after = p_debug_synch.param2;
5339  float last_UA_value = p_debug_synch.param3;
5340  float cooldown_value = p_debug_synch.param4;
5341  float cooldown_active = p_debug_synch.param5;
5342  GetSoftSkillsManager().SetGeneralBonusBefore(general_bonus_before);
5343  GetSoftSkillsManager().SetGeneralBonusAfter(general_bonus_after);
5344  GetSoftSkillsManager().SetLastUAValue(last_UA_value);
5345  GetSoftSkillsManager().SetCoolDownValue(cooldown_value);
5346  GetSoftSkillsManager().SetCoolDown(cooldown_active);
5347  break;
5348 
5349  case ERPCs.RPC_WARNING_ITEMDROP:
5350  {
5351  if (GetGame().IsClient() && GetGame().GetUIManager() && !GetGame().GetUIManager().FindMenu(MENU_WARNING_ITEMDROP))
5352  {
5353  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_WARNING_ITEMDROP,null);
5354  GetGame().GetMission().AddActiveInputExcludes({"menu"});
5355  }
5356  break;
5357  }
5358 
5359  case ERPCs.RPC_WARNING_TELEPORT:
5360  {
5361  if (GetGame().IsClient() && GetGame().GetUIManager() && !GetGame().GetUIManager().FindMenu(MENU_WARNING_TELEPORT))
5362  {
5363  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_WARNING_TELEPORT,null);
5364  GetGame().GetMission().AddActiveInputExcludes({"menu"});
5365  }
5366  break;
5367  }
5368  case ERPCs.RPC_INIT_SET_QUICKBAR:
5369  ref Param1<int> count = new Param1<int>(0);
5370  if (ctx.Read(count));
5371  {
5372  for (int i = 0; i < count.param1 ; i++)
5373  {
5374  m_QuickBarBase.OnSetEntityRPC(ctx);
5375  }
5376  }
5377  break;
5378 
5379  case ERPCs.RPC_SYNC_THERMOMETER:
5380  {
5381  float value;
5382  if (ctx.Read(value))
5383  m_Hud.SetTemperature(value.ToString() + "#degrees_celsius");
5384  break;
5385  }
5386 
5387 
5388  case ERPCs.RPC_CHECK_PULSE:
5389  ctx.Read(CachedObjectsParams.PARAM1_INT);
5390  EPulseType pulse;
5391  if ((CachedObjectsParams.PARAM1_INT.param1 & ActionCheckPulse.TARGET_IRREGULAR_PULSE_BIT) == 0)
5392  {
5393  pulse = EPulseType.REGULAR;
5394  }
5395  else
5396  {
5397  pulse = EPulseType.IRREGULAR;
5398  }
5399 
5400  int blood_level = ~ActionCheckPulse.TARGET_IRREGULAR_PULSE_BIT & CachedObjectsParams.PARAM1_INT.param1;
5401  if (m_CheckPulseLastTarget)
5402  {
5403  m_CheckPulseLastTarget.SetLastUAMessage(ActionCheckPulse.GetPulseMessage(pulse, blood_level));
5404  }
5405  break;
5406 
5408  //woodcutting
5409  case PlantType.TREE_HARD:
5410  SoundHardTreeFallingPlay();
5411  break;
5412 
5413  case PlantType.TREE_SOFT:
5414  SoundSoftTreeFallingPlay();
5415  break;
5416 
5417  case PlantType.BUSH_HARD:
5418  SoundHardBushFallingPlay();
5419  break;
5420 
5421  case PlantType.BUSH_SOFT:
5422  SoundSoftBushFallingPlay();
5423  break;
5424 
5425  case ERPCs.RPC_DEBUG_MONITOR_FLT:
5426  if (m_DebugMonitorValues)
5427  {
5428  m_DebugMonitorValues.OnRPCFloat(ctx);
5429  }
5430  break;
5431 
5432  case ERPCs.RPC_DEBUG_MONITOR_STR:
5433  if (m_DebugMonitorValues)
5434  {
5435  m_DebugMonitorValues.OnRPCString(ctx);
5436  }
5437  break;
5438  #endif
5439 
5440 
5441  /*
5442  case ERPCs.RPC_CRAFTING_INVENTORY_INSTANT:
5443  ref Param3<int, ItemBase, ItemBase> craftParam = new Param3<int, ItemBase, ItemBase>(-1, NULL, NULL);
5444  if (ctx.Read(craftParam))
5445  {
5446  m_ModuleRecipesManager.PerformRecipeServer(craftParam.param1, craftParam.param2, craftParam.param3, this);
5447  }
5448  break;
5449  */
5450 
5451 
5452 
5453  #ifdef DIAG_DEVELOPER
5454  case ERPCs.DEV_RPC_AGENT_RESET:
5455  {
5456  bool val;
5457  if (ctx.Read(val))
5458  m_AgentPool.RemoveAllAgents();
5459  break;
5460  }
5461 
5462  case ERPCs.DEV_PLAYER_DEBUG_REQUEST:
5463  {
5464  PluginRemotePlayerDebugServer plugin_remote_server = PluginRemotePlayerDebugServer.Cast(GetPlugin(PluginRemotePlayerDebugServer));
5465  plugin_remote_server.OnRPC(ctx, this);
5466  break;
5467  }
5468 
5469  case ERPCs.DEV_PLAYER_DEBUG_DATA:
5470  {
5471  PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(GetPlugin(PluginRemotePlayerDebugClient));
5472  PluginDeveloper plugin_dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
5473  if (plugin_dev.m_ScriptConsole)
5474  plugin_dev.m_ScriptConsole.OnRPCEx(rpc_type, ctx);
5475  else
5476  plugin_remote_client.OnRPC(ctx);
5477  break;
5478  }
5479 
5480  case ERPCs.DEV_AGENT_GROW:
5481  {
5482  m_AgentPool.RemoteGrowRequestDebug(ctx);
5483  break;
5484  }
5485 
5486  case ERPCs.RPC_ITEM_DIAG_CLOSE:
5487  {
5489  mid.StopWatchRequest(this);
5490  break;
5491  }
5492 
5494  case ERPCs.DEV_REQUEST_UTS_DEBUG:
5495  {
5496  PluginUniversalTemperatureSourceServer plugin_uts_server = PluginUniversalTemperatureSourceServer.Cast(GetPlugin(PluginUniversalTemperatureSourceServer));
5497  plugin_uts_server.OnRPC(ctx, this);
5498  break;
5499  }
5500 
5501  case ERPCs.DEV_UTS_DEBUG_DATA:
5502  {
5503  PluginUniversalTemperatureSourceClient plugin_uts_client = PluginUniversalTemperatureSourceClient.Cast(GetPlugin(PluginUniversalTemperatureSourceClient));
5504  plugin_uts_client.OnRPC(ctx);
5505  break;
5506  }
5508  #endif
5509 
5510  #ifdef DEVELOPER
5511  case ERPCs.DEV_RPC_SERVER_SCRIPT:
5512  {
5513  //PluginItemDiagnostic plugin = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
5514  //SetDebugDeveloper_item(plugin.GetWatchedItem(this));//!! needs to be inside DEVELOPER ifdef
5515 
5516  if (ctx.Read(CachedObjectsParams.PARAM1_STRING))
5517  {
5518  _player = this;
5519  string code = CachedObjectsParams.PARAM1_STRING.param1;
5520  bool success = GetGame().ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
5521  CachedObjectsParams.PARAM1_BOOL.param1 = success;
5522  RPCSingleParam(ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT, CachedObjectsParams.PARAM1_BOOL,true, GetIdentity());
5523  }
5524  break;
5525  }
5526 
5527  case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
5528  {
5529  PluginDeveloper dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
5530  if (dev.m_ScriptConsole)
5531  dev.m_ScriptConsole.OnRPCEx(rpc_type, ctx);
5532  break;
5533  }
5534 
5535  case ERPCs.DEV_SET_DEV_ITEM:
5536  {
5537  Param1<EntityAI> ent = new Param1<EntityAI>(null);
5538  if (ctx.Read(ent) && ent.param1)
5539  {
5541  mid2.RegisterDebugItem(ent.param1, this);
5542  }
5543  //SetDebugDeveloper_item(this);
5544  break;
5545  }
5546 
5547  case ERPCs.RPC_ITEM_DIAG:
5548  {
5549  Param1<EntityAI> p1 = new Param1<EntityAI>(null);
5550  if (ctx.Read(p1))
5551  {
5553  plgn.OnRPC(p1.param1, ctx);
5554  }
5555  break;
5556  }
5557  #endif
5558  }
5559 
5560  #ifdef DIAG_DEVELOPER
5561  PluginDeveloper module_rc = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
5562  if (module_rc)
5563  module_rc.OnRPC(this, rpc_type, ctx);
5564 
5565  PluginDeveloperSync module_rcs = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
5566  if (module_rcs)
5567  module_rcs.OnRPC(this, rpc_type, ctx);
5568 
5569  #ifdef SERVER
5570  PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenuServer));
5571  #else
5572  PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenuClient));
5573  #endif
5574 
5575  if (plugin_diag_menu)
5576  plugin_diag_menu.OnRPC(this, rpc_type, ctx);
5577  #endif
5578  }
5579 
5580  override void OnGameplayDataHandlerSync()
5581  {
5582  super.OnGameplayDataHandlerSync();
5583 
5584  UpdateLighting();
5585  //Print("setting respawn to " + CfgGameplayHandler.GetDisableRespawnDialog());
5586  GetGame().GetMission().SetRespawnModeClient(CfgGameplayHandler.GetDisableRespawnDialog());//TODO: maybe move to mission/game ?
5587  SetHitPPEEnabled(CfgGameplayHandler.GetHitIndicationPPEEnabled());
5588  }
5589 
5590  void UpdateLighting()
5591  {
5592  Mission mission = GetGame().GetMission();
5593  if (mission)
5594  {
5595  WorldLighting wLighting = mission.GetWorldLighting();
5596  if (wLighting)
5597  wLighting.SetGlobalLighting(CfgGameplayHandler.GetLightingConfig());
5598  }
5599  }
5600 
5601  void SetContaminatedEffectEx(bool enable, int ppeIdx = -1, int aroundId = ParticleList.CONTAMINATED_AREA_GAS_AROUND, int tinyId = ParticleList.CONTAMINATED_AREA_GAS_TINY, string soundset = "", bool partDynaUpdate = false, int newBirthRate = 0)
5602  {
5603  if (enable) // enable
5604  {
5605  // We assume that if this is set to true the PPE is already active
5606  if (m_ContaminatedAreaEffectEnabled == enable)
5607  return;
5608 
5609  if (aroundId !=0)
5610  {
5611  if (!m_ContaminatedAroundPlayer)
5612  {
5613  m_ContaminatedAroundPlayer = ParticleManager.GetInstance().PlayInWorld(aroundId, GetPosition());
5614  }
5615  // First entry in an area with dynamic tweaks to particles
5616  if (partDynaUpdate)
5617  {
5618  m_ContaminatedAroundPlayer.SetParameter(0, EmitorParam.BIRTH_RATE, newBirthRate);
5619  }
5620  }
5621 
5622  if (!m_ContaminatedAroundPlayerTiny && tinyId !=0)
5623  {
5624  m_ContaminatedAroundPlayerTiny = ParticleManager.GetInstance().PlayInWorld(tinyId, GetPosition());
5625  }
5626 
5627  if (ppeIdx != -1)
5628  {
5629  PPERequesterBase ppeRequester;
5630  if (Class.CastTo(ppeRequester, PPERequesterBank.GetRequester(ppeIdx)))
5631  ppeRequester.Start();
5632  }
5633 
5634  // We start playing the ambient sound
5635  if (!m_AmbientContamination && soundset != "")
5636  PlaySoundSetLoop(m_AmbientContamination, soundset, 0.1, 0.1);
5637 
5638  }
5639  else // disable
5640  {
5641  if (m_ContaminatedAroundPlayer)
5642  {
5643  m_ContaminatedAroundPlayer.Stop();
5644  m_ContaminatedAroundPlayer = null;
5645  }
5646 
5647  if (m_ContaminatedAroundPlayerTiny)
5648  {
5649  m_ContaminatedAroundPlayerTiny.Stop();
5650  m_ContaminatedAroundPlayerTiny = null;
5651  }
5652  if (ppeIdx != -1)
5653  PPERequesterBank.GetRequester(ppeIdx).Stop(new Param1<bool>(true)); //fade out
5654 
5655  // We stop the ambient sound
5656  if (m_AmbientContamination)
5657  StopSoundSet(m_AmbientContamination);
5658 
5659  // We make sure to reset the state
5660  }
5661  m_ContaminatedAreaEffectEnabled = enable;
5662  }
5663 
5664  void SetContaminatedEffect(bool enable, int ppeIdx = -1, int aroundId = ParticleList.CONTAMINATED_AREA_GAS_AROUND, int tinyId = ParticleList.CONTAMINATED_AREA_GAS_TINY, bool partDynaUpdate = false, int newBirthRate = 0)
5665  {
5666  SetContaminatedEffectEx(enable, ppeIdx, aroundId, tinyId, "", partDynaUpdate, newBirthRate);
5667  }
5668 
5669  // -------------------------------------------------------------------------
5670  void UpdateCorpseState()
5671  {
5672  UpdateCorpseStateVisual();
5673  if (m_CorpseState > 0)
5674  SetDecayEffects(Math.AbsInt(m_CorpseState));
5675  else if (m_CorpseState < 0)
5676  SetDecayEffects();//no params means remove the effects
5677  m_CorpseStateLocal = m_CorpseState;
5678  }
5679 
5680  // -------------------------------------------------------------------------
5681  override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
5682  {
5683  super.EEHealthLevelChanged(oldLevel, newLevel, zone);
5684  if (!GetGame().IsDedicatedServer())
5685  {
5686  if (newLevel == GameConstants.STATE_RUINED)
5687  {
5688  ClearLastUAMessage();
5689  }
5690  if (m_CorpseState != 0)
5691  {
5692  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseState, 0, false);
5693  }
5694  }
5695  }
5696 
5697 
5698  // -------------------------------------------------------------------------
5699  override void OnVariablesSynchronized()
5700  {
5701  super.OnVariablesSynchronized();
5702  if (m_ModuleLifespan)
5703  {
5704  m_ModuleLifespan.SynchLifespanVisual(this, m_LifeSpanState, m_HasBloodyHandsVisible, m_HasBloodTypeVisible, m_BloodType);
5705 
5706  if (m_LifespanLevelLocal != m_LifeSpanState) //client solution, lifespan level changed
5707  {
5708  m_LifespanLevelLocal = m_LifeSpanState;
5709  UpdateHairSelectionVisibility();
5710  }
5711  }
5712 
5713  CheckSoundEvent();
5714  if (GetBleedingManagerRemote() && IsPlayerLoaded())
5715  {
5716  GetBleedingManagerRemote().OnVariablesSynchronized(GetBleedingBits());
5717  }
5718 
5719  if (m_CorpseStateLocal != m_CorpseState && (IsPlayerLoaded() || IsControlledPlayer()))
5720  {
5721  UpdateCorpseState();
5722  }
5723 
5724  if (m_RefreshAnimStateIdx != m_LocalRefreshAnimStateIdx)
5725  {
5726  RefreshHandAnimationState(396); //mean animation blend time
5727  m_LocalRefreshAnimStateIdx = m_RefreshAnimStateIdx;
5728  }
5729  if (m_InsideEffectArea != m_InsideEffectAreaPrev)
5730  {
5731  if (m_InsideEffectArea)
5732  {
5733  OnPlayerIsNowInsideEffectAreaBeginClient();
5734  }
5735  else
5736  {
5737  OnPlayerIsNowInsideEffectAreaEndClient();
5738  }
5739  m_InsideEffectAreaPrev = m_InsideEffectArea;
5740  }
5741 
5742  //-------MODIFIERS START--------
5743  if (m_SyncedModifiers != m_SyncedModifiersPrev)
5744  {
5745  int diff = (m_SyncedModifiers & ~m_SyncedModifiersPrev) | (~m_SyncedModifiers & m_SyncedModifiersPrev);//XOR gets us a mask for modifiers that changed by either deactivating, or activating
5746 
5747  if (eModifierSyncIDs.MODIFIER_SYNC_DROWNING & diff)//has this modifier's status as active/inactive changed ?
5748  {
5749  if (eModifierSyncIDs.MODIFIER_SYNC_DROWNING & m_SyncedModifiers)//is this modifier currently active ? if so, it means it's been just activated
5750  {
5751  SetDrowning(true);
5752  }
5753  else
5754  {
5755  SetDrowning(false);
5756  }
5757 
5758  }
5759 
5760  m_SyncedModifiersPrev = m_SyncedModifiers;
5761  }
5762  //-------MODIFIERS END--------
5763 
5764  HandleBrokenLegsSync();
5765 
5767  ItemBase itemHands = GetItemInHands();
5768  if (itemHands)
5769  {
5770  RemotelyActivatedItemBehaviour raib = itemHands.GetRemotelyActivatedItemBehaviour();
5771  if (raib)
5772  {
5773  raib.OnVariableSynchronized();
5774  }
5775  }
5776  }
5777 
5779  bool IsSyncedModifierActive(eModifierSyncIDs modifier)
5780  {
5781  return (m_SyncedModifiers & m_SyncedModifiersPrev);
5782  }
5783 
5784  void HandleBrokenLegsSync()
5785  {
5786  if (m_BrokenLegState != m_LocalBrokenState)
5787  {
5788  m_LocalBrokenState = m_BrokenLegState;
5789  bool initial = (m_BrokenLegState < 0);
5790  int state = GetBrokenLegs();
5791  if (state == eBrokenLegs.BROKEN_LEGS)
5792  {
5793  //Print(m_BrokenLegState);
5794  if (initial)// <0 values indicate initial activation
5795  {
5796  //Print("synced variables - inital activation of broken legs");
5797  BreakLegSound();
5798  }
5799  else
5800  {
5801  //Print("synced variables - secondary activation of broken legs");
5802  }
5803  }
5804  }
5805  }
5806 
5807 
5808  void FixAllInventoryItems()
5809  {
5810  array<EntityAI> items = new array<EntityAI>;
5811  GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, items);
5812  foreach (EntityAI item : items)
5813  {
5814  item.SetHealthMax("","");
5815  }
5816  }
5817 
5818 
5819  void OnInventoryMenuOpen()
5820  {
5821 
5822  }
5823 
5824  void OnInventoryMenuClose()
5825  {
5826 
5827  }
5828 
5829  //--------------------------------------------------------------------------
5830  void OnSelectPlayer()
5831  {
5832  //Print("PlayerBase | OnSelectPlayer()");
5833  m_PlayerSelected = true;
5834 
5835  m_QuickBarBase.updateSlotsCount();
5836 
5837  m_WeaponManager.SortMagazineAfterLoad();
5838 
5839  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
5840  {
5841  PlayerIdentity identity = GetIdentity();
5842 
5843  if (identity)
5844  {
5845  m_CachedPlayerID = identity.GetId();
5846  m_CachedPlayerName = identity.GetName();
5847  }
5848 
5850  SetAITargetCallbacks(new AITargetCallbacksPlayer(this));
5851 
5852  array<ref Param> params = new array<ref Param>;
5853  if (m_aQuickBarLoad)
5854  {
5855  int count = m_aQuickBarLoad.Count();
5856  Param1<int> paramCount = new Param1<int>(count);
5857  params.Insert(paramCount);
5858  for (int i = 0; i < count; i++)
5859  {
5860  m_QuickBarBase.OnSetEntityNoSync(m_aQuickBarLoad.Get(i).param1,m_aQuickBarLoad.Get(i).param2);
5861  params.Insert(m_aQuickBarLoad.Get(i));
5862  }
5863 
5864  if (count > 0 && GetGame().IsMultiplayer())
5865  {
5866  GetGame().RPC(this, ERPCs.RPC_INIT_SET_QUICKBAR, params, true, identity);
5867  }
5868  m_aQuickBarLoad = NULL;
5869  }
5870 
5871  GetSoftSkillsManager().InitSpecialty(GetStatSpecialty().Get());
5872  GetModifiersManager().SetModifiers(true);
5873 
5874  SetSynchDirty();
5875 
5876  if (GetGame().IsMultiplayer())
5877  {
5878  //Drop item warning
5879  if (m_ProcessUIWarning)
5880  {
5881  GetGame().RPCSingleParam(this, ERPCs.RPC_WARNING_ITEMDROP, null, true, identity);
5882  m_ProcessUIWarning = false;
5883  }
5884 
5885  GetGame().GetMission().SyncRespawnModeInfo(identity);
5886  }
5887  }
5888 
5889  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
5890  {
5891  m_ActionManager = new ActionManagerServer(this);
5892  m_ConstructionActionData = new ConstructionActionData();
5893 
5894  CheckForGag();
5895  }
5896  else if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
5897  {
5898  m_ActionManager = new ActionManagerClient(this);
5899  m_CraftingManager = new CraftingManager(this,m_ModuleRecipesManager);
5900  m_ConstructionActionData = new ConstructionActionData();
5901 
5902  }
5903  else if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER)
5904  {
5905  m_ActionManager = new ActionManagerServer(this);
5906  }
5907 
5908  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
5909  {
5910  //m_PlayerLightManager = new PlayerLightManager(this);
5911  if (GetGame().GetMission())
5912  {
5913  GetGame().GetMission().ResetGUI();
5914  // force update player
5915  GetDayZGame().GetBacklit().UpdatePlayer(true);
5916  }
5917 
5918  m_DeathCheckTimer = new Timer();
5919  m_DeathCheckTimer.Run(0.1, this, "CheckDeath", null, true);
5920  PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
5921  CheckForBurlap();
5922 
5923  int characterCount = GetGame().GetMenuData().GetCharactersCount() - 1;
5924  int idx = GetGame().GetMenuData().GetLastPlayedCharacter();
5925  if (idx == GameConstants.DEFAULT_CHARACTER_MENU_ID || idx > characterCount)
5926  {
5927  GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetNewCharName);
5928  }
5929 
5930  GetGame().GetMission().EnableAllInputs(true);
5931 
5932  m_PresenceNotifier = PluginPresenceNotifier.Cast(GetPlugin(PluginPresenceNotifier));
5933  m_PresenceNotifier.Init(this);
5934  OnGameplayDataHandlerSync();//only here for legacy reasons
5935  }
5936 
5937 #ifdef BOT
5938  m_Bot = new Bot(this);
5939  m_Bot.Start(true, new MyBotTrigger(this));
5940 #endif
5941  }
5942 
5943  override void SimulateDeath(bool state)
5944  {
5945  super.SimulateDeath(state);
5946 
5947  m_UndergroundHandler = null;
5948  if (m_EffectWidgets)
5949  {
5950  m_EffectWidgets.StopAllEffects();
5951  m_EffectWidgets.ClearSuspendRequests();
5952  }
5953  }
5954 
5955  void SetNewCharName()
5956  {
5957  g_Game.GetMenuData().SaveCharacter(false, true);
5958  g_Game.GetMenuData().SetCharacterName(g_Game.GetMenuData().GetLastPlayedCharacter(), g_Game.GetMenuDefaultCharacterData(false).GetCharacterName());
5959  g_Game.GetMenuData().SaveCharactersLocal();
5960  }
5961 
5962  void CheckForBurlap()
5963  {
5964  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
5965  {
5966  BurlapSackCover attachment;
5967  Class.CastTo(attachment, GetInventory().FindAttachment(InventorySlots.HEADGEAR));
5968 
5969  PPERequester_BurlapSackEffects req;
5970  if (Class.CastTo(req,PPERequesterBank.GetRequester(PPERequesterBank.REQ_BURLAPSACK)))
5971  {
5972  if (attachment)
5973  {
5974  req.Start();
5975  }
5976  else if (req.IsRequesterRunning())
5977  {
5978  PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Stop();
5979  }
5980  }
5981  }
5982  }
5983 
5984  void CheckForGag()
5985  {
5986  #ifdef SERVER
5987  Clothing item;
5988  Class.CastTo(item, GetInventory().FindAttachment(InventorySlots.MASK));
5989  if (!item)
5990  {
5991  Class.CastTo(item, GetInventory().FindAttachment(InventorySlots.HEADGEAR));
5992  }
5993 
5994  if (item && item.IsObstructingVoice())
5995  {
5996  item.MutePlayer(this,true);
5997  }
5998  else //should probably check for relevant types before removing mumbling and obstruction specifically..
5999  {
6000  GetGame().SetVoiceEffect(this, VoiceEffectMumbling, false);
6001  GetGame().SetVoiceEffect(this, VoiceEffectObstruction, false);
6002  }
6003  #endif
6004  }
6005 
6006  void UpdateMaskBreathWidget(notnull MaskBase mask, bool is_start = false)
6007  {
6008  if (is_start)
6009  m_EffectWidgets.ResetMaskUpdateCount();
6010  float resistance = 0;
6011  if (mask.HasIntegratedFilter() || mask.IsExternalFilterAttached())
6012  resistance = 1 - mask.GetFilterQuantity01();
6013 
6014 
6015  m_EffectWidgets.OnVoiceEvent(resistance);
6016  m_EffectWidgets.IncreaseMaskUpdateCount();
6017 
6018  }
6019 
6020 
6021  // -------------------------------------------------------------------------
6022  void OnVoiceEvent(PlayerSoundEventBase voice_event)
6023  {
6024  if (m_EffectWidgets)
6025  {
6026  MaskBase mask = MaskBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
6027  if (mask)
6028  {
6029  UpdateMaskBreathWidget(mask, true);
6030  //m_EffectWidgets.SetBreathIntensityStamina(GetStaminaHandler().GetStaminaCap(),GetStaminaHandler().GetStamina());
6031  }
6032  }
6033  }
6034 
6035  // -------------------------------------------------------------------------
6037  void OnVoiceEventPlayback(PlayerSoundEventBase voice_event, AbstractWave callback, float playback_time)
6038  {
6039  if (m_EffectWidgets)
6040  {
6041  MaskBase mask = MaskBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
6042  if (mask)
6043  {
6044  if (m_EffectWidgets.m_MaskWidgetUpdateCount < 2 && callback.GetLength() > 2 && playback_time > 0.5 )
6045  UpdateMaskBreathWidget(mask);
6046  }
6047  }
6048  }
6049 
6050 
6051  // -------------------------------------------------------------------------
6052  override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
6053  {
6054  if (super.OnInputUserDataProcess(userDataType, ctx))
6055  return true;
6056 
6057  if (m_QuickBarBase.OnInputUserDataProcess(userDataType, ctx))
6058  return true;
6059 
6060  if (m_WeaponManager.OnInputUserDataProcess(userDataType, ctx))
6061  return true;
6062 
6063  if (HandleRemoteItemManipulation(userDataType, ctx))
6064  return true;
6065 
6066  if (userDataType == INPUT_UDT_INVENTORY && GetHumanInventory().OnInputUserDataProcess(ctx))
6067  return true;
6068 
6069  if (TogglePlacingServer(userDataType, ctx))
6070  return true;
6071 
6072  if (ResetADSPlayerSync(userDataType, ctx))
6073  return true;
6074 
6075  string uid;
6076  bool mute;
6077  if (userDataType == INPUT_UDT_USER_MUTE_XBOX)
6078  {
6079  if (ctx.Read(uid) && ctx.Read(mute))
6080  {
6081  GetGame().MutePlayer(uid, GetIdentity().GetPlainId(), mute);
6082  // commented because plainID should not be present in logs
6083  //Print("Player: " + GetIdentity().GetId() + " set mute for " + uid + " to " + mute);
6084  }
6085  }
6086 
6087  if (m_EmoteManager && userDataType == INPUT_UDT_GESTURE)
6088  return m_EmoteManager.OnInputUserDataProcess(userDataType, ctx);
6089 
6090  if (userDataType == INPUT_UDT_WEAPON_LIFT_EVENT)
6091  return ReadLiftWeaponRequest(userDataType, ctx);
6092 
6093  if (m_ActionManager)
6094  return m_ActionManager.OnInputUserDataProcess(userDataType, ctx);
6095  return false;
6096  }
6097 
6098  float GetHealthRegenSpeed()
6099  {
6100  float blood = GetHealth("GlobalHealth", "Blood");
6101  float blood_scale_normalized = Math.InverseLerp(PlayerConstants.BLOOD_THRESHOLD_FATAL, GetMaxHealth("", "Blood"), blood);
6102  blood_scale_normalized = Math.Clamp(blood_scale_normalized,0,1);
6103  return Math.Lerp(PlayerConstants.HEALTH_REGEN_MIN, PlayerConstants.HEALTH_REGEN_MAX, blood_scale_normalized);
6104  }
6105 
6106  bool HandleRemoteItemManipulation(int userDataType, ParamsReadContext ctx)
6107  {
6108  if (userDataType == INPUT_UDT_ITEM_MANIPULATION)
6109  {
6110  int type = -1;
6111  ItemBase item1 = null;
6112  ItemBase item2 = null;
6113  bool use_stack_max = false;
6114  int slot_id = -1;
6115 
6116  if (!ctx.Read(type))
6117  return false;
6118 
6119  if (type == 4)
6120  {
6121  if (!ctx.Read(item1))
6122  return false;
6124  if (dst.ReadFromContext(ctx))
6125  {
6126  //Print(InventoryLocation.DumpToStringNullSafe(dst));
6127  bool dummy;
6128  if (ctx.Read(dummy))
6129  item1.SplitItemToInventoryLocation(dst);
6130  else
6131  item1.SplitIntoStackMaxToInventoryLocation(dst);
6132  return true;
6133  }
6134  return false;
6135  }
6136 
6137  if (!ctx.Read(item1))
6138  return false;
6139  if (!ctx.Read(item2))
6140  return false;
6141  if (!ctx.Read(use_stack_max))
6142  return false;
6143  if (!ctx.Read(slot_id))
6144  return false;
6145 
6146  if (type == -1 && item1 && item2)//combine
6147  {
6148  item1.CombineItems(item2, use_stack_max);
6149  }
6150  else if (type == 1 && item1)
6151  {
6152  if (use_stack_max)
6153  item1.SplitIntoStackMax(item2, slot_id, this);
6154  else
6155  item1.SplitItem(this);
6156  }
6157  else if (type == 2 && item1)
6158  {
6159  int row, col;
6160  if (!ctx.Read(row))
6161  return false;
6162  if (!ctx.Read(col))
6163  return false;
6164  item1.SplitIntoStackMaxCargo(item2, slot_id, row, col);
6165  }
6166  else if (type == 3 && item1)
6167  {
6168  item1.SplitIntoStackMaxHands(this);
6169  }
6170  return true;
6171  }
6172  return false;
6173  }
6174 
6175  // -------------------------------------------------------------------------
6176  ItemBase GetItemInHands()
6177  {
6178  if (GetHumanInventory())
6179  {
6180  return ItemBase.Cast(GetHumanInventory().GetEntityInHands());
6181  }
6182  return null;
6183 
6184  }
6185 
6186  //--------------------------------------------------------------------------
6187 
6188 
6189  override EntityAI SpawnEntityOnGroundPos(string object_name, vector pos)
6190  {
6191  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
6192  {
6193  bool is_AI = GetGame().IsKindOf(object_name, "DZ_LightAI");
6194  if (is_AI)
6195  {
6196  return SpawnAI(object_name, pos);
6197  }
6198  else
6199  {
6200  InventoryLocation inv_loc = new InventoryLocation;
6201  vector mtx[4];
6202  Math3D.MatrixIdentity4(mtx);
6203  mtx[3] = pos;
6204  inv_loc.SetGround(NULL, mtx);
6205  //return GetGame().SpawnEntity(object_name, inv_loc, ECE_PLACE_ON_SURFACE, RF_DEFAULT);
6206  return EntityAI.Cast(GetGame().CreateObjectEx(object_name, inv_loc.GetPos(), ECE_PLACE_ON_SURFACE));
6207  }
6208  }
6209  return null;
6210  }
6211 
6212  EntityAI SpawnEntityOnGroundOnCursorDir(string object_name, float distance)
6213  {
6214  vector position = GetPosition() + (GetDirection() * distance);
6215  return SpawnEntityOnGroundPos(object_name, position);
6216  }
6217 
6218  EntityAI SpawnAI(string object_name, vector pos)
6219  {
6220  bool is_ai = GetGame().IsKindOf(object_name, "DZ_LightAI");
6221  if (is_ai)
6222  {
6223  return EntityAI.Cast(GetGame().CreateObjectEx(object_name, pos, ECE_PLACE_ON_SURFACE|ECE_INITAI|ECE_EQUIP_ATTACHMENTS));
6224  }
6225  return NULL;
6226  }
6227 
6241  /*EntityAI SpawnItem (string object_name, bool full_quantity, float distance = 0, bool usePosition = false, vector pos = "0 0 0", EntityAI attachmentObject = NULL)
6242  {
6243  EntityAI entity = NULL;
6244 
6245  // Creat Object
6246  bool is_ai = GetGame().IsKindOf(object_name, "DZ_LightAI");
6247  vector item_position;
6248  if (usePosition)
6249  {
6250  item_position = pos;
6251  }
6252  else
6253  {
6254  item_position = GetPosition() + (GetDirection() * distance);
6255  }
6256  entity = GetGame().CreateObject(object_name, item_position, false, is_ai);
6257 
6258  if (!entity)
6259  {
6260  string s = "Cannot spawn entity: "+object_name;
6261  Print(s);
6262  //g_Game.GetUIManager().ShowDialog("Spawn error", "Cannot spawn item: "+object_name, 0, DBT_OK, DBB_YES, DMT_EXCLAMATION, this);
6263  return NULL;
6264  }
6265 
6266  if (entity.IsInherited(ItemBase))
6267  {
6268  ItemBase item = entity;
6269 
6270  // Set full quantity
6271  if (full_quantity)
6272  {
6273  item.SetQuantity(item.GetQuantityMax());
6274  }
6275 
6276  // Spawn In Inventory
6277  if (spawn_type == SPAWNTYPE_INVENTORY)
6278  {
6279  TakeItemToInventory(item);
6280  }
6281  // Spawn In Hands
6282  if (spawn_type == SPAWNTYPE_HANDS)
6283  {
6284  TakeItemToHands(item);
6285  }
6286  // Spawn As Attachment
6287  if (spawn_type == SPAWNTYPE_ATTACHMENT)
6288  {
6289  Object cursor_obj = GetCursorObject();
6290  if (cursor_obj != NULL && cursor_obj.IsInherited(EntityAI))
6291  {
6292  EntityAI eai = (EntityAI)cursor_obj;
6293  eai.TakeEntityAsAttachment(item);
6294  }
6295  else if (attachmentObject != NULL)
6296  {
6297  attachmentObject.TakeEntityAsAttachment(item);
6298  }
6299  }
6300  }
6301 
6302  return entity;
6303  }*/
6304 
6305  //--------------------------------------------------------------------------
6306  bool DropItem(ItemBase item)
6307  {
6308  bool can_be_dropped = CanDropEntity(item);
6309  if (can_be_dropped)
6310  {
6311  can_be_dropped = PredictiveDropEntity(item);
6312  }
6313 
6314  vector pos_spawn = GetPosition() + GetDirection();
6315  pos_spawn[0] = pos_spawn[0] + Math.RandomFloat(-0.2, 0.2);
6316  pos_spawn[2] = pos_spawn[2] + Math.RandomFloat(-0.2, 0.2);
6317 
6318  item.SetPosition(pos_spawn);
6319  item.PlaceOnSurface();
6320  return can_be_dropped;
6321  }
6322 
6323  // -------------------------------------------------------------------------
6334  EntityAI CreateInInventory(string item_name, string cargo_type = "", bool full_quantity = false) // TODO: Create item in cargo
6335  {
6336  InventoryLocation inv_loc = new InventoryLocation;
6337  if (GetInventory().FindFirstFreeLocationForNewEntity(item_name, FindInventoryLocationType.ANY, inv_loc))
6338  {
6339  return SpawnItemOnLocation(item_name, inv_loc, full_quantity);
6340  }
6341  return NULL;
6342  }
6343 
6344 
6345  // -------------------------------------------------------------------------
6354  /*ItemBase CopyInventoryItem(ItemBase orig_item)
6355  {
6356  ItemBase item = ItemBase.Cast(GetInventory().CreateInInventory(orig_item.GetType()));
6357  if (item == NULL)
6358  {
6359  return NULL;
6360  }
6361 
6362  // Copy of quantity
6363  item.SetQuantity(orig_item.GetQuantity());
6364 
6365  // Copy of damage
6366  item.SetHealth("", "", orig_item.GetHealth("", ""));
6367 
6368  return item;
6369  }*/
6370 
6371  ItemBase CreateCopyOfItemInInventory (ItemBase src)
6372  {
6374  string t = src.GetType();
6375  if (GetInventory().FindFirstFreeLocationForNewEntity(t, FindInventoryLocationType.CARGO, loc))
6376  {
6377  bool locked = GetGame().HasInventoryJunctureDestination(this, loc);
6378  if (locked)
6379  {
6380  Print("Warning: Split: CreateCopyOfItemInInventory - Cannot create entity at locked inventory at loc=" + InventoryLocation.DumpToStringNullSafe(loc));
6381  return null;
6382  }
6383  ItemBase dst = ItemBase.Cast(GetInventory().LocationCreateLocalEntity(loc, t, ECE_IN_INVENTORY, RF_DEFAULT));
6384  if (dst)
6385  {
6386  MiscGameplayFunctions.TransferItemProperties(src, dst);
6387 
6388  GetGame().RemoteObjectTreeCreate(dst);
6389 
6390  Print("CreateCopyOfItemInInventory - created " + dst.GetName() + " at loc=" + InventoryLocation.DumpToStringNullSafe(loc));
6391  }
6392  return dst;
6393  }
6394  return NULL;
6395  }
6396 
6397  ItemBase CreateCopyOfItemInInventoryOrGround(ItemBase src)
6398  {
6399  return CreateCopyOfItemInInventoryOrGroundEx(src, false);
6400  }
6401 
6402  ItemBase CreateCopyOfItemInInventoryOrGroundEx(ItemBase src, bool markItemAsSplitResult = false)
6403  {
6404  ItemBase dst = CreateCopyOfItemInInventory(src);
6405  if (!dst)
6406  {
6407  dst = ItemBase.Cast(SpawnEntityOnGroundPos(src.GetType(), this.GetPosition()));
6408  dst.PlaceOnSurface();
6409  dst.SetResultOfSplit(markItemAsSplitResult);
6410  MiscGameplayFunctions.TransferItemProperties(src, dst);
6411  }
6412 
6413  return dst;
6414  }
6415 
6416 
6417 
6418  // -------------------------------------------------------------------------
6425  void Message(string text, string style)
6426  {
6427  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
6428  {
6429  GetGame().ChatMP(this, text, style);
6430  }
6431  else
6432  {
6433  GetGame().Chat(text, style);
6434  }
6435  }
6436 
6437  // -------------------------------------------------------------------------
6438  void MessageStatus(string text)
6439  {
6440  Message(text, "colorStatusChannel");
6441  }
6442 
6443  // -------------------------------------------------------------------------
6444  void MessageAction(string text)
6445  {
6446  Message(text, "colorAction");
6447  }
6448 
6449  // -------------------------------------------------------------------------
6450  void MessageFriendly(string text)
6451  {
6452  Message(text, "colorFriendly");
6453  }
6454 
6455  // -------------------------------------------------------------------------
6456  void MessageImportant(string text)
6457  {
6458  Message(text, "colorImportant");
6459  }
6460 
6461  void CloseInventoryMenu()
6462  {
6463  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
6464  {
6465 #ifndef NO_GUI
6466  UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
6467  if (menu && (menu.GetID() == MENU_INVENTORY || menu.GetID() == MENU_INSPECT))
6468  {
6469  GetGame().GetUIManager().CloseAll();
6470  GetGame().GetMission().RemoveActiveInputExcludes({"inventory"},false);
6471  GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
6472  }
6473 #endif
6474  }
6475  }
6476 
6477  // -------------------------------------------------------------------------
6486  override void ClearInventory()
6487  {
6488  if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
6489  {
6490  GameInventory inv = PlayerBase.Cast(this).GetInventory();
6491  array<EntityAI> items = new array<EntityAI>;
6492  inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
6493  for (int i = 0; i < items.Count(); i++)
6494  {
6495  ItemBase item = ItemBase.Cast(items.Get(i));
6496  if (item)
6497  {
6498  GetGame().ObjectDelete(item);
6499  }
6500  }
6501 
6502  ItemBase item_in_hands = ItemBase.Cast(GetHumanInventory().GetEntityInHands());
6503 
6504  if (item_in_hands)
6505  {
6506  LocalDestroyEntityInHands();
6507  }
6508  }
6509  }
6510 
6512  void DropAllItems()
6513  {
6514  array<EntityAI> itemsArray = new array<EntityAI>;
6515  ItemBase item;
6516  GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, itemsArray);
6517  int count = itemsArray.Count();
6518 
6519  for (int i = 0; i < itemsArray.Count(); i++)
6520  {
6521  Class.CastTo(item, itemsArray.Get(i));
6522 
6523  if (item && !item.IsInherited(SurvivorBase))
6524  {
6525  ServerDropEntity(item);
6526  }
6527  }
6528  }
6529 
6530  string GetPlayerClass()
6531  {
6532  string type;
6533  GetGame().ObjectGetType(this, type);
6534  return type;
6535  }
6536 
6537  // --------------------------------------------------
6538  // Lifespan
6539  //---------------------------------------------------
6540 
6541  void ShavePlayer()
6542  {
6543  SetLastShavedSeconds(StatGet(AnalyticsManagerServer.STAT_PLAYTIME));
6544 
6545  m_ModuleLifespan.UpdateLifespan(this, true);
6546  }
6547 
6548  bool CanShave()
6549  {
6550  if (!HasCoveredFaceForShave() && GetLifeSpanState())
6551  {
6552  return true;
6553  }
6554  else
6555  {
6556  return false;
6557  }
6558  }
6559 
6560 
6561  override void OnParticleEvent(string pEventType, string pUserString, int pUserInt)
6562  {
6563  super.OnParticleEvent(pEventType ,pUserString, pUserInt);
6564 
6565  if (!GetGame().IsDedicatedServer())
6566  {
6567  if (pUserInt == 123456) // 123456 is ID for vomiting effect. The current implementation is WIP.
6568  {
6569  PlayerBase player = PlayerBase.Cast(this);
6570  int boneIdx = player.GetBoneIndexByName("Head");
6571 
6572  if (boneIdx != -1)
6573  {
6574  EffectParticle eff;
6575 
6576  if (m_SyncedModifiers & eModifierSyncIDs.MODIFIER_SYNC_CONTAMINATION2)
6577  {
6578  eff = new EffVomitBlood();
6579  }
6580  else
6581  {
6582  eff = new EffVomit();
6583  }
6584 
6585  eff.SetDecalOwner(player);
6586  eff.SetAutodestroy(true);
6587  SEffectManager.PlayInWorld(eff, vector.Zero);
6588  Particle p = eff.GetParticle();
6589  player.AddChild(p, boneIdx);
6590  }
6591  }
6592  }
6593  }
6594 
6595 
6596  bool CanSpawnBreathVaporEffect()
6597  {
6598  if (!ToDelete() && IsAlive() && !IsSwimming() && !m_IsDrowning)
6599  {
6600  return true;
6601  }
6602  return false;
6603  }
6604 
6605 
6606  void ProcessADDModifier()
6607  {
6608  if (m_AddModifier != -1)
6609  {
6611  if (ad)
6612  ad.StartModifier(m_AddModifier);
6613 
6614  m_AddModifier = -1;
6615  }
6616  }
6617 
6618  void SpawnBreathVaporEffect()
6619  {
6620  //Print("SpawnBreathVaporEffect:"+GetGame().GetTime());
6621  int boneIdx = GetBoneIndexByName("Head");
6622  if (boneIdx != -1)
6623  {
6624  Particle p;
6625  switch (m_BreathVapour)
6626  {
6627  case 1:
6628  p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_LIGHT, "-0.03 0.15 0");
6629  break;
6630  case 2:
6631  p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_MEDIUM, "-0.03 0.15 0");
6632  break;
6633  case 3:
6634  p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_HEAVY, "-0.03 0.15 0");
6635  break;
6636  default:
6637  break;
6638  }
6639 
6640  if (p)
6641  AddChild(p, boneIdx);
6642  }
6643  }
6644 
6645  // returns 'true' if the player is submerged under water deep enough so that we consider him/her to be eligible for drowning, do note some other conditions may apply for actual drowning to be turned on
6646  bool GetDrowningWaterLevelCheck()
6647  {
6648  int index = GetBoneIndexByName("head");
6649  vector pos = GetBonePositionWS(index);
6650  float depth = g_Game.GetWaterDepth(pos);
6651 
6652  if (IsSwimming())
6653  {
6654  return depth > PlayerConstants.DROWNING_SWIMMING_THRESHOLD;
6655  }
6656  else if (IsUnconscious())
6657  {
6658  return depth > PlayerConstants.DROWNING_UNCONSCIOUS_THRESHOLD;
6659  }
6660  return depth > PlayerConstants.DROWNING_DEFAULT_THRESHOLD;
6661  }
6662 
6663  void SetLifeSpanStateVisible(int show_state)
6664  {
6665  bool state_changed;
6666  if (show_state != m_LifeSpanState)
6667  state_changed = true;
6668  m_LifeSpanState = show_state;
6669  SetSynchDirty();
6670 
6671  if (state_changed) //server only, client solution in OnVariablesSynchronized()
6672  {
6673  //SendLifespanSyncEvent(m_LifeSpanState);
6674 
6675  UpdateHairSelectionVisibility();
6676  }
6677  }
6678 
6679  int GetLifeSpanState()
6680  {
6681  return m_LifeSpanState;
6682  }
6683 
6684  int GetLastShavedSeconds()
6685  {
6686  return m_LastShavedSeconds;
6687  }
6688 
6689  void SetLastShavedSeconds(int last_shaved_seconds)
6690  {
6691  m_LastShavedSeconds = last_shaved_seconds;
6692  }
6693 
6694  bool HasCoveredFaceForShave()
6695  {
6696  return IsExclusionFlagPresent(GetFaceCoverageShaveValues());
6697  }
6698 
6700  static set<int> GetFaceCoverageShaveValues()
6701  {
6702  set<int> ret = new set<int>;
6703  ret.Insert(EAttExclusions.SHAVING_MASK_ATT_0);
6704  ret.Insert(EAttExclusions.SHAVING_HEADGEAR_ATT_0);
6705  //ret.Insert(EAttExclusions.SHAVING_EYEWEAR_ATT_0);
6706 
6707  return ret;
6708  }
6709 
6710  eBloodyHandsTypes HasBloodyHandsEx()
6711  {
6712  return m_HasBloodyHandsVisible;
6713  }
6714 
6715  bool HasBloodyHands()
6716  {
6717  return m_HasBloodyHandsVisible;
6718  }
6719 
6720  void SetBloodyHands(bool show)
6721  {
6722  SetBloodyHandsBase(show);
6723  }
6724 
6726  {
6727  SetBloodyHandsBase(type);
6728  }
6729 
6730  private void SetBloodyHandsBase(int type)
6731  {
6732  m_HasBloodyHandsVisible = type;
6733  SetSynchDirty();
6734 
6735  #ifdef DIAG_DEVELOPER
6736  #ifndef SERVER
6737  if (IsControlledPlayer())
6738  {
6739  bool enable = type;
6740  DiagMenu.SetValue(DiagMenuIDs.LIFESPAN_BLOODY_HANDS, enable);
6741  }
6742  #endif
6743  #endif
6744  }
6745 
6746  void SetBloodyHandsPenalty()
6747  {
6748  InsertAgent(eAgents.SALMONELLA, 1);
6749  }
6750 
6751  bool HasBloodTypeVisible()
6752  {
6753  return m_HasBloodTypeVisible;
6754  }
6755 
6756  void SetBloodTypeVisible(bool show)
6757  {
6758  m_HasBloodTypeVisible = show;
6759  SetSynchDirty();
6760  }
6761 
6762  int GetBloodType()
6763  {
6764  return m_BloodType;
6765  }
6766 
6767  void SetBloodType(int blood_type)
6768  {
6769  m_BloodType = blood_type;
6770  SetSynchDirty();
6771  }
6772 
6773  // --------------------------------------------------
6774  // Soft Skills
6775  //---------------------------------------------------
6776 
6777  SoftSkillsManager GetSoftSkillsManager()
6778  {
6779  return m_SoftSkillsManager;
6780  }
6781 
6782  void CheckDeath()
6783  {
6784  if (IsPlayerSelected() && !IsAlive())
6785  {
6786  SimulateDeath(true);
6787  m_DeathCheckTimer.Stop();
6788  }
6789  }
6790 
6791  // -------------------------------------------------------------------------
6792 
6793  // --------------------------------------------------
6794  // AI Presence
6795  //---------------------------------------------------
6796 
6798  int GetNoisePresenceInAI()
6799  {
6800  if (m_PresenceNotifier)
6801  {
6802  return m_PresenceNotifier.GetNoisePresence();
6803  }
6804 
6805  return 0;
6806  }
6807 
6808  // is a bit on in the persistent flags
6809  bool IsPersistentFlag(PersistentFlag bit)
6810  {
6811  return (m_PersistentFlags & bit);
6812  }
6813  // turn on/off a bit in the persistent flag
6814  void SetPersistentFlag(PersistentFlag bit, bool enable)
6815  {
6816  if (enable)//turn on bit
6817  m_PersistentFlags = (m_PersistentFlags | bit);
6818  else//turn off bit
6819  m_PersistentFlags = ((~bit) & m_PersistentFlags);
6820 
6821  }
6822 
6823 
6824  // -------------------------------------------------------------------------
6825 
6826  int GetStoreLoadVersion()
6827  {
6828  return m_StoreLoadVersion;
6829  }
6830 
6831  override void OnStoreSave(ParamsWriteContext ctx)
6832  {
6833  //Print("OnStoreSave");
6834  if (GetGame().SaveVersion() < 102)
6835  {
6836  ctx.Write(ACT_STORE_SAVE_VERSION);//to be removed after we push 102+
6837  }
6838 
6839  super.OnStoreSave(ctx);
6840 
6841  GetHumanInventory().OnStoreSave(ctx); // FSM of hands
6842  OnStoreSaveLifespan(ctx);
6843 
6844  if (GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer())
6845  {
6846  GetPlayerStats().SaveStats(ctx);// save stats
6847  m_ModifiersManager.OnStoreSave(ctx);// save modifiers
6848  m_AgentPool.OnStoreSave(ctx);//save agents
6849  GetSymptomManager().OnStoreSave(ctx);//save states
6850  if (GetBleedingManagerServer())
6851  {
6852  GetBleedingManagerServer().OnStoreSave(ctx);//save bleeding sources
6853  }
6854  m_PlayerStomach.OnStoreSave(ctx);
6855  ctx.Write(GetBrokenLegs());
6856  //ctx.Write(m_LocalBrokenState);
6857  SaveAreaPersistenceFlag(ctx);
6858 
6860  if (ladder)
6861  {
6862  ctx.Write(true);
6863  ctx.Write(ladder.GetLogoutPosition());
6864  }
6865  else
6866  {
6867  ctx.Write(false);
6868  }
6869 
6870  ArrowManagerPlayer arrowManager = ArrowManagerPlayer.Cast(GetArrowManager());
6871  arrowManager.Save(ctx);
6872  }
6873  }
6874 
6875 
6876  void SaveAreaPersistenceFlag(ParamsWriteContext ctx)
6877  {
6878  if (GetModifiersManager())
6879  SetPersistentFlag(PersistentFlag.AREA_PRESENCE, GetModifiersManager().IsModifierActive(eModifiers.MDF_AREAEXPOSURE));//set the flag for player's presence in contaminated area
6880  ctx.Write(m_PersistentFlags);
6881  }
6882 
6883 
6884  override bool OnStoreLoad(ParamsReadContext ctx, int version)
6885  {
6886  //Print("---- PlayerBase OnStoreLoad START ----, version: "+version);
6887  m_aQuickBarLoad = new array<ref Param2<EntityAI,int>>;
6888 
6889  // todo :: this should be after base call !!!!
6890  if (version < 102)//write removed in v. 102
6891  {
6892  if (!ctx.Read(m_StoreLoadVersion))
6893  return false;
6894  }
6895 
6896  if (!super.OnStoreLoad(ctx, version))
6897  return false;
6898 
6899  // FSM of hands
6900  if (!GetHumanInventory().OnStoreLoad(ctx, version))
6901  return false;
6902 
6903  if (!OnStoreLoadLifespan(ctx, version))
6904  return false;
6905 
6906  if (GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer())
6907  {
6908  if (!GetPlayerStats().LoadStats(ctx, version)) // load stats
6909  {
6910  Print("---- failed to load PlayerStats ----");
6911  return false;
6912  }
6913 
6914  if (version < m_ModifiersManager.GetStorageVersion())//load modifiers !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
6915  {
6916  Print("---- failed to load ModifiersManager, unsupported version ----");
6917  return false;
6918  }
6919  else
6920  {
6921  if (!m_ModifiersManager.OnStoreLoad(ctx, version))
6922  {
6923  Print("---- failed to load ModifiersManager, read fail ----");
6924  return false;
6925  }
6926  }
6927 
6928  if (version < m_AgentPool.GetStorageVersion())//load agents !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
6929  {
6930  Print("---- failed to load AgentPool, unsupported version ----");
6931  return false;
6932  }
6933  else
6934  {
6935  if (!m_AgentPool.OnStoreLoad(ctx, version))
6936  {
6937  Print("---- failed to load AgentPool, read fail ----");
6938  return false;
6939  }
6940  }
6941 
6942 
6943  if (version < GetSymptomManager().GetStorageVersion())//load symptoms !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
6944  {
6945  Print("---- failed to load SymptomManager, unsupported version ----");
6946  return false;
6947  }
6948  else
6949  {
6950  if (!GetSymptomManager().OnStoreLoad(ctx, version))
6951  {
6952  Print("---- failed to load SymptomManager, read fail ----");
6953  return false;
6954  }
6955  }
6956 
6957  if (version < GetBleedingManagerServer().GetStorageVersion())//load bleeding manager !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
6958  {
6959  Print("---- failed to load BleedingManagerServer, unsupported version ----");
6960  return false;
6961  }
6962  else
6963  {
6964  if (!GetBleedingManagerServer().OnStoreLoad(ctx, version))
6965  {
6966  Print("---- failed to load BleedingManagerServer, read fail ----");
6967  return false;
6968  }
6969  }
6970 
6971  if (version < m_PlayerStomach.GetStorageVersion())//load PlayerStomach !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
6972  {
6973  Print("---- failed to load PlayerStomach, unsupported version ----");
6974  return false;
6975  }
6976  else
6977  {
6978  if (!m_PlayerStomach.OnStoreLoad(ctx, version))
6979  {
6980  Print("---- failed to load PlayerStomach, read fail ----");
6981  return false;
6982  }
6983  }
6984 
6985  //Check for broken leg value
6986  if (version >= 116)
6987  {
6988  if (!ctx.Read(m_BrokenLegState))
6989  {
6990  return false;
6991  }
6992  if (version <= 126)// WHILE >= 116
6993  {
6994  if (!ctx.Read(m_LocalBrokenState))
6995  {
6996  return false;
6997  }
6998  }
6999  }
7000  //Check for broken leg value
7001  if (version >= 125 && (!ctx.Read(m_PersistentFlags)))
7002  {
7003  Print("---- failed to load Persistent Flags, read fail ----");
7004  return false;
7005  }
7006 
7007  if (version >= 131)
7008  {
7009  bool onLadder;
7010  if (!ctx.Read(onLadder))
7011  {
7012  return false;
7013  }
7014 
7015  if (onLadder)
7016  {
7017  vector position;
7018  if (!ctx.Read(position))
7019  {
7020  return false;
7021  }
7022 
7023  Hive hive = GetHive();
7024  if (!hive || !hive.CharacterIsLoginPositionChanged(this))
7025  {
7026  SetPosition(position);
7027  }
7028  }
7029  }
7030 
7031  if (version >= 134)
7032  {
7033  ArrowManagerPlayer arrowManager = ArrowManagerPlayer.Cast(GetArrowManager());
7034  arrowManager.Load(ctx);
7035  }
7036  }
7037 
7038  Print("---- PlayerBase OnStoreLoad SUCCESS ----");
7039  return true;
7040  }
7041 
7042  override void AfterStoreLoad()
7043  {
7044  GetHumanInventory().OnAfterStoreLoad();
7045  if (m_EmoteManager)
7046  {
7047  m_EmoteManager.AfterStoreLoad();
7048  }
7049  }
7050 
7051  void OnStoreSaveLifespan(ParamsWriteContext ctx)
7052  {
7053  ctx.Write(m_LifeSpanState);
7054  ctx.Write(m_LastShavedSeconds);
7055  ctx.Write(m_HasBloodyHandsVisible);
7056  ctx.Write(m_HasBloodTypeVisible);
7057  ctx.Write(m_BloodType);
7058  }
7059 
7060  bool OnStoreLoadLifespan(ParamsReadContext ctx, int version)
7061  {
7062  int lifespan_state = 0;
7063  if (!ctx.Read(lifespan_state))
7064  return false;
7065  m_LifeSpanState = lifespan_state;
7066 
7067  int last_shaved = 0;
7068  if (!ctx.Read(last_shaved))
7069  return false;
7070  m_LastShavedSeconds = last_shaved;
7071 
7072  if (version < 122)
7073  {
7074  bool bloody_hands_old;
7075  if (!ctx.Read(bloody_hands_old))
7076  return false;
7077  m_HasBloodyHandsVisible = bloody_hands_old;
7078  }
7079  else
7080  {
7081  int bloody_hands = 0;
7082  if (!ctx.Read(bloody_hands))
7083  return false;
7084  m_HasBloodyHandsVisible = bloody_hands;
7085  }
7086 
7087 
7088  bool blood_visible = false;
7089  if (!ctx.Read(blood_visible))
7090  return false;
7091  m_HasBloodTypeVisible = blood_visible;
7092 
7093  int blood_type = 0;
7094  if (!ctx.Read(blood_type))
7095  return false;
7096  m_BloodType = blood_type;
7097 
7098  return true;
7099  }
7100 
7101  vector m_PlayerOldPos;
7102  void UpdatePlayerMeasures()
7103  {
7104  int hour, minute, second;
7105  GetHourMinuteSecond(hour, minute, second);
7106  float distance;
7107  distance = StatGet(AnalyticsManagerServer.STAT_DISTANCE);
7108  if (m_AnalyticsTimer)
7109  {
7111  data.m_CharacterId = g_Game.GetDatabaseID();
7112  data.m_TimeInterval = m_AnalyticsTimer.GetRemaining();
7113  data.m_DaytimeHour = hour;
7114  data.m_PositionStart = m_PlayerOldPos;
7115  data.m_PositionEnd = GetPosition();
7116  data.m_DistanceOnFoot = distance;
7117  Analytics.PlayerMeasures(data);
7118  }
7119 
7120  m_PlayerOldPos = GetPosition();
7121  }
7122 
7123  void OnConnect()
7124  {
7125  Debug.Log("Player connected:"+this.ToString(),"Connect");
7126 
7127  // analytics
7128  GetGame().GetAnalyticsServer().OnPlayerConnect(this);
7129 
7130  m_PlayerOldPos = GetPosition();
7131  if (m_AnalyticsTimer)
7132  m_AnalyticsTimer.Run(60, this, "UpdatePlayerMeasures", null, true);
7133 
7134  //construction action data
7135  ResetConstructionActionData();
7136  }
7137 
7138  void OnReconnect()
7139  {
7140  Debug.Log("Player reconnected:"+this.ToString(),"Reconnect");
7141 
7142  //construction action data
7143 
7144  ResetConstructionActionData();
7145  }
7146 
7147  void OnDisconnect()
7148  {
7149  Debug.Log("Player disconnected:"+this.ToString(),"Connect");
7150 
7151  // analytics
7152  // force update of the stats
7153  // if player disconnect too soon, UpdatePlayersStats() is not called
7154  GetGame().GetAnalyticsServer().OnPlayerDisconnect(this);
7155 
7157  data.m_CharacterId = g_Game.GetDatabaseID();
7158  data.m_Reason = "Disconnected";
7159  Analytics.PlayerDisconnected(data);
7160 
7161  if (m_AnalyticsTimer)
7162  m_AnalyticsTimer.Stop();
7163  UpdatePlayerMeasures();
7164 
7165  SetPlayerDisconnected(true);
7166  }
7167 
7168  void SetModifiers(bool enable)
7169  {
7170  GetModifiersManager().SetModifiers(enable);
7171  }
7172 
7173  bool Consume(ItemBase source, float amount, EConsumeType consume_type)
7174  {
7175  PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
7176  int agents;
7177  if (consume_type == EConsumeType.ENVIRO_POND || consume_type == EConsumeType.ENVIRO_WELL)
7178  {
7179  if (consume_type == EConsumeType.ENVIRO_POND)
7180  {
7181  agents = agents | eAgents.CHOLERA;
7182  //plugin.TransmitAgents(NULL, this, AGT_WATER_POND, amount);
7183  }
7184  m_PlayerStomach.AddToStomach(Liquid.GetLiquidClassname(LIQUID_WATER), amount, 0 , agents);
7185 
7186 
7187  return true;
7188  }
7189 
7190  Edible_Base edible_item = Edible_Base.Cast(source);
7191  if (!edible_item)
7192  {
7193  return false;
7194  }
7195  agents = edible_item.GetAgents();
7196  if (consume_type == EConsumeType.ITEM_SINGLE_TIME || consume_type == EConsumeType.ITEM_CONTINUOUS)
7197  {
7198  if (consume_type == EConsumeType.ITEM_SINGLE_TIME)
7199  {
7200  plugin.TransmitAgents(edible_item, this, AGT_UACTION_CONSUME, amount);
7201  }
7202  /*
7203  else
7204  {
7205  plugin.TransmitAgents(edible_item, this, AGT_UACTION_TO_PLAYER, amount);
7206  }
7207  */
7208  if (edible_item.IsLiquidContainer())
7209  {
7210  int liquid_type = edible_item.GetLiquidType();
7211  string liquidClassName = Liquid.GetLiquidClassname(liquid_type);
7212  if (liquidClassName.Length() == 0)
7213  Error("Error! Trying to add unknown liquid to stomach with item=" + Object.GetDebugName(edible_item) + " consume_type=" + consume_type + " liquid_type=" + liquid_type);
7214  m_PlayerStomach.AddToStomach(liquidClassName, amount, 0, agents);
7215  }
7216  else
7217  {
7218  int food_stage_type;
7219  if (edible_item.GetFoodStage())
7220  {
7221  food_stage_type = edible_item.GetFoodStage().GetFoodStageType();
7222  }
7223  m_PlayerStomach.AddToStomach(source.GetType(), amount, food_stage_type, agents);
7224  }
7225  edible_item.Consume(amount, this);
7226  return true;
7227 
7228  }
7229  /*
7230  if (consume_type == EConsumeType.ITEM_CONTINUOUS)
7231  {
7232  if (edible_item)
7233  {
7234  plugin.TransmitAgents(edible_item, this, AGT_UACTION_TO_PLAYER, amount);
7235  edible_item.Consume(amount, this);
7236  //ProcessNutritions(edible_item.GetNutritionalProfile(),amount);
7237  m_PlayerStomach.AddToStomach(source.GetType(), amount, edible_item.GetNutritionalProfile());
7238  return true;
7239  }
7240  }
7241  */
7242  return false;
7243  }
7244 
7245  /*
7246  void ProcessNutritions(NutritionalProfile profile, float consumedquantity)
7247  {
7248  float energy_per_unit = profile.GetEnergy() / 100;
7249  float water_per_unit = profile.GetWaterContent() / 100;
7250  float nutritions = profile.GetNutritionalIndex();
7251  float fullness_index = profile.GetFullnessIndex();
7252  float toxicity = profile.GetToxicity();
7253  bool is_liquid = profile.IsLiquid();
7254 
7255  if (consumedquantity > 0)
7256  {
7257  float water_consumed = consumedquantity * water_per_unit;
7258  GetStatStomachVolume().Add(consumedquantity * fullness_index);
7259  GetStatStomachEnergy().Add(consumedquantity * energy_per_unit);
7260  GetStatStomachWater().Add(water_consumed);
7261  GetStatToxicity().Add(consumedquantity * toxicity);
7262  }
7263  else
7264  {
7265  Print("ProcessNutritions - ZERO VOLUME! Fix config");
7266  }
7267  }
7268  */
7269 
7270  void ShowUnconsciousScreen(bool show)
7271  {
7272  #ifndef NO_GUI
7273  if (show)
7274  {
7275  GetGame().GetUIManager().ScreenFadeIn(0, "You are Unconscious", FadeColors.BLACK, FadeColors.WHITE);
7276  PrintString("Fade in");
7277  }
7278  else
7279  {
7280  GetGame().GetUIManager().ScreenFadeOut(0);
7281  PrintString("Fade out");
7282  }
7283  #endif
7284  }
7285 
7286  override void RequestSoundEventEx(EPlayerSoundEventID id, bool from_server_and_client = false, int param = 0)
7287  {
7288  if (from_server_and_client && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
7289  {
7290  PlaySoundEventEx(id, false, false, param);
7291  return;
7292  }
7293  SendSoundEventEx(id, param);
7294  }
7295 
7296  override void RequestSoundEvent(EPlayerSoundEventID id, bool from_server_and_client = false)
7297  {
7298  RequestSoundEventEx(id, from_server_and_client);
7299  }
7300 
7301  override protected void SendSoundEvent(EPlayerSoundEventID id)
7302  {
7303  SendSoundEventEx(id);
7304  }
7305 
7306  override protected void SendSoundEventEx(EPlayerSoundEventID id, int param = 0)
7307  {
7308  if (!GetGame().IsServer())
7309  {
7310  return;
7311  }
7312  m_SoundEvent = id;
7313  m_SoundEventParam = param;
7314  SetSynchDirty();
7315 
7316  if (!GetGame().IsMultiplayer())
7317  {
7318  CheckSoundEvent();
7319  }
7320 
7321  //PrintString(GetGame().GetTime().ToString() + " Set SoundEvent, id:" + id.ToString());
7322  }
7323 
7324  void CheckZeroSoundEvent()
7325  {
7326  if (m_SoundEvent != 0 && m_SoundEventSent)
7327  {
7328  m_SoundEvent = 0;
7329  m_SoundEventParam = 0;
7330  m_SoundEventSent = false;
7331  SetSynchDirty();
7332  }
7333  }
7334 
7335  void CheckSendSoundEvent()
7336  {
7337  if (m_SoundEvent!= 0 && !m_SoundEventSent)
7338  {
7339  m_SoundEventSent = true;
7340  }
7341  }
7342 
7343  override bool PlaySoundEvent(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false)
7344  {
7345  return PlaySoundEventEx(id, from_anim_system, is_from_server);
7346  }
7347 
7348  override bool PlaySoundEventEx(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false, int param = 0)
7349  {
7350  if (!m_PlayerSoundEventHandler)
7351  return false;
7352 
7353  return m_PlayerSoundEventHandler.PlayRequestEx(id, is_from_server, param);
7354  }
7355 
7356  PlayerSoundEventHandler GetPlayerSoundEventHandler()
7357  {
7358  return m_PlayerSoundEventHandler;
7359  }
7360 
7361  void OnBleedingBegin();
7362  void OnBleedingEnd();
7363 
7364  void OnBleedingSourceAdded()
7365  {
7366  m_BleedingSourceCount++;
7367  if (IsControlledPlayer())
7368  {
7369  if (!GetGame().IsDedicatedServer())
7370  {
7371  DisplayElementBadge dis_elm = DisplayElementBadge.Cast(GetVirtualHud().GetElement(eDisplayElements.DELM_BADGE_BLEEDING));
7372  if (dis_elm)
7373  {
7374  dis_elm.SetValue(GetBleedingSourceCount());
7375  }
7376 
7377 
7378  //Print("----------bleeding_SoundSet----------");
7379  SEffectManager.PlaySoundOnObject("bleeding_SoundSet", this);
7380  }
7381  }
7382  }
7383 
7384  void OnBleedingSourceRemoved()
7385  {
7386  m_BleedingSourceCount--;
7387  if (GetGame().IsServer())
7388  {
7389  ArrowManagerBase arrowManager = GetArrowManager();
7390  if (GetBleedingSourceCount() > 0)
7391  {
7392  arrowManager.DropFirstArrow();
7393  }
7394  else
7395  {
7396  arrowManager.DropAllArrows();
7397  }
7398  }
7399 
7400  if (IsControlledPlayer())
7401  {
7402  if (!GetGame().IsDedicatedServer())
7403  {
7404  //Print("GetBleedingSourceCount() "+GetBleedingSourceCount());
7405  DisplayElementBadge dis_elm = DisplayElementBadge.Cast(GetVirtualHud().GetElement(eDisplayElements.DELM_BADGE_BLEEDING));
7406  if (dis_elm)
7407  {
7408  dis_elm.SetValue(GetBleedingSourceCount());
7409  }
7410  }
7411  }
7412  }
7413 
7414 
7415  void OnBleedingSourceRemovedEx(ItemBase item)
7416  {
7417  OnBleedingSourceRemoved();
7418  }
7419 
7420  int GetBleedingSourceCount()
7421  {
7422  return m_BleedingSourceCount;
7423  }
7424 
7425  // for debug purposes, should reset some systems like Modifiers, Stats, Damage etc.....
7426  void ResetPlayer(bool set_max)
7427  {
7428  #ifdef DIAG_DEVELOPER
7429  if (GetGame().IsServer() || !GetGame().IsMultiplayer())
7430  {
7431  GetStomach().ClearContents();
7432 
7433  DamageSystem.ResetAllZones(this);
7434  GetModifiersManager().ResetAll();
7435 
7436  // bleeding sources
7437  if (m_BleedingManagerServer)
7438  m_BleedingManagerServer.RemoveAllSources();
7439 
7440  // Stats
7441  if (GetPlayerStats())
7442  {
7443  int bloodType = GetStatBloodType().Get();
7444  GetPlayerStats().ResetAllStats();
7445  GetStatBloodType().Set(bloodType);
7446  }
7447 
7448  // Agents
7449  if (m_AgentPool)
7450  m_AgentPool.RemoveAllAgents();
7451 
7452  if (m_StaminaHandler)
7453  m_StaminaHandler.SetStamina(GameConstants.STAMINA_MAX);
7454 
7455  // uncon
7456  if (IsUnconscious())
7457  DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, false);
7458 
7459  // set max
7460  if (set_max)
7461  {
7462  GetStatWater().Set(GetStatWater().GetMax());
7463  GetStatEnergy().Set(GetStatEnergy().GetMax());
7464  }
7465 
7466  // fix up inventory
7467  FixAllInventoryItems();
7468 
7469  //remove bloody hands
7470  PluginLifespan moduleLifespan = PluginLifespan.Cast(GetPlugin(PluginLifespan));
7471  moduleLifespan.UpdateBloodyHandsVisibilityEx(this, eBloodyHandsTypes.CLEAN);
7472 
7473  if (GetArrowManager())
7474  GetArrowManager().ClearArrows();
7475 
7476  }
7477 
7478  // client + single + server
7480  if (vehCmd)
7481  {
7482  CarScript car = CarScript.Cast(vehCmd.GetTransport());
7483  if (car)
7484  {
7485  car.FixEntity();
7486  }
7487  }
7488  #endif
7489  }
7490 
7491  void CheckSoundEvent()
7492  {
7493  if (m_SoundEvent != 0)
7494  {
7495  PlaySoundEventEx(m_SoundEvent, false, true,m_SoundEventParam);
7496  m_SoundEvent = 0;
7497  m_SoundEventParam = 0;
7498  }
7499  }
7500 
7501  void TestSend()
7502  {
7503  if (GetGame().IsClient()) return;
7504  RequestSoundEvent(1234);
7505  //Math.RandomInt(1,4096)
7506  }
7507 
7508  void SetStaminaState(eStaminaState state)
7509  {
7510  if (state != m_StaminaState)
7511  {
7512  m_StaminaState = state;
7513  //PrintString("m_StaminaState:"+m_StaminaState.ToString());
7514  SetSynchDirty();
7515  }
7516  }
7517 
7518  int GetStaminaState()
7519  {
7520  return m_StaminaState;
7521  }
7522 
7523  void UpdateQuickBarExtraSlots()
7524  {
7525  m_QuickBarBase.updateSlotsCount();
7526  }
7527 
7528  bool Save()
7529  {
7530  // saved player must be alive and not captive
7531  if (GetPlayerState() == EPlayerStates.ALIVE && !IsRestrained())
7532  {
7533  GetHive().CharacterSave(this);
7534  Debug.Log("Player "+this.ToString()+ " saved as alive");
7535 
7536  return true;
7537  }
7538  return false;
7539  }
7540 
7541  // agent transfer
7542 
7543  static ref array<Object> SPREAD_AGENTS_OBJECTS = new array<Object>;
7544  static ref array<CargoBase> SPREAD_AGENTS_PROXY_CARGOS = new array<CargoBase>;
7545 
7546 
7548  void SpreadAgentsEx(float distance = 3,float chance = 0.25)
7549  {
7550  if (Math.RandomFloat01() > chance)
7551  return;
7552 
7553  GetGame().GetPlayers(m_ServerPlayers);
7554  float dist_check = distance * distance;//make it sq
7555  PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
7556 
7557  foreach (Man target: m_ServerPlayers)
7558  {
7559  if (vector.DistanceSq(GetWorldPosition(), target.GetWorldPosition()) < dist_check && target != this)
7560  {
7561  plugin.TransmitAgents(this, target, AGT_AIRBOURNE_BIOLOGICAL, 1);
7562  }
7563  }
7564  }
7565 
7566  void SpreadAgents()//legacy method
7567  {
7568  SpreadAgentsEx(3,1);
7569  }
7570 
7571  //--------------------------------------------------------------------------------------------
7572  override int GetAgents()
7573  {
7574  return m_AgentPool.GetAgents();
7575  }
7576 
7577  //--------------------------------------------------------------------------------------------
7578  override void RemoveAgent(int agent_id) //removes a single agent type from the player agent pool
7579  {
7580  m_AgentPool.RemoveAgent(agent_id);
7581  }
7582 
7583  //--------------------------------------------------------------------------------------------
7584  override void RemoveAllAgents()
7585  {
7586  m_AgentPool.RemoveAllAgents();
7587  }
7588 
7589 
7590  //--------------------------------------------------------------------------------------------
7591  override void InsertAgent(int agent, float count = 1) //adds a single agent type to the player agent pool
7592  {
7593  m_AgentPool.AddAgent(agent,count);
7594  }
7595 
7596  //--------------------------------------------------------------------------------------------
7597  int GetSingleAgentCount(int agent_id)
7598  {
7599  return m_AgentPool.GetSingleAgentCount(agent_id);
7600  }
7601 
7602  //--------------------------------------------------------------------------------------------
7603  float GetSingleAgentCountNormalized(int agent_id)
7604  {
7605  int max_count = PluginTransmissionAgents.GetAgentMaxCount(agent_id);
7606  return m_AgentPool.GetSingleAgentCount(agent_id) / max_count;
7607  }
7608 
7609  float GetTotalAgentCount()
7610  {
7611  return m_AgentPool.GetTotalAgentCount();
7612  }
7613 
7614  void PrintAgents()
7615  {
7616  m_AgentPool.PrintAgents();
7617  }
7618 
7619  void ImmuneSystemTick(float value, float deltaT)
7620  {
7621  m_AgentPool.ImmuneSystemTick(value, deltaT);
7622  }
7623 
7624  void AntibioticsAttack(float value)
7625  {
7626  m_AgentPool.AntibioticsAttack(value);
7627  }
7628 
7629  //Get aim (player crosshair) position
7630  vector GetAimPosition()
7631  {
7632  float min_distance = 0.5; //min distance, default = 5m
7633 
7634  vector from = GetGame().GetCurrentCameraPosition();
7635  vector to = from + (GetGame().GetCurrentCameraDirection() * min_distance);
7636  vector contactPos;
7637  vector contactDir;
7638  int contactComponent;
7639 
7640  DayZPhysics.RaycastRV(from, to, contactPos, contactDir, contactComponent, NULL, NULL, NULL, false, true);
7641 
7642  return contactPos;
7643  }
7644 
7645 
7646  bool CanEatAndDrink()
7647  {
7648  ItemBase mask = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
7649  return (!mask || (mask && mask.AllowFoodConsumption()));
7650  }
7651 
7652  //get modifier manager
7653  ModifiersManager GetModifiersManager()
7654  {
7655  return m_ModifiersManager;
7656  }
7657 
7658  PlayerStat<float> GetStatWater()
7659  {
7660  if (!m_StatWater && GetPlayerStats())
7661  {
7662  m_StatWater = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.WATER));
7663  }
7664  return m_StatWater;
7665  }
7666 
7667  PlayerStat<float> GetStatToxicity()
7668  {
7669  if (!m_StatToxicity && GetPlayerStats())
7670  {
7671  m_StatToxicity = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.TOXICITY));
7672  }
7673  return m_StatToxicity;
7674  }
7675 
7676  PlayerStat<float> GetStatEnergy()
7677  {
7678  if (!m_StatEnergy && GetPlayerStats())
7679  {
7680  m_StatEnergy = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.ENERGY));
7681  }
7682  return m_StatEnergy;
7683  }
7684 
7685  PlayerStat<float> GetStatHeatComfort()
7686  {
7687  if (!m_StatHeatComfort && GetPlayerStats())
7688  {
7689  m_StatHeatComfort = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.HEATCOMFORT));
7690  }
7691  return m_StatHeatComfort;
7692  }
7693 
7694  PlayerStat<float> GetStatTremor()
7695  {
7696  if (!m_StatTremor && GetPlayerStats())
7697  {
7698  m_StatTremor = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.TREMOR));
7699  }
7700  return m_StatTremor;
7701  }
7702 
7703  PlayerStat<int> GetStatWet()
7704  {
7705  if (!m_StatWet && GetPlayerStats())
7706  {
7707  m_StatWet = PlayerStat<int>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.WET));
7708  }
7709  return m_StatWet;
7710  }
7711 
7712  PlayerStat<float> GetStatDiet()
7713  {
7714  if (!m_StatDiet && GetPlayerStats())
7715  {
7716  m_StatDiet = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.DIET));
7717  }
7718  return m_StatDiet;
7719  }
7720 
7721  PlayerStat<float> GetStatStamina()
7722  {
7723  if (!m_StatStamina && GetPlayerStats())
7724  {
7725  m_StatStamina = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.STAMINA));
7726  }
7727  return m_StatStamina;
7728  }
7729 
7730  PlayerStat<float> GetStatSpecialty()
7731  {
7732  if (!m_StatSpecialty && GetPlayerStats())
7733  {
7734  m_StatSpecialty = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.SPECIALTY));
7735  }
7736  return m_StatSpecialty;
7737  }
7738 
7739  PlayerStat<int> GetStatBloodType()
7740  {
7741  if (!m_StatBloodType && GetPlayerStats())
7742  {
7743  m_StatBloodType = PlayerStat<int>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.BLOODTYPE));
7744  }
7745  return m_StatBloodType;
7746  }
7747 
7748  PlayerStat<float> GetStatHeatBuffer()
7749  {
7750  if (!m_StatHeatBuffer && GetPlayerStats())
7751  {
7752  m_StatHeatBuffer = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.HEATBUFFER));
7753  }
7754  return m_StatHeatBuffer;
7755  }
7756 
7757  void ToggleHeatBufferVisibility(bool show)
7758  {
7759  m_HasHeatBuffer = show;
7760  SetSynchDirty();
7761  }
7762 
7764  string GetLastUAMessage()
7765  {
7766  return m_UALastMessage;
7767  }
7768 
7769  void SetLastUAMessage(string pMsg)
7770  {
7771  m_UALastMessage = pMsg;
7772 
7773  if (m_UALastMessageTimer.IsRunning())
7774  {
7775  m_UALastMessageTimer.Stop();
7776  }
7777 
7778  m_UALastMessageTimer.Run(PlayerConstants.LAST_UA_MSG_LIFETIME, this, "ClearLastUAMessage", null);
7779  }
7780 
7781  protected void ClearLastUAMessage()
7782  {
7783  if (m_UALastMessageTimer.IsRunning())
7784  {
7785  m_UALastMessageTimer.Stop();
7786  }
7787 
7788  m_UALastMessage = "";
7789  }
7790 
7793 
7795  void ForceUpdateInjuredState()
7796  {
7797  m_InjuryHandler.CheckValue(true);
7798  }
7799 
7800  // -------------------------------------------------------------------------
7801  override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
7802  {
7803  PluginTransmissionAgents pluginTransmissionAgents = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
7804 
7805  string name;
7806  int id;
7807  map<int,string> agentList = pluginTransmissionAgents.GetSimpleAgentList();
7808 
7809  for (int i = 0; i < agentList.Count(); i++)
7810  {
7811  name = agentList.GetElement(i);
7812  id = agentList.GetKey(i);
7813 
7814  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_AGENTS_RANGE_INJECT_START + id, "Inject " + name, Colors.WHITE));
7815  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_AGENTS_RANGE_REMOVE_START + id, "Remove " + name, Colors.WHITE));
7816  }
7817  }
7818 
7819  //-------------------------------------------------------------
7823 
7824  override void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
7825  {
7826  super.OnSyncJuncture(pJunctureID, pCtx);
7827 
7828  switch(pJunctureID)
7829  {
7830  case DayZPlayerSyncJunctures.SJ_INJURY:
7831  eInjuryHandlerLevels level;
7832  bool enable;
7833  DayZPlayerSyncJunctures.ReadInjuryParams(pCtx, enable, level);
7834  m_InjuryHandler.SetInjuryCommandParams(enable, level);
7835  break;
7836  case DayZPlayerSyncJunctures.SJ_PLAYER_STATES:
7837  GetSymptomManager().SetAnimation(pCtx);
7838  break;
7839  case DayZPlayerSyncJunctures.SJ_QUICKBAR_SET_SHORTCUT:
7840  OnQuickbarSetEntityRequest(pCtx);
7841  break;
7842  case DayZPlayerSyncJunctures.SJ_INVENTORY:
7843  GetInventory().OnInventoryJunctureFromServer(pCtx);
7844  break;
7845  case DayZPlayerSyncJunctures.SJ_INVENTORY_REPAIR:
7846  GetInventory().OnInventoryJunctureRepairFromServer(pCtx);
7847  break;
7848  case DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE:
7849  GetInventory().OnInventoryJunctureFailureFromServer(pCtx);
7850  break;
7851  case DayZPlayerSyncJunctures.SJ_ACTION_INTERRUPT:
7852  case DayZPlayerSyncJunctures.SJ_ACTION_ACK_ACCEPT:
7853  case DayZPlayerSyncJunctures.SJ_ACTION_ACK_REJECT:
7854  m_ActionManager.OnSyncJuncture(pJunctureID,pCtx);
7855  break;
7856  case DayZPlayerSyncJunctures.SJ_WEAPON_ACTION_ACK_ACCEPT:
7857  case DayZPlayerSyncJunctures.SJ_WEAPON_ACTION_ACK_REJECT:
7858  case DayZPlayerSyncJunctures.SJ_WEAPON_SET_JAMMING_CHANCE:
7859  m_WeaponManager.OnSyncJuncture(pJunctureID,pCtx);
7860  break;
7861  case DayZPlayerSyncJunctures.SJ_UNCONSCIOUSNESS:
7862  DayZPlayerSyncJunctures.ReadPlayerUnconsciousnessParams(pCtx, m_ShouldBeUnconscious);
7863  break;
7864  case DayZPlayerSyncJunctures.SJ_PLAYER_ADD_MODIFIER:
7865  GetSymptomManager().SetAnimation(pCtx);
7866  break;
7867  case DayZPlayerSyncJunctures.SJ_KURU_REQUEST:
7868  float amount;
7869  if (DayZPlayerSyncJunctures.ReadKuruRequest(pCtx, amount))
7870  {
7871  if (GetAimingModel() && IsFireWeaponRaised())
7872  {
7873  GetAimingModel().RequestKuruShake(amount);
7874  }
7875  }
7876  break;
7877  case DayZPlayerSyncJunctures.SJ_GESTURE_REQUEST :
7878  m_EmoteManager.OnSyncJuncture(pJunctureID, pCtx);
7879  break;
7880  case DayZPlayerSyncJunctures.SJ_WEAPON_LIFT:
7881  SetLiftWeapon(pJunctureID, pCtx);
7882  break;
7883  case DayZPlayerSyncJunctures.SJ_ADS_RESET:
7884  m_ResetADS = true;
7885  break;
7886  case DayZPlayerSyncJunctures.SJ_DELETE_ITEM:
7887  SetToDelete(pCtx);
7888  break;
7889  case DayZPlayerSyncJunctures.SJ_BROKEN_LEGS:
7890  m_BrokenLegsJunctureReceived = true;
7891  DayZPlayerSyncJunctures.ReadBrokenLegsParamsEx(pCtx, m_BrokenLegState);
7892  break;
7893  case DayZPlayerSyncJunctures.SJ_SHOCK :
7894  DayZPlayerSyncJunctures.ReadShockParams(pCtx, m_CurrentShock);
7895  break;
7896  case DayZPlayerSyncJunctures.SJ_STAMINA:
7897  m_StaminaHandler.OnSyncJuncture(pJunctureID, pCtx);
7898  break;
7899  case DayZPlayerSyncJunctures.SJ_STAMINA_MISC:
7900  m_StaminaHandler.OnSyncJuncture(pJunctureID, pCtx);
7901  break;
7902  #ifdef DEVELOPER
7903  case DayZPlayerSyncJunctures.SJ_DEBUG_GET_IN_CAR:
7904  EntityAI car;
7905  DayZPlayerSyncJunctures.ReadGetInCarParams(pCtx, car);
7906  SetGetInVehicleDebug(car);
7907  break;
7908  #endif
7909  }
7910  }
7911 
7912  bool IsItemsToDelete()
7913  {
7914  return m_ItemsToDelete.Count() > 0;
7915  }
7916 
7917  void SetToDelete(ParamsReadContext pCtx)
7918  {
7919  EntityAI item;
7920  pCtx.Read(item);
7921  AddItemToDelete(item);
7922  }
7923 
7924  override void AddItemToDelete(EntityAI item)
7925  {
7926  if (item)
7927  {
7928  item.SetPrepareToDelete();
7929  m_ItemsToDelete.Insert(item);
7930  }
7931  }
7932 
7933  bool CanDeleteItems()
7934  {
7935  return !(IsEmotePlaying() || GetThrowing().IsThrowingAnimationPlaying() || GetDayZPlayerInventory().IsProcessing() || (GetActionManager() && GetActionManager().GetRunningAction()));
7936  }
7937 
7938  override void JunctureDeleteItem(EntityAI item)
7939  {
7940  DayZPlayerSyncJunctures.SendDeleteItem(this, item);
7941  }
7942 
7943  void UpdateDelete()
7944  {
7945  int count = m_ItemsToDelete.Count();
7946  if (count > 0)
7947  {
7948  if (CanDeleteItems())
7949  {
7950  EntityAI itemToDelete;
7951 
7952  if (GetGame().IsClient() && GetGame().IsMultiplayer())
7953  {
7955  for (int i = count - 1; i >= 0 ; i--)
7956  {
7957  itemToDelete = m_ItemsToDelete.Get(i);
7958  if (itemToDelete != null)
7959  {
7960  itemToDelete.GetInventory().GetCurrentInventoryLocation(il);
7961  }
7962 
7963  if (itemToDelete == null || (GetItemInHands() == null && il.GetType() == InventoryLocationType.UNKNOWN))
7964  {
7965  m_ItemsToDelete.Remove(i);
7966  }
7967  }
7968  }
7969  else
7970  {
7971  for (int j = count - 1; j >= 0 ; j--)
7972  {
7973  itemToDelete = m_ItemsToDelete.Get(j);
7974  if (itemToDelete == null)
7975  {
7976  m_ItemsToDelete.Remove(j);
7977  }
7978  else
7979  {
7980  itemToDelete.Delete();
7981  m_ItemsToDelete.Remove(j);
7982  }
7983  }
7984  }
7985  }
7986  }
7987  }
7988 
7989  override bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
7990  {
7993  {
7995  HumanItemBehaviorCfg hibcfg = hia.GetItemInHandsBehaviourCfg();
7996  if (hibcfg && hibcfg.m_StanceRotation[m_MovementState.m_iStanceIdx] == DayZPlayerConstants.ROTATION_DISABLE)
7997  {
7998  return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
7999  }
8000  else
8001  {
8002  m_fLastHeadingDiff = 0;
8003  return DayZPlayerImplementHeading.ClampHeading(pDt, pModel, m_fLastHeadingDiff);
8004  }
8005  }
8006 
8007  return super.HeadingModel(pDt, pModel);
8008  }
8009 
8010  override bool IsInventorySoftLocked()
8011  {
8012  return m_InventorySoftLockCount > 0;
8013  }
8014 
8016  override void SetInventorySoftLock(bool status)
8017  {
8018  if (status)
8019  m_InventorySoftLockCount++;
8020  else
8021  m_InventorySoftLockCount--;
8022 
8023  if (m_InventorySoftLockCount < 0)
8024  m_InventorySoftLockCount = 0;
8025 
8026  m_InventorySoftLocked = IsInventorySoftLocked();
8027  }
8028 
8029  void SetLoadedQuickBarItemBind(EntityAI entity, int index)
8030  {
8031  if (m_aQuickBarLoad)
8032  m_aQuickBarLoad.Insert(new Param2<EntityAI, int>(entity,index));
8033  }
8034 
8035  override bool IsLiftWeapon()
8036  {
8037  return m_LiftWeapon_player;
8038  }
8039 
8040  //Server
8041  bool ReadLiftWeaponRequest(int userDataType, ParamsReadContext ctx)
8042  {
8043  bool state;
8044  ctx.Read(state);
8045 
8047  pCtx.Write(state);
8048 
8049  SendSyncJuncture(DayZPlayerSyncJunctures.SJ_WEAPON_LIFT, pCtx);
8050 
8051  return true;
8052  }
8053 
8054  void SetLiftWeapon(int pJunctureID, ParamsReadContext ctx)
8055  {
8056  bool state;
8057  ctx.Read(state);
8058 
8059  m_ProcessLiftWeaponState = state;
8060  m_ProcessLiftWeapon = true;
8061 
8062  //Print("SetLiftWeapon | STS: " + GetSimulationTimeStamp());
8063  }
8064 
8066  void SendLiftWeaponSync(bool state)
8067  {
8068  HumanCommandWeapons hcw;
8069  //SP version
8070  if (!GetGame().IsMultiplayer())
8071  {
8072  m_LiftWeapon_player = state;
8073 
8075  if (hcw)
8076  hcw.LiftWeapon(state);
8077 
8078  GetWeaponManager().OnLiftWeapon();
8079 
8080  return;
8081  }
8082 
8084 
8085  if (GetGame().IsMultiplayer() && GetGame().IsClient() && !ctx.CanStoreInputUserData())
8086  {
8087  //Print("ctx unavailable");
8088  return;
8089  }
8090  else if (GetGame().IsMultiplayer() && GetGame().IsClient() && ctx.CanStoreInputUserData())
8091  {
8092  //Print("sending ECB cancel request");
8093  ctx.Write(INPUT_UDT_WEAPON_LIFT_EVENT);
8094  ctx.Write(state);
8095  ctx.Send();
8096  }
8097  }
8098 
8099  override void CheckLiftWeapon()
8100  {
8101  // lift weapon check
8102  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
8103  {
8104  Weapon_Base weap;
8105  if (Weapon_Base.CastTo(weap, GetItemInHands()))
8106  {
8107  bool limited = weap.LiftWeaponCheck(this);
8108 
8109  if (limited && !m_LiftWeapon_player)
8110  SendLiftWeaponSync(true);
8111  else if (!limited && m_LiftWeapon_player)
8112  SendLiftWeaponSync(false);
8113  }
8114  else if (m_LiftWeapon_player)
8115  {
8116  SendLiftWeaponSync(false);
8117  }
8118  }
8119  }
8120 
8121  override void ProcessLiftWeapon()
8122  {
8123  if (m_ProcessLiftWeapon)
8124  {
8126  if (hcw)
8127  hcw.LiftWeapon(m_ProcessLiftWeaponState);
8128 
8129  GetWeaponManager().OnLiftWeapon();
8130  m_LiftWeapon_player = m_ProcessLiftWeaponState;
8131  m_ProcessLiftWeapon = false;
8132 
8133  //Debug.Log("SimulationStamp_server: " + this.GetSimulationTimeStamp());
8134  }
8135  }
8136 
8138  override void HideClothing(ItemOptics optic, bool state)
8139  {
8140  super.HideClothing(optic, state);
8141  array<int> clothingArray = new array<int>;
8142  Clothing clothes;
8143 
8144  if (state && DayZPlayerCameraOptics.Cast(m_CurrentCamera))
8145  {
8146  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
8147  {
8148  clothingArray.Insert(InventorySlots.BACK);
8149  clothingArray.Insert(InventorySlots.SHOULDER);
8150  clothingArray.Insert(InventorySlots.MELEE);
8151  if (optic && optic.GetCurrentStepFOV() < GameConstants.DZPLAYER_CAMERA_FOV_IRONSIGHTS)
8152  {
8153  clothingArray.Insert(InventorySlots.BODY);
8154  clothingArray.Insert(InventorySlots.VEST);
8155  }
8156 
8157  SetInvisibleRecursive(true,this,clothingArray);
8158  }
8159  }
8160  //showing should be instant (called directly, not via CallLater)
8161  else
8162  {
8163  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
8164  {
8165  clothingArray = {InventorySlots.BACK,InventorySlots.BODY,InventorySlots.VEST,InventorySlots.SHOULDER,InventorySlots.MELEE};
8166 
8167  SetInvisibleRecursive(false,this,clothingArray);
8168  }
8169  }
8170  }
8171 
8172  void RequestUnconsciousness(bool enable)
8173  {
8174  DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, enable);
8175  }
8176 
8177  override void SetDeathDarknessLevel(float duration, float tick_time)
8178  {
8179  super.SetDeathDarknessLevel(duration, tick_time);
8180 
8181  if (IsControlledPlayer())
8182  {
8183  float actual_tick = tick_time;
8184  if (GetDamageDealtEffect())
8185  m_DamageDealtEffect = null;
8186 
8187  if (GetFlashbangEffect())
8188  m_FlashbangEffect = null;
8189 
8190  float progress;
8191  if (duration > 0)
8192  progress = 1 - ((duration - m_DeathDarkeningCurrentTime) / duration);
8193 
8194  m_DeathDarkeningCurrentTime += actual_tick;
8195 
8196  if (!IsAlive() && IsPlayerSelected())
8197  {
8198  m_DeathDarkeningParam.param1 = progress;
8199  PPERequesterBank.GetRequester(PPERequester_DeathDarkening).Start(m_DeathDarkeningParam);
8200  }
8201 
8202  if (m_DeathDarkeningCurrentTime >= duration)
8203  {
8204  StopDeathDarkeningEffect();
8205  }
8206  }
8207  else
8208  {
8209  StopDeathDarkeningEffect();
8210  }
8211  }
8212 
8213  override bool IsInFBEmoteState()
8214  {
8215  if (!IsEmotePlaying())
8216  return false;
8217  if ((m_EmoteManager.m_Callback && m_EmoteManager.m_Callback.m_IsFullbody) || m_EmoteManager.m_IsSurrendered)
8218  {
8219  return true;
8220  }
8221  return false;
8222  }
8223 
8225  void EndSurrenderRequest(SurrenderData data = null)
8226  {
8227  if (m_EmoteManager)
8228  m_EmoteManager.EndSurrenderRequest(data);
8229  }
8230 
8231  bool IsSurrendered()
8232  {
8233  if (m_EmoteManager)
8234  return m_EmoteManager.m_IsSurrendered;
8235 
8236  return false;
8237  }
8238 
8239  bool IsPlayerLoaded()
8240  {
8241  return m_PlayerLoaded;
8242  }
8243 
8244  //disconnected, caused problems. Awaiting refactor
8245  override void CheckAnimationOverrides()
8246  {
8247  //FB gesture slideposeangle override
8248  if (IsInFBEmoteState() && IsControlledPlayer() && IsPlayerSelected())
8249  {
8250  OverrideSlidePoseAngle(Math.PI2);
8251  }
8252  else if (!IsInFBEmoteState() && IsControlledPlayer() && IsPlayerSelected())
8253  {
8254  OverrideSlidePoseAngle(m_OriginalSlidePoseAngle);
8255  }
8256 
8257  //+add more, if needed
8258  }
8259 
8260  /*void OnSurrenderEnd()
8261  {
8262  }*/
8263 
8264  bool CanRedirectToWeaponManager (notnull EntityAI item, out bool isActionPossible)
8265  {
8266  isActionPossible = false;
8267  Magazine mag = Magazine.Cast(item);
8268  Weapon_Base wpn = Weapon_Base.Cast(item.GetHierarchyParent());
8269  if (mag && wpn)
8270  {
8271  if (GetWeaponManager().CanDetachMagazine(wpn, mag))
8272  {
8273  //Print("[inv] PlayerBase.CanRedirectToWeaponManager OK, can detach mag=" + mag + " from wpn=" + wpn);
8274  isActionPossible = true;
8275  }
8276  else
8277  {
8278  //Print("[inv] PlayerBase.CanRedirectToWeaponManager cannot detach mag=" + mag + " from wpn=" + wpn);
8279  }
8280  return true;
8281  }
8282  return false;
8283  }
8284 
8285  // Inventory actions with redirection to weapon manager
8286  override bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
8287  {
8288  bool can_detach;
8289  if (CanRedirectToWeaponManager(item,can_detach))
8290  {
8292  if (can_detach && target.GetInventory().FindFreeLocationFor(item, flags, il))
8293  {
8294  return GetWeaponManager().DetachMagazine(il);
8295  }
8296  return false;
8297  }
8298  return super.PredictiveTakeEntityToTargetInventory(target, flags, item);
8299  }
8300 
8301  override bool PredictiveTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
8302  {
8303  bool can_detach;
8304  if (CanRedirectToWeaponManager(item,can_detach))
8305  {
8307  if (can_detach && GetInventory().FindFreeLocationFor(item, flags, il))
8308  {
8309  return GetWeaponManager().DetachMagazine(il);
8310  }
8311  return false;
8312  }
8313  return super.PredictiveTakeEntityToInventory(flags, item);
8314  }
8315 
8316  override bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
8317  {
8318  Weapon_Base parentWpn = Weapon_Base.Cast(target);
8319  Magazine mag = Magazine.Cast(item);
8320  if (parentWpn && mag)
8321  {
8322  if (GetWeaponManager().CanAttachMagazine(parentWpn, mag))
8323  return GetWeaponManager().AttachMagazine(mag);
8324 
8325  return false;
8326  }
8327  return super.PredictiveTakeEntityToTargetAttachment(target, item);
8328  }
8329 
8330  override bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
8331  {
8332  Weapon_Base parentWpn = Weapon_Base.Cast(target);
8333  Magazine mag = Magazine.Cast(item);
8334  if (parentWpn && mag)
8335  {
8336  if (target.CanReceiveAttachment(item,slot) && GetWeaponManager().CanAttachMagazine(parentWpn, mag))
8337  return GetWeaponManager().AttachMagazine(mag);
8338 
8339  return false;
8340  }
8341  return super.PredictiveTakeEntityToTargetAttachmentEx(target, item,slot);
8342  }
8343 
8344  override bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
8345  {
8346  bool can_detach;
8347  if (CanRedirectToWeaponManager(item,can_detach))
8348  {
8350  if (can_detach && target.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, il))
8351  {
8352  return GetWeaponManager().DetachMagazine(il);
8353  }
8354  return false;
8355  }
8356  return super.PredictiveTakeEntityToTargetCargo(target,item);
8357  }
8358 
8359  override bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
8360  {
8361  bool can_detach;
8362  if (CanRedirectToWeaponManager(item, can_detach))
8363  {
8364  if (can_detach)
8365  {
8367  dst.SetCargoAuto(cargo, item, row, col, item.GetInventory().GetFlipCargo());
8368 
8369  return GetWeaponManager().DetachMagazine(dst);
8370  }
8371  return false;
8372  }
8373  return super.PredictiveTakeEntityToTargetCargoEx (cargo, item, row, col);
8374  }
8375 
8376  override bool PredictiveDropEntity (notnull EntityAI item)
8377  {
8378  bool can_detach;
8379  if (CanRedirectToWeaponManager(item,can_detach))
8380  {
8381  if (can_detach)
8382  {
8383  vector m4[4];
8384  Math3D.MatrixIdentity4(m4);
8385 
8387  GameInventory.PrepareDropEntityPos(this, item, m4, false, GameConstants.INVENTORY_ENTITY_DROP_OVERLAP_DEPTH);
8389  il.SetGround(item, m4);
8390  return GetWeaponManager().DetachMagazine(il);
8391  }
8392  return false;
8393  }
8394  return super.PredictiveDropEntity(item);
8395  }
8396 
8397  override bool PredictiveSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
8398  {
8399  ForceStandUpForHeavyItemsSwap(item1, item2);
8400  //Print("PlayerBase | PredictiveSwapEntities");
8401  Magazine swapmag1 = Magazine.Cast(item1);
8402  Magazine swapmag2 = Magazine.Cast(item2);
8403 
8404  if (swapmag1 && swapmag2)
8405  {
8406  Weapon_Base parentWpn;
8407 
8408  if (Class.CastTo(parentWpn, swapmag1.GetHierarchyParent()))
8409  {
8410  if (GetWeaponManager().CanSwapMagazine(parentWpn, swapmag2))
8411  {
8412  Print("[inv] PlayerBase.PredictiveSwapEntities: swapping mag1=" + swapmag1 + " to parent wpn=" + parentWpn + " of mag1=" + swapmag1);
8413  return GetWeaponManager().SwapMagazine(swapmag2);
8414  }
8415  else
8416  {
8417  Print("[inv] PlayerBase.PredictiveSwapEntities: can not swap magazines");
8418  return false;
8419  }
8420  }
8421 
8422  if (Class.CastTo(parentWpn, swapmag2.GetHierarchyParent()))
8423  {
8424  if (GetWeaponManager().CanSwapMagazine(parentWpn, swapmag1))
8425  {
8426  Print("[inv] PlayerBase.PredictiveSwapEntities: swapping mag1=" + swapmag1 + " to parent wpn=" + parentWpn + " of mag2=" + swapmag2);
8427  return GetWeaponManager().SwapMagazine(swapmag1);
8428  }
8429  else
8430  {
8431  Print("[inv] PlayerBase.PredictiveSwapEntities: can not swap magazines");
8432  return false;
8433  }
8434  }
8435  }
8436 
8437  EntityAI item_hands;
8438  EntityAI item_ground;
8439  if (IsSwapBetweenHandsAndGroundLargeItem(item1,item2,item_hands,item_ground) && !m_ActionManager.GetRunningAction())
8440  {
8441  ActionManagerClient mngr_client;
8442  CastTo(mngr_client,m_ActionManager);
8443 
8444  ActionTarget atrg = new ActionTarget(item_ground,null,-1,vector.Zero,-1.0);
8445  if (mngr_client.GetAction(ActionSwapItemToHands).Can(this,atrg,ItemBase.Cast(item_hands)))
8446  {
8447  mngr_client.PerformActionStart(mngr_client.GetAction(ActionSwapItemToHands),atrg,ItemBase.Cast(item_hands));
8448  return true;
8449  }
8450  return super.PredictiveSwapEntities(item1, item2);
8451  }
8452  else
8453  return super.PredictiveSwapEntities(item1, item2);
8454  }
8455 
8456  override bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
8457  {
8458  ForceStandUpForHeavyItemsSwap(item1, item2);
8459 
8461  if (item1.IsHeavyBehaviour() && item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND && !m_ActionManager.GetRunningAction())
8462  {
8463  //Print("override bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)");
8464  ActionManagerClient mngr_client;
8465  CastTo(mngr_client,m_ActionManager);
8466 
8467  ActionTarget atrg = new ActionTarget(item1,null,-1,vector.Zero,-1.0);
8468  if (mngr_client.GetAction(ActionSwapItemToHands).Can(this,atrg,ItemBase.Cast(item2)))
8469  {
8470  mngr_client.PerformActionStart(mngr_client.GetAction(ActionSwapItemToHands),atrg,ItemBase.Cast(item2));
8471  }
8472  return true;
8473  }
8474  else
8475  return super.PredictiveForceSwapEntities(item1, item2, item2_dst);
8476  }
8477 
8478  override void PredictiveTakeEntityToHands(EntityAI item)
8479  {
8480  if (item.IsHeavyBehaviour() && !m_ActionManager.GetRunningAction() && !item.GetHierarchyParent())
8481  {
8482  ActionManagerClient mngr_client;
8483  if (CastTo(mngr_client,m_ActionManager))
8484  {
8485  ActionTarget atrg = new ActionTarget(item,null,-1,vector.Zero,-1.0);
8486 
8487  if (mngr_client.GetAction(ActionTakeItemToHands).Can(this,atrg,null))
8488  {
8489  mngr_client.PerformActionStart(mngr_client.GetAction(ActionTakeItemToHands),atrg,null);
8490  }
8491  /*).Can(this,
8492  mngr_client.ActionStart(mngr_client.GetAction(ActionTakeItemToHands),mngr_client.FindActionTarget(),null);
8493  return;*/
8494  }
8495  }
8496  else
8497  super.PredictiveTakeEntityToHands(item);
8498  }
8499 
8500  override bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
8501  {
8502  EntityAI item = src.GetItem();
8503  if (item)
8504  {
8505  bool can_detach;
8506 
8507  if (CanRedirectToWeaponManager(item,can_detach))
8508  {
8509  if (can_detach)
8510  {
8511  return GetWeaponManager().DetachMagazine(dst);
8512  }
8513  return false;
8514  }
8515  return super.PredictiveTakeToDst(src,dst);
8516  }
8517  return false;
8518  }
8519 
8520  bool IsSwapBetweenHandsAndGroundLargeItem(notnull EntityAI item1, notnull EntityAI item2, out EntityAI item_hands, out EntityAI item_ground)
8521  {
8523  if (item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.HANDS)
8524  item_hands = item1;
8525  if (item2.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.HANDS)
8526  item_hands = item2;
8527  if (item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND)
8528  item_ground = item1;
8529  if (item2.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND)
8530  item_ground = item2;
8531 
8532  return item_hands && item_ground && item_ground.IsHeavyBehaviour();
8533  }
8534 
8536  void SetHairLevelToHide(int level, bool state, bool was_debug = false)
8537  {
8538  if (was_debug && GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
8539  return;
8540 
8541  if (!m_CharactersHead)
8542  {
8543  ErrorEx("No valid head detected on character!");
8544  return;
8545  }
8546 
8547  if (level == -1) //hide/show ALL
8548  {
8549  m_HideHairAnimated = !m_HideHairAnimated;
8550  for (int i = 0; i < m_CharactersHead.m_HeadHairSelectionArray.Count(); ++i)
8551  {
8552  //m_CharactersHead.SetSimpleHiddenSelectionState(i,m_HideHairAnimated);
8553  SelectionTranslation stt = SelectionTranslation.Cast(m_CharactersHead.m_HeadHairHidingStateMap.Get(i));
8554  stt.SetSelectionState(m_HideHairAnimated);
8555  m_CharactersHead.m_HeadHairHidingStateMap.Set(i, stt);
8556 #ifdef DIAG_DEVELOPER
8557 #ifndef SERVER
8559  diagmenu.m_HairHidingStateMap.Set(i, m_HideHairAnimated);
8560 #endif
8561 #endif
8562  }
8563  }
8564  else //hide/show selected level only
8565  {
8566  bool switchState;
8567  if (was_debug)
8568  {
8569 #ifdef DIAG_DEVELOPER
8570 #ifndef SERVER
8572  switchState = !diagmenuu.m_HairHidingStateMap.Get(level);
8573  diagmenuu.m_HairHidingStateMap.Set(level, switchState);
8574 #endif
8575 #endif
8576  }
8577  else
8578  {
8579  switchState = !state;
8580  }
8581  //m_CharactersHead.SetSimpleHiddenSelectionState(level,switchState);
8582  stt = SelectionTranslation.Cast(m_CharactersHead.m_HeadHairHidingStateMap.Get(level));
8583  stt.SetSelectionState(switchState);
8584  m_CharactersHead.m_HeadHairHidingStateMap.Set(level, stt); //nescessary?
8585  }
8586  }
8587 
8588  void HideHairSelections(ItemBase item, bool state)
8589  {
8590  if (!item || !item.GetHeadHidingSelection() || !m_CharactersHead)
8591  return;
8592 
8593  int slot_id; //item currently attached (or detaching from) here
8594  string slot_name; //item currently attached (or detaching from) here
8595  string str
8596  int idx = 0;
8597  int i;
8598  int count;
8599  item.GetInventory().GetCurrentAttachmentSlotInfo(slot_id,slot_name);
8600 
8601  if (item.HidesSelectionBySlot())
8602  {
8603  count = item.GetInventory().GetSlotIdCount();
8604  for (i = 0; i < count; i++)
8605  {
8606  if (item.GetInventory().GetSlotId(i) == slot_id)
8607  {
8608  str = item.GetHeadHidingSelection().Get(i);
8609  idx = m_CharactersHead.m_HeadHairSelectionArray.Find(str);
8610  if (idx != -1)
8611  SetHairLevelToHide(idx,state);
8612  #ifdef DEVELOPER
8613  else
8614  Debug.Log("No valid selection '" + str + "' found on head of " + GetType() + ". Verify the p3d, model config, and the 'HAIR_HIDING_SELECTIONS' macro in basicDefines.");
8615  #endif
8616  }
8617  }
8618  }
8619  else
8620  {
8621  count = item.GetHeadHidingSelection().Count();
8622  for (i = 0; i < count; i++)
8623  {
8624  str = item.GetHeadHidingSelection().Get(i);
8625  idx = m_CharactersHead.m_HeadHairSelectionArray.Find(str);
8626  if (idx != -1)
8627  SetHairLevelToHide(idx,state);
8628  #ifdef DEVELOPER
8629  else
8630  Debug.Log("No valid selection '" + str + "' found on head of " + GetType() + ". Verify the p3d, model config, and the 'HAIR_HIDING_SELECTIONS' macro in basicDefines.");
8631  #endif
8632  }
8633  }
8634  UpdateHairSelectionVisibility();
8635  }
8636 
8637  void UpdateHairSelectionVisibility(bool was_debug = false)
8638  {
8639  if (!m_CharactersHead)
8640  return;
8641  bool shown;
8642  bool exception_hidden = false;
8643  int i;
8644  int count = m_CharactersHead.m_HeadHairHidingStateMap.Count();
8646 
8647  //hide/show beard
8648  if (IsMale() && m_CharactersHead.GetBeardIndex() > -1 && !was_debug)
8649  {
8650  SetHairLevelToHide(m_CharactersHead.GetBeardIndex(),GetLifeSpanState() != LifeSpanState.BEARD_EXTRA);
8651  }
8652 
8653  //show all first
8654  for (i = 0; i < count; i++)
8655  {
8656  m_CharactersHead.SetSimpleHiddenSelectionState(i,true);
8657  }
8658  //then carve it up
8659  for (i = 0; i < count; i++)
8660  {
8661  stt = m_CharactersHead.m_HeadHairHidingStateMap.Get(i);
8662  shown = stt.GetSelectionState();
8663  if (!shown)
8664  {
8665  if (/*IsMale() && */!m_CharactersHead.IsHandlingException())
8666  {
8667  m_CharactersHead.SetSimpleHiddenSelectionState(i,shown);
8668  UpdateTranslatedSelections(stt);
8669  //Print("hidden idx: " + i);
8670  }
8671  else
8672  {
8673  exception_hidden = true;
8674  }
8675  }
8676  }
8677 
8678  //exceptions handled differently; hides hair
8679  if (exception_hidden)
8680  {
8681  m_CharactersHead.SetSimpleHiddenSelectionState(m_CharactersHead.GetHairIndex(),false);
8682  if (IsMale())
8683  m_CharactersHead.SetSimpleHiddenSelectionState(m_CharactersHead.GetBeardIndex(),false);
8684  }
8685  }
8686 
8687  void UpdateTranslatedSelections(SelectionTranslation stt)
8688  {
8689  int index;
8690  array<int> translatedSelectinosArray = stt.GetTranslatedSelections();
8691  for (int i = 0; i < translatedSelectinosArray.Count(); i++)
8692  {
8693  index = translatedSelectinosArray.Get(i);
8694  //if (index > -1)
8695  m_CharactersHead.SetSimpleHiddenSelectionState(index,false); //safe this way, only hiding/carving from shown parts
8696  }
8697  }
8698 
8700  void CheckHairClippingOnCharacterLoad()
8701  {
8702  ItemBase headgear = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.HEADGEAR));
8703  ItemBase mask = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
8704 
8705  HideHairSelections(headgear,true);
8706  HideHairSelections(mask,true);
8707  }
8708 
8709  bool IsNVGWorking()
8710  {
8711  return m_ActiveNVTypes && m_ActiveNVTypes.Count() > 0;
8712  }
8713 
8714  bool IsNVGLowered()
8715  {
8716  return m_LoweredNVGHeadset;
8717  }
8718 
8719  int GetNVType()
8720  {
8721  if (!m_ActiveNVTypes || m_ActiveNVTypes.Count() == 0)
8722  {
8723  return NVTypes.NONE;
8724  }
8725  else
8726  {
8727  return m_ActiveNVTypes[m_ActiveNVTypes.Count() - 1];
8728  }
8729  }
8730 
8731  array<int> GetNVTypesArray()
8732  {
8733  return m_ActiveNVTypes;
8734  }
8735 
8737  void SetNVGWorking(bool state)
8738  {
8739  //Deprecated, below is for legacy's sake
8740  AddActiveNV(NVTypes.NV_GOGGLES);
8741  }
8742 
8743  void SetNVGLowered(bool state)
8744  {
8745  m_LoweredNVGHeadset = state;
8746  }
8747 
8748  void AddActiveNV(int type)
8749  {
8750  if (!m_ActiveNVTypes || (GetGame().IsMultiplayer() && GetGame().IsServer()))
8751  {
8752  #ifdef DEVELOPER
8753  Error("AddActiveNV | illegal server-side call!");
8754  #endif
8755 
8756  return;
8757  }
8758 
8759  if (m_ActiveNVTypes.Find(type) == -1) //TODO - set instead?
8760  m_ActiveNVTypes.Insert(type);
8761  }
8762 
8763  void RemoveActiveNV(int type)
8764  {
8765  if (!m_ActiveNVTypes || (GetGame().IsMultiplayer() && GetGame().IsServer()))
8766  {
8767  #ifdef DEVELOPER
8768  Error("RemoveActiveNV | illegal server-side call!");
8769  #endif
8770 
8771  return;
8772  }
8773 
8774  if (m_ActiveNVTypes.Find(type) != -1) //TODO - set instead?
8775  m_ActiveNVTypes.RemoveItem(type);
8776  }
8777 
8778  void ResetActiveNV()
8779  {
8780  m_ActiveNVTypes.Clear();
8781  }
8782 
8783 #ifdef DEVELOPER
8784  override string GetDebugText()
8785  {
8786  string text = super.GetDebugText();
8787  /*
8788  text += "GetMovementTimeToStrafeJog:" + CfgGameplayHandler.GetMovementTimeToStrafeJog() + "\n";
8789  text += "GetMovementTimeToStrafeSprint:" + CfgGameplayHandler.GetMovementTimeToStrafeSprint()+ "\n";
8790 
8791  SHumanCommandMoveSettings moveSettings = GetDayZPlayerType().CommandMoveSettingsW();
8792  if (moveSettings)
8793  {
8794  text += "hmcs.m_fDirFilterTimeout:" + moveSettings.m_fDirFilterTimeout + "\n";
8795  text += "hmcs.m_fDirFilterSprintTimeout:" + moveSettings.m_fDirFilterSprintTimeout+ "\n";
8796  }*/
8797 
8798  return text;
8799  }
8800 
8801 
8802 
8803  void DEBUGRotateNVG()
8804  {
8805  NVGoggles nvg;
8806 
8807  if (FindAttachmentBySlotName("Eyewear"))
8808  {
8809  nvg = NVGoggles.Cast(FindAttachmentBySlotName("Eyewear").FindAttachmentBySlotName("NVG"));
8810  }
8811  else if (FindAttachmentBySlotName("Headgear"))
8812  {
8813  nvg = NVGoggles.Cast(FindAttachmentBySlotName("Headgear").FindAttachmentBySlotName("NVG"));
8814  }
8815 
8816  if (nvg)
8817  {
8818  nvg.RotateGoggles(nvg.m_IsLowered);
8819  }
8820  }
8821 #endif
8822 
8823  void AdjustBandana(EntityAI item, string slot_name)
8824  {
8825  if (Bandana_ColorBase.Cast(item))
8826  {
8827  if (slot_name == "Headgear")
8828  {
8829  item.SetSimpleHiddenSelectionState(0,1);
8830  item.SetSimpleHiddenSelectionState(1,0);
8831  }
8832  else if (slot_name == "Mask")
8833  {
8834  item.SetSimpleHiddenSelectionState(0,0);
8835  item.SetSimpleHiddenSelectionState(1,1);
8836  }
8837  }
8838  }
8839 
8840  //client-side
8841  void UpdateCorpseStateVisual()
8842  {
8843  //Print("---Prettying up corpses... | " + GetGame().GetTime() + " | " + this + " | " + GetType() + "---");
8844  //Print("m_DecayedTexture = " + m_DecayedTexture);
8845  int state = Math.AbsInt(m_CorpseState);//negative sign denotes a special meaning(state was forced to a live player), but we are only intetested in the positive value here
8846  if (state == PlayerConstants.CORPSE_STATE_DECAYED)
8847  {
8848  EntityAI bodypart;
8849  ItemBase item;
8850 
8851  string path;
8852  int idx;
8853  int slot_id;
8854  array<string> bodyparts = {"Gloves","Body","Legs","Feet"};
8855 
8856  for (int i = 0; i < bodyparts.Count(); i++)
8857  {
8858  slot_id = InventorySlots.GetSlotIdFromString(bodyparts.Get(i));
8859  bodypart = GetInventory().FindPlaceholderForSlot(slot_id);
8860  item = ItemBase.Cast(GetInventory().FindAttachment(slot_id));
8861 
8862  if (bodypart)
8863  {
8864  path = "cfgVehicles " + bodypart.GetType();
8865  idx = bodypart.GetHiddenSelectionIndex("personality");
8866  if (idx > -1)
8867  {
8868  bodypart.SetObjectTexture(idx,m_DecayedTexture);
8869  }
8870  }
8871  if (item)
8872  {
8873  path = "cfgVehicles " + item.GetType();
8874  idx = item.GetHiddenSelectionIndex("personality");
8875  if (idx > -1)
8876  {
8877  item.SetObjectTexture(idx,m_DecayedTexture);
8878  }
8879  }
8880  }
8881 
8882  SetFaceTexture(m_DecayedTexture);
8883  }
8884  }
8885 
8886  void SetDecayEffects(int effect = -1)
8887  {
8888  int boneIdx = GetBoneIndexByName("Spine2");
8889  Particle p;
8890 
8891  switch (effect)
8892  {
8893  case PlayerConstants.CORPSE_STATE_MEDIUM :
8894  //play medium sound/flies particle
8895  if (!m_FliesEff)
8896  m_FliesEff = new EffSwarmingFlies();
8897 
8898  if (m_FliesEff && !SEffectManager.IsEffectExist(m_FliesIndex))
8899  {
8900  m_FliesEff.SetDecalOwner(this);
8901  m_FliesIndex = SEffectManager.PlayOnObject(m_FliesEff, this, "0 0.25 0");
8902  p = m_FliesEff.GetParticle();
8903  AddChild(p, boneIdx);
8904  if (!m_SoundFliesEffect)
8905  {
8906  PlaySoundSetLoop(m_SoundFliesEffect, "Flies_SoundSet", 1.0, 1.0);
8907 // ErrorEx("DbgFlies | CORPSE_STATE_MEDIUM | m_SoundFliesEffect created! " + m_SoundFliesEffect,ErrorExSeverity.INFO);
8908  }
8909  }
8910  break;
8911  case PlayerConstants.CORPSE_STATE_DECAYED :
8912  //play serious sound/flies particle
8913  if (!m_FliesEff)
8914  m_FliesEff = new EffSwarmingFlies();
8915 
8916  if (m_FliesEff && !SEffectManager.IsEffectExist(m_FliesIndex))
8917  {
8918  m_FliesEff.SetDecalOwner(this);
8919  m_FliesIndex = SEffectManager.PlayOnObject(m_FliesEff, this, "0 0.25 0");
8920  p = m_FliesEff.GetParticle();
8921  AddChild(p, boneIdx);
8922  if (!m_SoundFliesEffect)
8923  {
8924  PlaySoundSetLoop(m_SoundFliesEffect, "Flies_SoundSet", 1.0, 1.0);
8925 // ErrorEx("DbgFlies | CORPSE_STATE_DECAYED | m_SoundFliesEffect created! " + m_SoundFliesEffect,ErrorExSeverity.INFO);
8926  }
8927  }
8928  break;
8929  //remove
8930  default:
8931  SEffectManager.DestroyEffect(m_FliesEff);
8932 // ErrorEx("DbgFlies | StopSoundSet | exit 3 ",ErrorExSeverity.INFO);
8933  StopSoundSet(m_SoundFliesEffect);
8934  break;
8935  }
8936  }
8937 
8938  void PreloadDecayTexture()
8939  {
8940  int idx;
8941  int slot_id;
8942 
8943  idx = GetHiddenSelectionIndex("decay_preload");
8944  if (idx > -1)
8945  {
8946  SetObjectTexture(idx,m_DecayedTexture);
8947  //Print("'decay_preload'" + m_DecayedTexture +" loaded on " + GetModelName());
8948  }
8949  else
8950  {
8951  //Print("No 'decay_preload' selection found on " + this);
8952  }
8953  }
8954 
8955  void SetLastMapInfo(float scale, vector pos)
8956  {
8957  m_LastMapScale = scale;
8958  m_LastMapPos = pos;
8959  }
8960 
8961  bool GetLastMapInfo(out float scale, out vector pos)
8962  {
8963  scale = m_LastMapScale;
8964  pos = m_LastMapPos;
8965 
8966  return m_LastMapScale != -1.0;
8967  }
8968 
8969  override bool PhysicalPredictiveDropItem(EntityAI entity, bool heavy_item_only = true)
8970  {
8971  vector dir;
8972  ItemBase item = ItemBase.Cast(entity);
8973 
8974  if (GetItemInHands() == item) //from hands
8975  {
8976  //HOTFIX
8977  return PredictiveDropEntity(item);
8978 
8979  if (entity.ConfigGetString("physLayer") != "item_large" && heavy_item_only)
8980  {
8981  return PredictiveDropEntity(item);
8982  }
8983  else
8984  {
8985  dir = GetOrientation();
8986  //item.m_ItemBeingDropped = true;
8987  return GetHumanInventory().ThrowEntity(item,dir,0);
8988  }
8989  }
8990  else //from anywhere else
8991  {
8992  ActionManagerClient mngr_client;
8993  if (CastTo(mngr_client,m_ActionManager))
8994  {
8995  ActionTarget atrg = new ActionTarget(null, null, -1, vector.Zero, -1);
8996  if (mngr_client.GetAction(ActionDropItemSimple).Can(this,atrg,item))
8997  {
8998  //Param1<bool> p1 = new Param1<bool>(false);
8999  //p1.param1 = heavy_item_only;
9000  mngr_client.PerformActionStart(mngr_client.GetAction(ActionDropItemSimple),atrg,item/*,p1*/);
9001  return true;
9002  }
9003  return false;
9004  }
9005  else
9006  return true;
9007  }
9008  }
9009 
9010  override void SetProcessUIWarning(bool state)
9011  {
9012  m_ProcessUIWarning = state;
9013  }
9014 
9015  void dmgDebugPrint(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9016  {
9017  /*Print("ProjectileDebugging | Damage Health: " + damageResult.GetDamage(dmgZone,"Health") + " | Component: " + component + " | Zone: " + dmgZone + "| Timestamp: " + GetSimulationTimeStamp());
9018  Print("ProjectileDebugging | speedCoef: " + speedCoef);
9019  Print("ProjectileDebugging | GetWorldTime(): " + GetWorldTime());
9020  Print("-----------------------------------------------");*/
9021  }
9022 
9023  //Use this method to process additionnal dmg to legs specifically (must use the dmg system to fire relevant events)
9024  //Legzone is a dummy to inflict damage once and NOT transfer damage to other zones. All leg zones will drop to 0 anyway
9025  void DamageAllLegs(float inputDmg)
9026  {
9027  array<string> legZones = new array<string>;
9028  legZones.Insert("LeftLeg");
9029  legZones.Insert("RightLeg");
9030  legZones.Insert("RightFoot");
9031  legZones.Insert("LeftFoot");
9032 
9033  for (int i = 0; i < legZones.Count(); i++)
9034  {
9035  DecreaseHealth(legZones[i],"",inputDmg);
9036  }
9037  }
9038 
9040  void TryHideItemInHands(bool hide, bool force = false)
9041  {
9042  if (!hide && ((!IsSwimming() && !IsClimbingLadder() && !IsInVehicle() && !AnimCommandCheck(HumanMoveCommandID.CommandSwim | HumanMoveCommandID.CommandLadder | HumanMoveCommandID.CommandVehicle)) || force))
9043  {
9044  GetItemAccessor().HideItemInHands(false);
9045  }
9046  else
9047  {
9048  GetItemAccessor().HideItemInHands(true);
9049  }
9050  }
9051 
9053  bool CheckAndExecuteStackSplit(FindInventoryLocationType flags, notnull EntityAI item, notnull EntityAI target)
9054  {
9055  float stackable = item.GetTargetQuantityMax();
9056  if (!(stackable == 0 || stackable >= item.GetQuantity()))
9057  {
9059  if (target && target.GetInventory().FindFreeLocationFor(item, flags, il))
9060  {
9061  ItemBase itemB;
9062  if (CastTo(itemB, item))
9063  {
9064  itemB.SplitIntoStackMaxToInventoryLocationClient(il);
9065  return true;
9066  }
9067  }
9068  }
9069  return false;
9070  }
9071 
9072  bool CheckAndExecuteStackSplitToInventoryLocation(InventoryLocation il, notnull EntityAI item)
9073  {
9074  float stackable = item.GetTargetQuantityMax();
9075  if (!(stackable == 0 || stackable >= item.GetQuantity()))
9076  {
9077  ItemBase itemB;
9078  if (CastTo(itemB, item))
9079  {
9080  itemB.SplitIntoStackMaxToInventoryLocationClient(il);
9081  return true;
9082  }
9083  }
9084  return false;
9085  }
9086 
9087  override protected bool TakeEntityToInventoryImpl(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
9088  {
9089  if (CheckAndExecuteStackSplit(flags, item, this))
9090  {
9091  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Inv(SPLIT) item=" + GetDebugName(item));
9092  return true;
9093  }
9094 
9095  return super.TakeEntityToInventoryImpl(mode, flags, item);
9096  }
9097 
9098  override protected bool TakeEntityToCargoImpl(InventoryMode mode, notnull EntityAI item)
9099  {
9100  if (CheckAndExecuteStackSplit(FindInventoryLocationType.CARGO, item, this))
9101  {
9102  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Cgo(SPLIT) item=" +GetDebugName(item));
9103  return true;
9104  }
9105 
9106  return super.TakeEntityToCargoImpl(mode, item);
9107  }
9108 
9109  override protected bool TakeEntityAsAttachmentImpl(InventoryMode mode, notnull EntityAI item)
9110  {
9111  if (CheckAndExecuteStackSplit(FindInventoryLocationType.ATTACHMENT, item, this))
9112  {
9113  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Att(SPLIT) item=" + GetDebugName(item));
9114  return true;
9115  }
9116 
9117  return super.TakeEntityAsAttachmentImpl(mode, item);
9118  }
9119 
9120  override void TakeEntityToHandsImpl(InventoryMode mode, EntityAI item)
9121  {
9122  if (CheckAndExecuteStackSplit(FindInventoryLocationType.HANDS, item, this))
9123  {
9124  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Hands(SPLIT) item=" + GetDebugName(item));
9125  return;
9126  }
9127 
9128  super.TakeEntityToHandsImpl(mode, item);
9129  }
9130 
9131  override protected bool TakeEntityToTargetInventoryImpl(InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
9132  {
9133  if (CheckAndExecuteStackSplit(flags, item, target))
9134  {
9135  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetInv(SPLIT) item=" + GetDebugName(item));
9136  return true;
9137  }
9138 
9139  return super.TakeEntityToTargetInventoryImpl(mode, target, flags, item);
9140  }
9141 
9142  override protected bool TakeEntityToTargetCargoImpl(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
9143  {
9144  if (CheckAndExecuteStackSplit(FindInventoryLocationType.CARGO, item, target))
9145  {
9146  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetCgo(SPLIT) item=" + GetDebugName(item));
9147  return true;
9148  }
9149 
9150  return super.TakeEntityToTargetCargoImpl(mode, target, item);
9151  }
9152 
9153  override protected bool TakeEntityToTargetAttachmentImpl(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
9154  {
9155  if (CheckAndExecuteStackSplit(FindInventoryLocationType.ATTACHMENT, item, target))
9156  {
9157  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetAtt(SPLIT) item=" + GetDebugName(item));
9158  return true;
9159  }
9160 
9161  return super.TakeEntityToTargetAttachmentImpl(mode, target, item);
9162  }
9163 
9164  override protected bool TakeToDstImpl(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
9165  {
9166  if (CheckAndExecuteStackSplitToInventoryLocation(dst, dst.GetItem()))
9167  {
9168  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Dst(SPLIT) item=" + GetDebugName(dst.GetItem()));
9169  return true;
9170  }
9171 
9172  return super.TakeToDstImpl(mode, src, dst);
9173  }
9174 
9175  override vector GetCenter()
9176  {
9177  return GetBonePositionWS(GetBoneIndexByName("spine3"));
9178  }
9179 
9180 
9181  // contaminated areas - temp stuff
9182  void ContaminatedParticleAdjustment()
9183  {
9184  if (GetCommand_Move() && m_ContaminatedAroundPlayer && m_ContaminatedAroundPlayerTiny)
9185  {
9186  float playerSpeed = GetCommand_Move().GetCurrentMovementSpeed();
9187  //Print(playerSpeed);
9188 
9189  // 1 - prone, crouch
9190  // 2 - jog
9191  // 3 - sprint
9192  float particleLifetime = 5.25;
9193  float particleSpeed = 0.25;
9194  if (playerSpeed >= 1)
9195  {
9196  particleLifetime = 3.5;
9197  particleSpeed = 3.25;
9198  }
9199  if (playerSpeed >= 2)
9200  {
9201  particleLifetime = 2.5;
9202  particleSpeed = 5.25;
9203  }
9204  if (playerSpeed >= 3)
9205  {
9206  particleLifetime = 1.5;
9207  particleSpeed = 8.25;
9208  }
9209  m_ContaminatedAroundPlayer.SetParameter(0, EmitorParam.LIFETIME, particleLifetime);
9210  m_ContaminatedAroundPlayer.SetParameter(1, EmitorParam.LIFETIME, particleLifetime);
9211  m_ContaminatedAroundPlayer.SetParameter(2, EmitorParam.LIFETIME, particleLifetime);
9212  m_ContaminatedAroundPlayer.SetParameter(3, EmitorParam.LIFETIME, particleLifetime);
9213 
9214  m_ContaminatedAroundPlayerTiny.SetParameter(0, EmitorParam.VELOCITY, particleSpeed);
9215  vector transform[4];
9216  GetTransform(transform);
9217  m_ContaminatedAroundPlayer.SetTransform(transform);
9218  m_ContaminatedAroundPlayerTiny.SetTransform(transform);
9219  }
9220  }
9221 
9222  void HandleGlassesEffect()
9223  {
9224  if (!IsControlledPlayer())
9225  return;
9226  int i;
9227 
9228  if (m_ProcessRemoveGlassesEffects)
9229  {
9230  for (i = 0; i < m_ProcessRemoveGlassesEffects.Count(); i++)
9231  {
9232  PPERequesterBank.GetRequester(m_ProcessRemoveGlassesEffects[i]).Stop();
9233  }
9234  m_ProcessRemoveGlassesEffects.Clear();
9235  }
9236 
9237  if (m_ProcessAddGlassesEffects)
9238  {
9239  for (i = 0; i < m_ProcessAddGlassesEffects.Count(); i++)
9240  {
9241  PPERequesterBank.GetRequester(m_ProcessAddGlassesEffects[i]).Start();
9242  }
9243  m_ProcessAddGlassesEffects.Clear();
9244  }
9245  }
9246 
9247  override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
9248  {
9249  CachedObjectsArrays.ARRAY_STRING.Clear();
9250  GetActionComponentNameList(componentIndex, CachedObjectsArrays.ARRAY_STRING, LOD.NAME_FIRE);
9251 
9252  int pivot = componentIndex;
9253  int newPivot = -1;
9254  string compName;
9255  for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count() && newPivot == -1; i++)
9256  {
9257  compName = CachedObjectsArrays.ARRAY_STRING.Get(i);
9258  newPivot = GetBoneIndexByName(compName);
9259 
9260  }
9261 
9262  if (newPivot != -1)
9263  {
9264  pivot = newPivot;
9265 
9266  }
9267 
9268  vector parentTransMat[4];
9269  vector arrowTransMat[4];
9270 
9271  arrow.GetTransform(arrowTransMat);
9272 
9273  if (pivot == -1)
9274  {
9275  GetTransformWS(parentTransMat);
9276  }
9277  else
9278  {
9279  vector rotMatrix[3];
9280  Math3D.YawPitchRollMatrix(closeBoneRotWS * Math.RAD2DEG,rotMatrix);
9281 
9282  parentTransMat[0] = rotMatrix[0];
9283  parentTransMat[1] = rotMatrix[1];
9284  parentTransMat[2] = rotMatrix[2];
9285  parentTransMat[3] = closeBonePosWS;
9286  }
9287 
9288  Math3D.MatrixInvMultiply4(parentTransMat, arrowTransMat, arrowTransMat);
9289  Math3D.MatrixOrthogonalize4(arrowTransMat);
9290  arrow.SetTransform(arrowTransMat);
9291 
9292  AddChild(arrow, pivot);
9293 
9294  #ifdef SERVER
9295  // creating bleeding source
9296  BleedingSourcesManagerServer bleedingManager = GetBleedingManagerServer();
9297  if (bleedingManager)
9298  {
9299  if (!bleedingManager.AttemptAddBleedingSourceBySelection(compName))
9300  bleedingManager.AttemptAddBleedingSourceBySelection("Pelvis");//fallback, if we can't attach bleeding source to the fallback location because there already is another one, it's fine, we are just trying make sure there is at least one
9301  }
9302  #endif
9303  }
9304 
9305  override bool IsManagingArrows()
9306  {
9307  return true;
9308  }
9309 
9310  string GetCachedName()
9311  {
9312  return m_CachedPlayerName;
9313  }
9314 
9315  string GetCachedID()
9316  {
9317  return m_CachedPlayerID;
9318  }
9319 }
9320 
9321 
9322 #ifdef DEVELOPER
9323 
9325 #endif
ItemBase
Definition: inventoryitem.c:730
Param2< float, float >
InitializeActions
void InitializeActions()
Definition: advancedcommunication.c:56
RF_DEFAULT
const int RF_DEFAULT
Definition: centraleconomy.c:65
MENU_WARNING_TELEPORT
const int MENU_WARNING_TELEPORT
Definition: constants.c:200
GetGame
proto native CGame GetGame()
MENU_INSPECT
const int MENU_INSPECT
Definition: constants.c:169
UIScriptedMenu
Definition: dayzgame.c:63
ActionUncoverHeadTarget
Definition: actionuncoverheadtarget.c:9
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
MENU_WARNING_ITEMDROP
const int MENU_WARNING_ITEMDROP
Definition: constants.c:198
CanRoll
bool CanRoll()
ShockHandler
Definition: shockhandler.c:1
IsRunning
bool IsRunning()
Definition: tools.c:264
IsIdle
override bool IsIdle()
Definition: weaponstablestate.c:91
GetWeightSpecialized
override protected float GetWeightSpecialized(bool forceRecalc=false)
Definition: itembase.c:3341
IsControllsLocked
bool IsControllsLocked()
Definition: emotemanager.c:852
RemoveAgent
override void RemoveAgent(int agent_id)
Definition: itembase.c:3841
ActionTakeItemToHands
Definition: actiontakeitemtohands.c:1
mission
Mission mission
Definition: displaystatus.c:28
ConstructionActionData
Definition: constructionactiondata.c:1
INPUT_UDT_GESTURE
const int INPUT_UDT_GESTURE
Definition: _constants.c:18
HumanCommandAdditives
class HumanCommandWeapons HumanCommandAdditives()
Definition: human.c:1099
SetBloodyHands
void SetBloodyHands(PlayerBase player, bool show)
Definition: pluginlifespan.c:449
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
QuickBarBase
void QuickBarBase(PlayerBase player)
Definition: quickbarbase.c:21
ActionMineBushByHand
Definition: actionminebushbyhand.c:1
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
m_Hud
Hud m_Hud
Definition: displaystatus.c:29
INPUT_UDT_ITEM_MANIPULATION
const int INPUT_UDT_ITEM_MANIPULATION
Definition: _constants.c:8
OnReconnect
void OnReconnect(PlayerBase player)
is called when a modifier is being re-activated upon player server connection, use to activate system...
Definition: modifierbase.c:191
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
OnCommandMelee2Finish
void OnCommandMelee2Finish()
ActionCPR
Definition: actioncpr.c:11
IsManagingArrows
override bool IsManagingArrows()
Definition: dayzanimal.c:70
MENU_MAP
const int MENU_MAP
Definition: constants.c:181
PluginDiagMenuClient
Definition: plugindiagmenuclient.c:6
LogManager
Definition: debug.c:734
Mission
Mission class.
Definition: gameplay.c:670
HeadingModel
bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
GetCommand_Ladder
proto native HumanCommandLadder GetCommand_Ladder()
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
IsFullBody
bool IsFullBody(PlayerBase player)
Definition: actionbase.c:553
m_StaminaHandler
StaminaHandler m_StaminaHandler
Definition: staminasoundhandler.c:108
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
GetBoneIndexByName
proto native int GetBoneIndexByName(string pBoneName)
returns bone index for a name (-1 if pBoneName doesn't exist)
OnCommandMoveStart
void OnCommandMoveStart()
m_RecipeID
WorldCraftActionReciveData m_RecipeID
DayZPlayerUtils
private void DayZPlayerUtils()
cannot be instantiated
Definition: dayzplayerutils.c:461
OnCommandLadderFinish
void OnCommandLadderFinish()
OnCommandVehicleFinish
void OnCommandVehicleFinish()
SoftSkillsManager
Definition: softskillsmanager.c:1
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
m_ActionsInitialize
bool m_ActionsInitialize
Definition: advancedcommunication.c:4
StanceIndicator
Definition: stanceindicator.c:1
ActionCheckPulse
Definition: actioncheckpulse.c:1
GetSuitableFinisherHitComponents
array< string > GetSuitableFinisherHitComponents()
Definition: dayzplayer.c:507
ECE_EQUIP_ATTACHMENTS
const int ECE_EQUIP_ATTACHMENTS
Definition: centraleconomy.c:20
eMixedSoundStates
eMixedSoundStates
bits
Definition: emixedsoundstates.c:2
ActionLockedDoors
Definition: actionlockeddoors.c:1
PluginConfigDebugProfile
Definition: pluginconfigdebugprofilefixed.c:1
DiagMenu
Definition: endebug.c:232
DayZPlayerCamera
class DayZPlayerCameraResult DayZPlayerCamera(DayZPlayer pPlayer, HumanInputController pInput)
Definition: dayzplayer.c:56
TStringArray
array< string > TStringArray
Definition: enscript.c:685
OnCommandClimbFinish
void OnCommandClimbFinish()
AnalyticsManagerServer
Definition: analyticsmanagerserver.c:1
RandomGeneratorSyncManager
void RandomGeneratorSyncManager(DayZPlayer player)
Definition: randomgeneratorsyncmanager.c:17
CanReceiveItemIntoCargo
override bool CanReceiveItemIntoCargo(EntityAI item)
Definition: container_base.c:72
SpawnItemOnLocation
class MaleFeet_Base extends InventoryItem SpawnItemOnLocation
EStaminaModifiers
EStaminaModifiers
Definition: estaminamodifiers.c:1
EffVomit
Definition: vomit.c:1
IsInProne
bool IsInProne()
Definition: human.c:1139
SetRestrained
void SetRestrained()
Definition: dayzplayercfgbase.c:145
m_Recipes
class RecipeCacheData m_Recipes
ActionWashHandsWater
ActionWashHandsWaterCB ActionContinuousBaseCB ActionWashHandsWater()
Definition: actionwashhandswater.c:11
eBloodyHandsTypes
eBloodyHandsTypes
Definition: pluginlifespan.c:8
ActionOpenDoors
Definition: actionopendoors.c:1
OnCommandSwimFinish
void OnCommandSwimFinish()
PluginPresenceNotifier
void PluginPresenceNotifier()
Definition: pluginpresencenotifier.c:108
UndergroundHandlerClient
void UndergroundHandlerClient(PlayerBase player)
Definition: undergroundhandlerclient.c:35
Hive
Definition: hive.c:5
GetActions
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Definition: advancedcommunication.c:68
OnJumpStart
void OnJumpStart()
HiddenSelectionsData
Definition: hiddenselectionsdata.c:1
WeightDebugData
Definition: debug.c:939
SendSyncJuncture
proto native void SendSyncJuncture(int pJunctureID, ParamsWriteContext ctx)
-------------— sync stuff ----------------------—
ScriptInputUserData
Definition: gameplay.c:120
BREATH_VAPOUR_LEVEL_MAX
const int BREATH_VAPOUR_LEVEL_MAX
Definition: breathvapourmdfr.c:1
SetModifiers
void SetModifiers()
Definition: huddebugwincharmodifiers.c:155
Consume
bool Consume(float amount, PlayerBase consumer)
Definition: edible_base.c:85
DebugMonitorValues
Definition: debugmonitorvalues.c:1
OnCommandSwimStart
void OnCommandSwimStart()
ActionSwitchSeats
Definition: actionswitchseats.c:2
Bot
Definition: bot.c:18
VirtualHud
void VirtualHud(PlayerBase player)
Definition: displaystatus.c:36
CanReleaseAttachment
override bool CanReleaseAttachment(EntityAI attachment)
Definition: fireplacebase.c:2654
ClothingBase
Definition: dallasmask.c:1
OnItemInHandsChanged
class HumanItemBehaviorCfg OnItemInHandsChanged(bool pInstant=false)
signalization from script to engine that item in hands changed
CarScript
Definition: civiliansedan.c:1
m_AdminLog
PluginAdminLog m_AdminLog
Definition: emotemanager.c:150
DayZPlayerCameraOptics
void DayZPlayerCameraOptics(DayZPlayer pPlayer, HumanInputController pInput)
Definition: dayzplayercameraironsights.c:365
IsInventoryVisible
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
Definition: advancedcommunication.c:135
Print
proto void Print(void var)
Prints content of variable to console/log.
GetDayZPlayerType
proto native DayZPlayerType GetDayZPlayerType()
returns appropriate DayZPlayerType
INPUT_UDT_ADVANCED_PLACEMENT
const int INPUT_UDT_ADVANCED_PLACEMENT
Definition: _constants.c:10
GetInstanceType
proto native DayZPlayerInstanceType GetInstanceType()
FirearmActionLoadMultiBulletRadial
Definition: firearmactionloadmultibullet.c:171
m_PlayerStats
ref array< ref PlayerStatBase > m_PlayerStats
Definition: playerstatspco.c:70
IsProcessing
bool IsProcessing()
Definition: dayzplayerinventory.c:2383
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
GetStatObject
PlayerStatBase GetStatObject(int id)
Definition: playerstatspco.c:72
RemoveAction
void RemoveAction(typename actionName)
Definition: advancedcommunication.c:118
ActionUngagTarget
Definition: actionungagtarget.c:1
SDayZPlayerHeadingModel
private void SDayZPlayerHeadingModel()
cannot be created from script
Definition: dayzplayer.c:1080
ActionCheckPulseTarget
Definition: actioncheckpulsetarget.c:9
SIMPLE_SELECTION_MELEE_RIFLE
class SDayZPlayerAimingModel SIMPLE_SELECTION_MELEE_RIFLE
SoundObject
class SoundObjectBuilder SoundObject(SoundParams soundParams)
OnCommandVehicleStart
void OnCommandVehicleStart()
Hologram
Definition: hologram.c:1
EEHitByRemote
override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
Definition: clockbase.c:128
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: anniversarymusicsource.c:42
EPresenceNotifierNoiseEventType
EPresenceNotifierNoiseEventType
Definition: pluginpresencenotifier.c:1
LIQUID_WATER
const int LIQUID_WATER
Definition: constants.c:505
m_LastTick
int m_LastTick
Definition: displaystatus.c:30
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
SIMPLE_SELECTION_SHOULDER_MELEE
const int SIMPLE_SELECTION_SHOULDER_MELEE
Definition: dayzplayer.c:1119
ClientData
Definition: clientdata.c:1
OnThrowingModeChange
void OnThrowingModeChange(bool change_to_enabled)
Definition: dayzplayer.c:1321
MapNavigationBehaviour
void MapNavigationBehaviour(PlayerBase pPlayer, EMapNavigationType pNavigationType=EMapNavigationType.BASIC)
Definition: mapnavigationbehaviour.c:27
PlayerSoundEventHandler
void PlayerSoundEventHandler(PlayerBase player)
Definition: playersoundeventhandler.c:49
ActionStopEngine
Definition: actionstopengine.c:1
ActionUnrestrainTargetHands
Definition: actionunrestraintargetempty.c:27
StaminaHandler
Definition: staminahandler.c:260
GetMax
proto native float GetMax()
CommandHandler
void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
-------------— command handling ----------------------—
m_MeleeCombat
protected ref DayZPlayerImplementMeleeCombat m_MeleeCombat
Definition: dayzplayermeleefightlogic_lightheavy.c:20
CachedObjectsParams
Definition: utilityclasses.c:9
PlayerStomach
void PlayerStomach(PlayerBase player)
Definition: playerstomach.c:127
SymptomManager
Definition: statemanager.c:42
OnCommandLadderStart
void OnCommandLadderStart()
GetTransformWS
enum HumanMoveCommandID GetTransformWS(out vector pTm[4])
gets human transform in World Space
RemotelyActivatedItemBehaviour
Definition: remotelyactivateditembehaviour.c:1
GetElement
DisplayElementBase GetElement(eDisplayElements element_id)
Definition: displaystatus.c:95
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
ShockDealtEffect
Definition: shockhitreaction.c:1
ActionManagerBase
void ActionManagerBase(PlayerBase player)
Definition: actionmanagerbase.c:62
LOD
LOD class.
Definition: gameplay.c:202
COLOR_RED_A
const int COLOR_RED_A
Definition: constants.c:69
SoundObjectBuilder
void SoundObjectBuilder(SoundParams soundParams)
InventoryItem
Definition: itembase.c:13
Param3< float, float, bool >
OnScheduledTick
void OnScheduledTick(float delta_time)
Definition: modifiersmanager.c:200
EmitorParam
EmitorParam
Definition: envisual.c:113
InsertAgent
override void InsertAgent(int agent, float count=1)
Definition: itembase.c:3860
GetCommandModifier_Additives
proto native HumanCommandAdditives GetCommandModifier_Additives()
default (always-on modifiers)
IsLeaning
bool IsLeaning()
Definition: human.c:1151
ToString
proto string ToString()
WorldLighting
Definition: worldlighting.c:1
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
MyBotTrigger
Definition: bot.c:8
DisplayElementBadge
Definition: badgebleeding.c:1
EffectParticle
Wrapper class for managing particles through SEffectManager.
Definition: effectparticle.c:4
IsPlayerInStance
bool IsPlayerInStance(int pStanceMask)
-------------— camera additiona functions ----------------------—
Definition: dayzplayer.c:1264
EPlayerStats_current
EPlayerStats_current
Definition: playerstatspco.c:293
ActionTakeArrow
Definition: actiontakearrow.c:11
ScriptJunctureData
Definition: gameplay.c:150
ErrorEx
enum ShapeType ErrorEx
IEntity
Definition: enentity.c:164
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:170
OnCommandFallStart
void OnCommandFallStart()
Colors
Definition: colors.c:3
RemoveAllAgents
override void RemoveAllAgents()
Definition: itembase.c:3850
ActionTakeArrowToHands
Definition: actiontakearrowtohands.c:1
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
EEDelete
override void EEDelete(EntityAI parent)
Definition: contaminatedarea.c:69
HumanMovementState
Definition: human.c:1125
GetItemAccessor
proto native HumanItemAccessor GetItemAccessor()
AbortWeaponEvent
void AbortWeaponEvent()
Definition: dayzplayerinventory.c:269
BetaSound
Definition: betasound.c:1
m_BloodType
protected ref map< PlayerBase, int > m_BloodType
Definition: pluginlifespan.c:35
m_MovementState
ref HumanMovementState m_MovementState
movement state
Definition: dayzplayercamera3rdperson.c:155
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
CanChangeStance
bool CanChangeStance(int previousStance, int newStance)
Called by code to see if it can.
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
IsRaised
bool IsRaised()
Definition: human.c:1127
OnInputUserDataProcess
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Definition: emotemanager.c:497
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
DayZPlayerImplementHeading
Definition: dayzplayerimplementheading.c:10
EConsumeType
EConsumeType
Definition: econsumetype.c:1
_player
protected PlayerBase _player
Definition: quickbarbase.c:18
PlayerAgentPool
Definition: playeragentpool.c:1
PPEManagerStatic
Static component of PPE manager, used to hold the instance.
Definition: ppemanager.c:2
DiagMenuIDs
DiagMenuIDs
Definition: ediagmenuids.c:1
ForceStandUpForHeavyItemsSwap
void ForceStandUpForHeavyItemsSwap(notnull EntityAI item1, notnull EntityAI item2)
Definition: dayzplayer.c:1315
HeatComfortAnimHandler
Definition: heatcomfortanimhandler.c:1
m_ShowDbgUI
bool m_ShowDbgUI
Definition: plugindayzcreatureaidebug.c:88
ActionUncoverHeadSelf
ActionUncoverHeadTargetCB ActionUncoverHeadSelf
SoundParams
Definition: sound.c:100
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
GetVirtualHud
VirtualHud GetVirtualHud()
Definition: notifiersmanager.c:77
SetBloodyHandsEx
void SetBloodyHandsEx(PlayerBase player, eBloodyHandsTypes type)
Definition: pluginlifespan.c:434
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
ActionEnterLadder
Definition: actionenterladder.c:2
NotifiersManager
void NotifiersManager(PlayerBase player)
Definition: notifiersmanager.c:36
PersistentFlag
PersistentFlag
Definition: persistentflag.c:5
ParticleList
Definition: particlelist.c:11
ScriptedEntity
Definition: triggercarrierbase.c:1
SurrenderData
Definition: emotemanager.c:1146
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
eAgents
eAgents
Definition: eagents.c:2
PlayerConstants
Definition: playerconstants.c:1
vector
Definition: enconvert.c:105
Clothing
Definition: armband_colorbase.c:1
AfterStoreLoad
void AfterStoreLoad()
Definition: emotemanager.c:577
GetHourMinuteSecond
proto void GetHourMinuteSecond(out int hour, out int minute, out int second)
Returns world time.
EStaminaConsumers
EStaminaConsumers
Definition: estaminaconsumers.c:1
MaskBase
Definition: airbornemask.c:1
ModifiersManager
void ModifiersManager(PlayerBase player)
Definition: modifiersmanager.c:80
INPUT_UDT_RESET_ADS
const int INPUT_UDT_RESET_ADS
Definition: _constants.c:17
Analytics
Definition: scriptanalytics.c:145
PlayerSoundEventBase
Definition: damageevents.c:1
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
GetID
int GetID()
Get the ID registered in SEffectManager.
Definition: effect.c:534
HumanCommandFall
class HumanCommandMelee2 HumanCommandFall()
Definition: human.c:574
ActionTarget
class ActionTargets ActionTarget
INPUT_UDT_INVENTORY
const int INPUT_UDT_INVENTORY
Definition: _constants.c:9
SIMPLE_SELECTION_SHOULDER_RIFLE
const int SIMPLE_SELECTION_SHOULDER_RIFLE
Definition: dayzplayer.c:1118
ManBase
Definition: playerbase.c:1
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
NVTypes
NVTypes
Definition: dayzplayercamera_base.c:54
ActionCloseCarDoors
Definition: actionclosecardoors.c:1
PluginLifespan
void PluginLifespan()
Definition: pluginlifespan.c:45
FlashbangEffect
Definition: flashbangeffect.c:1
TotalDamageResult
Definition: damagesystem.c:1
ActionExitLadder
Definition: actionexitladder.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Surface
Definition: surface.c:1
OnRollStart
void OnRollStart(bool isToTheRight)
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
ArrowManagerPlayer
Definition: arrowmanagerplayer.c:1
EPulseType
EPulseType
Definition: epulsetype.c:1
GetHitComponentForAI
string GetHitComponentForAI()
Definition: dayzplayer.c:485
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
CargoBase
represents base for cargo storage for entities
Definition: cargo.c:6
ActionUnfoldMapCB
Definition: actionunfoldmap.c:1
GetArrowManager
override ArrowManagerBase GetArrowManager()
Definition: animalbase.c:9
ShapeFlags
ShapeFlags
Definition: endebug.c:125
EndSurrenderRequest
void EndSurrenderRequest(SurrenderData data=null)
directly force-ends surrender state from outside of normal flow
Definition: emotemanager.c:1024
HumanCommandMove
Definition: human.c:433
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
OnCommandMelee2Start
void OnCommandMelee2Start()
DamageDealtEffect
Definition: bullethitreaction.c:1
GetDebugText
string GetDebugText()
Definition: modifierbase.c:68
GetInputController
proto native HumanInputController GetInputController()
returns human input controller
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Object
Definition: objecttyped.c:1
EEKilled
override void EEKilled(Object killer)
Definition: remotedetonator.c:242
CraftingManager
Client only - manage set up crafting on client.
Definition: craftingmanager.c:2
PrintString
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition: enscript.c:345
eModifiers
eModifiers
Definition: emodifiers.c:1
HumanCommandActionCallback
Definition: statecb.c:1
OnCommandDeathStart
void OnCommandDeathStart()
SetActions
void SetActions()
Definition: advancedcommunication.c:79
OnRollFinish
void OnRollFinish()
GetDebugActions
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition: edible_base.c:744
Environment
Definition: environment.c:1
PPERequesterBase
Definition: pperequestplatformsbase.c:2
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
IsHoldingBreath
bool IsHoldingBreath()
return true if player is trying to hold breah, otherwise false
PlayerSoundManagerClient
void PlayerSoundManagerClient(PlayerBase player)
Definition: playersoundmanager.c:102
SelectionTranslation
Definition: head.c:67
EEHitBy
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition: broom.c:43
DayZPlayerSyncJunctures
Definition: dayzplayersyncjunctures.c:4
GetCommand_Action
proto native HumanCommandActionCallback GetCommand_Action()
is human is in command action - returns its callback, if current command is action
HumanCommandUnconscious
Definition: human.c:619
InjuryAnimationHandler
void InjuryAnimationHandler(PlayerBase player)
Definition: injuryhandler.c:59
IsInWater
proto native bool IsInWater()
m_ForceInjuryAnimMask
int m_ForceInjuryAnimMask
Definition: injuryhandler.c:57
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
m_Agents
int m_Agents
Definition: actiongivebloodself.c:4
StartCommand_Unconscious
proto native HumanCommandUnconscious StartCommand_Unconscious(float pType)
starts command - unconscious
EPlayerStates
EPlayerStates
Definition: eplayerstates.c:1
OnCommandFallFinish
void OnCommandFallFinish()
HumanInputController
Definition: human.c:17
Get
array< ref PlayerStatBase > Get()
Definition: playerstatspco.c:103
IsEmotePlaying
bool IsEmotePlaying()
Definition: emotemanager.c:1092
AddArrow
override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
Definition: dayzanimal.c:75
GetPluginManager
PluginManager GetPluginManager()
Returns registred plugin by class type, better is to use global funtion GetPlugin(typename plugin_typ...
Definition: pluginmanager.c:274
EActions
EActions
Definition: eactions.c:1
HumanCommandVehicle
Definition: human.c:689
ActionManagerClient
Definition: actionmanagerclient.c:4
OnTick
private void OnTick(PlayerBase player, float deltaT)
Definition: modifierbase.c:234
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
GetCurrentCamera
proto native DayZPlayerCamera GetCurrentCamera()
-------------— camera additional functions ----------------------—
FallDamageData
Definition: dayzplayerimplementfalldamage.c:1
Bolt_Base
Definition: ammunitionpiles.c:90
eInjuryHandlerLevels
eInjuryHandlerLevels
Definition: injuryhandler.c:18
array< EntityAI >
AITargetCallbacksPlayer
Definition: aitargetcallbacksplayer.c:1
MENU_RESPAWN_DIALOGUE
const int MENU_RESPAWN_DIALOGUE
Definition: constants.c:199
GetRunningAction
proto native int GetRunningAction()
returns -1 when no action is running or RELOAD,MECHANISM, ....
Definition: actionmanagerbase.c:90
GetDefaultHitPosition
override vector GetDefaultHitPosition()
Definition: carscript.c:2592
PhysicsGetVelocity
proto native void PhysicsGetVelocity(out vector pVelocity)
outs pVelocity - linear velocity of PHYSICS CONTROLLER
eModifierSyncIDs
eModifierSyncIDs
Definition: modifiersmanager.c:2
DayZPlayerCameraBase
this is main camera class
Definition: dayzplayercamera1stperson.c:4
AGT_UACTION_CONSUME
const int AGT_UACTION_CONSUME
Definition: constants.c:468
SyncEvents
Definition: syncevents.c:1
m_ModulePlayerStatus
PluginPlayerStatus m_ModulePlayerStatus
Definition: modifierbase.c:30
PlayerStats
Definition: playerstats.c:6
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
ActionBase
void ActionBase()
Definition: actionbase.c:73
GetActionManager
protected void GetActionManager()
Definition: crosshairselector.c:132
SetPosition
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition: effect.c:436
GetDebugName
override string GetDebugName()
Definition: dayzplayer.c:1126
ActionUngagSelf
Definition: actionungagself.c:1
PPERequesterCategory
PPERequesterCategory
Definition: ppeconstants.c:27
EStatLevels
EStatLevels
Definition: estatlevels.c:1
EOnFrame
protected override void EOnFrame(IEntity other, float timeSlice)
Definition: testframework.c:240
OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
Definition: modifierbase.c:229
HumanCommandWeapons
Definition: human.c:986
ActionStartEngine
void ActionStartEngine()
DEPRECATED.
Definition: actionstartengine.c:19
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
EEHealthLevelChanged
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition: basebuildingbase.c:463
OnStanceChange
void OnStanceChange(int previousStance, int newStance)
gets called on stance change
StartCommand_Move
proto native HumanCommandMove StartCommand_Move()
--— MOVE --—
TInputActionMap
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Definition: actionmanagerclient.c:1
IsModifierActive
proto native bool IsModifierActive()
is modifier active
m_ArrowManager
protected ref ArrowManagerBase m_ArrowManager
Definition: animalbase.c:2
EffVomitBlood
Definition: vomitblood.c:1
GameConstants
Definition: constants.c:612
Debug
Definition: debug.c:13
InventoryTraversalType
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition: gameplay.c:5
ActionPullBodyFromTransport
Definition: actionpullbodyfromtransport.c:1
GetQuickBarBonus
override int GetQuickBarBonus()
Definition: itembase.c:274
INPUT_UDT_WEAPON_LIFT_EVENT
const int INPUT_UDT_WEAPON_LIFT_EVENT
Definition: _constants.c:16
PluginDiagMenuServer
Definition: plugindiagmenuserver.c:6
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
m_ConfigDebugProfile
PluginConfigDebugProfile m_ConfigDebugProfile
Definition: pluginitemdiagnostic.c:58
DayZPhysics
Definition: dayzphysics.c:123
HumanItemBehaviorCfg
Definition: humanitems.c:5
PluginItemDiagnostic
void PluginItemDiagnostic()
Definition: pluginitemdiagnostic.c:83
SoundObjectBuilder
Definition: sound.c:45
AddChild
proto native void AddChild(Widget child, bool immedUpdate=true)
EffectTrigger
Definition: contaminatedtrigger.c:2
PlaySound
void PlaySound()
Definition: hungersoundhandler.c:38
HumanCommandLadder
Definition: human.c:644
GetDefaultHitComponent
string GetDefaultHitComponent()
Definition: dayzplayer.c:497
AGT_AIRBOURNE_BIOLOGICAL
const int AGT_AIRBOURNE_BIOLOGICAL
Definition: constants.c:472
ERPCs
ERPCs
Definition: erpcs.c:1
Liquid
Definition: liquid.c:1
Timer
Definition: dayzplayerimplement.c:62
OnCommandClimbStart
void OnCommandClimbStart()
GetCommand_Vehicle
proto native HumanCommandVehicle GetCommand_Vehicle()
GameplayEffectWidgets_base
grouped gameplay effect widgets and their handling
Definition: gameplayeffectwidgets.c:6
PhysicsIsFalling
proto native bool PhysicsIsFalling(bool pValidate)
returns true if physics controller is falling
GetStorageVersion
int GetStorageVersion()
Definition: modifiersmanager.c:170
syncDebugPrint
void syncDebugPrint(string s)
Definition: debug.c:1
EmoteManager
void EmoteManager(PlayerBase player)
Definition: emotemanager.c:159
ItemOptics
Definition: itemoptics.c:1
Bandana_ColorBase
Definition: consumables.c:2
SAT_DEBUG_ACTION
const int SAT_DEBUG_ACTION
Definition: constants.c:424
GetCommand_Unconscious
proto native HumanCommandUnconscious GetCommand_Unconscious()
HumanItemAccessor
private void HumanItemAccessor()
Definition: humanitems.c:141
GetUApi
proto native UAInputAPI GetUApi()
ActionCloseDoors
Definition: actionclosedoors.c:1
OnSyncJuncture
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
Definition: emotemanager.c:529
ActionOpenCarDoors
Definition: actionopencardoors.c:1
StatsEventDisconnectedData
Definition: scriptanalytics.c:59
InventoryActionHandler
Client only - manage set up crafting on client.
Definition: inventoryactionhandler.c:2
EffectRadial
void EffectRadial(Param param1, Param param2)
Definition: bullethitreaction.c:59
GetDefaultHitPositionComponent
string GetDefaultHitPositionComponent()
Definition: dayzplayer.c:502
Math
Definition: enmath.c:6
EPlayerSoundEventID
EPlayerSoundEventID
Definition: playersoundeventhandler.c:1
StartCommand_Vehicle
proto native HumanCommandVehicle StartCommand_Vehicle(Transport pTransport, int pTransportPositionIndex, int pVehicleSeat, bool fromUnconscious=false)
--— VEHICLE --—
ClearInventory
override void ClearInventory()
Definition: itembase.c:3440
CFG_AMMO
const string CFG_AMMO
Definition: constants.c:212
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
GetCommandModifier_Weapons
proto native HumanCommandWeapons GetCommandModifier_Weapons()
returns interface for handling weapons
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition: enentity.c:44
m_QuickBarBonus
int m_QuickBarBonus
Definition: itembase.c:51
m_VirtualHud
ref VirtualHud m_VirtualHud
Definition: notifiersmanager.c:32
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
EEItemAttached
override void EEItemAttached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:520
AbstractWave
Definition: sound.c:118
IsRefresherSignalingViable
override bool IsRefresherSignalingViable()
Definition: animalbase.c:14
EffSwarmingFlies
Definition: swarmingflies.c:1
TSelectableActionInfoWithColor
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition: entityai.c:97
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
GetHive
proto native Hive GetHive()
GetCommand_Melee
proto native HumanCommandMelee GetCommand_Melee()
ActionGetOutTransport
void ActionGetOutTransport()
Definition: actiongetouttransport.c:24
EUndergroundPresence
EUndergroundPresence
Definition: undergroundhandlerclient.c:1
COLOR_GREEN_A
const int COLOR_GREEN_A
Definition: constants.c:70
PluginDiagMenu
Definition: plugindiagmenu.c:29
EEItemDetached
override void EEItemDetached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:529
INPUT_UDT_USER_MUTE_XBOX
const int INPUT_UDT_USER_MUTE_XBOX
Definition: _constants.c:13
OnStoreLoad
bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition: modifiersmanager.c:270
ArrowManagerBase
Definition: arrowmanagerbase.c:1
TStringSet
set< string > TStringSet
Definition: enscript.c:775
ActionDrinkPondContinuous
void ActionDrinkPondContinuous()
Definition: actiondrinkpondcontinuous.c:14
EntityAI
Definition: building.c:5
GetAgents
override int GetAgents()
Definition: itembase.c:3875
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
Math3D
Definition: enmath3d.c:27
ActionIgniteFireplaceByAir
Definition: actionignitefireplacebyair.c:9
IsIgnoredByConstruction
override bool IsIgnoredByConstruction()
Definition: dayzanimal.c:65
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
SIMPLE_SELECTION_MELEE_MELEE
const int SIMPLE_SELECTION_MELEE_MELEE
Definition: dayzplayer.c:1117
float
Definition: enconvert.c:96
StatsEventMeasuresData
Definition: scriptanalytics.c:2
InjuryAnimValues
Definition: injuryhandler.c:9
ActionDropItemSimple
Definition: actiondropitemsimple.c:1
CachedObjectsArrays
Definition: utilityclasses.c:40
Edible_Base
Definition: bearsteakmeat.c:1
ECE_INITAI
const int ECE_INITAI
Definition: centraleconomy.c:17
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
Hud
Definition: gameplay.c:623
GetCommand_Move
proto native HumanCommandMove GetCommand_Move()
ECE_IN_INVENTORY
const int ECE_IN_INVENTORY
Definition: centraleconomy.c:36
HumanMoveCommandID
HumanMoveCommandID
do not process rotations !
Definition: human.c:1242
GetCurrentWaterLevel
float GetCurrentWaterLevel()
path
string path
Definition: optionselectormultistate.c:135
m_InputActionMap
TInputActionMap m_InputActionMap
Definition: advancedcommunication.c:3
WeaponManager
Definition: weaponmanager.c:1
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306
ActionManagerServer
Definition: actionmanagerserver.c:1
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition: dayzplayer.c:1058