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