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