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