Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzplayerimplement.c
Go to the documentation of this file.
1 /*
2 DayZPlayerImplement
3 
4 this file is implemenation of dayzPlayer in script
5 - logic of movement
6 - camera switching logic
7 
8 */
9 
11 {
12  //----------------------------------
13  // callbacks
14 
15  override void OnSimulationEnd()
16  {
17  if (LogManager.IsSyncLogEnable()) syncDebugPrint("DZPI::OnSimulationEnd - trying to drop item");
18 
19  if (GetGame().IsServer())
20  {
21  EntityAI itemInHands = m_pPlayer.GetHumanInventory().GetEntityInHands();
22  if (itemInHands)
23  {
24  int boneIndex = m_pPlayer.GetBoneIndexByName("RightHand_Dummy");
25 
26  vector m4[4];
27  m_pPlayer.GetBoneTransformWS(boneIndex, m4);
28 
29  m_pPlayer.GetInventory().DropEntityWithTransform(InventoryMode.SERVER, m_pPlayer, itemInHands, m4);
30 
31  if (GetCEApi())
32  {
33  int deadBodyLifetime = GetCEApi().GetCEGlobalInt("CleanupLifetimeDeadPlayer");
34  if (deadBodyLifetime <= 0)
35  {
36  deadBodyLifetime = 3600;
37  }
38  itemInHands.SetLifetime(deadBodyLifetime);
39  }
40  }
41  }
42  }
43 
44  override bool ShouldSimulationBeDisabled()
45  {
46  return m_pPlayer.m_WasInVehicle == false;
47  }
48 
49  PlayerBase m_pPlayer;
50 }
51 
52 class DayZPlayerVehicleCommandDeathCallback : HumanCommandDeathCallback
53 {
54  override void OnSimulationEnd()
55  {
56  m_pPlayer.PhysicsEnableGravity(true);
57  }
58 
60 }
61 
62 class DeathEffectTimer extends Timer
63 {
64  override void Stop()
65  {
66  super.Stop();
67 
68  PPERequesterBank.GetRequester(PPERequester_DeathDarkening).Stop();
69  }
70 };
71 
73 {
74  static const int DEAD_SCREEN_DELAY = 1000;
75  static const float DEFAULT_DYING_TIME = 2.5;
76  static const float DYING_PROGRESSION_TIME = 0.05;
77 
78 
80  protected ref DayZPlayerImplementAiming m_AimingModel;
82  protected ref DayZPlayerMeleeFightLogic_LightHeavy m_MeleeFightLogic;
83  protected ref DayZPlayerImplementSwimming m_Swimming;
84  protected ref DayZPlayerImplementThrowing m_Throwing;
85  protected ref DayZPlayerImplementJumpClimb m_JumpClimb;
86  protected ref DayZPlayerImplementFallDamage m_FallDamage;
87  protected ref PlayerSoundEventHandler m_PlayerSoundEventHandler;
88  protected SHumanCommandMoveSettings m_MoveSettings;
89  protected float m_FallYDiff;
90  protected float m_SprintedTime;
91  protected float m_SprintedTimePerStanceMin;
92  protected bool m_SprintFull;
93  protected bool m_IsRaised;
94  protected bool m_ShouldReload;
95  protected bool m_Camera3rdPerson;
96  protected bool m_CameraZoomToggle;
97  protected bool m_bADS;
98  private float m_WeaponRaiseTime;
99  protected bool m_WeaponRaiseCompleted;
100  protected ECameraZoomType m_CameraEyeZoomLevel;
101  protected bool m_WasIronsight; // was previously ironsights. Only used on weapons
102  protected bool m_CameraIronsight; // Ironsight NOW!
103  protected bool m_CameraOptics; // Optics NOW!
104 
105  protected float m_DeathDarkeningCurrentTime;
106  protected bool m_IsTryingHoldBreath;
107  protected bool m_IsShootingFromCamera;
108  protected bool m_PlayerSelected;
109  protected bool m_Suicide;
110  protected bool m_IsUnconscious;
111  protected bool m_ShouldBeUnconscious;
112  protected bool m_IsUnconsciousFalling;
113  bool m_UnconsciousDebug;
114  protected int m_LastCommandBeforeUnconscious;
115  ref WeaponDebug m_WeaponDebug;
116  ref DeathEffectTimer m_DeathEffectTimer;
117  ref Timer m_FightEndBlendTimer;
118  protected bool m_ProcessFirearmMeleeHit;
119  protected bool m_ContinueFirearmMelee;
120  protected bool m_LiftWeapon_player;
121  protected bool m_ProcessLiftWeapon;
122  protected bool m_ProcessLiftWeaponState;
123  protected int m_LastSurfaceUnderHash;
124  protected Transport m_TransportCache;
125  protected string m_ClimbingLadderType;
126  bool m_isFBsymptomPlaying;
127  protected bool m_HandheldOpticsInUse;
128  protected bool m_ResetADS;
129  protected int m_StepCounter;
130  protected int m_NextVoNNoiseTime;
131  protected ref array<ref SyncHitInfo> m_SyncedHitDataArray;
132 
133  // aiming model helpers
134  protected bool m_RaiseStarted = false;
135  protected bool m_AimingFinisherStarted = false;
136  protected bool m_IsWeapon;
137 
138  private float m_CurrentWaterLevel;
139 
140  bool m_WasInVehicle;
141  protected bool m_TriggerPullPlayerOutOfVehicleSynch;
142  protected bool m_PullPlayerOutOfVehicleKeepsInLocalSpace = false;
143  protected int m_PullPlayerOutOfVehicleState = -1;
144  int m_ActionSoundCategoryHash;
145 
146  protected float m_dT;
147 
149  void DayZPlayerImplement()
150  {
151  m_SprintFull = false;
152  m_SprintedTime = 0;
153  m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_DEFAULT;
154  m_AimingModel = new DayZPlayerImplementAiming(this);
156  m_MeleeFightLogic = new DayZPlayerMeleeFightLogic_LightHeavy(this);
157  m_Swimming = new DayZPlayerImplementSwimming(this);
158  m_Throwing = new DayZPlayerImplementThrowing(this);
159  m_JumpClimb = new DayZPlayerImplementJumpClimb(this);
160  m_FallDamage = new DayZPlayerImplementFallDamage(this);
161  m_ADSAutomationTimer = new Timer();
162  m_bADS = false;
163  m_WeaponRaiseCompleted = false;
164  SetOptics(false);
165  m_IsShootingFromCamera = true;
166  m_ProcessFirearmMeleeHit = false;
167  m_ContinueFirearmMelee = false;
168  m_WasIronsight = true; //initially uses ironsights by default
169  #ifdef PLATFORM_CONSOLE
170  m_Camera3rdPerson = !GetGame().GetWorld().Is3rdPersonDisabled();
171  #endif
172  m_LastSurfaceUnderHash = ("cp_gravel").Hash();
173  m_NextVoNNoiseTime = 0;
174  m_SyncedHitDataArray = new array<ref SyncHitInfo>;
175  m_CurrentWaterLevel = 0;
176  m_WeaponRaiseTime = 0;
177 
178  RegisterNetSyncVariableBoolSignal("m_TriggerPullPlayerOutOfVehicleSynch");
179  }
180 
181  DayZPlayerImplementAiming GetAimingModel()
182  {
183  return m_AimingModel;
184  }
185 
186  DayZPlayerImplementMeleeCombat GetMeleeCombat()
187  {
188  return m_MeleeCombat;
189  }
190 
191  DayZPlayerMeleeFightLogic_LightHeavy GetMeleeFightLogic()
192  {
193  return m_MeleeFightLogic;
194  }
195 
196  DayZPlayerImplementThrowing GetThrowing()
197  {
198  return m_Throwing;
199  }
200 
201  DayZPlayerImplementFallDamage GetFallDamage()
202  {
203  return m_FallDamage;
204  }
205 
206  void ~DayZPlayerImplement()
207  {
208  }
209 
211  override bool IsEyeZoom()
212  {
213  return GetEyeZoomLevel() > 0;
214  }
215 
216  override int GetEyeZoomLevel()
217  {
218  return m_CameraEyeZoomLevel;
219  }
220 
221  override bool IsShootingFromCamera()
222  {
223  return m_IsShootingFromCamera;
224  }
225 
226  void OverrideShootFromCamera(bool pState)
227  {
228  m_IsShootingFromCamera = pState;
229  }
230 
231  bool IsInIronsights()
232  {
233  return m_CameraIronsight;
234  }
235 
236  bool IsInOptics()
237  {
238  return m_CameraOptics;
239  }
240 
241  override bool IsInThirdPerson()
242  {
243  return m_Camera3rdPerson;
244  }
245 
246  void SetIsInThirdPerson(bool state)
247  {
248  m_Camera3rdPerson = state;
249  }
250 
251  bool IsFireWeaponRaised()
252  {
254  if (m_MovementState)
255  return m_MovementState.IsRaised();
256 
257  return false;
258  }
259 
260  bool IsTryingHoldBreath()
261  {
262  return m_IsTryingHoldBreath;
263  }
264 
265  bool IsSprintFull()
266  {
267  return m_SprintFull;
268  }
269 
270  void ShowWeaponDebug(bool show)
271  {
272  if (show)
273  {
274  m_WeaponDebug = new WeaponDebug;
275  }
276  else
277  {
278  m_WeaponDebug = null;
279  }
280  }
281 
282  bool IsWeaponDebugEnabled()
283  {
284  return m_WeaponDebug != null;
285  }
286 
287  void SetFallYDiff(float value)
288  {
289  m_FallYDiff = value;
290  }
291 
292  override float GetCurrentWaterLevel()
293  {
294  return m_CurrentWaterLevel;
295  }
296 
297  override void SetCurrentWaterLevel(float pWaterLevel)
298  {
299  m_CurrentWaterLevel = pWaterLevel;
300  }
301 
302  void SetIronsights(bool value)
303  {
304  Weapon_Base weapon = Weapon_Base.Cast(GetHumanInventory().GetEntityInHands());
305  if (weapon)
306  {
307  m_WasIronsight = m_CameraIronsight;
308  }
309 
310  m_CameraIronsight = value;
311 
312  if (value)
313  {
315  if (hcw)
316  {
317  hcw.SetADS(true);
318  }
319  }
320  }
321 
322  void SetOptics(bool value)
323  {
324  m_CameraOptics = value;
325 
326  if (value)
327  {
329  if (hcw)
330  {
331  hcw.SetADS(!IsHandheldOpticsInUse());
332  }
333  }
334  }
335 
336  void ExitSights()
337  {
338  ItemOptics optics = null;
339  EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
340  Weapon weapon = Weapon.Cast(entityInHands);
341  if (weapon)
342  {
343  optics = weapon.GetAttachedOptics();
344  }
345  else
346  {
347  optics = ItemOptics.Cast(entityInHands);
348  }
349 
350  SetIronsights(false);
351  SetOptics(false);
352 
353  if (optics)
354  {
355  SwitchOptics(optics,false);
356  }
357 
359  if (hcw)
360  {
361  hcw.SetADS(false);
362  }
363  }
364 
365  void SwitchOptics(ItemOptics optic, bool state)
366  {
367  if (optic)
368  {
369  if (state)
370  {
371  if (optic.HasEnergyManager())
372  optic.GetCompEM().SwitchOn();
373  optic.EnterOptics();
374  optic.OnOpticEnter();
375  }
376  else
377  {
378  optic.ExitOptics();
379  optic.OnOpticExit();
380  if (optic.HasEnergyManager())
381  optic.GetCompEM().SwitchOff();
382  }
383  }
384 
385  if (m_CameraOptics != state)
386  {
387  SetOptics(state);
388  }
389  }
390 
391  void SetClimbingLadderType(string value)
392  {
393  m_ClimbingLadderType = value;
394  }
395 
397  bool CanConsumeStamina(EStaminaConsumers consumer) {};
398  bool CanStartConsumingStamina(EStaminaConsumers consumer) {};
399  void DepleteStamina(EStaminaModifiers modifier, float dT = -1) {};
400 
401  bool IsInVehicle()
402  {
403  return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_VEHICLE || (GetParent() != null && GetParent().IsInherited(Transport));
404  }
405 
406  bool IsSwimming()
407  {
408  return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_SWIM;
409  }
410 
411  bool IsClimbingLadder()
412  {
413  return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_LADDER;
414  }
415 
416 
417  bool PlaySoundEvent(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false) {};
418  bool PlaySoundEventEx(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false, int param = 0) {};
419 
420  bool IsFBSymptomPlaying()
421  {
422  return m_isFBsymptomPlaying;
423  }
424 
425  float GetDeltaT()
426  {
427  return m_dT;
428  }
429 
430  //-------------------------------------------------------------
434 
435  int m_DeathAnimType = -2;
436  float m_DeathHitDir = 0;
437  bool m_DeathJuctureSent = false;
438 
439  override string GetDebugText()
440  {
441  string text = super.GetDebugText();
442  text += "Parent: " + Object.GetDebugName(Object.Cast(GetParent())) + "\n";//keep
443  text += "IsSimulationDisabled: " + GetIsSimulationDisabled() + "\n";//keep
444  /*
445  text += "DamageDestroyed: " + IsDamageDestroyed() + "\n";
446  text += "DeathProcessed: " + IsDeathProcessed() + "\n";
447  text += "DeathConditionMet: " + IsDeathConditionMet() + "\n";
448  text += "PullOutOfVehicleState: " + m_PullPlayerOutOfVehicleState + "\n";
449  text += "PullOutOfVehicleSynch: " + m_TriggerPullPlayerOutOfVehicleSynch + "\n";
450  text += "Position: " + GetPosition() + "\n";*/
451  return text;
452  }
453 
454  void TriggerPullPlayerOutOfVehicle()
455  {
456  if (!GetGame().IsServer())
457  {
458  return;
459  }
460 
461  Transport transport;
462  if (!Class.CastTo(transport, GetParent()))
463  {
464  return;
465  }
466 
467  int crewIdx = -1;
468  for (int i = 0; i < transport.CrewSize(); ++i)
469  {
470  if (transport.CrewMember(i) == this)
471  {
472  crewIdx = i;
473  break;
474  }
475  }
476 
477  if (crewIdx == -1)
478  {
479  return;
480  }
481 
482  transport.CrewGetOut(crewIdx);
483  TriggerPullPlayerOutOfVehicleImpl();
484 
485  SetSynchDirty();
486  }
487 
488  void TriggerPullPlayerOutOfVehicleImpl()
489  {
492 
494  DisableSimulation(false);
495 
496  switch (GetInstanceType())
497  {
498  case DayZPlayerInstanceType.INSTANCETYPE_SERVER:
499  case DayZPlayerInstanceType.INSTANCETYPE_CLIENT:
500  case DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER:
501  case DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER:
502  m_PullPlayerOutOfVehicleState = 0;
503  m_TriggerPullPlayerOutOfVehicleSynch = true;
504  break;
505  }
506  }
507 
508  override void OnVariablesSynchronized()
509  {
510  if (m_TriggerPullPlayerOutOfVehicleSynch && !GetGame().IsDedicatedServer())
511  {
512  TriggerPullPlayerOutOfVehicleImpl();
513  }
514 
515  super.OnVariablesSynchronized();
516  }
517 
518  bool HandleDeath(int pCurrentCommandID)
519  {
520  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_DEATH)
521  {
522  switch (m_PullPlayerOutOfVehicleState)
523  {
524  case -1:
525  break;
526  case 0:
527  m_PullPlayerOutOfVehicleState = -1;
528 
529  PhysicsSetSolid(true);
530 
532  DayZPlayerVehicleCommandDeathCallback callbackVeh;
533  Class.CastTo(callbackVeh, StartCommand_Death(DayZPlayerConstants.DEATH_PULL_OUT_TRANSPORT, 0, DayZPlayerVehicleCommandDeathCallback, m_PullPlayerOutOfVehicleKeepsInLocalSpace));
534  Class.CastTo(callbackVeh.m_pPlayer, this);
535  break;
536  }
537 
538  return true;
539  }
540 
541  if (m_DeathAnimType != -2 && g_Game.GetMissionState() == g_Game.MISSION_STATE_GAME)
542  {
543  if (!CommitedSuicide())
544  {
545  int type = m_DeathAnimType;
546  if (type == DayZPlayerConstants.DEATH_DEFAULT)
547  type = GetTypeOfDeath(pCurrentCommandID);
548 
549  m_WasInVehicle = false;
551  if (hcv)
552  {
553  m_TransportCache = hcv.GetTransport();
554  m_WasInVehicle = !hcv.IsGettingIn() && !hcv.IsGettingOut();
555  }
556 
557  bool keepInLocalSpace = false;
558  if (IsUnconscious() || m_WasInVehicle)
559  {
560  if (m_TransportCache)
561  {
562  m_TransportCache.CrewDeath(m_TransportCache.CrewMemberIndex(this));
563  m_TransportCache.MarkCrewMemberDead(m_TransportCache.CrewMemberIndex(this));
564  }
565  }
566  else
567  {
568  if (m_TransportCache)
569  {
570  m_TransportCache.CrewGetOut(m_TransportCache.CrewMemberIndex(this));
571  m_TransportCache.MarkCrewMemberDead(m_TransportCache.CrewMemberIndex(this));
572  }
573 
574  keepInLocalSpace = m_PullPlayerOutOfVehicleKeepsInLocalSpace;
575  }
576 
577  DisableSimulation(false);
578  GetItemAccessor().HideItemInHands(false);
579  m_TransportCache = null;
580 
582  Class.CastTo(callback, StartCommand_Death(type, m_DeathHitDir, DayZPlayerCommandDeathCallback, keepInLocalSpace));
583  Class.CastTo(callback.m_pPlayer, this);
584  }
585  else
586  {
587  PhysicsSetRagdoll(true);
588  }
589 
590  // disable voice communication
591  GetGame().GetWorld().SetVoiceOn(false, false);
592 
593  return true;
594  }
595 
596  return false;
597  }
598 
599  void ResetDeathStartTime()
600  {
602  }
603 
604  int GetTypeOfDeath(int pCurrentCommandID)
605  {
606  switch (pCurrentCommandID)
607  {
608  case DayZPlayerConstants.COMMANDID_SWIM:
609  return DayZPlayerConstants.DEATH_WATER;
610  case DayZPlayerConstants.COMMANDID_FALL:
611  return DayZPlayerConstants.DEATH_FALL;
612  case DayZPlayerConstants.COMMANDID_UNCONSCIOUS:
614  if (hcu)
615  {
616  if (hcu.IsOnLand())
617  return DayZPlayerConstants.DEATH_UNCON_ON_LAND;
618  if (hcu.IsInWater())
619  return DayZPlayerConstants.DEATH_UNCON_IN_WATER;
620  }
621 
622  break;
623  }
624 
625  return DayZPlayerConstants.DEATH_BODY;
626  }
627 
628  void SendDeathJuncture(int pAnimTypeDeath, float pAnimHitDirDeath)
629  {
630  if (m_DeathJuctureSent)
631  return;
632 
633  DayZPlayerSyncJunctures.SendDeath(this, pAnimTypeDeath, pAnimHitDirDeath);
634  m_DeathJuctureSent = true;
635  }
636 
637  override void EEKilled(Object killer)
638  {
639  SendDeathJuncture(-1, 0);
640 
641  super.EEKilled(killer);
642  }
643 
644  void ShowDeadScreen(bool show, float duration)
645  {
646  #ifndef NO_GUI
647  if (show && IsPlayerSelected())
648  {
649  #ifdef PLATFORM_PS4
650  OnlineServices.SetMultiplayState(false);
651  #endif
652 
653  string message = "";
654  if (!GetGame().GetMission().IsPlayerRespawning())
655  {
656  message = "#dayz_implement_dead";
657  }
658 
659  #ifdef PLATFORM_CONSOLE
660  GetGame().GetUIManager().ScreenFadeIn(duration, message, FadeColors.DARK_RED, FadeColors.WHITE);
661  #else
662  GetGame().GetUIManager().ScreenFadeIn(duration, message, FadeColors.BLACK, FadeColors.WHITE);
663  #endif
664  }
665  else
666  {
667  GetGame().GetUIManager().ScreenFadeOut(duration);
668 
669  if (duration > 0)
670  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(StopDeathDarkeningEffect, duration*1000, false);
671  else
672  GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(StopDeathDarkeningEffect);
673  }
674  #endif
675  }
676 
677  override void StopDeathDarkeningEffect()
678  {
679  if (m_DeathEffectTimer && m_DeathEffectTimer.IsRunning())
680  {
681  m_DeathEffectTimer.Stop();
682  m_DeathEffectTimer = null;
683  }
684  }
685 
686  void SimulateDeath(bool state)
687  {
688  if (g_Game.GetMissionState() != DayZGame.MISSION_STATE_GAME)
689  return;
690 
691  LockControls(state);
692 
693  if (state)
694  {
695  float duration = DEFAULT_DYING_TIME;
696  if (m_KilledByHeadshot)
697  {
698  duration = 0;
699  }
700 
701  if (duration > DYING_PROGRESSION_TIME && !m_IsUnconscious)
702  {
703  if (!m_DeathEffectTimer)
704  m_DeathEffectTimer = new DeathEffectTimer();
705 
706  Param2<float,float> par = new Param2<float,float>(duration, DYING_PROGRESSION_TIME);
707  m_DeathEffectTimer.Run(DYING_PROGRESSION_TIME, this, "SetDeathDarknessLevel", par, true);
708  }
709 
710  ShowDeadScreen(state, duration);
711 
712  GetGame().GetSoundScene().SetSoundVolume(0,0);
713  GetGame().GetSoundScene().SetSpeechExVolume(0,0);
714  GetGame().GetSoundScene().SetMusicVolume(0,0);
715  GetGame().GetSoundScene().SetVOIPVolume(0,0);
716  GetGame().GetSoundScene().SetRadioVolume(0,0);
717  }
718  else
719  {
720  StopDeathDarkeningEffect();
721  ShowDeadScreen(state, 0);
722  }
723  }
724 
725  void LockControls(bool state)
726  {
727  if (state == true)
728  {
729  GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_MOUSE);
730  GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_KEYBOARD);
731  GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_GAMEPAD);
732 
733  if (GetGame().GetUIManager())
734  {
735  GetGame().GetUIManager().ShowUICursor(true);
736  if (GetGame().GetUIManager().IsDialogVisible())
737  GetGame().GetUIManager().CloseDialog();
738  }
739  }
740  else
741  {
742  GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_MOUSE);
743  GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_KEYBOARD);
744  GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_GAMEPAD);
745 
746  if (GetGame().GetUIManager())
747  {
748  if (GetGame().GetUIManager().GetMenu())
749  {
750  GetGame().GetUIManager().ShowUICursor(true);
751  }
752  else
753  {
754  GetGame().GetUIManager().ShowUICursor(false);
755  }
756  }
757  }
758  }
759 
760  void SetDeathDarknessLevel(float duration, float tick_time);
761 
762  void SendCompleteWeaponRaiseJuncture();
763 
764  void CompleteWeaponRaise()
765  {
766  m_WeaponRaiseTime = 0;
767  m_WeaponRaiseCompleted = true;
768  }
769 
770  void ResetWeaponRaiseProgress()
771  {
772  m_WeaponRaiseTime = 0;
773  m_WeaponRaiseCompleted = false;
774  }
775 
776  bool IsWeaponRaiseCompleted()
777  {
778  return m_WeaponRaiseCompleted;
779  }
780 
781  DayZPlayerInventory GetDayZPlayerInventory()
782  {
783  DayZPlayerInventory inv = DayZPlayerInventory.Cast(GetInventory());
784  return inv;
785  }
786 
787  override void OnInputForRemote(ParamsReadContext ctx)
788  {
789  int userDataType = 0;
790  if (!ctx.Read(userDataType))
791  {
792  Error("DayZPlayer: OnInputForRemote - cannot read input type");
793  return;
794  }
795 
796  switch (userDataType)
797  {
799  GetDayZPlayerInventory().OnEventForRemoteWeapon(ctx);
800  break;
802  GetDayZPlayerInventory().OnHandEventForRemote(ctx);
803  break;
804  case INPUT_UDT_INVENTORY:
805  GetDayZPlayerInventory().OnInputUserDataForRemote(ctx);
806  break;
807  default:
808  Error("OnInputForRemote - unknown userDataType=" + userDataType);
809  break;
810  }
811  }
812 
813  override void OnInputFromServer (ParamsReadContext ctx)
814  {
815  int userDataType = 0;
816  if (!ctx.Read(userDataType))
817  {
818  Error("DayZPlayer: OnInputFromServer - cannot read input type");
819  return;
820  }
821 
822  switch (userDataType)
823  {
824  case INPUT_UDT_INVENTORY:
825  GetDayZPlayerInventory().OnServerInventoryCommand(ctx);
826  break;
827  default:
828  Error("OnInputFromServer - unknown userDataType=" + userDataType);
829  break;
830  }
831  }
832  void RequestSoundEvent(EPlayerSoundEventID id, bool from_server_and_client = false);
833  void RequestSoundEventEx(EPlayerSoundEventID id, bool from_server_and_client = false, int param = 0);
834  protected void SendSoundEvent(EPlayerSoundEventID id);
835  protected void SendSoundEventEx(EPlayerSoundEventID id, int param = 0);
836 
837  override void OnItemInHandsChanged()
838  {
839  //Print("inv: DayZPlayerImplement::OnItemInHandsChanged: "/* + GetHumanInventory().GetEntityInHands()*/);
840  StopWeaponEvent();
841  GetItemAccessor().OnItemInHandsChanged();
842 
843  if (!IsAlive())
844  {
845  //Print("inv: DayZPlayerImplement::OnItemInHandsChanged - human not alive! calling ResetWeaponInHands");
846  GetItemAccessor().ResetWeaponInHands();
847  }
848  }
849 
850  WeaponManager GetWeaponManager() { return null; }
851 
852  //-------------------------------------------------------------
856  void HandleWeapons(float pDt, Entity pInHands, HumanInputController pInputs, out bool pExitIronSights)
857  {
859  GetDayZPlayerInventory().HandleWeaponEvents(pDt, pExitIronSights);
860 
861  Weapon_Base weapon;
862  Class.CastTo(weapon, pInHands);
863  ItemOptics optic = weapon.GetAttachedOptics();
864 
865  CheckLiftWeapon();
866  ProcessLiftWeapon();
867 
869 
870  // hold breath
871  if (pInputs.IsHoldBreath() && m_MovementState.IsRaised() && (IsInIronsights() || IsInOptics()))
872  {
873  m_IsTryingHoldBreath = true;
874  }
875  else
876  {
877  m_IsTryingHoldBreath = false;
878  }
879 
880  if (pInputs.IsFireModeChange())
881  {
882  GetWeaponManager().SetNextMuzzleMode();
883  }
884  if (pInputs.IsZeroingUp())
885  {
886  if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
887  {
888  optic.StepZeroingUp();
889  }
890  else
891  {
892  weapon.StepZeroingUpAllMuzzles();
893  }
894  }
895  if (pInputs.IsZeroingDown())
896  {
897  if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
898  {
899  optic.StepZeroingDown();
900  }
901  else
902  {
903  weapon.StepZeroingDownAllMuzzles();
904  }
905  }
906 
907  if (!m_LiftWeapon_player && (m_CameraIronsight || !weapon.CanEnterIronsights() || m_CameraOptics/*m_ForceHandleOptics*/)) // HACK straight to optics, if ironsights not allowed
908  {
909  if (optic)
910  HandleOptic(optic, false, pInputs, pExitIronSights);
911  }
912 
913  if (!m_MovementState.IsRaised())
914  {
915  m_IsFireWeaponRaised = false; //legacy reasons
916  if (weapon && weapon.IsInOptics())
917  {
918  weapon.ExitOptics();
919  }
920 
921  ResetWeaponRaiseProgress();
922 
923  return; // if not raised => return
924  }
925  else
926  {
927  m_IsFireWeaponRaised = true; //legacy reasons
928  if (!IsWeaponRaiseCompleted())
929  {
930  m_WeaponRaiseTime += pDt;
931  }
932 
933  if (m_WeaponRaiseTime >= PlayerConstants.WEAPON_RAISE_BLEND_DELAY)
934  {
935  CompleteWeaponRaise();
936  }
937  }
938 
940  if (GetWeaponManager().CanFire(weapon))
941  {
942  bool autofire = weapon.GetCurrentModeAutoFire(weapon.GetCurrentMuzzle()) && weapon.IsChamberEjectable(weapon.GetCurrentMuzzle());
943  int burst = weapon.GetCurrentModeBurstSize(weapon.GetCurrentMuzzle());
944  int burst_count = weapon.GetBurstCount();
945  if (!autofire && (burst < 2 || burst_count < 1))
946  {
947  if (pInputs.IsAttackButtonDown() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
948  {
949  GetWeaponManager().Fire(weapon);
950  }
951  }
952  else if (autofire || burst > 1)
953  {
954 #ifdef DIAG_DEVELOPER
955  int burst_option = GetWeaponManager().GetBurstOption();
956  if (burst_option == 0)
957  {
958 #endif
959  if (pInputs.IsAttackButton() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
960  {
961  if (autofire || burst_count < burst)
962  {
963  GetWeaponManager().Fire(weapon);
964  }
965  }
966  else
967  {
968  weapon.ResetBurstCount();
969  }
970 #ifdef DIAG_DEVELOPER
971  }
972  else if (burst_option == 1)
973  {
974  if (burst > 1 && burst_count == burst)
975  {
976  weapon.ResetBurstCount();
977  }
978  else if (burst > 1 && burst_count < burst)
979  {
980  GetWeaponManager().Fire(weapon);
981  }
982  else
983  {
984  //Autofire
985  if (pInputs.IsAttackButton())
986  {
987  GetWeaponManager().Fire(weapon);
988  }
989  }
990  }
991 #endif
992  }
993  }
994 
995  #ifdef PLATFORM_CONSOLE
996  if (GetGame().GetInput().LocalRelease("UAFire", false) || m_ShouldReload)
997  {
998  if (!weapon.IsWaitingForActionFinish() && !IsFighting())
999  {
1000  int muzzle_index = weapon.GetCurrentMuzzle();
1001 
1002  if (weapon.IsChamberFiredOut(muzzle_index))
1003  {
1004  if (weapon.CanProcessWeaponEvents())
1005  {
1006  if (GetWeaponManager().CanEjectBullet(weapon))
1007  {
1008  GetWeaponManager().EjectBullet();
1009  pExitIronSights = true;
1010  m_ShouldReload = false;
1011  }
1012  }
1013  }
1014  }
1015  else
1016  {
1017  m_ShouldReload = true;
1018  }
1019  }
1020  #endif
1021  }
1022 
1023  void HandleOptic(notnull ItemOptics optic, bool inHands, HumanInputController pInputs, out bool pExitOptics)
1024  {
1025  UAInterface input = GetInputInterface();
1026  if (!input)
1027  {
1028  return;
1029  }
1030 
1031  Weapon_Base weapon;
1032  int FOVcount;
1033  bool controllerPressIn;
1034  bool controllerPressOut;
1035 
1036  if (input.SyncedPress_ID(UAZoomInOptics))
1037  {
1038  weapon = Weapon_Base.Cast(optic.GetHierarchyParent());
1039  FOVcount = optic.GetStepFOVCount();
1040  controllerPressIn = input.SyncedPress_ID(UAZoomInOpticsControllerHelper);
1041 
1042  if (weapon && m_CameraIronsight && !m_CameraOptics)
1043  {
1044  SetIronsights(false);
1045  SwitchOptics(optic,true);
1046  optic.SetStepFOVIndex(0);
1047  }
1048  else if (m_CameraOptics)
1049  {
1050  if (controllerPressIn) //controller
1051  {
1052  if (!optic.StepFOVUp())
1053  {
1054  if (FOVcount > 0)
1055  {
1056  optic.SetStepFOVIndex(0); //loop to minimum magnification
1057  }
1058 
1059  if (weapon && weapon.CanEnterIronsights()) //loop into ironsights
1060  {
1061  SwitchOptics(optic,false);
1062  pInputs.ResetFreeLookToggle();
1063  SetIronsights(true);
1064  }
1065  }
1066  }
1067  else //m&k
1068  {
1069  optic.StepFOVUp();
1070  }
1071  }
1072  }
1073 
1074  if (input.SyncedPress_ID(UAZoomOutOptics))
1075  {
1076  weapon = Weapon_Base.Cast(optic.GetHierarchyParent());
1077  FOVcount = optic.GetStepFOVCount();
1078  controllerPressOut = input.SyncedPress_ID(UAZoomOutOpticsControllerHelper);
1079  if (m_CameraOptics)
1080  {
1081  if (!optic.StepFOVDown())
1082  {
1083  if (controllerPressOut)
1084  {
1085  if (FOVcount > 0 && (!weapon || !weapon.CanEnterIronsights()))
1086  {
1087  optic.SetStepFOVIndex(FOVcount - 1); //loop to maximum magnification
1088  }
1089  }
1090 
1091  if (weapon && weapon.CanEnterIronsights())
1092  {
1093  SwitchOptics(optic,false);
1094  pInputs.ResetFreeLookToggle();
1095  SetIronsights(true);
1096  }
1097  }
1098  }
1099  else if (controllerPressOut && weapon && m_CameraIronsight)
1100  {
1101  SwitchOptics(optic,true);
1102  if (FOVcount > 0)
1103  {
1104  optic.SetStepFOVIndex(FOVcount - 1); //loop to maximum magnification
1105  }
1106  }
1107  }
1108  }
1109 
1110  //-------------------------------------------------------------
1114 
1115  bool m_DamageHitFullbody = false;
1116  int m_DamageHitAnimType = -1.0;
1117  float m_DamageHitDir = 0.0;
1118  float m_DamageHealth = 0.0;
1119 
1120  const float HIT_INTERVAL_MIN = 0.3; // Minimum time in seconds before a COMMANDID_HIT to COMMANDID_HIT transition is allowed
1121  float m_HitElapsedTime = HIT_INTERVAL_MIN;
1122 
1123  bool IsInFullbodyDamageAnimation()
1124  {
1125  return (m_DamageHitFullbody && m_DamageHitAnimType != -1) || GetCommand_Damage() != null;
1126  }
1127 
1129  void EvaluateDamageHit(int pCurrentCommandID)
1130  {
1132  m_DamageHitAnimType = -1;
1133 
1134  if (!m_SyncedHitDataArray || m_SyncedHitDataArray.Count() == 0)
1135  {
1136  return;
1137  }
1138 
1139  //evaluate all hit data
1140  SyncHitInfo data;
1141  SyncHitInfo greatest_hit;
1142  for (int i = 0; i < m_SyncedHitDataArray.Count(); i++)
1143  {
1144  data = m_SyncedHitDataArray[i];
1145  m_DamageHitDir = data.m_HitDir;
1146 
1147  //client-side effects
1148  #ifndef SERVER
1149  if (IsAlive() && !IsUnconscious() && data.m_HasSource && GetGame().GetMission().GetHud() && GetGame().GetPlayer() == this) //only for controlled players
1150  {
1151  m_DamageHealth = data.m_HealthDamage;
1152  if (m_DamageHealth > 0.0)
1153  {
1154  float rel = m_DamageHealth / (GetMaxHealth("","Health") * PlayerConstants.HEAVY_HIT_THRESHOLD);
1155  GetGame().GetMission().GetHud().SpawnHitDirEffect(this,m_DamageHitDir,rel);
1156  }
1157  }
1158  #endif
1159 
1160  if (!greatest_hit)
1161  {
1162  greatest_hit = data;
1163  }
1164  //else if (data.m_HealthDamage > greatest_hit.m_HealthDamage || (data.m_Fullbody && !greatest_hit.m_Fullbody)) //TODO - revisit cumulative calculation for animation evaluation purposes (stagger on shotgun to the chest)
1165  else if (data.m_Fullbody) //temporary solution; last fullbody hit is used for animation purposes, some light hit otherwise
1166  {
1167  greatest_hit = data;
1168  }
1169  }
1170 
1171  m_SyncedHitDataArray.Clear();
1172  m_DamageHealth = 0.0;
1173 
1175  if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1176  {
1177  return;
1178  }
1179 
1180  //general effects
1181  m_DamageHitFullbody = greatest_hit.m_Fullbody;
1182  m_DamageHitAnimType = greatest_hit.m_AnimType;
1183  m_DamageHitDir = greatest_hit.m_HitDir;
1184  }
1185 
1186  bool HandleDamageHit(int pCurrentCommandID)
1187  {
1188  // Update elapsed time since hit first
1189  if ( pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE )
1190  {
1191  // Throttle heavy hit command up to a fixed rate
1192  if ( m_HitElapsedTime < HIT_INTERVAL_MIN )
1193  {
1194  m_HitElapsedTime += m_dT;
1195  ResetDamageHitState(false);
1196  return false;
1197  }
1198  }
1199 
1200  // If transportcache is not null, player is unconscious inside of a car and should not head into a damage command
1201  if (m_DamageHitAnimType != -1 && m_TransportCache == null && !CommitedSuicide())
1202  {
1203  HumanCommandVehicle vehCommand = GetCommand_Vehicle();
1204  if (m_DamageHitFullbody && (!vehCommand || vehCommand.IsGettingIn() || vehCommand.IsGettingOut()))
1205  {
1206  StartCommand_Damage(m_DamageHitAnimType, m_DamageHitDir);
1207  ResetDamageHitState(true);
1208  return true;
1209  }
1210  else
1211  {
1212  AddCommandModifier_Damage(m_DamageHitAnimType, m_DamageHitDir);
1213  ResetDamageHitState(false);
1214  return false;
1215  }
1216  }
1217 
1218  return pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE;
1219  }
1220 
1221  void ResetDamageHitState(bool resetTimer)
1222  {
1223  m_DamageHitAnimType = -1;
1224  m_DamageHitFullbody = false;
1225 
1226  if (resetTimer)
1227  {
1228  m_HitElapsedTime = 0;
1229  }
1230  }
1231 
1233  bool EvaluateDeathAnimation(int pDamageType, EntityAI pSource, string pAmmoType, out int pAnimType, out float pAnimHitDir)
1234  {
1235  bool doPhxImpulse = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " doPhxImpulse") > 0;
1236 
1237  pAnimType = DayZPlayerConstants.DEATH_DEFAULT;
1238  if (doPhxImpulse)
1239  pAnimType = DayZPlayerConstants.DEATH_FAST;
1240 
1242  vector targetDirection = GetDirection();
1243  vector toSourceDirection = (pSource.GetPosition() - GetPosition());
1244 
1245  targetDirection[1] = 0;
1246  toSourceDirection[1] = 0;
1247 
1248  targetDirection.Normalize();
1249  toSourceDirection.Normalize();
1250 
1251  float cosFi = vector.Dot(targetDirection, toSourceDirection);
1252  vector cross = targetDirection * toSourceDirection;
1253 
1254  pAnimHitDir = Math.Acos(cosFi) * Math.RAD2DEG;
1255  if (cross[1] < 0)
1256  pAnimHitDir = -pAnimHitDir;
1257 
1258  return true;
1259  }
1260 
1262  bool EvaluateDamageHitAnimation(TotalDamageResult pDamageResult, int pDamageType, EntityAI pSource, string pComponent, string pAmmoType, vector pModelPos, out int pAnimType, out float pAnimHitDir, out bool pAnimHitFullbody)
1263  {
1264  int invertHitDir = 0; //Used to flip the heavy hit animation direction
1265 
1266  pAnimType = 0;
1267  pAnimHitFullbody = false; // additive anm
1269 
1270  switch (pDamageType)
1271  {
1272  case DT_CLOSE_COMBAT:
1274  if (pSource.IsInherited(DayZInfected))
1275  break;
1276 
1277  pAnimType = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " hitAnimation");
1278  invertHitDir = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " invertHitDir");
1279  if (!IsUnconscious() && pAnimType == 1 && !m_MeleeFightLogic.IsInBlock())
1280  pAnimHitFullbody = true;
1281  break;
1282 
1283  case DT_FIRE_ARM:
1284  int impactBehaviour = 0;
1285 
1286  if (!IsUnconscious() && GetHealth("", "Shock") > 25)
1287  {
1289  if (pComponent == "Torso" || pComponent == "Head")
1290  {
1291  impactBehaviour = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " impactBehaviour");
1292  float fireDamage = pDamageResult.GetHighestDamage("Health");
1293  float shockDamage = pDamageResult.GetHighestDamage("Shock");
1294  if ((fireDamage > 80.0 || shockDamage > 40.0) && impactBehaviour == 1)
1295  pAnimHitFullbody = true;
1296  }
1297  }
1298 
1299  break;
1300 
1301  case DT_EXPLOSION:
1302  break;
1303 
1304  case DT_CUSTOM:
1305  pAnimType = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " hitAnimation");
1306  if (pAnimType == 1)
1307  pAnimHitFullbody = true;
1308  else
1309  return false;
1310 
1311  break;
1312  }
1313 
1315  vector targetDirection = GetDirection();
1316  vector toSourceDirection = (pSource.GetPosition() - GetPosition());
1317 
1318  targetDirection[1] = 0;
1319  toSourceDirection[1] = 0;
1320 
1321  targetDirection.Normalize();
1322  toSourceDirection.Normalize();
1323 
1324  float cosFi = vector.Dot(targetDirection, toSourceDirection);
1325  vector cross = targetDirection * toSourceDirection;
1326 
1327  pAnimHitDir = Math.Acos(cosFi) * Math.RAD2DEG;
1328 
1329  // We will invert direction of the hit
1330  if (invertHitDir > 0)
1331  pAnimHitDir -= 180;
1332 
1333  if (cross[1] < 0)
1334  pAnimHitDir = -pAnimHitDir;
1335 
1336  return true;
1337  }
1338 
1340  override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
1341  {
1342  super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
1343 
1344  m_TransportHitRegistered = false;
1345 
1346  if (!IsAlive())
1347  {
1348  int animTypeDeath;
1349  float animHitDirDeath;
1350  if (EvaluateDeathAnimation(damageType, source, ammo, animTypeDeath, animHitDirDeath))
1351  {
1352  SendDeathJuncture(animTypeDeath, animHitDirDeath);
1353  }
1354 
1355  if (!m_DeathSyncSent) //checked until the death is evaluated by 'OnCommandHandlerTick' higher up the road
1356  {
1357  Man killer = source.GetHierarchyRootPlayer();
1358 
1359  if (!m_KillerData) //only one player is considered killer in the event of crossfire
1360  {
1361  m_KillerData = new KillerData();
1362  m_KillerData.m_Killer = killer;
1363  m_KillerData.m_MurderWeapon = source;
1364  }
1365 
1366  if (killer && killer.IsPlayer())
1367  {
1368  // was player killed by headshot?
1369  if (dmgZone == "Brain")
1370  {
1371  m_KilledByHeadshot = true;
1372  if (m_KillerData.m_Killer == killer)
1373  m_KillerData.m_KillerHiTheBrain = true;
1374  }
1375  }
1376  }
1377  }
1378  else
1379  {
1380  int animType;
1381  float animHitDir;
1382  bool animHitFullbody;
1383  if (EvaluateDamageHitAnimation(damageResult, damageType, source, dmgZone, ammo, modelPos, animType, animHitDir, animHitFullbody))
1384  DayZPlayerSyncJunctures.SendDamageHitEx(this, animType, animHitDir, animHitFullbody, damageResult, damageType, source, dmgZone, ammo, modelPos);
1385  else
1386  {
1387  bool skipSoundRequest = false;
1388  if (damageType == DamageType.CUSTOM && GetCommand_Fall())
1389  skipSoundRequest = GetFallDamage().GetLandType() < HumanCommandFall.LANDTYPE_MEDIUM;
1390 
1391  if (!skipSoundRequest)
1392  RequestSoundEvent(EPlayerSoundEventID.TAKING_DMG_LIGHT);
1393  }
1394  }
1395 
1396  // interupt melee for non-blocked hit or heavy hit
1397  if (animHitFullbody)
1398  {
1400  if (hcm)
1401  hcm.Cancel();
1402  }
1403  }
1404 
1405  //-------------------------------------------------------------
1409  float m_fLastHeadingDiff = 0;
1410 
1412  override bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
1413  {
1414  if (!IsAlive())
1415  {
1416  return false;
1417  }
1418 
1420 
1422  if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_LADDER)
1423  {
1424  m_fLastHeadingDiff = 0;
1425  return false;
1426  }
1427  if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_VEHICLE)
1428  {
1430  if (hmv.IsGettingOut() || hmv.IsGettingIn())
1431  {
1432  return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
1433  }
1434 
1435  m_fLastHeadingDiff = 0;
1436  return false;
1437  }
1438  if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
1439  {
1441  if (!hcu.IsWakingUp())
1442  {
1443  m_fLastHeadingDiff = 0;
1444  //pModel.m_iCamMode = DayZPlayerConstants.CAMERAMODE_HEAD;
1445  return false;
1446  }
1447  }
1448 
1449  if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_CLIMB)
1450  {
1451  m_fLastHeadingDiff = 0;
1452  return false;
1453  }
1454 
1455 #ifdef DEVELOPER
1456  int actMenuValue = DiagMenu.GetEngineValue(DayZPlayerConstants.DEBUG_TURNSLIDE);
1457  if (actMenuValue != 0)
1458  {
1460  return DayZPlayerImplementHeading.ClampHeading(pDt, pModel, m_fLastHeadingDiff);
1461  }
1462 #endif
1463 
1464  if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1465  {
1466  m_fLastHeadingDiff = 0;
1467  return false;
1468  }
1469 
1471  if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_MOVE)
1472  {
1474  if (hcm.IsStandingFromBack())
1475  {
1476  m_fLastHeadingDiff = 0;
1477  return false;
1478  }
1479  }
1480 
1482  HumanItemBehaviorCfg hibcfg = hia.GetItemInHandsBehaviourCfg();
1483  if (hibcfg && hibcfg.m_StanceRotation[m_MovementState.m_iStanceIdx] == DayZPlayerConstants.ROTATION_DISABLE)
1484  {
1485  return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
1486  }
1487  if (IsUnconscious() || (GetCommand_Move() && GetCommand_Move().IsLeavingUncon()))
1488  {
1489  return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
1490  }
1491 
1492  return DayZPlayerImplementHeading.RotateOrient(pDt, pModel, m_fLastHeadingDiff);
1493  }
1494 
1495 
1496  //-------------------------------------------------------------
1500  override bool AimingModel(float pDt, SDayZPlayerAimingModel pModel)
1501  {
1503  if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_MELEE2)
1504  {
1506  if (hcm.IsFinisher())
1507  {
1508  if (!m_AimingFinisherStarted)
1509  {
1510  m_AimingModel.OnFinisherBegin(pModel.m_fCurrentAimY);
1511  m_AimingFinisherStarted = true;
1512  }
1513  m_AimingModel.ProcessStealthFilters(pDt, pModel);
1514  }
1515 
1516  return true;
1517  }
1518 
1519  if (m_MovementState.IsRaised())
1520  {
1521  if (!m_RaiseStarted)
1522  {
1523  m_AimingModel.OnRaiseBegin(this);
1524  m_RaiseStarted = true;
1525  }
1526  m_AimingModel.ProcessAimFilters(pDt, pModel, m_MovementState.m_iStanceIdx);
1527 
1528  return true;
1529  }
1530 
1531  m_RaiseStarted = false;
1532  m_AimingFinisherStarted = false;
1533 
1534  return true;
1535  }
1536 
1537  //-------------------------------------------------------------
1541 
1542 
1544  bool CanJump()
1545  {
1546  if (IsFBSymptomPlaying() || IsRestrained() || IsUnconscious() || IsInFBEmoteState())
1547  return false;
1548 
1549  if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1550  return false;
1551 
1552  if (IsRaised() && GetInputInterface().SyncedPress("UAGetOverControllerHelper")) //no raised jump on cotroller
1553  {
1554  return false;
1555  }
1556 
1557  HumanItemBehaviorCfg hibcfg = GetItemAccessor().GetItemInHandsBehaviourCfg();
1558  if (!hibcfg.m_bJumpAllowed)
1559  return false;
1560 
1561  if (!DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_ERECT) || !DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_RAISEDERECT))
1562  return false;
1563 
1565  if (hcm)
1566  {
1567  if (hcm.IsChangingStance())
1568  return false;
1569  }
1570 
1571  return true;
1572  }
1573 
1574  bool CanClimb(int climbType, SHumanCommandClimbResult climbRes)
1575  {
1576  if (IsFBSymptomPlaying() || IsRestrained() || IsUnconscious() || IsInFBEmoteState())
1577  return false;
1578 
1579  if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1580  return false;
1581 
1582  if (IsRaised() && GetInputInterface().SyncedPress("UAGetOverControllerHelper")) //no raised climb on cotroller
1583  {
1584  return false;
1585  }
1586 
1587  HumanItemBehaviorCfg hibcfg = GetItemAccessor().GetItemInHandsBehaviourCfg();
1588  if (!hibcfg.m_bJumpAllowed)
1589  return false;
1590 
1591  if (climbRes)
1592  {
1593  EntityAI entity;
1594  if (Class.CastTo(entity,climbRes.m_GrabPointParent) && entity.IsHologram())
1595  return false;
1596  if (Class.CastTo(entity,climbRes.m_ClimbStandPointParent) && entity.IsHologram())
1597  return false;
1598  if (Class.CastTo(entity,climbRes.m_ClimbOverStandPointParent) && entity.IsHologram())
1599  return false;
1600  }
1601 
1602  return true;
1603  }
1604 
1605 
1606  void OnJumpStart()
1607  {
1608  }
1609 
1610  void OnJumpEnd(int pLandType = 0)
1611  {
1612  }
1613 
1614  void StopHandEvent()
1615  {
1616  GetDayZPlayerInventory().CancelHandEvent();
1617  }
1618 
1619  void StopWeaponEvent()
1620  {
1621  GetDayZPlayerInventory().CancelWeaponEvent();
1622  }
1623 
1624  void AbortWeaponEvent()
1625  {
1626  GetDayZPlayerInventory().AbortWeaponEvent();
1627  }
1628 
1629  //-------------------------------------------------------------
1633  void HandleADS()
1634  {
1635  if (!IsAlive())
1636  {
1637  if (m_CameraIronsight || m_CameraOptics)
1638  {
1639  ExitSights();
1640  }
1641  return;
1642  }
1643 
1644  bool bADSToggle = false;
1645  bool exitSights = false;
1649  PlayerBase playerPB = PlayerBase.Cast(this);
1651 
1652  if (playerPB.IsRolling())
1653  {
1654  exitSights = true;
1655  }
1656 
1657  if (m_ResetADS || !hia.IsItemInHandsWeapon())
1658  {
1659  hic.ResetADS();
1660  m_ResetADS = false;
1661  }
1662 
1663  if (!m_MovementState.IsRaised() || m_LiftWeapon_player)
1664  {
1665  ResetWeaponRaiseProgress();
1666  exitSights = true;
1667  }
1668  else
1669  {
1670  if (m_bADS != hic.WeaponADS())
1671  {
1672  m_bADS = hic.WeaponADS();
1673  bADSToggle = true;
1674  }
1675 
1676  if (m_bADS && !m_CameraIronsight && !m_CameraOptics)
1677  {
1679  if (!IsWeaponRaiseCompleted())
1680  {
1681  bADSToggle = false;
1682  exitSights = true;
1683  }
1684  else
1685  {
1686  bADSToggle = true;
1687  }
1688  }
1689  }
1690 
1691  if (bADSToggle && !GetCommand_Melee2() && !GetThrowing().IsThrowingModeEnabled())
1692  {
1693  if (hia.IsItemInHandsWeapon() && playerPB.GetItemInHands() && playerPB.GetItemInHands().IsWeapon() && playerPB.GetWeaponManager() && !playerPB.GetWeaponManager().IsRunning())
1694  {
1695  Weapon_Base weapon = Weapon_Base.Cast(GetHumanInventory().GetEntityInHands());
1696  ItemOptics optic = weapon.GetAttachedOptics();
1697  bool switchToADS = false;
1698  bool canUseIronsights = weapon.CanEnterIronsights();
1699  bool canUseOptics = optic != NULL;
1700 
1701  if (canUseIronsights || canUseOptics)
1702  switchToADS = m_bADS;
1703 
1704  // go to ironsights - disable ironsights when
1707  if (!m_MovementState.IsRaised() || m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
1708  {
1709  switchToADS = false;
1710  }
1711 
1712  // fixes camera switching during item transitions
1713  if (IsLiftWeapon() || !IsRaised() || GetDayZPlayerInventory().IsProcessing() || !IsWeaponRaiseCompleted() || IsFighting())
1714  {
1715  exitSights = true;
1716  }
1717  else if (switchToADS) // enter ironsights or optics
1718  {
1719  // filter by usability
1720  if (m_WasIronsight && !canUseIronsights)
1721  {
1722  m_WasIronsight = false;
1723  }
1724  else if (!m_WasIronsight && !canUseOptics)
1725  {
1726  m_WasIronsight = true;
1727  }
1728 
1729  if (m_WasIronsight)
1730  {
1731  hic.ResetFreeLookToggle();
1732  SwitchOptics(optic,false);
1733  SetIronsights(true);
1734  }
1735  else if (!m_WasIronsight || (!canUseIronsights && canUseOptics))
1736  {
1737  SetIronsights(false);
1738  SwitchOptics(optic,true);
1739  }
1740  else
1741  {
1742  exitSights = true;
1743  }
1744 
1745  if (hcw && (m_CameraOptics/* || m_CameraIronsight*/))
1746  {
1747  hcw.SetADS(true);
1748  }
1749  }
1750  else
1751  {
1752  exitSights = true;
1753  }
1754  }
1755  }
1756 
1757  // leave ironsight and/ or optics
1758  if (exitSights && !IsHandheldOpticsInUse() && (m_CameraIronsight || m_CameraOptics) || GetCommand_Melee2())
1759  {
1760  ExitSights();
1761  }
1762  }
1763 
1764  void HandleView()
1765  {
1766  if (!IsAlive())
1767  {
1768  if (m_CameraIronsight || m_CameraOptics)
1769  {
1770  ExitSights();
1771  }
1772  return;
1773  }
1774 
1776 
1777  bool camChange = hic.CameraViewChanged();
1778 
1779  if (IsRaised())
1780  {
1781  if (m_IsWeapon)
1782  {
1783  camChange = false;
1784  }
1785  }
1786 
1788  if (GetGame().GetWorld().Is3rdPersonDisabled())
1789  {
1790  m_Camera3rdPerson = false;
1791  }
1792  else if (camChange)
1793  {
1794  m_Camera3rdPerson = !m_Camera3rdPerson;
1795  }
1796 
1797  // exits optics completely, comment to return to ADS
1798  if (m_LiftWeapon_player && (m_CameraOptics || m_CameraIronsight))
1799  ExitSights();
1800 
1801  if (IsPlayerInStance(DayZPlayerConstants.STANCEMASK_RAISEDPRONE) && (m_CameraOptics || m_CameraIronsight))
1802  GetDayZPlayerType().SetVerticalMinimumAimLimit(DayZPlayerCameraIronsights.CONST_UD_MIN_BACK);
1803  else
1804  GetDayZPlayerType().SetVerticalMinimumAimLimit(DayZPlayerCameraIronsights.CONST_UD_MIN);
1805 
1806  if (hic.IsZoomToggle() && !m_MovementState.IsRaised())
1807  {
1808  m_CameraEyeZoomLevel = ECameraZoomType.NORMAL;
1809  if ((IsClimbingLadder() && Math.AbsInt(m_MovementState.m_iMovement) == 2) || (IsSwimming() && m_MovementState.m_iMovement == 3))
1810  {
1811  m_CameraEyeZoomLevel = ECameraZoomType.SHALLOW;
1812  }
1813  else if (!IsClimbingLadder() && !IsSwimming() && !IsInVehicle())
1814  {
1815  float pSpeed;
1816  vector pLocalDirection;
1817  hic.GetMovement(pSpeed ,pLocalDirection);
1818 
1819  if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT && pSpeed == 3)
1820  {
1821  m_CameraEyeZoomLevel = ECameraZoomType.SHALLOW;
1822  }
1823  }
1824  }
1825  else
1826  {
1827  m_CameraEyeZoomLevel = ECameraZoomType.NONE;
1828  }
1829 
1830  if (m_MovementState.IsRaisedInProne())
1831  {
1832  float headingAngle = MiscGameplayFunctions.GetHeadingAngle(this);
1833  float headingAngleDiffBlock = Math.AbsFloat(m_LastHeadingAngleBlock - headingAngle);
1834  float headingAngleDiffBlock2 = Math.AbsFloat(m_LastHeadingAngleBlock2 - headingAngle);
1835  float headingAngleDiff = 0.0;
1836 
1837  if (m_LastHeadingAngle * headingAngle < 0.0)
1838  {
1839  headingAngleDiff = Math.AbsFloat(m_LastHeadingAngle + headingAngle);
1840  }
1841  else
1842  {
1843  headingAngleDiff = Math.AbsFloat(m_LastHeadingAngle - headingAngle);
1844  }
1845 
1846  if (headingAngleDiff > 0.2)
1847  {
1848  int time = GetGame().GetTime();
1849 
1850  float timefilterconstant = 400 - (headingAngleDiff * 100);
1851 
1852  if (headingAngleDiffBlock > 0.8 && time - m_LastBackSoundTime > timefilterconstant)
1853  {
1854  float volume = headingAngleDiff / 0.5;
1855  if (volume > 1)
1856  {
1857  volume = 1;
1858  }
1859  if (volume < 0.25)
1860  {
1861  volume = 0.25;
1862  }
1863 
1864  m_SoundOffset = headingAngleDiff / 2;
1865  if (m_SoundOffset > 0.25)
1866  {
1867  m_SoundOffset = 0.25;
1868  }
1869 
1870  string soundSetName = "Cloth_Body_longmove_TShirt_Soundset";
1871 
1872  string bodyClothName = "";
1873  EntityAI attachment = GetInventory().FindAttachment(InventorySlots.BODY);
1874  if (attachment)
1875  {
1876  bodyClothName = attachment.GetAttachmentSoundType();
1877  }
1878 
1879  if (bodyClothName != "")
1880  {
1881  string path = "CfgSoundTables CfgAttachmentSoundTables Cloth_Body_Longmove_LookupTable";
1882  int soundCount = GetGame().ConfigGetChildrenCount(path);
1883 
1884  for (int i = 0; i < soundCount; i++)
1885  {
1886  string name = "";
1887  GetGame().ConfigGetChildName(path, i, name);
1888 
1889  if (name == bodyClothName)
1890  {
1891  TStringArray stringArray = new TStringArray();
1892  GetGame().ConfigGetTextArray(path + " " + name + " soundSets", stringArray);
1893  soundSetName = stringArray.Get(0);
1894 
1895  delete stringArray;
1896  }
1897  }
1898  }
1899 
1900  SoundParams soundParams = new SoundParams(soundSetName);
1901  SoundObjectBuilder soundObjectBuilder = new SoundObjectBuilder(soundParams);
1902 
1903  if (soundObjectBuilder != NULL)
1904  {
1905  SoundObject soundObject = soundObjectBuilder.BuildSoundObject();
1906 
1907  if (soundObject != NULL)
1908  {
1909  soundObject.SetPosition(GetPosition());
1910 
1911  AbstractWave wave = GetGame().GetSoundScene().Play3D(soundObject, soundObjectBuilder);
1912  wave.SetStartOffset(m_SoundOffset);
1913  wave.SetVolumeRelative(volume);
1914 
1915  m_LastBackSoundTime = GetGame().GetTime();
1916  m_LastHeadingAngleBlock = headingAngle;
1917  }
1918  }
1919  }
1920 
1921  if (headingAngleDiffBlock2 > 1.5 && time - m_LastBackSoundTime2 > (timefilterconstant * 2))
1922  {
1923  float volume2 = headingAngleDiff * 2;
1924  if (volume2 > 1)
1925  {
1926  volume2 = 1;
1927  }
1928 
1929  m_SoundOffset = headingAngleDiff / 1.8;
1930  if (m_SoundOffset < 0.1)
1931  {
1932  m_SoundOffset = 0.1;
1933  }
1934  if (m_SoundOffset > 0.3)
1935  {
1936  m_SoundOffset = 0.3;
1937  }
1938 
1939  string soundSetName2 = "walkProne_noHS_asphalt_ext_Char_SoundSet";
1940  string surfaceType = GetSurfaceType();
1941 
1942  if (surfaceType != "")
1943  {
1944  string movementSurfaceType = "walkProne_" + surfaceType;
1945 
1946  string path2 = "CfgSoundTables CfgStepSoundTables walkProne_noHS_Char_LookupTable";
1947  int soundCount2 = GetGame().ConfigGetChildrenCount(path2);
1948 
1949  for (int i2 = 0; i2 < soundCount2; i2++)
1950  {
1951  string name2 = "";
1952  GetGame().ConfigGetChildName(path2, i2, name2);
1953 
1954  if (name2 == movementSurfaceType)
1955  {
1956  TStringArray stringArray2 = new TStringArray();
1957  GetGame().ConfigGetTextArray(path2 + " " + name2 + " soundSets", stringArray2);
1958  soundSetName2 = stringArray2.Get(0);
1959 
1960  delete stringArray2;
1961  }
1962  }
1963  }
1964 
1965  SoundParams soundParams2 = new SoundParams(soundSetName2);
1966  SoundObjectBuilder soundObjectBuilder2 = new SoundObjectBuilder(soundParams2);
1967 
1968  if (soundObjectBuilder2 != NULL)
1969  {
1970  SoundObject soundObject2 = soundObjectBuilder2.BuildSoundObject();
1971 
1972  if (soundObject2 != NULL)
1973  {
1974  soundObject2.SetPosition(GetPosition());
1975 
1976  AbstractWave wave2 = GetGame().GetSoundScene().Play3D(soundObject2, soundObjectBuilder2);
1977  wave2.SetStartOffset(m_SoundOffset);
1978  wave2.SetVolumeRelative(volume2);
1979 
1980  m_LastBackSoundTime2 = GetGame().GetTime();
1981  m_LastHeadingAngleBlock2 = headingAngle;
1982  }
1983  }
1984  }
1985 
1986  m_LastHeadingAngle = headingAngle;
1987  }
1988  }
1989  }
1990 
1991  float m_LastHeadingAngleBlock;
1992  float m_LastHeadingAngleBlock2;
1993  float m_LastHeadingAngle;
1994  int m_LastBackSoundTime;
1995  int m_LastBackSoundTime2;
1996  float m_SoundOffset;
1997 
1998 
1999  //-------------------------------------------------------------
2003  // these functions are for modded overide in script command mods
2004 
2005  bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
2006  {
2007  return false;
2008  }
2009 
2010  bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
2011  {
2012  return false;
2013  }
2014 
2015  bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
2016  {
2017  return false;
2018  }
2019 
2020  //-------------------------------------------------------------
2024 
2025 
2027  override void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
2028  {
2029  m_dT = pDt;
2030 
2031  if (ModCommandHandlerBefore(pDt, pCurrentCommandID, pCurrentCommandFinished))
2032  {
2033  return;
2034  }
2035 
2037  EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
2039 
2040  bool isRaisedNow = m_MovementState.IsRaised();
2041  bool isWeapon = entityInHands && entityInHands.IsInherited(Weapon);
2042 
2043  bool updateAimingMdfr = false;
2044  if (isWeapon != m_IsWeapon)
2045  {
2046  m_IsWeapon = isWeapon;
2047  updateAimingMdfr = true;
2048  }
2049 
2050  if (isRaisedNow != m_IsRaised)
2051  {
2052  updateAimingMdfr = true;
2053  m_IsRaised = m_MovementState.IsRaised();
2054  }
2055 
2056  if (updateAimingMdfr)
2057  {
2058  if (isRaisedNow && isWeapon)
2059  GetUApi().ActivateModificator("aiming");
2060  else
2061  GetUApi().DeactivateModificator("aiming");
2062  }
2063 
2064  // handle ADS ironsights/optics transition logic
2065  HandleADS();
2066 
2067  // handle weapons
2068  if (hic)
2069  {
2070  ItemOptics opticInHands = ItemOptics.Cast(entityInHands);
2071  if (isWeapon && (!m_ProcessFirearmMeleeHit || !m_ContinueFirearmMelee))
2072  {
2073  m_ProcessFirearmMeleeHit = false;
2074  bool exitIronSights = false;
2075  HandleWeapons(pDt, entityInHands, hic, exitIronSights);
2076  }
2077  else if (IsHandheldOpticsInUse() && m_CameraOptics && opticInHands)
2078  {
2079  bool exitOptic = false;
2080  HandleOptic(opticInHands, true, hic, exitOptic);
2081  }
2082  }
2083 
2085  HandleView();
2086 
2087  if (m_MovementState.m_iMovement != m_MovementState.m_LocalMovement)
2088  {
2089  OnMovementChanged();
2090  m_MovementState.m_LocalMovement = m_MovementState.m_iMovement;
2091  }
2092 
2094  if (HandleDeath(pCurrentCommandID))
2095  {
2096  return;
2097  }
2098 
2100  if (pCurrentCommandFinished)
2101  {
2102  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
2103  {
2104  if ((m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE) && (m_TransportCache != null))
2105  {
2106  int crew_index = m_TransportCache.CrewMemberIndex(this);
2107  int seat = m_TransportCache.GetSeatAnimationType(crew_index);
2108  StartCommand_Vehicle(m_TransportCache, crew_index, seat, true);
2109  m_TransportCache = null;
2110  return;
2111  }
2112  }
2113  // start moving
2114 
2115  // start falling ? (could happen after climbing)
2116  if (PhysicsIsFalling(true))
2117  {
2118  StartCommand_Fall(0);
2119  SetFallYDiff(GetPosition()[1]);
2120  return;
2121  }
2122 
2124  if (m_Swimming.m_bWasSwimming)
2125  {
2127  return;
2128  }
2129 
2131 
2132  if (GetHumanInventory().GetEntityInHands())
2133  ForceStandUpForHeavyItems(GetHumanInventory().GetEntityInHands());
2134 
2135  return;
2136  }
2137 
2138 
2139  //--------------------------------------------
2141 
2142  if (ModCommandHandlerInside(pDt, pCurrentCommandID, pCurrentCommandFinished))
2143  {
2144  return;
2145  }
2146 
2147 
2148  //--------------------------------------------
2149  // vehicle handling
2150  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_VEHICLE)
2151  {
2153  if (hcv.WasGearChange())
2154  {
2156  cb.SetVehicleCommand(hcv);
2157  }
2158 
2159  return;
2160  }
2161 
2163  //--------------------------------------------
2165  if (hcm && hcm.GetCurrentMovementSpeed() > 2.99 && m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
2166  {
2167  m_SprintedTime += pDt;
2168  if (m_SprintedTime > m_SprintedTimePerStanceMin)
2169  {
2170  m_SprintFull = true;
2171  m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_DEFAULT;
2172  }
2173  else
2174  m_SprintFull = false;
2175  }
2176  else
2177  {
2178  m_SprintedTime = 0.0;
2179  m_SprintFull = false;
2180  }
2181 
2182  //--------------------------------------------
2183  // swimming handling
2184  if (m_Swimming.HandleSwimming(pCurrentCommandID, hcm, m_MovementState))
2185  {
2186  m_JumpClimb.CheckAndFinishJump();
2187  return;
2188  }
2189 
2190  //--------------------------------------------
2191  // ladder handling
2192  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_LADDER)
2193  {
2194  OnLadder(pDt, m_MovementState);
2195  return;
2196  }
2197 
2198  //--------------------------------------------
2199  // climb handling
2200  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_CLIMB)
2201  {
2202  return;
2203  }
2204 
2205  //--------------------------------------------
2206  // fall handling
2207 
2208  if (IsAlreadyInFallingCommand(pCurrentCommandID))
2209  {
2210  if (IsLanded(pCurrentCommandID))
2211  {
2213  NoiseParams npar;
2214 
2215  FallDamageData fallDamageData = new FallDamageData();
2216  fallDamageData.m_Height = m_FallYDiff - GetPosition()[1];
2217 
2218  // land
2219  if (fallDamageData.m_Height < 0.5)
2220  {
2221  fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_NONE;
2222  OnLand(pCurrentCommandID, fallDamageData);
2223  npar = type.GetNoiseParamsLandLight();
2224  AddNoise(npar);
2225  }
2226  else if (fallDamageData.m_Height < 3.0)
2227  {
2228  if (m_MovementState.IsInProne() || m_MovementState.IsInRaisedProne())
2229  fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_NONE;
2230  else
2231  fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_LIGHT;
2232 
2233  OnLand(pCurrentCommandID, fallDamageData);
2234  npar = type.GetNoiseParamsLandLight();
2235  AddNoise(npar);
2236  }
2237  else if (fallDamageData.m_Height < 5.0)
2238  {
2239  fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_MEDIUM;
2240  OnLand(pCurrentCommandID, fallDamageData);
2241  npar = type.GetNoiseParamsLandHeavy();
2242  AddNoise(npar);
2243  }
2244  else
2245  {
2246  fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_HEAVY;
2247  OnLand(pCurrentCommandID, fallDamageData);
2248  npar = type.GetNoiseParamsLandHeavy();
2249  AddNoise(npar);
2250  }
2251 
2252  if (fallDamageData.m_Height >= DayZPlayerImplementFallDamage.HEALTH_HEIGHT_LOW && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2253  {
2254  OnPlayerRecievedHit();
2255  }
2256 
2257  m_FallDamage.HandleFallDamage(fallDamageData);
2258  m_JumpClimb.CheckAndFinishJump(fallDamageData.m_LandType);
2259  }
2260 
2262  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL)
2263  {
2264  return;
2265  }
2266  }
2267  else if (PhysicsIsFalling(false))
2268  {
2269  // Not in a falling command but the controller is falling, start default fall
2270  StartCommand_Fall(0);
2271  SetFallYDiff(GetPosition()[1]);
2272  return;
2273  }
2274 
2275  //--------------------------------------------
2276  // handle jumping
2277 
2278 #ifndef NO_GUI
2279 #ifdef DEVELOPER
2280 
2282  if (DiagMenu.GetEngineValue(DayZPlayerConstants.DEBUG_ENABLEJUMP))
2283  {
2284  SHumanCommandClimbSettings hcls = GetDayZPlayerType().CommandClimbSettingsW();
2285 
2286  if (m_MovementState.m_iMovement != DayZPlayerConstants.MOVEMENTIDX_IDLE)
2287  hcls.m_fFwMaxDistance = 3;
2288  else
2289  hcls.m_fFwMaxDistance = 1.2;
2290 
2291  SHumanCommandClimbResult ret;
2292 
2294  HumanCommandClimb.DoClimbTest(this, ret, 0x3);
2295  }
2296 
2297 #endif
2298 #endif
2299 
2300  // start jump
2301  if (hic.IsJumpClimb())
2302  {
2303  m_JumpClimb.JumpOrClimb();
2304 
2305  if (m_JumpClimb.WasSuccessful())
2306  {
2307  return;
2308  }
2309  }
2310 
2312 
2313  bool force = false;
2314 #ifndef NO_GUI
2315 #ifdef DEVELOPER
2316  force = DiagMenu.GetEngineValue(DayZPlayerConstants.DEBUG_ENABLETALKING);
2318 #endif
2319 #endif
2320  float amplitude = IsPlayerSpeaking();
2321 
2322  if (amplitude > 0.1 || force)
2323  {
2324  if (ad)
2325  ad.SetTalking(true);
2326 
2327  // add noises on server
2328  if (GetGame().IsServer())
2329  {
2330  int now = GetGame().GetTime();
2331  if (now >= m_NextVoNNoiseTime)
2332  {
2333  m_NextVoNNoiseTime = now + 1000;
2334 
2335  int voiceLevel = GetGame().GetVoiceLevel(this);
2337 
2338  // add noise every second while talking
2339  NoiseParams vonpar;
2340  switch (voiceLevel)
2341  {
2342  case VoiceLevelWhisper:
2343  vonpar = pt.GetNoiseParamsWhisper();
2344  break;
2345  case VoiceLevelTalk:
2346  vonpar = pt.GetNoiseParamsTalk();
2347  break;
2348  case VoiceLevelShout:
2349  vonpar = pt.GetNoiseParamsShout();
2350  break;
2351  }
2352  AddNoise(vonpar);
2353  }
2354  }
2355  }
2356  else
2357  {
2358  if (ad)
2359  ad.SetTalking(false);
2360  }
2361 
2362  //--------------------------------------------
2363  // anything whats handled by InputController
2364 
2366 
2367  if (hic)
2368  {
2371  m_Throwing.HandleThrowing(hic, hcw, entityInHands, pDt);
2372 
2374  if (m_MeleeFightLogic.CanFight())
2375  {
2376  if (m_MeleeFightLogic.HandleFightLogic(pCurrentCommandID, hic, entityInHands, m_MovementState, m_ContinueFirearmMelee))
2377  {
2378  m_ProcessFirearmMeleeHit = isWeapon && (hic.IsMeleeWeaponAttack() || m_ProcessFirearmMeleeHit) || m_ContinueFirearmMelee;
2379  return;
2380  }
2381  }
2382  }
2383 
2384 
2386  if (ModCommandHandlerAfter(pDt, pCurrentCommandID, pCurrentCommandFinished))
2387  {
2388  return;
2389  }
2390  }
2391 
2392  void HideClothing(ItemOptics optic, bool state) {}
2393 
2394  //-------------------------------------------------------------
2398 
2399  float m_TestDamageCounter = -1;
2400  float m_DebugDirectionVal = -180;
2401  bool m_DebugTypeVal = false;
2402 
2403  int m_DebugWeaponChangeStage = 0;
2404  string m_DebugWeaponChangeItem;
2405  int m_DebugWeaponChangeShowSlot;
2406 
2408  void CommandHandlerDebug(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
2409  {
2410  if (GetPluginManager())
2411  {
2413  if (playerDebug)
2414  {
2415  playerDebug.CommandHandler();
2416 
2418  if (m_DebugWeaponChangeStage == 0)
2419  {
2420 
2421  // debug weapon change
2422  int hideSlot;
2423 
2424  if (playerDebug.IsWeaponChange(m_DebugWeaponChangeItem, hideSlot, m_DebugWeaponChangeShowSlot))
2425  {
2426  //Print("Change Weapon started: " + m_DebugWeaponChangeItem + "," + hideSlot.ToString() + "," + m_DebugWeaponChangeShowSlot.ToString());
2427 
2429  w.StartAction(WeaponActions.HIDE, hideSlot);
2430 
2431  m_DebugWeaponChangeStage = 1;
2432  }
2433  }
2434  else if (m_DebugWeaponChangeStage == 1)
2435  {
2436  // wait for weapon hide to meet event
2438  if (w2 && w2.GetRunningAction() == WeaponActions.HIDE)
2439  {
2440  if (w2.IsEvent() == WeaponEvents.CHANGE_HIDE)
2441  {
2443  //Print("Change Weapon - hidden: ");
2444 
2446  PlayerBase player = PlayerBase.Cast(this);
2447  EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
2448  if (item_in_hands != NULL && player.CanDropEntity(item_in_hands) && GetGame().GetPlayer().GetHumanInventory().CanRemoveEntityInHands())
2449  {
2450  player.PredictiveDropEntity(item_in_hands);
2451  }
2452 
2453  if (m_DebugWeaponChangeItem != "")
2454  {
2456  dst.SetHands(this, NULL);
2457  EntityAI item = SpawnEntity(m_DebugWeaponChangeItem, dst,ECE_IN_INVENTORY,RF_DEFAULT);
2458  }
2459 
2461  w2.StartAction(WeaponActions.SHOW, 3);
2462 
2463  m_DebugWeaponChangeStage = 2;
2464  }
2465  }
2466  }
2467  else if (m_DebugWeaponChangeStage == 2)
2468  {
2470  if (w3 && w3.IsActionFinished())
2471  {
2472  m_DebugWeaponChangeStage = 0;
2473  }
2474  }
2475  }
2476  }
2477 
2478 
2480  if (m_TestDamageCounter >= 0)
2481  {
2482  if (m_TestDamageCounter > 3)
2483  {
2484  m_DebugDirectionVal = m_DebugDirectionVal + 90;
2485  m_TestDamageCounter = 0;
2486 
2487  if (m_DebugDirectionVal > 90)
2488  {
2489  m_DebugDirectionVal = -180;
2490  m_DebugTypeVal = !m_DebugTypeVal;
2491  }
2492 
2493  if (m_DebugTypeVal)
2494  {
2495  AddCommandModifier_Damage(0, m_DebugDirectionVal); // starts light
2496  }
2497  else
2498  {
2499  StartCommand_Damage(0, m_DebugDirectionVal); // starts heavy (full body)
2500  }
2501  // 0.. types
2502  // from: -180 back, -90 left, 0 front, 90 right, 180 back
2503  //AddCommandModifier_Damage(0, directionVal); // starts light
2504  //StartCommand_Damage(0, 0); // starts heavy (full body)
2505  }
2506 
2507  m_TestDamageCounter += pDt;
2508  }
2509 
2510 
2511 #ifndef NO_GUI
2512 #ifdef DEVELOPER
2513 
2514  // injury / exhaustion
2515  {
2517 
2519  float v = DiagMenu.GetEngineRangeValue(DayZPlayerConstants.DEBUG_SHOWINJURY);
2520  if (v > 0)
2521  {
2522  ad.SetInjured(v, true);
2523  }
2524 
2526  v = DiagMenu.GetEngineRangeValue(DayZPlayerConstants.DEBUG_SHOWEXHAUSTION);
2527  if (v > 0)
2528  {
2529  ad.SetExhaustion(v, true);
2530  }
2531  }
2532 #endif
2533 #endif
2534 
2535  }
2536 
2537 
2538 
2539  //-------------------------------------------------------------
2543  override int CameraHandler(int pCameraMode)
2544  {
2546  if (!m_LiftWeapon_player)
2547  {
2548  ItemOptics optics = null;
2549  EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
2550  Weapon weapon = Weapon.Cast(entityInHands);
2551  if (weapon)
2552  optics = weapon.GetAttachedOptics();
2553  else if (entityInHands)
2554  Class.CastTo(optics,entityInHands);
2555 
2556  if (m_CameraOptics && optics)
2557  {
2558  return DayZPlayerCameras.DAYZCAMERA_OPTICS;
2559  }
2560  else if (m_CameraIronsight && weapon)
2561  {
2562  return DayZPlayerCameras.DAYZCAMERA_IRONSIGHTS;
2563  }
2564  }
2565 
2566  // If the logic above doesn't reach optics nor ironsights camera,
2567  // yet weapon is still raised and ads is wanted, enforce 1pv camera
2568  // as this will reduce erratic behaviour of camera switching in 3pv
2570  if (m_Camera3rdPerson && m_IsWeapon && m_IsRaised && hic && hic.WeaponADS())
2571  {
2572  return DayZPlayerCameras.DAYZCAMERA_1ST;
2573  }
2574 
2575  //uncon
2576  if ( GetCurrentCommandID() == DayZPlayerConstants.COMMANDID_UNCONSCIOUS )
2577  {
2578  return DayZPlayerCameras.DAYZCAMERA_1ST_UNCONSCIOUS;
2579  }
2580 
2581  HumanCommandVehicle vehicleCommand = GetCommand_Vehicle();
2582 
2583  if (!m_Camera3rdPerson)
2584  {
2585  if (vehicleCommand)
2586  {
2587  return DayZPlayerCameras.DAYZCAMERA_1ST_VEHICLE;
2588  }
2589 
2590  return DayZPlayerCameras.DAYZCAMERA_1ST;
2591  }
2592  else
2593  {
2594  if (vehicleCommand)
2595  {
2596  Transport transport = vehicleCommand.GetTransport();
2597  if (transport && GetParent())
2598  {
2599  return transport.Get3rdPersonCameraType();
2600  }
2601  }
2602 
2605 
2609 
2611 
2613 
2614  if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_CLIMB)
2615  {
2616  return DayZPlayerCameras.DAYZCAMERA_3RD_CLIMB;
2617  }
2618 
2619  if (m_JumpClimb.m_bIsJumpInProgress)
2620  {
2621  return DayZPlayerCameras.DAYZCAMERA_3RD_JUMP;
2622  }
2623 
2624  int targetStanceIndex = m_MovementState.m_iStanceIdx;
2625 
2627  HumanCommandMove commandMove = GetCommand_Move();
2628  if (commandMove && commandMove.IsChangingStance() && m_MovementState.IsRaised())
2629  {
2630  targetStanceIndex = m_MovementState.m_iStanceIdx - DayZPlayerConstants.STANCEIDX_RAISED;
2631  }
2632 
2633  //
2634  // normal movement cameras
2635  if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_CROUCH)
2636  {
2637  return DayZPlayerCameras.DAYZCAMERA_3RD_CRO;
2638  }
2639  else if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
2640  {
2641  return DayZPlayerCameras.DAYZCAMERA_3RD_CRO_RAISED;
2642  }
2643  else if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_PRONE)
2644  {
2645  return DayZPlayerCameras.DAYZCAMERA_3RD_PRO;
2646  }
2647  else if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
2648  {
2649  return DayZPlayerCameras.DAYZCAMERA_3RD_PRO_RAISED;
2650  }
2651 
2652  if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
2653  {
2654  if (m_IsWeapon)
2655  {
2656  return DayZPlayerCameras.DAYZCAMERA_3RD_ERC_RAISED;
2657  }
2658  else
2659  {
2660  return DayZPlayerCameras.DAYZCAMERA_3RD_ERC_RAISED_MELEE;
2661  }
2662  }
2663  else if (targetStanceIndex == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
2664  {
2665  return DayZPlayerCameras.DAYZCAMERA_3RD_ERC_SPR;
2666  }
2667 
2668  // DayZPlayerConstants.STANCEIDX_ERECT
2669  return DayZPlayerCameras.DAYZCAMERA_3RD_ERC;
2670  }
2671 
2672  return DayZPlayerCameras.DAYZCAMERA_1ST;
2673  }
2674 
2676  void OnMovementChanged()//(int state_old, int state_new)
2677  {
2678  switch (m_MovementState.m_LocalMovement)
2679  {
2680  case DayZPlayerConstants.MOVEMENTIDX_CROUCH_RUN:
2681  {
2682  //OnCrouchRunEnd();
2683  break;
2684  }
2685  case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
2686  {
2687  OnSprintEnd();
2688  break;
2689  }
2690  case DayZPlayerConstants.MOVEMENTIDX_RUN:
2691  {
2692  //OnRunEnd();
2693  break;
2694  }
2695  case DayZPlayerConstants.MOVEMENTIDX_WALK:
2696  {
2697  //OnWalkEnd();
2698  break;
2699  }
2700  case DayZPlayerConstants.MOVEMENTIDX_IDLE:
2701  {
2702  //OnIdleEnd();
2703  break;
2704  }
2705  case DayZPlayerConstants.MOVEMENTIDX_SLIDE:
2706  {
2707  //OnSlideEnd();
2708  break;
2709  }
2710  }
2711 
2712  switch (m_MovementState.m_iMovement)
2713  {
2714  case DayZPlayerConstants.MOVEMENTIDX_CROUCH_RUN:
2715  {
2716  //OnCrouchRunStart();
2717  break;
2718  }
2719  case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
2720  {
2721  OnSprintStart();
2722  break;
2723  }
2724  case DayZPlayerConstants.MOVEMENTIDX_RUN:
2725  {
2726  //OnRunStart();
2727  break;
2728  }
2729  case DayZPlayerConstants.MOVEMENTIDX_WALK:
2730  {
2731  //OnWalkStart();
2732  break;
2733  }
2734  case DayZPlayerConstants.MOVEMENTIDX_IDLE:
2735  {
2736  //OnIdleStart();
2737  break;
2738  }
2739  case DayZPlayerConstants.MOVEMENTIDX_SLIDE:
2740  {
2741  //OnSlideStart();
2742  break;
2743  }
2744  }
2745  }
2746 
2747  void OnSprintStart()
2748  {
2749  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2750  {
2751  GetUApi().GetInputByID(UALeanLeft).Lock();
2752  GetUApi().GetInputByID(UALeanRight).Lock();
2753  }
2754  }
2755 
2756  void OnSprintEnd()
2757  {
2758  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2759  {
2760  GetUApi().GetInputByID(UALeanLeft).Unlock();
2761  GetUApi().GetInputByID(UALeanRight).Unlock();
2762  }
2763  }
2764  //-------------------------------------------------------------
2768 
2769  void OnInputUserDataReceived(ParamsReadContext ctx)
2770  {
2771  int userDataTypeParam = 0;
2772  if (!ctx.Read(userDataTypeParam))
2773  {
2774  Error("DayZPlayerImplement: cannot read input type");
2775  return;
2776  }
2777 
2778  OnInputUserDataProcess(userDataTypeParam, ctx);
2779  }
2780 
2781  bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
2782  {
2783  m_MeleeCombat.SetTargetObject(null);
2784  m_MeleeCombat.SetHitPos(vector.Zero);
2785  m_MeleeCombat.SetHitZoneIdx(-1);
2786  m_MeleeCombat.SetFinisherType(-1);
2787 
2788  if (userDataType == INPUT_UDT_MELEE_TARGET)
2789  {
2790  EntityAI target = null;
2791  if (ctx.Read(target))
2792  {
2793  m_MeleeCombat.SetTargetObject(target);
2794  }
2795 
2796  vector hitPos = vector.Zero;
2797  if (ctx.Read(hitPos))
2798  {
2799  m_MeleeCombat.SetHitPos(hitPos);
2800  }
2801 
2802  int hitZoneIdx = -1;
2803  if (ctx.Read(hitZoneIdx))
2804  {
2805  m_MeleeCombat.SetHitZoneIdx(hitZoneIdx);
2806  }
2807 
2808  int finisherType = -1;
2809  if (ctx.Read(finisherType))
2810  {
2811  m_MeleeCombat.SetFinisherType(finisherType);
2812  }
2813 
2814  return true;
2815  }
2816 
2817  return false;
2818  }
2819 
2820  //-------------------------------------------------------------
2824  void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
2825  {
2826  switch (pJunctureID)
2827  {
2828  case DayZPlayerSyncJunctures.SJ_DEATH:
2829  if (m_DeathAnimType == -2)
2830  DayZPlayerSyncJunctures.ReadDeathParams(pCtx, m_DeathAnimType, m_DeathHitDir);
2831  break;
2832 
2833  case DayZPlayerSyncJunctures.SJ_DAMAGE_HIT:
2834  SyncHitInfo data = new SyncHitInfo;
2835  if (DayZPlayerSyncJunctures.ReadDamageHitParamsEx(pCtx, data) && data != null)
2836  {
2837  m_SyncedHitDataArray.Insert(data);
2838  }
2839  break;
2840  }
2841  }
2842 
2843  AnimBootsType GetBootsType()
2844  {
2845  EntityAI boots = GetInventory().FindAttachment(InventorySlots.FEET);
2846  if (boots)
2847  {
2848  switch (boots.GetAttachmentSoundType())
2849  {
2850  case "Sneakers":
2851  return AnimBootsType.Sneakers;
2852  case "Boots":
2853  return AnimBootsType.Boots;
2854  }
2855  }
2856 
2857  return AnimBootsType.None;
2858  }
2859 
2860  //Get top body clothes
2861  AnimUpperBodyType GetBodyAttachmentType()
2862  {
2863  EntityAI attachment = GetInventory().FindAttachment(InventorySlots.BODY);
2864  if (attachment)
2865  {
2866  switch (attachment.GetAttachmentSoundType())
2867  {
2868  case "NylonJacket":
2869  return AnimUpperBodyType.NylonJacket;
2870  case "TShirt":
2871  return AnimUpperBodyType.TShirt;
2872  case "WoolShirt":
2873  return AnimUpperBodyType.WoolShirt;
2874  case "HeavyJacket":
2875  return AnimUpperBodyType.HeavyJacket;
2876  case "LeatherJacket":
2877  return AnimUpperBodyType.LeatherJacket;
2878  case "Coat":
2879  return AnimUpperBodyType.Coat;
2880  case "ChemlonDress":
2881  return AnimUpperBodyType.ChemlonDress;
2882  case "Ghillie":
2883  return AnimUpperBodyType.Ghillie;
2884  case "Chainmail":
2885  return AnimUpperBodyType.Chainmail;
2886  }
2887  }
2888 
2889  return AnimUpperBodyType.None;
2890  }
2891 
2892  AnimBackType GetBackAttachmentType()
2893  {
2894  EntityAI back = GetInventory().FindAttachment(InventorySlots.BACK);
2895  if (back)
2896  {
2897  switch (back.GetAttachmentSoundType())
2898  {
2899  case "Small":
2900  return AnimBackType.Small;
2901  case "Military":
2902  return AnimBackType.Military;
2903  case "Outdoor":
2904  return AnimBackType.Outdoor;
2905  case "Ghillie":
2906  return AnimBackType.Ghillie;
2907  }
2908  }
2909 
2910  return AnimBackType.None;
2911  }
2912 
2913  //Get weapon on back
2914  AnimRangedWeaponType GetShoulderAttachmentType()
2915  {
2916  EntityAI shoulderAttachment = GetInventory().FindAttachment(InventorySlots.SHOULDER);
2917  EntityAI meleeAttachment = GetInventory().FindAttachment(InventorySlots.MELEE);
2918 
2919  AnimRangedWeaponType shoulderAttType = AnimRangedWeaponType.None;
2920  AnimRangedWeaponType meleeAttType = AnimRangedWeaponType.None;
2921 
2922  if (shoulderAttachment)
2923  {
2924  switch (shoulderAttachment.GetAttachmentSoundType())
2925  {
2926  case "Shotgun":
2927  {
2928  shoulderAttType = AnimRangedWeaponType.Shotgun;
2929  break;
2930  }
2931  case "Rifle":
2932  {
2933  shoulderAttType = AnimRangedWeaponType.Rifle;
2934  break;
2935  }
2936  }
2937  }
2938  if (meleeAttachment)
2939  {
2940  switch (meleeAttachment.GetAttachmentSoundType())
2941  {
2942  case "Shotgun":
2943  {
2944  meleeAttType = AnimRangedWeaponType.Shotgun;
2945  break;
2946  }
2947  case "Rifle":
2948  {
2949  meleeAttType = AnimRangedWeaponType.Rifle;
2950  break;
2951  }
2952  }
2953  }
2954 
2955  if (shoulderAttType == AnimRangedWeaponType.Shotgun || meleeAttType == AnimRangedWeaponType.Shotgun)
2956  return AnimRangedWeaponType.Shotgun;
2957 
2958  if (shoulderAttType == AnimRangedWeaponType.Rifle || meleeAttType == AnimRangedWeaponType.Rifle)
2959  return AnimRangedWeaponType.Rifle;
2960 
2961  return AnimRangedWeaponType.None;
2962  }
2963 
2964  string GetSurfaceType(SurfaceAnimationBone limbType)
2965  {
2966  string surfaceType;
2967  int liquidType;
2968 
2969  g_Game.SurfaceUnderObjectByBone(this, limbType, surfaceType, liquidType);
2970 
2971  return surfaceType;
2972  }
2973 
2974  //-------------------------------------------------------------
2978 
2980  {
2981  if (so == null)
2982  return null;
2983 
2984  so.SetPosition(GetPosition());
2985  AbstractWave wave = GetGame().GetSoundScene().Play3D(so, sob);
2986  return wave;
2987  }
2988 
2989  void AddNoise(NoiseParams noisePar, float noiseMultiplier = 1.0)
2990  {
2991  if (noisePar != null)
2992  GetGame().GetNoiseSystem().AddNoise(this, noisePar, noiseMultiplier);
2993  }
2994 
2995  //-------------------------------------------------------------
2999 
3000  void OnStepEvent(string pEventType, string pUserString, int pUserInt)
3001  {
3003  ref HumanMovementState state = new HumanMovementState();
3004  GetMovementState(state);
3005 
3006  #ifndef SERVER
3007  DayZPlayerTypeStepSoundLookupTable table = type.GetStepSoundLookupTable();
3008  SoundObjectBuilder soundBuilder = NULL;
3009  if (pUserInt < 100)
3010  {
3011  string surface;
3012  if (pUserInt % 2 == 1)
3013  {
3014  surface = GetSurfaceType(SurfaceAnimationBone.LeftBackLimb);
3015  if (surface.Length() == 0)//if no surface found, try other leg
3016  surface = GetSurfaceType(SurfaceAnimationBone.RightBackLimb);
3017  }
3018  else
3019  {
3020  surface = GetSurfaceType(SurfaceAnimationBone.RightBackLimb);
3021  if (surface.Length() == 0)//if no surface found, try other leg
3022  surface = GetSurfaceType(SurfaceAnimationBone.LeftBackLimb);
3023  }
3024 
3025  if (surface.Length() != 0)
3026  m_LastSurfaceUnderHash = surface.Hash();
3027 
3028  soundBuilder = table.GetSoundBuilder(pUserInt, state.m_iMovement, m_LastSurfaceUnderHash, GetBootsType());
3029  }
3030  else
3031  {
3032  string surface2 = GetSurfaceType();
3033  if (surface2.Length() != 0)
3034  m_LastSurfaceUnderHash = surface2.Hash();
3035 
3036  soundBuilder = table.GetSoundBuilder(pUserInt, state.m_iMovement, m_LastSurfaceUnderHash, GetBootsType());
3037  }
3038 
3039  if (soundBuilder != NULL && GetGame().GetPlayer())
3040  {
3041  vector orientation = Vector(0, 0, 0);
3042  vector edgeLength = Vector(1.5, 3.0, 1.5);
3043  array<Object> excludedObjects = new array<Object>;
3044  array<Object> collidedObjects = new array<Object>;
3045 
3046  if (GetGame().IsBoxColliding(GetPosition(), orientation, edgeLength, excludedObjects, collidedObjects))
3047  {
3048  for (int i = 0; i < collidedObjects.Count(); ++i)
3049  {
3050  string objectClass = collidedObjects.Get(i).GetType();
3051 
3052  if (objectClass.Contains("BushSoft") || objectClass.Contains("BushHard"))
3053  {
3054  for (int j = 0; j < type.GetVegetationSounds().Count(); ++j)
3055  {
3056  VegetationSound vegetationSound = type.GetVegetationSounds().Get(j);
3057 
3058  if (vegetationSound.GetAnimEventIds().Find(pUserInt) >= 0)
3059  {
3060  SoundObjectBuilder vegSoundObjectBuilder = vegetationSound.GetSoundObjectBuilder();
3061  SoundObject vegSoundObject = vegetationSound.GetSoundObjectBuilder().BuildSoundObject();
3062 
3063  if (vegSoundObject != NULL)
3064  {
3065  AttenuateSoundIfNecessary(vegSoundObject);
3066  PlaySound(vegSoundObject, vegSoundObjectBuilder);
3067  }
3068 
3069  break;
3070  }
3071  }
3072 
3073  break;
3074  }
3075  }
3076  }
3077 
3078  SoundObject soundObject = soundBuilder.BuildSoundObject();
3079  if (soundObject != NULL)
3080  {
3081  AttenuateSoundIfNecessary(soundObject);
3082  PlaySound(soundObject, soundBuilder);
3083  }
3084  }
3085  #endif
3086 
3087  if (GetGame().IsServer())
3088  {
3089  m_StepCounter++;//move outside of server condition if needed on client as well
3090 
3091  float noiseMultiplier = 0;
3092 
3093  NoiseParams noiseParams;
3094  if (state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT || state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
3095  noiseParams = type.GetNoiseParamsStand();
3096  else if (state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH || state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
3097  noiseParams = type.GetNoiseParamsCrouch();
3098  else if (state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
3099  noiseParams = type.GetNoiseParamsProne();
3100  else
3101  {
3102  Debug.Log(string.Format("Wrong stance, id: %1 using backup with stand stance (id: 0)", state.m_iStanceIdx));
3103  noiseParams = type.GetNoiseParamsStand();
3104  }
3105 
3106  noiseMultiplier = NoiseAIEvaluate.GetNoiseMultiplier(this);
3107 
3108  AddNoise(noiseParams, noiseMultiplier);
3109 
3110  if ((m_StepCounter % PlayerConstants.CHECK_EVERY_N_STEP) == 0)
3111  {
3112  ProcessFeetDamageServer(pUserInt);
3113  }
3114  }
3115  }
3116 
3117  void OnSoundEvent(string pEventType, string pUserString, int pUserInt)
3118  {
3119  if (pEventType == "Sound")
3120  {
3121  ProcessSoundEvent(pEventType, pUserString, pUserInt);
3122  }
3123  else if (pEventType == "SoundWeapon")
3124  {
3125  ProcessWeaponEvent(pEventType, pUserString, pUserInt);
3126  }
3127  else if (pEventType == "SoundAttachment")
3128  {
3129  ProcessAttachmentEvent(pEventType, pUserString, pUserInt);
3130  }
3131  else if (pEventType == "SoundVoice")
3132  {
3133  if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE)
3134  {
3135  int event_id = m_PlayerSoundEventHandler.ConvertAnimIDtoEventID(pUserInt);
3136  if (event_id > 0)
3137  {
3138  PlaySoundEvent(event_id);
3139  return;
3140  }
3141  }
3142  ProcessVoiceEvent(pEventType, pUserString, pUserInt);
3143  }
3144  else
3145  {
3146  Debug.Log("OnSoundEvent: Unknown sound event \"" + pEventType + "\"");
3147  }
3148  }
3149 
3150  void OnParticleEvent(string pEventType, string pUserString, int pUserInt)
3151  {
3152 
3153  }
3154 
3155 
3156  void ProcessWeaponEvent(string pEventType, string pUserString, int pUserInt)
3157  {
3159  AnimSoundEvent soundEvent = null;
3160 
3161  float quantity = 0;
3162 
3163  EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
3164  if (entityInHands && entityInHands.IsInherited(ItemBase))
3165  {
3166  ItemBase item;
3167  Class.CastTo(item, entityInHands);
3168  if (item.HasQuantity())
3169  quantity = (float)item.GetQuantity() / (item.GetQuantityMax() - item.GetQuantityMin());
3170  InventoryItemType invItemType = item.GetInventoryItemType();
3171  soundEvent = invItemType.GetSoundEvent(pUserInt);
3172  }
3173 
3174  if (soundEvent == null)
3175  {
3176  quantity = 0;
3177  soundEvent = type.GetSoundWeaponEvent(pUserInt);
3178  }
3179 
3180  if (soundEvent != null)
3181  {
3182  if (!GetGame().IsDedicatedServer())
3183  {
3184  SoundObjectBuilder builder = soundEvent.GetSoundBuilderEx(m_ActionSoundCategoryHash);
3185  if (builder)
3186  {
3187  builder.AddVariable("quantity", quantity);
3188  builder.AddVariable("interior", IsSoundInsideBuilding());
3189 
3190  SoundObject soundObject = builder.BuildSoundObject();
3191  if (soundObject != NULL)
3192  {
3193  AttenuateSoundIfNecessary(soundObject);
3194  PlaySound(soundObject, builder);
3195  }
3196  }
3197  else
3198  {
3199  //TODO:Userful error message
3200  }
3201  }
3202 
3203  if (GetGame().IsServer())
3204  {
3205  AddNoise(soundEvent.m_NoiseParams);
3206  }
3207  }
3208  }
3209 
3210  void ProcessAttachmentEvent(string pEventType, string pUserString, int pUserInt)
3211  {
3213  DayZPlayerTypeAttachmentSoundLookupTable table = type.GetAttachmentSoundLookupTable();
3214 
3215  array<string> attachments = new array<string>();
3216  pUserString.Split(",", attachments);
3217  for (int i = 0; i < attachments.Count(); i++)
3218  {
3219  int attachmentHash = -1;
3220  if (attachments[i] == "shoulder")
3221  attachmentHash = GetShoulderAttachmentType();
3222  else if (attachments[i] == "body")
3223  attachmentHash = GetBodyAttachmentType();
3224  else if (attachments[i] == "back")
3225  attachmentHash = GetBackAttachmentType();
3226 
3227  SoundObjectBuilder soundBuilder = table.GetSoundBuilder(pUserInt, attachments[i], attachmentHash);
3228 
3229  if (soundBuilder != NULL)
3230  {
3231  SoundObject soundObject = soundBuilder.BuildSoundObject();
3232  if (soundObject != NULL)
3233  {
3234  AttenuateSoundIfNecessary(soundObject);
3235  PlaySound(soundObject, soundBuilder);
3236  }
3237  }
3238  }
3239  }
3240 
3241  void SetVariablesLadderSoundObjectBuilder(SoundObjectBuilder soundObjectBuilder)
3242  {
3243  if (m_ClimbingLadderType == "wood")
3244  {
3245  soundObjectBuilder.AddVariable("laddertype", 1);
3246  }
3247  else
3248  {
3249  soundObjectBuilder.AddVariable("laddertype", 0);
3250  }
3251 
3252  AnimBootsType pBoots = GetBootsType();
3253 
3254  if (pBoots == AnimBootsType.None)
3255  {
3256  soundObjectBuilder.AddVariable("bare", 1);
3257  soundObjectBuilder.AddVariable("sneakers", 0);
3258  soundObjectBuilder.AddVariable("boots", 0);
3259  }
3260  else if (pBoots == AnimBootsType.Sneakers)
3261  {
3262  soundObjectBuilder.AddVariable("bare", 0);
3263  soundObjectBuilder.AddVariable("sneakers", 1);
3264  soundObjectBuilder.AddVariable("boots", 0);
3265  }
3266  else if (pBoots == AnimBootsType.Boots)
3267  {
3268  soundObjectBuilder.AddVariable("bare", 0);
3269  soundObjectBuilder.AddVariable("sneakers", 0);
3270  soundObjectBuilder.AddVariable("boots", 1);
3271  }
3272  }
3273 
3274  void ProcessSoundEvent(string pEventType, string pUserString, int pUserInt)
3275  {
3277  DayZPlayerTypeAnimTable table = type.GetSoundTable();
3278  AnimSoundEvent soundEvent;
3279  if (table)
3280  {
3281  soundEvent = table.GetSoundEvent(pUserInt);
3282  }
3283 
3284  if (soundEvent != NULL)
3285  {
3286  if (!GetGame().IsDedicatedServer())
3287  {
3288  SoundObjectBuilder objectBuilder = soundEvent.GetSoundBuilder();
3289  if (GetCommand_Ladder())
3290  {
3291  SetVariablesLadderSoundObjectBuilder(objectBuilder);
3292  }
3293  objectBuilder.AddEnvSoundVariables(GetPosition());
3294 
3295  SoundObject soundObject = objectBuilder.BuildSoundObject();
3296  if (soundObject != NULL)
3297  {
3298  AttenuateSoundIfNecessary(soundObject);
3299  PlaySound(soundObject, objectBuilder);
3300  }
3301  }
3302 
3303  if (GetGame().IsServer())
3304  {
3305  if (soundEvent.m_NoiseParams != NULL)
3306  GetGame().GetNoiseSystem().AddNoise(this, soundEvent.m_NoiseParams);
3307  }
3308  }
3309  }
3310 
3311 
3312 
3313  AbstractWave ProcessVoiceEvent(string pEventType, string pUserString, int pUserInt)
3314  {
3315  #ifdef SERVER//none of this code needs to run on server, ifdef put here rather than before the method call to maintain mod compatibility
3316  return null;
3317  #endif
3319  DayZPlayerTypeVoiceSoundLookupTable table = type.GetVoiceSoundLookupTable();
3320  if (!table)
3321  return null;
3322  AbstractWave wave;
3323  EntityAI mask = GetInventory().FindAttachment(InventorySlots.MASK);
3324  EntityAI head_gear = GetInventory().FindAttachment(InventorySlots.HEADGEAR);
3325 
3326  string category;
3327  if (mask || head_gear)
3328  {
3329  string category_mask;
3330  string category_headgear;
3331 
3332  int priority_mask;
3333  int priority_headgear;
3334 
3335  if (mask)
3336  {
3337  category_mask = mask.ConfigGetString("soundVoiceType");
3338  priority_mask = mask.ConfigGetInt("soundVoicePriority");
3339  }
3340  if (head_gear)
3341  {
3342  category_headgear = head_gear.ConfigGetString("soundVoiceType");
3343  priority_headgear = head_gear.ConfigGetInt("soundVoicePriority");
3344  }
3345 
3346  if (priority_headgear >= priority_mask && category_headgear != "")
3347  {
3348  category = category_headgear;
3349  }
3350  else
3351  {
3352  category = category_mask;
3353  }
3354  }
3355 
3356  if (category == "")
3357  {
3358  category = "none";
3359  }
3360 
3361  SoundObjectBuilder soundBuilder = table.GetSoundBuilder(pUserInt, category.Hash());
3362 
3363  if (soundBuilder)
3364  {
3365  PlayerBase player = PlayerBase.Cast(this);
3366  //this code block looks super shady, but it's the only way the sounds play correctly, god knows what's going on on c++ side
3367  int maleVoiceType = 0;
3368  int femaleVoiceType = 0;
3369  if (player.IsMale())
3370  {
3371  maleVoiceType = player.GetVoiceType();
3372  }
3373  else
3374  {
3375  femaleVoiceType = player.GetVoiceType();
3376  }
3377 
3378  soundBuilder.AddVariable("male", maleVoiceType);
3379  soundBuilder.AddVariable("female", femaleVoiceType);
3380 
3381  // end of weirdness
3382  SoundObject soundObject = soundBuilder.BuildSoundObject();
3383  if (soundObject != NULL)
3384  {
3385  AttenuateSoundIfNecessary(soundObject);
3386  wave = PlaySound(soundObject, soundBuilder);
3387  }
3388 
3389  }
3390 
3391  return wave;
3392  }
3393 
3394  void ProcessFeetDamageServer(int pUserInt);
3395 
3396 
3397  //-------------------------------------------------------------
3401 
3402  bool CheckForTakeItem(EntityAI item)
3403  {
3404  bool restrained = IsRestrained(); // IsRestrained()
3405  bool unconscious = IsUnconscious(); // IsRestrained()
3406 
3407  ItemBase ib = ItemBase.Cast(item);
3408  if (ib && (PlayerBase.DEBUG_INVENTORY_ACCESS || !IsAlive() || restrained || unconscious || ib.CanBeMovedOverride()))
3409  return true;
3410  return false;
3411  }
3412 
3413  bool CheckForDropItem(EntityAI item)
3414  {
3415  /*
3416  bool restrained = IsRestrained(); // IsRestrained()
3417  bool unconscious = IsUnconscious(); // IsRestrained()
3418 
3419  ItemBase ib = ItemBase.Cast(item);
3420  if (!IsAlive() || restrained || unconscious || ib.CanBeMovedOverride())
3421  return true;
3422  return false;
3423  */
3424  return CheckForTakeItem(item); //the two functions are currently identical
3425  }
3426 
3427  //-------------------------------------------------------------
3431  bool CheckForRespawn(EntityAI item)
3432  {
3433  PlayerBase player = PlayerBase.Cast(this);
3434  if (!player)
3435  return true;
3436 
3437  if (!IsAlive() || player.IsUnconscious())
3438  return true;
3439  return false;
3440  }
3441 
3442 #ifdef DEVELOPER
3443 
3444  // -------------------------------------------------------------------------
3445  override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
3446  {
3447  super.OnRPC(sender, rpc_type, ctx);
3448 
3449  if (rpc_type == ERPCs.RPC_DAYZPLAYER_DEBUGSERVERWALK)
3450  {
3451  Print("ERPCs.RPC_DAYZPLAYER_DEBUGSERVERWALK");
3452 
3453  Param1<bool> rp = new Param1<bool>(false);
3454  ctx.Read(rp);
3455 
3456  GetInputController().OverrideMovementSpeed(rp.param1, 1);
3457  GetInputController().OverrideAimChangeX(rp.param1, 0.01);
3458 
3459  }
3460  }
3461 
3462 #endif
3463 
3464  bool IsLanded(int pCurrentCommandID)
3465  {
3466  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL)
3467  {
3469 
3470  if (fall)
3471  {
3472  return fall.PhysicsLanded();
3473  }
3474  }
3475 
3476  return false;
3477  }
3478 
3479  bool OnLand(int pCurrentCommandID, FallDamageData fallDamageData)
3480  {
3481  if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL)
3482  {
3484 
3485  if (fall)
3486  {
3487  fall.Land(fallDamageData.m_LandType);
3488  return true;
3489  }
3490  }
3491 
3492  return false;
3493  }
3494 
3495  bool IsAlreadyInFallingCommand(int pCurrentCommandID)
3496  {
3497  return pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL;
3498  }
3499 
3501  void OverrideSlidePoseAngle(float value)
3502  {
3503  if (!m_MoveSettings)
3504  m_MoveSettings = GetDayZPlayerType().CommandMoveSettingsW();
3505  if (m_MoveSettings.m_fSlidingPoseAngle != value)
3506  {
3507  m_MoveSettings.m_fSlidingPoseAngle = value;
3508  StartCommand_Move(); //nescessary, re-initializes with adjusted values
3509  }
3510  }
3511 
3512  float GetSlidePoseAngle()
3513  {
3514  return GetDayZPlayerType().CommandMoveSettingsW().m_fSlidingPoseAngle;
3515  }
3516 
3517  void CheckAnimationOverrides()
3518  {
3519  }
3520 
3521  bool IsPlayerSelected()
3522  {
3523  return m_PlayerSelected;
3524  }
3525 
3526  bool IsRestrained();
3527 
3529  bool IsInFBEmoteState();
3530 
3531  void SetSuicide(bool state)
3532  {
3533  m_Suicide = state;
3534  }
3535 
3536  bool CommitedSuicide()
3537  {
3538  return m_Suicide;
3539  }
3540 
3542  void OnLadder(float delta_time, HumanMovementState pState);
3543 
3544  //-------------------------------------------------------------
3548 
3549  override protected void EOnContact(IEntity other, Contact extra)
3550  {
3551  if (!IsAlive())
3552  return;
3553 
3554  if (GetParent() == other)
3555  return;
3556 
3557  Transport transport = Transport.Cast(other);
3558  if (transport)
3559  {
3560  if (GetGame().IsServer())
3561  {
3562  RegisterTransportHit(transport);
3563  }
3564  }
3565  }
3566 
3567  protected void AttenuateSoundIfNecessary(SoundObject soundObject)
3568  {
3569  if (GetGame().GetPlayer() != NULL && (IsSoundInsideBuilding() != GetGame().GetPlayer().IsSoundInsideBuilding() || IsCameraInsideVehicle() != GetGame().GetPlayer().IsCameraInsideVehicle()))
3570  {
3571  soundObject.SetKind(WaveKind.WAVEATTALWAYS);
3572  }
3573  else
3574  {
3575  soundObject.SetKind(WaveKind.WAVEEFFECTEX);
3576  }
3577  }
3578 
3579  void CheckLiftWeapon();
3580  void ProcessLiftWeapon();
3581 
3582  void SetHandheldOpticsInUse(bool state)
3583  {
3584  m_HandheldOpticsInUse = state;
3585  }
3586 
3587  bool IsHandheldOpticsInUse()
3588  {
3589  return m_HandheldOpticsInUse;
3590  }
3591 
3592  bool IsLiftWeapon();
3593  bool IsRaised()
3594  {
3595  return m_IsRaised;
3596  }
3597 
3598  bool IsFighting();
3599 
3601  // Will return true when the item is not heavy as well
3602  bool CanPickupHeavyItem(notnull EntityAI item)
3603  {
3604  return !item.IsHeavyBehaviour() || (item.IsHeavyBehaviour() && DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_ERECT));
3605  }
3606 
3607  bool CanPickupHeavyItemSwap(notnull EntityAI item1, notnull EntityAI item2)
3608  {
3609  return CanPickupHeavyItem(item1) && CanPickupHeavyItem(item2);
3610  }
3611 
3612 #ifdef DIAG_DEVELOPER
3613  Weapon_Base SpawnWeaponInHands(string type)
3614  {
3615  return Weapon_Base.Cast(GetHumanInventory().CreateInHands(type));
3616  }
3617 #endif
3618 
3620 //Obsolete stuff below this point//
3622 
3623  protected bool m_CameraEyeZoom; //DEPRECATED
3624  ref Timer m_ADSAutomationTimer; //DEPRECATED
3625  protected bool m_ADSTimerLaunched; //DEPRECATED
3626  protected bool m_ProcessWeaponRaiseCompleted; //DEPRECATED
3627  protected bool m_IsFireWeaponRaised; //DEPRECATED, value still set for legacy reasons
3628  void SetReturnToOptics(bool state); //DEPRECATED
3629  void RunADSTimer(); //DEPRECATED
3630  void StopADSTimer(); //DEPRECATED
3631 }
ItemBase
Definition: inventoryitem.c:730
Param2< float, float >
DayZPlayerImplementSwimming
Definition: dayzplayerimplementswimming.c:2
INPUT_DEVICE_GAMEPAD
const int INPUT_DEVICE_GAMEPAD
Definition: constants.c:28
RF_DEFAULT
const int RF_DEFAULT
Definition: centraleconomy.c:65
GetGame
proto native CGame GetGame()
CameraHandler
int CameraHandler(int pCameraMode)
-------------— camera handling ----------------------—
ResetDeathCooldown
proto native void ResetDeathCooldown()
GetCommand_Fall
proto native HumanCommandFall GetCommand_Fall()
HumanCommandAdditives
class HumanCommandWeapons HumanCommandAdditives()
Definition: human.c:1099
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
GearChangeActionCallback
Definition: dayzplayerimplementvehicle.c:1
AddCommandModifier_Damage
proto native HumanCommandDamage AddCommandModifier_Damage(int pType, float pDirection)
— modifier for light Damages
LogManager
Definition: debug.c:734
GetCommand_Ladder
proto native HumanCommandLadder GetCommand_Ladder()
HeadingModel
bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
OnInputForRemote
void OnInputForRemote(ParamsReadContext ctx)
Definition: dayzplayer.c:1273
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
DayZPlayerUtils
private void DayZPlayerUtils()
cannot be instantiated
Definition: dayzplayerutils.c:461
DayZPlayerTypeVoiceSoundLookupTable
Definition: dayzplayercfgsounds.c:167
DayZPlayerImplementJumpClimb
Definition: dayzplayerimplementjumpclimb.c:1
DiagMenu
Definition: endebug.c:232
TStringArray
array< string > TStringArray
Definition: enscript.c:685
HumanCommandDeathCallback
Definition: human.c:595
GetMovementState
proto native void GetMovementState(HumanMovementState pState)
returns movement state (current command id, )
DayZPlayerInventory
Definition: dayzplayerinventory.c:111
EStaminaModifiers
EStaminaModifiers
Definition: estaminamodifiers.c:1
ModCommandHandlerAfter
bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition: dayzanimal.c:136
GetCommand_Damage
proto native HumanCommandFullBodyDamage GetCommand_Damage()
HumanCommandMelee2
Definition: human.c:536
AimingModel
bool AimingModel(float pDt, SDayZPlayerAimingModel pModel)
-------------— aiming model ----------------------—
OnJumpStart
void OnJumpStart()
SpawnEntity
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
ForceStandUpForHeavyItems
void ForceStandUpForHeavyItems(notnull EntityAI item)
-------------— Forces player to stand up when swapping to heavy item ----------------------—
Definition: dayzplayer.c:1302
OnInputFromServer
void OnInputFromServer(ParamsReadContext ctx)
Definition: dayzplayer.c:1274
DayZPlayerType
private void DayZPlayerType()
Definition: dayzplayer.c:512
Weapon
script counterpart to engine's class Weapon
Definition: inventoryitem.c:48
SDayZPlayerAimingModel
Definition: dayzplayer.c:1088
OnItemInHandsChanged
class HumanItemBehaviorCfg OnItemInHandsChanged(bool pInstant=false)
signalization from script to engine that item in hands changed
Print
proto void Print(void var)
Prints content of variable to console/log.
GetDayZPlayerType
proto native DayZPlayerType GetDayZPlayerType()
returns appropriate DayZPlayerType
GetInstanceType
proto native DayZPlayerInstanceType GetInstanceType()
DayZPlayerMeleeFightLogic_LightHeavy
void DayZPlayerMeleeFightLogic_LightHeavy(DayZPlayerImplement player)
Definition: dayzplayermeleefightlogic_lightheavy.c:31
IsProcessing
bool IsProcessing()
Definition: dayzplayerinventory.c:2383
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
WeaponEvents
WeaponEvents
events
Definition: human.c:955
SDayZPlayerHeadingModel
private void SDayZPlayerHeadingModel()
cannot be created from script
Definition: dayzplayer.c:1080
SoundObject
class SoundObjectBuilder SoundObject(SoundParams soundParams)
DayZPlayerImplementMeleeCombat
void DayZPlayerImplementMeleeCombat(DayZPlayerImplement player)
Definition: dayzplayerimplementmeleecombat.c:90
IsEyeZoom
bool IsEyeZoom()
DEPRICATED(use GetEyeZoomLevel()) returns true if player is using EyeZoom, otherwise false.
PlayerSoundEventHandler
void PlayerSoundEventHandler(PlayerBase player)
Definition: playersoundeventhandler.c:49
CommandHandler
void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
-------------— command handling ----------------------—
m_MeleeCombat
protected ref DayZPlayerImplementMeleeCombat m_MeleeCombat
Definition: dayzplayermeleefightlogic_lightheavy.c:20
DayZInfected
Definition: zombiebase.c:1
PhysicsSetRagdoll
proto native void PhysicsSetRagdoll(bool pEnable)
Sets and synchronize interaction layers 'RAGDOLL' and 'RAGDOLL_NO_CHARACTER' to prevent body stacking...
ECameraZoomType
ECameraZoomType
Definition: ecamerazoomtype.c:1
OnSimulationEnd
class DeathEffectTimer extends Timer OnSimulationEnd
Definition: dayzplayerimplement.c:54
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
DayZPlayerImplementAiming
Definition: dayzplayerimplementaiming.c:31
SoundObjectBuilder
void SoundObjectBuilder(SoundParams soundParams)
StartCommand_Fall
proto native HumanCommandFall StartCommand_Fall(float pYVelocity)
--— FALL --—
GetCurrentCommandID
proto native int GetCurrentCommandID()
returns current command ID (see DayZPlayerConstants.COMMANDID_...)
PluginDayzPlayerDebug
void PluginDayzPlayerDebug()
Definition: plugindayzplayerdebug.c:275
VegetationSound
Definition: dayzplayer.c:190
WeaponDebug
Definition: weapondebug.c:11
GetCommandModifier_Additives
proto native HumanCommandAdditives GetCommandModifier_Additives()
default (always-on modifiers)
AnimBootsType
AnimBootsType
Definition: dayzanimevents.c:97
DayZPlayer
Definition: dayzplayerimplement.c:72
SHumanCommandMoveSettings
class SHumanGlobalSettings SHumanCommandMoveSettings()
Definition: humansettings.c:12
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
DayZPlayerCameras
Definition: dayzplayercameras.c:1
IsPlayerInStance
bool IsPlayerInStance(int pStanceMask)
-------------— camera additiona functions ----------------------—
Definition: dayzplayer.c:1264
DayZPlayerTypeStepSoundLookupTable
Definition: dayzplayer.c:146
IEntity
Definition: enentity.c:164
HumanMovementState
Definition: human.c:1125
GetItemAccessor
proto native HumanItemAccessor GetItemAccessor()
AbortWeaponEvent
void AbortWeaponEvent()
Definition: dayzplayerinventory.c:269
m_MovementState
ref HumanMovementState m_MovementState
movement state
Definition: dayzplayercamera3rdperson.c:155
WeaponActions
WeaponActions
actions
Definition: human.c:808
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
IsRaised
bool IsRaised()
Definition: human.c:1127
EOnContact
override void EOnContact(IEntity other, Contact extra)
Definition: easteregg.c:112
IsPlayerSpeaking
proto native float IsPlayerSpeaking()
-------------— speaking anim ----------------------—
SetCurrentWaterLevel
void SetCurrentWaterLevel(float pWaterLevel)
OnInputUserDataProcess
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Definition: emotemanager.c:497
NoiseAIEvaluate
Definition: sensesaievaluate.c:1
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
DayZPlayerImplementHeading
Definition: dayzplayerimplementheading.c:10
ModCommandHandlerInside
bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition: dayzanimal.c:131
HumanCommandClimb
command itself
Definition: human.c:771
PhysicsSetSolid
proto native void PhysicsSetSolid(bool pSolid)
SoundParams
Definition: sound.c:100
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
StartCommand_Swim
proto native HumanCommandSwim StartCommand_Swim()
--— LADDER --—
PlayerBase
Definition: playerbaseclient.c:1
IsInThirdPerson
bool IsInThirdPerson()
return true if player is currently in 3pp, otherwise false
PlayerConstants
Definition: playerconstants.c:1
vector
Definition: enconvert.c:105
SHumanCommandClimbSettings
class SHumanCommandSwimSettings SHumanCommandClimbSettings()
Definition: humansettings.c:74
GetCommand_Melee2
proto native HumanCommandMelee2 GetCommand_Melee2()
EStaminaConsumers
EStaminaConsumers
Definition: estaminaconsumers.c:1
NoiseParams
class ObjectSpawnerHandler NoiseParams
HumanCommandFall
class HumanCommandMelee2 HumanCommandFall()
Definition: human.c:574
INPUT_UDT_INVENTORY
const int INPUT_UDT_INVENTORY
Definition: _constants.c:9
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
SyncedValue
Definition: syncedvalue.c:1
IsShootingFromCamera
bool IsShootingFromCamera()
return true if shots are fired from camere, otherwise false
DayZPlayerImplementThrowing
Definition: dayzplayerimplementthrowing.c:1
TotalDamageResult
Definition: damagesystem.c:1
GetEyeZoomLevel
int GetEyeZoomLevel()
returns eye zoom level, uses ECameraZoomType values
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
HumanCommandMove
Definition: human.c:433
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
DayZPlayerTypeAttachmentSoundLookupTable
Definition: dayzplayer.c:170
GetDebugText
string GetDebugText()
Definition: modifierbase.c:68
GetInputController
proto native HumanInputController GetInputController()
returns human input controller
Object
Definition: objecttyped.c:1
EEKilled
override void EEKilled(Object killer)
Definition: remotedetonator.c:242
KillerData
Definition: killerdata.c:1
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
WaveKind
WaveKind
Definition: sound.c:1
AddCommandModifier_Action
proto native HumanCommandActionCallback AddCommandModifier_Action(int pActionID, typename pCallbackClass)
adds action command modifier, creates callback instance for you
Contact
Definition: enphysics.c:300
EEHitBy
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition: broom.c:43
DayZPlayerSyncJunctures
Definition: dayzplayersyncjunctures.c:4
HumanCommandUnconscious
Definition: human.c:619
DayZPlayerImplement
Definition: manbase.c:1
DayZPlayerImplementFallDamage
void DayZPlayerImplementFallDamage(DayZPlayer pPlayer)
Definition: dayzplayerimplementfalldamage.c:73
AddNoise
proto void AddNoise(EntityAI source_entity, NoiseParams noise_params, float external_strenght_multiplier=1.0)
HumanInputController
Definition: human.c:17
GetPluginManager
PluginManager GetPluginManager()
Returns registred plugin by class type, better is to use global funtion GetPlugin(typename plugin_typ...
Definition: pluginmanager.c:274
INPUT_UDT_MELEE_TARGET
const int INPUT_UDT_MELEE_TARGET
Definition: _constants.c:6
HumanCommandVehicle
Definition: human.c:689
DayZPlayerCommandDeathCallback
Definition: dayzplayerimplement.c:10
FallDamageData
Definition: dayzplayerimplementfalldamage.c:1
array< ref SyncHitInfo >
INPUT_DEVICE_MOUSE
const int INPUT_DEVICE_MOUSE
Definition: constants.c:24
StartCommand_Damage
proto native HumanCommandFullBodyDamage StartCommand_Damage(int pType, float pDirection)
--— FullBody Damages --—
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
INPUT_UDT_HAND_REMOTE_EVENT
const int INPUT_UDT_HAND_REMOTE_EVENT
Definition: _constants.c:14
m_pPlayer
PlayerBase m_pPlayer
Definition: dayzplayerimplement.c:39
HumanCommandWeapons
Definition: human.c:986
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
StartCommand_Move
proto native HumanCommandMove StartCommand_Move()
--— MOVE --—
Debug
Definition: debug.c:13
StartCommand_Death
proto native HumanCommandDeathCallback StartCommand_Death(int pType, float pDirection, typename pCallbackClass, bool pKeepInLocalSpaceAfterLeave=false)
--— Death --—
Entity
Definition: camera.c:1
IsLeavingUncon
proto native bool IsLeavingUncon()
return true if character transitions out of uncon
ModCommandHandlerBefore
bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition: dayzanimal.c:126
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
HumanItemBehaviorCfg
Definition: humanitems.c:5
SoundObjectBuilder
Definition: sound.c:45
PlaySound
void PlaySound()
Definition: hungersoundhandler.c:38
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition: effect.c:405
ERPCs
ERPCs
Definition: erpcs.c:1
Timer
Definition: dayzplayerimplement.c:62
GetCommand_Vehicle
proto native HumanCommandVehicle GetCommand_Vehicle()
PhysicsIsFalling
proto native bool PhysicsIsFalling(bool pValidate)
returns true if physics controller is falling
syncDebugPrint
void syncDebugPrint(string s)
Definition: debug.c:1
InventoryItemType
Definition: inventoryitemtype.c:1
ItemOptics
Definition: itemoptics.c:1
GetCommand_Unconscious
proto native HumanCommandUnconscious GetCommand_Unconscious()
HumanItemAccessor
private void HumanItemAccessor()
Definition: humanitems.c:141
GetUApi
proto native UAInputAPI GetUApi()
OnSyncJuncture
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
Definition: emotemanager.c:529
INPUT_DEVICE_KEYBOARD
const int INPUT_DEVICE_KEYBOARD
Definition: constants.c:23
GetInput
ActionInput GetInput()
Definition: actionbase.c:1066
Math
Definition: enmath.c:6
INPUT_UDT_WEAPON_REMOTE_EVENT
const int INPUT_UDT_WEAPON_REMOTE_EVENT
Definition: _constants.c:12
EPlayerSoundEventID
EPlayerSoundEventID
Definition: playersoundeventhandler.c:1
StartCommand_Vehicle
proto native HumanCommandVehicle StartCommand_Vehicle(Transport pTransport, int pTransportPositionIndex, int pVehicleSeat, bool fromUnconscious=false)
--— VEHICLE --—
GetCommandModifier_Weapons
proto native HumanCommandWeapons GetCommandModifier_Weapons()
returns interface for handling weapons
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
AbstractWave
Definition: sound.c:118
UAInterface
Definition: uainput.c:95
OnlineServices
Definition: onlineservices.c:1
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
EntityAI
Definition: building.c:5
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
float
Definition: enconvert.c:96
Stop
void Stop()
Stops all elements this effect consists of.
Definition: effect.c:179
GetCommand_Move
proto native HumanCommandMove GetCommand_Move()
GetCEApi
proto native CEApi GetCEApi()
Get the CE API.
ECE_IN_INVENTORY
const int ECE_IN_INVENTORY
Definition: centraleconomy.c:36
GetCurrentWaterLevel
float GetCurrentWaterLevel()
path
string path
Definition: optionselectormultistate.c:135
WeaponManager
Definition: weaponmanager.c:1
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition: dayzplayer.c:1058