DayZ 1.24
Loading...
Searching...
No Matches
DayZPlayerImplement.c File Reference

Go to the source code of this file.

Classes

class  DayZPlayerCommandDeathCallback
 
class  Timer
 
class  DayZPlayer
 

Functions

override bool ShouldSimulationBeDisabled ()
 

Variables

PlayerBase m_pPlayer
 
class DeathEffectTimer extends Timer OnSimulationEnd
 

Function Documentation

◆ ShouldSimulationBeDisabled()

override bool OnSimulationEnd::ShouldSimulationBeDisabled ( )

Definition at line 83 of file DayZPlayerImplement.c.

148 {
149 m_SprintFull = false;
150 m_SprintedTime = 0;
151 m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_DEFAULT;
152 m_AimingModel = new DayZPlayerImplementAiming(this);
154 m_MeleeFightLogic = new DayZPlayerMeleeFightLogic_LightHeavy(this);
155 m_Swimming = new DayZPlayerImplementSwimming(this);
156 m_Throwing = new DayZPlayerImplementThrowing(this);
157 m_JumpClimb = new DayZPlayerImplementJumpClimb(this);
158 m_FallDamage = new DayZPlayerImplementFallDamage(this);
159 m_ADSAutomationTimer = new Timer();
160 m_bADS = false;
161 m_WeaponRaiseCompleted = false;
162 SetOptics(false);
163 m_IsShootingFromCamera = true;
164 m_ProcessFirearmMeleeHit = false;
165 m_ContinueFirearmMelee = false;
166 m_WasIronsight = true; //initially uses ironsights by default
167#ifdef PLATFORM_CONSOLE
168 m_Camera3rdPerson = !GetGame().GetWorld().Is3rdPersonDisabled();
169#endif
170 m_LastSurfaceUnderHash = ("cp_gravel").Hash();
171 m_NextVoNNoiseTime = 0;
172 m_SyncedHitDataArray = new array<ref SyncHitInfo>;
173 m_CurrentWaterLevel = 0;
174 m_WeaponRaiseTime = 0;
175
176 RegisterNetSyncVariableBoolSignal("m_TriggerPullPlayerOutOfVehicleSynch");
177 }
178
179 DayZPlayerImplementAiming GetAimingModel()
180 {
181 return m_AimingModel;
182 }
183
184 DayZPlayerImplementMeleeCombat GetMeleeCombat()
185 {
186 return m_MeleeCombat;
187 }
188
189 DayZPlayerMeleeFightLogic_LightHeavy GetMeleeFightLogic()
190 {
191 return m_MeleeFightLogic;
192 }
193
194 DayZPlayerImplementThrowing GetThrowing()
195 {
196 return m_Throwing;
197 }
198
199 DayZPlayerImplementFallDamage GetFallDamage()
200 {
201 return m_FallDamage;
202 }
203
205 {
206 }
207
209 override bool IsEyeZoom()
210 {
211 return GetEyeZoomLevel() > 0;
212 }
213
214 override int GetEyeZoomLevel()
215 {
216 return m_CameraEyeZoomLevel;
217 }
218
219 override bool IsShootingFromCamera()
220 {
221 return m_IsShootingFromCamera;
222 }
223
224 void OverrideShootFromCamera(bool pState)
225 {
226 m_IsShootingFromCamera = pState;
227 }
228
229 bool IsInIronsights()
230 {
231 return m_CameraIronsight;
232 }
233
234 bool IsInOptics()
235 {
236 return m_CameraOptics;
237 }
238
239 override bool IsInThirdPerson()
240 {
241 return m_Camera3rdPerson;
242 }
243
244 void SetIsInThirdPerson(bool state)
245 {
246 m_Camera3rdPerson = state;
247 }
248
249 bool IsFireWeaponRaised()
250 {
252 if (m_MovementState)
253 return m_MovementState.IsRaised();
254
255 return false;
256 }
257
258 bool IsTryingHoldBreath()
259 {
260 return m_IsTryingHoldBreath;
261 }
262
263 bool IsSprintFull()
264 {
265 return m_SprintFull;
266 }
267
268 void ShowWeaponDebug(bool show)
269 {
270 if (show)
271 m_WeaponDebug = new WeaponDebug;
272 else
273 m_WeaponDebug = null;
274 }
275
276 bool IsWeaponDebugEnabled()
277 {
278 return m_WeaponDebug != null;
279 }
280
281 void SetFallYDiff(float value)
282 {
283 m_FallYDiff = value;
284 }
285
286 override float GetCurrentWaterLevel()
287 {
288 return m_CurrentWaterLevel;
289 }
290
291 override void SetCurrentWaterLevel(float pWaterLevel)
292 {
293 m_CurrentWaterLevel = pWaterLevel;
294 }
295
296 void SetIronsights(bool value)
297 {
298 Weapon_Base weapon = Weapon_Base.Cast(GetHumanInventory().GetEntityInHands());
299 if (weapon)
300 m_WasIronsight = m_CameraIronsight;
301
302 m_CameraIronsight = value;
303
304 if (value)
305 {
307 if (hcw)
308 hcw.SetADS(true);
309 }
310 }
311
312 void SetOptics(bool value)
313 {
314 m_CameraOptics = value;
315
316 if (value)
317 {
319 if (hcw)
320 hcw.SetADS(!IsHandheldOpticsInUse());
321 }
322 }
323
324 void ExitSights()
325 {
327 EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
329 if (weapon)
330 optics = weapon.GetAttachedOptics();
331 else
333
334 SetIronsights(false);
335 SetOptics(false);
336
337 if (optics)
338 SwitchOptics(optics, false);
339
341 if (hcw)
342 hcw.SetADS(false);
343 }
344
345 void SwitchOptics(ItemOptics optic, bool state)
346 {
347 if (optic)
348 {
349 if (state)
350 {
351 if (optic.HasEnergyManager())
352 optic.GetCompEM().SwitchOn();
353 optic.EnterOptics();
354 optic.OnOpticEnter();
355 }
356 else
357 {
358 optic.ExitOptics();
359 optic.OnOpticExit();
360 if (optic.HasEnergyManager())
361 optic.GetCompEM().SwitchOff();
362 }
363 }
364
365 if (m_CameraOptics != state)
366 SetOptics(state);
367 }
368
369 void SetClimbingLadderType(string value)
370 {
371 m_ClimbingLadderType = value;
372 }
373
375 bool CanConsumeStamina(EStaminaConsumers consumer) {};
376 bool CanStartConsumingStamina(EStaminaConsumers consumer) {};
377 void DepleteStamina(EStaminaModifiers modifier, float dT = -1) {};
378
379 bool IsInVehicle()
380 {
381 return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_VEHICLE || (GetParent() != null && GetParent().IsInherited(Transport));
382 }
383
384 bool IsSwimming()
385 {
386 return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_SWIM;
387 }
388
389 bool IsClimbingLadder()
390 {
391 return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_LADDER;
392 }
393
394
395 bool PlaySoundEvent(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false) {};
396 bool PlaySoundEventEx(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false, int param = 0) {};
397
398 bool IsFBSymptomPlaying()
399 {
400 return m_isFBsymptomPlaying;
401 }
402
403 float GetDeltaT()
404 {
405 return m_dT;
406 }
407
408 //-------------------------------------------------------------
412
413 int m_DeathAnimType = -2;
414 float m_DeathHitDir = 0;
415 bool m_DeathJuctureSent = false;
416
417 override string GetDebugText()
418 {
419 string text = super.GetDebugText();
420 text += "Parent: " + Object.GetDebugName(Object.Cast(GetParent())) + "\n";//keep
421 text += "IsSimulationDisabled: " + GetIsSimulationDisabled() + "\n";//keep
422 /*
423 text += "DamageDestroyed: " + IsDamageDestroyed() + "\n";
424 text += "DeathProcessed: " + IsDeathProcessed() + "\n";
425 text += "DeathConditionMet: " + IsDeathConditionMet() + "\n";
426 text += "PullOutOfVehicleState: " + m_PullPlayerOutOfVehicleState + "\n";
427 text += "PullOutOfVehicleSynch: " + m_TriggerPullPlayerOutOfVehicleSynch + "\n";
428 text += "Position: " + GetPosition() + "\n";*/
429 return text;
430 }
431
432 void TriggerPullPlayerOutOfVehicle()
433 {
434 if (!GetGame().IsServer())
435 return;
436
439 return;
440
441 int crewIdx = -1;
442 for (int i = 0; i < transport.CrewSize(); ++i)
443 {
444 if (transport.CrewMember(i) == this)
445 {
446 crewIdx = i;
447 break;
448 }
449 }
450
451 if (crewIdx == -1)
452 return;
453
454 transport.CrewGetOut(crewIdx);
455 TriggerPullPlayerOutOfVehicleImpl();
456
457 SetSynchDirty();
458 }
459
460 void TriggerPullPlayerOutOfVehicleImpl()
461 {
464
466 DisableSimulation(false);
467
468 switch (GetInstanceType())
469 {
470 case DayZPlayerInstanceType.INSTANCETYPE_SERVER:
471 case DayZPlayerInstanceType.INSTANCETYPE_CLIENT:
472 case DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER:
473 case DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER:
474 m_PullPlayerOutOfVehicleState = 0;
475 m_TriggerPullPlayerOutOfVehicleSynch = true;
476 break;
477 }
478 }
479
480 override void OnVariablesSynchronized()
481 {
482 if (m_TriggerPullPlayerOutOfVehicleSynch && !GetGame().IsDedicatedServer())
483 TriggerPullPlayerOutOfVehicleImpl();
484
485 super.OnVariablesSynchronized();
486 }
487
488 bool HandleDeath(int pCurrentCommandID)
489 {
490 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_DEATH)
491 {
492 switch (m_PullPlayerOutOfVehicleState)
493 {
494 case -1:
495 break;
496 case 0:
497 m_PullPlayerOutOfVehicleState = -1;
498
499 PhysicsSetSolid(true);
500
503 Class.CastTo(callbackVeh, StartCommand_Death(DayZPlayerConstants.DEATH_PULL_OUT_TRANSPORT, 0, DayZPlayerVehicleCommandDeathCallback, m_PullPlayerOutOfVehicleKeepsInLocalSpace));
504 Class.CastTo(callbackVeh.m_pPlayer, this);
505 break;
506 }
507
508 return true;
509 }
510
511 if (m_DeathAnimType != -2 && g_Game.GetMissionState() == g_Game.MISSION_STATE_GAME)
512 {
513 if (!CommitedSuicide())
514 {
515 int type = m_DeathAnimType;
516 if (type == DayZPlayerConstants.DEATH_DEFAULT)
517 type = GetTypeOfDeath(pCurrentCommandID);
518
519 m_WasInVehicle = false;
521 if (hcv)
522 {
523 m_TransportCache = hcv.GetTransport();
524 m_WasInVehicle = !hcv.IsGettingIn() && !hcv.IsGettingOut();
525 }
526
527 bool keepInLocalSpace = false;
528 if (IsUnconscious() || m_WasInVehicle)
529 {
530 if (m_TransportCache)
531 {
532 m_TransportCache.CrewDeath(m_TransportCache.CrewMemberIndex(this));
533 m_TransportCache.MarkCrewMemberDead(m_TransportCache.CrewMemberIndex(this));
534 }
535 }
536 else
537 {
538 if (m_TransportCache)
539 {
540 m_TransportCache.CrewGetOut(m_TransportCache.CrewMemberIndex(this));
541 m_TransportCache.MarkCrewMemberDead(m_TransportCache.CrewMemberIndex(this));
542 }
543
544 keepInLocalSpace = m_PullPlayerOutOfVehicleKeepsInLocalSpace;
545 }
546
547 DisableSimulation(false);
548 GetItemAccessor().HideItemInHands(false);
549 m_TransportCache = null;
550
553 Class.CastTo(callback.m_pPlayer, this);
554 }
555 else
556 PhysicsSetRagdoll(true);
557
558 // disable voice communication
559 GetGame().GetWorld().SetVoiceOn(false, false);
560
561 return true;
562 }
563
564 return false;
565 }
566
567 void ResetDeathStartTime()
568 {
570 }
571
572 int GetTypeOfDeath(int pCurrentCommandID)
573 {
574 switch (pCurrentCommandID)
575 {
576 case DayZPlayerConstants.COMMANDID_SWIM:
577 return DayZPlayerConstants.DEATH_WATER;
578 case DayZPlayerConstants.COMMANDID_FALL:
579 return DayZPlayerConstants.DEATH_FALL;
580 case DayZPlayerConstants.COMMANDID_UNCONSCIOUS:
582 if (hcu)
583 {
584 if (hcu.IsOnLand())
585 return DayZPlayerConstants.DEATH_UNCON_ON_LAND;
586 if (hcu.IsInWater())
587 return DayZPlayerConstants.DEATH_UNCON_IN_WATER;
588 }
589
590 break;
591 }
592
593 return DayZPlayerConstants.DEATH_BODY;
594 }
595
596 void SendDeathJuncture(int pAnimTypeDeath, float pAnimHitDirDeath)
597 {
598 if (m_DeathJuctureSent)
599 return;
600
602 m_DeathJuctureSent = true;
603 }
604
605 override void EEKilled(Object killer)
606 {
607 SendDeathJuncture(-1, 0);
608
609 super.EEKilled(killer);
610 }
611
612 void ShowDeadScreen(bool show, float duration)
613 {
614#ifndef NO_GUI
615 if (show && IsPlayerSelected())
616 {
617#ifdef PLATFORM_PS4
619#endif
620
621 string message = "";
622 if (!GetGame().GetMission().IsPlayerRespawning())
623 message = "#dayz_implement_dead";
624
625#ifdef PLATFORM_CONSOLE
626 GetGame().GetUIManager().ScreenFadeIn(duration, message, FadeColors.DARK_RED, FadeColors.WHITE);
627#else
628 GetGame().GetUIManager().ScreenFadeIn(duration, message, FadeColors.BLACK, FadeColors.WHITE);
629#endif
630 }
631 else
632 {
633 GetGame().GetUIManager().ScreenFadeOut(duration);
634
635 if (duration > 0)
636 GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(StopDeathDarkeningEffect, duration * 1000, false);
637 else
638 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(StopDeathDarkeningEffect);
639 }
640#endif
641 }
642
643 override void StopDeathDarkeningEffect()
644 {
645 if (m_DeathEffectTimer && m_DeathEffectTimer.IsRunning())
646 {
647 m_DeathEffectTimer.Stop();
648 m_DeathEffectTimer = null;
649 }
650 }
651
652 void SimulateDeath(bool state)
653 {
654 if (g_Game.GetMissionState() != DayZGame.MISSION_STATE_GAME)
655 return;
656
657 LockControls(state);
658
659 if (state)
660 {
661 float duration = DEFAULT_DYING_TIME;
662 if (m_KilledByHeadshot)
663 duration = 0;
664
665 if (duration > DYING_PROGRESSION_TIME && !m_IsUnconscious)
666 {
667 if (!m_DeathEffectTimer)
668 m_DeathEffectTimer = new DeathEffectTimer();
669
670 Param2<float, float> par = new Param2<float, float>(duration, DYING_PROGRESSION_TIME);
671 m_DeathEffectTimer.Run(DYING_PROGRESSION_TIME, this, "SetDeathDarknessLevel", par, true);
672 }
673
674 ShowDeadScreen(state, duration);
675
676 GetGame().GetSoundScene().SetSoundVolume(0, 0);
677 GetGame().GetSoundScene().SetSpeechExVolume(0, 0);
678 GetGame().GetSoundScene().SetMusicVolume(0, 0);
679 GetGame().GetSoundScene().SetVOIPVolume(0, 0);
680 GetGame().GetSoundScene().SetRadioVolume(0, 0);
681 }
682 else
683 {
684 StopDeathDarkeningEffect();
685 ShowDeadScreen(state, 0);
686 }
687 }
688
689 void LockControls(bool state)
690 {
691 if (state == true)
692 {
693 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_MOUSE);
694 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_KEYBOARD);
695 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_GAMEPAD);
696
697 if (GetGame().GetUIManager())
698 {
699 GetGame().GetUIManager().ShowUICursor(true);
700 if (GetGame().GetUIManager().IsDialogVisible())
701 GetGame().GetUIManager().CloseDialog();
702 }
703 }
704 else
705 {
706 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_MOUSE);
707 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_KEYBOARD);
708 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_GAMEPAD);
709
710 if (GetGame().GetUIManager())
711 {
712 if (GetGame().GetUIManager().GetMenu())
713 GetGame().GetUIManager().ShowUICursor(true);
714 else
715 GetGame().GetUIManager().ShowUICursor(false);
716 }
717 }
718 }
719
720 void SetDeathDarknessLevel(float duration, float tick_time);
721
722 void SendCompleteWeaponRaiseJuncture();
723
724 void CompleteWeaponRaise()
725 {
726 m_WeaponRaiseTime = 0;
727 m_WeaponRaiseCompleted = true;
728 }
729
730 void ResetWeaponRaiseProgress()
731 {
732 m_WeaponRaiseTime = 0;
733 m_WeaponRaiseCompleted = false;
734 }
735
736 bool IsWeaponRaiseCompleted()
737 {
738 return m_WeaponRaiseCompleted;
739 }
740
741 DayZPlayerInventory GetDayZPlayerInventory()
742 {
743 DayZPlayerInventory inv = DayZPlayerInventory.Cast(GetInventory());
744 return inv;
745 }
746
748 {
749 int userDataType = 0;
750 if (!ctx.Read(userDataType))
751 {
752 Error("DayZPlayer: OnInputForRemote - cannot read input type");
753 return;
754 }
755
756 switch (userDataType)
757 {
759 GetDayZPlayerInventory().OnEventForRemoteWeapon(ctx);
760 break;
762 GetDayZPlayerInventory().OnHandEventForRemote(ctx);
763 break;
765 GetDayZPlayerInventory().OnInputUserDataForRemote(ctx);
766 break;
767 default:
768 Error("OnInputForRemote - unknown userDataType=" + userDataType);
769 break;
770 }
771 }
772
774 {
775 int userDataType = 0;
776 if (!ctx.Read(userDataType))
777 {
778 Error("DayZPlayer: OnInputFromServer - cannot read input type");
779 return;
780 }
781
782 switch (userDataType)
783 {
785 GetDayZPlayerInventory().OnServerInventoryCommand(ctx);
786 break;
787 default:
788 Error("OnInputFromServer - unknown userDataType=" + userDataType);
789 break;
790 }
791 }
792 void RequestSoundEvent(EPlayerSoundEventID id, bool from_server_and_client = false);
793 void RequestSoundEventEx(EPlayerSoundEventID id, bool from_server_and_client = false, int param = 0);
794 protected void SendSoundEvent(EPlayerSoundEventID id);
795 protected void SendSoundEventEx(EPlayerSoundEventID id, int param = 0);
796
797 override void OnItemInHandsChanged()
798 {
799 //Print("inv: DayZPlayerImplement::OnItemInHandsChanged: "/* + GetHumanInventory().GetEntityInHands()*/);
800 StopWeaponEvent();
801 GetItemAccessor().OnItemInHandsChanged();
802
803 if (!IsAlive())
804 {
805 //Print("inv: DayZPlayerImplement::OnItemInHandsChanged - human not alive! calling ResetWeaponInHands");
806 GetItemAccessor().ResetWeaponInHands();
807 }
808 }
809
810 WeaponManager GetWeaponManager() { return null; }
811
812 //-------------------------------------------------------------
816 void HandleWeapons(float pDt, Entity pInHands, HumanInputController pInputs, out bool pExitIronSights)
817 {
819 GetDayZPlayerInventory().HandleWeaponEvents(pDt, pExitIronSights);
820
823 ItemOptics optic = weapon.GetAttachedOptics();
824
825 CheckLiftWeapon();
826 ProcessLiftWeapon();
827
829
830 // hold breath
831 if (pInputs.IsHoldBreath() && m_MovementState.IsRaised() && (IsInIronsights() || IsInOptics()))
832 m_IsTryingHoldBreath = true;
833 else
834 m_IsTryingHoldBreath = false;
835
836 if (pInputs.IsFireModeChange())
837 GetWeaponManager().SetNextMuzzleMode();
838 if (pInputs.IsZeroingUp())
839 {
840 if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
841 optic.StepZeroingUp();
842 else
843 weapon.StepZeroingUpAllMuzzles();
844 }
845 if (pInputs.IsZeroingDown())
846 {
847 if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
848 optic.StepZeroingDown();
849 else
850 weapon.StepZeroingDownAllMuzzles();
851 }
852
853 if (!m_LiftWeapon_player && (m_CameraIronsight || !weapon.CanEnterIronsights() || m_CameraOptics/*m_ForceHandleOptics*/)) // HACK straight to optics, if ironsights not allowed
854 {
855 if (optic)
856 HandleOptic(optic, false, pInputs, pExitIronSights);
857 }
858
859 if (!m_MovementState.IsRaised())
860 {
861 m_IsFireWeaponRaised = false; //legacy reasons
862 if (weapon && weapon.IsInOptics())
863 weapon.ExitOptics();
864
865 ResetWeaponRaiseProgress();
866
867 return; // if not raised => return
868 }
869 else
870 {
871 m_IsFireWeaponRaised = true; //legacy reasons
872 if (!IsWeaponRaiseCompleted())
873 m_WeaponRaiseTime += pDt;
874
875 if (m_WeaponRaiseTime >= PlayerConstants.WEAPON_RAISE_BLEND_DELAY)
876 CompleteWeaponRaise();
877 }
878
880 if (GetWeaponManager().CanFire(weapon))
881 {
882 bool autofire = weapon.GetCurrentModeAutoFire(weapon.GetCurrentMuzzle()) && weapon.IsChamberEjectable(weapon.GetCurrentMuzzle());
883 int burst = weapon.GetCurrentModeBurstSize(weapon.GetCurrentMuzzle());
884 int burst_count = weapon.GetBurstCount();
885 if (!autofire && (burst < 2 || burst_count < 1))
886 {
887 if (pInputs.IsAttackButtonDown() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
888 GetWeaponManager().Fire(weapon);
889 }
890 else if (autofire || burst > 1)
891 {
892#ifdef DIAG_DEVELOPER
893 int burst_option = GetWeaponManager().GetBurstOption();
894 if (burst_option == 0)
895 {
896#endif
897 if (pInputs.IsAttackButton() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
898 {
899 if (autofire || burst_count < burst)
900 GetWeaponManager().Fire(weapon);
901 }
902 else
903 weapon.ResetBurstCount();
904#ifdef DIAG_DEVELOPER
905 }
906 else if (burst_option == 1)
907 {
908 if (burst > 1 && burst_count == burst)
909 weapon.ResetBurstCount();
910 else if (burst > 1 && burst_count < burst)
911 GetWeaponManager().Fire(weapon);
912 else
913 {
914 //Autofire
915 if (pInputs.IsAttackButton())
916 GetWeaponManager().Fire(weapon);
917 }
918 }
919#endif
920 }
921 }
922
923#ifdef PLATFORM_CONSOLE
924 if (GetGame().GetInput().LocalRelease("UAFire", false) || m_ShouldReload)
925 {
926 if (!weapon.IsWaitingForActionFinish() && !IsFighting())
927 {
928 int muzzle_index = weapon.GetCurrentMuzzle();
929
930 if (weapon.IsChamberFiredOut(muzzle_index))
931 {
932 if (weapon.CanProcessWeaponEvents())
933 {
934 if (GetWeaponManager().CanEjectBullet(weapon))
935 {
936 GetWeaponManager().EjectBullet();
937 pExitIronSights = true;
938 m_ShouldReload = false;
939 }
940 }
941 }
942 }
943 else
944 m_ShouldReload = true;
945 }
946#endif
947 }
948
950 {
951 UAInterface input = GetInputInterface();
952 if (!input)
953 return;
954
956 int FOVcount;
959
960 if (input.SyncedPress_ID(UAZoomInOptics))
961 {
962 weapon = Weapon_Base.Cast(optic.GetHierarchyParent());
963 FOVcount = optic.GetStepFOVCount();
965
966 if (weapon && m_CameraIronsight && !m_CameraOptics)
967 {
968 SetIronsights(false);
969 SwitchOptics(optic, true);
970 optic.SetStepFOVIndex(0);
971 }
972 else if (m_CameraOptics)
973 {
974 if (controllerPressIn) //controller
975 {
976 if (!optic.StepFOVUp())
977 {
978 if (FOVcount > 0)
979 {
980 optic.SetStepFOVIndex(0); //loop to minimum magnification
981 }
982
983 if (weapon && weapon.CanEnterIronsights()) //loop into ironsights
984 {
985 SwitchOptics(optic, false);
986 pInputs.ResetFreeLookToggle();
987 SetIronsights(true);
988 }
989 }
990 }
991 else //m&k
992 optic.StepFOVUp();
993 }
994 }
995
996 if (input.SyncedPress_ID(UAZoomOutOptics))
997 {
998 weapon = Weapon_Base.Cast(optic.GetHierarchyParent());
999 FOVcount = optic.GetStepFOVCount();
1001 if (m_CameraOptics)
1002 {
1003 if (!optic.StepFOVDown())
1004 {
1006 {
1007 if (FOVcount > 0 && (!weapon || !weapon.CanEnterIronsights()))
1008 {
1009 optic.SetStepFOVIndex(FOVcount - 1); //loop to maximum magnification
1010 }
1011 }
1012
1013 if (weapon && weapon.CanEnterIronsights())
1014 {
1015 SwitchOptics(optic, false);
1016 pInputs.ResetFreeLookToggle();
1017 SetIronsights(true);
1018 }
1019 }
1020 }
1021 else if (controllerPressOut && weapon && m_CameraIronsight)
1022 {
1023 SwitchOptics(optic, true);
1024 if (FOVcount > 0)
1025 {
1026 optic.SetStepFOVIndex(FOVcount - 1); //loop to maximum magnification
1027 }
1028 }
1029 }
1030 }
1031
1032 //-------------------------------------------------------------
1036
1037 bool m_DamageHitFullbody = false;
1038 int m_DamageHitAnimType = -1.0;
1039 float m_DamageHitDir = 0.0;
1040 float m_DamageHealth = 0.0;
1041
1042 const float HIT_INTERVAL_MIN = 0.3; // Minimum time in seconds before a COMMANDID_HIT to COMMANDID_HIT transition is allowed
1043 float m_HitElapsedTime = HIT_INTERVAL_MIN;
1044
1045 bool IsInFullbodyDamageAnimation()
1046 {
1047 return (m_DamageHitFullbody && m_DamageHitAnimType != -1) || GetCommand_Damage() != null;
1048 }
1049
1051 void EvaluateDamageHit(int pCurrentCommandID)
1052 {
1054 m_DamageHitAnimType = -1;
1055
1056 if (!m_SyncedHitDataArray || m_SyncedHitDataArray.Count() == 0)
1057 return;
1058
1059 //evaluate all hit data
1062 for (int i = 0; i < m_SyncedHitDataArray.Count(); i++)
1063 {
1064 data = m_SyncedHitDataArray[i];
1065 m_DamageHitDir = data.m_HitDir;
1066
1067 //client-side effects
1068#ifndef SERVER
1069 if (IsAlive() && !IsUnconscious() && data.m_HasSource && GetGame().GetMission().GetHud() && GetGame().GetPlayer() == this) //only for controlled players
1070 {
1071 m_DamageHealth = data.m_HealthDamage;
1072 if (m_DamageHealth > 0.0)
1073 {
1074 float rel = m_DamageHealth / (GetMaxHealth("", "Health") * PlayerConstants.HEAVY_HIT_THRESHOLD);
1075 GetGame().GetMission().GetHud().SpawnHitDirEffect(this, m_DamageHitDir, rel);
1076 }
1077 }
1078#endif
1079
1080 if (!greatest_hit)
1082 //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)
1083 else if (data.m_Fullbody) //temporary solution; last fullbody hit is used for animation purposes, some light hit otherwise
1085 }
1086
1087 m_SyncedHitDataArray.Clear();
1088 m_DamageHealth = 0.0;
1089
1091 if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1092 return;
1093
1094 //general effects
1095 m_DamageHitFullbody = greatest_hit.m_Fullbody;
1096 m_DamageHitAnimType = greatest_hit.m_AnimType;
1097 m_DamageHitDir = greatest_hit.m_HitDir;
1098 }
1099
1100 bool HandleDamageHit(int pCurrentCommandID)
1101 {
1102 // Update elapsed time since hit first
1103 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE)
1104 {
1105 // Throttle heavy hit command up to a fixed rate
1106 if (m_HitElapsedTime < HIT_INTERVAL_MIN)
1107 {
1108 m_HitElapsedTime += m_dT;
1109 ResetDamageHitState(false);
1110 return false;
1111 }
1112 }
1113
1114 // If transportcache is not null, player is unconscious inside of a car and should not head into a damage command
1115 if (m_DamageHitAnimType != -1 && m_TransportCache == null && !CommitedSuicide())
1116 {
1118 if (m_DamageHitFullbody && (!vehCommand || vehCommand.IsGettingIn() || vehCommand.IsGettingOut()))
1119 {
1120 StartCommand_Damage(m_DamageHitAnimType, m_DamageHitDir);
1121 ResetDamageHitState(true);
1122 return true;
1123 }
1124 else
1125 {
1126 AddCommandModifier_Damage(m_DamageHitAnimType, m_DamageHitDir);
1127 ResetDamageHitState(false);
1128 return false;
1129 }
1130 }
1131
1132 return pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE;
1133 }
1134
1135 void ResetDamageHitState(bool resetTimer)
1136 {
1137 m_DamageHitAnimType = -1;
1138 m_DamageHitFullbody = false;
1139
1140 if (resetTimer)
1141 m_HitElapsedTime = 0;
1142 }
1143
1145 bool EvaluateDeathAnimation(int pDamageType, EntityAI pSource, string pAmmoType, out int pAnimType, out float pAnimHitDir)
1146 {
1147 bool doPhxImpulse = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " doPhxImpulse") > 0;
1148
1149 pAnimType = DayZPlayerConstants.DEATH_DEFAULT;
1150 if (doPhxImpulse)
1151 pAnimType = DayZPlayerConstants.DEATH_FAST;
1152
1154 vector targetDirection = GetDirection();
1155 vector toSourceDirection = (pSource.GetPosition() - GetPosition());
1156
1157 targetDirection[1] = 0;
1158 toSourceDirection[1] = 0;
1159
1160 targetDirection.Normalize();
1161 toSourceDirection.Normalize();
1162
1165
1167 if (cross[1] < 0)
1169
1170 return true;
1171 }
1172
1174 bool EvaluateDamageHitAnimation(TotalDamageResult pDamageResult, int pDamageType, EntityAI pSource, string pComponent, string pAmmoType, vector pModelPos, out int pAnimType, out float pAnimHitDir, out bool pAnimHitFullbody)
1175 {
1176 int invertHitDir = 0; //Used to flip the heavy hit animation direction
1177
1178 pAnimType = 0;
1179 pAnimHitFullbody = false; // additive anm
1181
1182 switch (pDamageType)
1183 {
1184 case DT_CLOSE_COMBAT:
1186 if (pSource.IsInherited(DayZInfected))
1187 break;
1188
1189 pAnimType = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " hitAnimation");
1190 invertHitDir = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " invertHitDir");
1191 if (!IsUnconscious() && pAnimType == 1 && !m_MeleeFightLogic.IsInBlock())
1192 pAnimHitFullbody = true;
1193 break;
1194
1195 case DT_FIRE_ARM:
1196 int impactBehaviour = 0;
1197
1198 if (!IsUnconscious() && GetHealth("", "Shock") > 25)
1199 {
1201 if (pComponent == "Torso" || pComponent == "Head")
1202 {
1203 impactBehaviour = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " impactBehaviour");
1204 float fireDamage = pDamageResult.GetHighestDamage("Health");
1205 float shockDamage = pDamageResult.GetHighestDamage("Shock");
1206 if ((fireDamage > 80.0 || shockDamage > 40.0) && impactBehaviour == 1)
1207 pAnimHitFullbody = true;
1208 }
1209 }
1210
1211 break;
1212
1213 case DT_EXPLOSION:
1214 break;
1215
1216 case DT_CUSTOM:
1217 pAnimType = GetGame().ConfigGetInt("cfgAmmo " + pAmmoType + " hitAnimation");
1218 if (pAnimType == 1)
1219 pAnimHitFullbody = true;
1220 else
1221 return false;
1222
1223 break;
1224 }
1225
1227 vector targetDirection = GetDirection();
1228 vector toSourceDirection = (pSource.GetPosition() - GetPosition());
1229
1230 targetDirection[1] = 0;
1231 toSourceDirection[1] = 0;
1232
1233 targetDirection.Normalize();
1234 toSourceDirection.Normalize();
1235
1238
1240
1241 // We will invert direction of the hit
1242 if (invertHitDir > 0)
1243 pAnimHitDir -= 180;
1244
1245 if (cross[1] < 0)
1247
1248 return true;
1249 }
1250
1253 {
1255
1256 m_TransportHitRegistered = false;
1257
1258 if (!IsAlive())
1259 {
1260 int animTypeDeath;
1261 float animHitDirDeath;
1262 if (EvaluateDeathAnimation(damageType, source, ammo, animTypeDeath, animHitDirDeath))
1263 SendDeathJuncture(animTypeDeath, animHitDirDeath);
1264
1265 if (!m_DeathSyncSent) //checked until the death is evaluated by 'OnCommandHandlerTick' higher up the road
1266 {
1267 Man killer = source.GetHierarchyRootPlayer();
1268
1269 if (!m_KillerData) //only one player is considered killer in the event of crossfire
1270 {
1271 m_KillerData = new KillerData();
1272 m_KillerData.m_Killer = killer;
1273 m_KillerData.m_MurderWeapon = source;
1274 }
1275
1276 if (killer && killer.IsPlayer())
1277 {
1278 // was player killed by headshot?
1279 if (dmgZone == "Brain")
1280 {
1281 m_KilledByHeadshot = true;
1282 if (m_KillerData.m_Killer == killer)
1283 m_KillerData.m_KillerHiTheBrain = true;
1284 }
1285 }
1286 }
1287 }
1288 else
1289 {
1290 int animType;
1291 float animHitDir;
1292 bool animHitFullbody;
1293 if (EvaluateDamageHitAnimation(damageResult, damageType, source, dmgZone, ammo, modelPos, animType, animHitDir, animHitFullbody))
1295 else
1296 {
1297 bool skipSoundRequest = false;
1298 if (damageType == DamageType.CUSTOM && GetCommand_Fall())
1299 skipSoundRequest = GetFallDamage().GetLandType() < HumanCommandFall.LANDTYPE_MEDIUM;
1300
1301 if (!skipSoundRequest)
1302 RequestSoundEvent(EPlayerSoundEventID.TAKING_DMG_LIGHT);
1303 }
1304 }
1305
1306 // interupt melee for non-blocked hit or heavy hit
1307 if (animHitFullbody)
1308 {
1310 if (hcm)
1311 hcm.Cancel();
1312 }
1313 }
1314
1315 //-------------------------------------------------------------
1319 float m_fLastHeadingDiff = 0;
1320
1322 override bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
1323 {
1324 if (!IsAlive())
1325 return false;
1326
1328
1330 if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_LADDER)
1331 {
1332 m_fLastHeadingDiff = 0;
1333 return false;
1334 }
1335 if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_VEHICLE)
1336 {
1338 if (hmv.IsGettingOut() || hmv.IsGettingIn())
1339 return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
1340
1341 m_fLastHeadingDiff = 0;
1342 return false;
1343 }
1344 if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
1345 {
1347 if (!hcu.IsWakingUp())
1348 {
1349 m_fLastHeadingDiff = 0;
1350 //pModel.m_iCamMode = DayZPlayerConstants.CAMERAMODE_HEAD;
1351 return false;
1352 }
1353 }
1354
1355 if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_CLIMB)
1356 {
1357 m_fLastHeadingDiff = 0;
1358 return false;
1359 }
1360
1361#ifdef DEVELOPER
1363 if (actMenuValue != 0)
1364 {
1366 return DayZPlayerImplementHeading.ClampHeading(pDt, pModel, m_fLastHeadingDiff);
1367 }
1368#endif
1369
1370 if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1371 {
1372 m_fLastHeadingDiff = 0;
1373 return false;
1374 }
1375
1377 if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_MOVE)
1378 {
1380 if (hcm.IsStandingFromBack())
1381 {
1382 m_fLastHeadingDiff = 0;
1383 return false;
1384 }
1385 }
1386
1388 HumanItemBehaviorCfg hibcfg = hia.GetItemInHandsBehaviourCfg();
1389 if (hibcfg && hibcfg.m_StanceRotation[m_MovementState.m_iStanceIdx] == DayZPlayerConstants.ROTATION_DISABLE)
1390 return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
1391 if (IsUnconscious() || (GetCommand_Move() && GetCommand_Move().IsLeavingUncon()))
1392 return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
1393
1394 return DayZPlayerImplementHeading.RotateOrient(pDt, pModel, m_fLastHeadingDiff);
1395 }
1396
1397
1398 //-------------------------------------------------------------
1402 override bool AimingModel(float pDt, SDayZPlayerAimingModel pModel)
1403 {
1405 if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_MELEE2)
1406 {
1408 if (hcm.IsFinisher())
1409 {
1410 if (!m_AimingFinisherStarted)
1411 {
1412 m_AimingModel.OnFinisherBegin(pModel.m_fCurrentAimY);
1413 m_AimingFinisherStarted = true;
1414 }
1415 m_AimingModel.ProcessStealthFilters(pDt, pModel);
1416 }
1417
1418 return true;
1419 }
1420
1421 if (m_MovementState.IsRaised())
1422 {
1423 if (!m_RaiseStarted)
1424 {
1425 m_AimingModel.OnRaiseBegin(this);
1426 m_RaiseStarted = true;
1427 }
1428 m_AimingModel.ProcessAimFilters(pDt, pModel, m_MovementState.m_iStanceIdx);
1429
1430 return true;
1431 }
1432
1433 m_RaiseStarted = false;
1434 m_AimingFinisherStarted = false;
1435
1436 return true;
1437 }
1438
1439 //-------------------------------------------------------------
1443
1444
1446 bool CanJump()
1447 {
1448 if (IsFBSymptomPlaying() || IsRestrained() || IsUnconscious() || IsInFBEmoteState())
1449 return false;
1450
1451 if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1452 return false;
1453
1454 if (IsRaised() && GetInputInterface().SyncedPress("UAGetOverControllerHelper")) //no raised jump on cotroller
1455 return false;
1456
1457 HumanItemBehaviorCfg hibcfg = GetItemAccessor().GetItemInHandsBehaviourCfg();
1458 if (!hibcfg.m_bJumpAllowed)
1459 return false;
1460
1461 if (!DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_ERECT) || !DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_RAISEDERECT))
1462 return false;
1463
1465 if (hcm)
1466 {
1467 if (hcm.IsChangingStance())
1468 return false;
1469 }
1470
1471 return true;
1472 }
1473
1474 bool CanClimb(int climbType, SHumanCommandClimbResult climbRes)
1475 {
1476 if (IsFBSymptomPlaying() || IsRestrained() || IsUnconscious() || IsInFBEmoteState())
1477 return false;
1478
1479 if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
1480 return false;
1481
1482 if (IsRaised() && GetInputInterface().SyncedPress("UAGetOverControllerHelper")) //no raised climb on cotroller
1483 return false;
1484
1485 HumanItemBehaviorCfg hibcfg = GetItemAccessor().GetItemInHandsBehaviourCfg();
1486 if (!hibcfg.m_bJumpAllowed)
1487 return false;
1488
1489 if (climbRes)
1490 {
1492 if (Class.CastTo(entity, climbRes.m_GrabPointParent) && entity.IsHologram())
1493 return false;
1494 if (Class.CastTo(entity, climbRes.m_ClimbStandPointParent) && entity.IsHologram())
1495 return false;
1496 if (Class.CastTo(entity, climbRes.m_ClimbOverStandPointParent) && entity.IsHologram())
1497 return false;
1498 }
1499
1500 return true;
1501 }
1502
1503
1504 void OnJumpStart()
1505 {
1506 }
1507
1508 void OnJumpEnd(int pLandType = 0)
1509 {
1510 }
1511
1512 void StopHandEvent()
1513 {
1514 GetDayZPlayerInventory().CancelHandEvent();
1515 }
1516
1517 void StopWeaponEvent()
1518 {
1519 GetDayZPlayerInventory().CancelWeaponEvent();
1520 }
1521
1522 void AbortWeaponEvent()
1523 {
1524 GetDayZPlayerInventory().AbortWeaponEvent();
1525 }
1526
1527 //-------------------------------------------------------------
1531 void HandleADS()
1532 {
1533 if (!IsAlive())
1534 {
1535 if (m_CameraIronsight || m_CameraOptics)
1536 ExitSights();
1537 return;
1538 }
1539
1540 bool bADSToggle = false;
1541 bool exitSights = false;
1545 PlayerBase playerPB = PlayerBase.Cast(this);
1547
1548 if (playerPB.IsRolling())
1549 exitSights = true;
1550
1551 if (m_ResetADS || !hia.IsItemInHandsWeapon())
1552 {
1553 hic.ResetADS();
1554 m_ResetADS = false;
1555 }
1556
1557 if (!m_MovementState.IsRaised() || m_LiftWeapon_player)
1558 {
1559 ResetWeaponRaiseProgress();
1560 exitSights = true;
1561 }
1562 else
1563 {
1564 if (m_bADS != hic.WeaponADS())
1565 {
1566 m_bADS = hic.WeaponADS();
1567 bADSToggle = true;
1568 }
1569
1570 if (m_bADS && !m_CameraIronsight && !m_CameraOptics)
1571 {
1573 if (!IsWeaponRaiseCompleted())
1574 {
1575 bADSToggle = false;
1576 exitSights = true;
1577 }
1578 else
1579 bADSToggle = true;
1580 }
1581 }
1582
1583 if (bADSToggle && !GetCommand_Melee2() && !GetThrowing().IsThrowingModeEnabled())
1584 {
1585 if (hia.IsItemInHandsWeapon() && playerPB.GetItemInHands() && playerPB.GetItemInHands().IsWeapon() && playerPB.GetWeaponManager() && !playerPB.GetWeaponManager().IsRunning())
1586 {
1587 Weapon_Base weapon = Weapon_Base.Cast(GetHumanInventory().GetEntityInHands());
1588 ItemOptics optic = weapon.GetAttachedOptics();
1589 bool switchToADS = false;
1590 bool canUseIronsights = weapon.CanEnterIronsights();
1591 bool canUseOptics = optic != NULL;
1592
1594 switchToADS = m_bADS;
1595
1596 // go to ironsights - disable ironsights when
1599 if (!m_MovementState.IsRaised() || m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
1600 switchToADS = false;
1601
1602 // fixes camera switching during item transitions
1603 if (IsLiftWeapon() || !IsRaised() || GetDayZPlayerInventory().IsProcessing() || !IsWeaponRaiseCompleted() || IsFighting())
1604 exitSights = true;
1605 else if (switchToADS) // enter ironsights or optics
1606 {
1607 // filter by usability
1608 if (m_WasIronsight && !canUseIronsights)
1609 m_WasIronsight = false;
1610 else if (!m_WasIronsight && !canUseOptics)
1611 m_WasIronsight = true;
1612
1613 if (m_WasIronsight)
1614 {
1615 hic.ResetFreeLookToggle();
1616 SwitchOptics(optic, false);
1617 SetIronsights(true);
1618 }
1619 else if (!m_WasIronsight || (!canUseIronsights && canUseOptics))
1620 {
1621 SetIronsights(false);
1622 SwitchOptics(optic, true);
1623 }
1624 else
1625 exitSights = true;
1626
1627 if (hcw && (m_CameraOptics/* || m_CameraIronsight*/))
1628 hcw.SetADS(true);
1629 }
1630 else
1631 exitSights = true;
1632 }
1633 }
1634
1635 // leave ironsight and/ or optics
1636 if (exitSights && !IsHandheldOpticsInUse() && (m_CameraIronsight || m_CameraOptics) || GetCommand_Melee2())
1637 ExitSights();
1638 }
1639
1640 void HandleView()
1641 {
1642 if (!IsAlive())
1643 {
1644 if (m_CameraIronsight || m_CameraOptics)
1645 ExitSights();
1646 return;
1647 }
1648
1650
1651 bool camChange = hic.CameraViewChanged();
1652
1653 if (IsRaised())
1654 {
1655 if (m_IsWeapon)
1656 camChange = false;
1657 }
1658
1660 if (GetGame().GetWorld().Is3rdPersonDisabled())
1661 m_Camera3rdPerson = false;
1662 else if (camChange)
1663 m_Camera3rdPerson = !m_Camera3rdPerson;
1664
1665 // exits optics completely, comment to return to ADS
1666 if (m_LiftWeapon_player && (m_CameraOptics || m_CameraIronsight))
1667 ExitSights();
1668
1669 if (IsPlayerInStance(DayZPlayerConstants.STANCEMASK_RAISEDPRONE) && (m_CameraOptics || m_CameraIronsight))
1670 GetDayZPlayerType().SetVerticalMinimumAimLimit(DayZPlayerCameraIronsights.CONST_UD_MIN_BACK);
1671 else
1672 GetDayZPlayerType().SetVerticalMinimumAimLimit(DayZPlayerCameraIronsights.CONST_UD_MIN);
1673
1674 if (hic.IsZoomToggle() && !m_MovementState.IsRaised())
1675 {
1676 m_CameraEyeZoomLevel = ECameraZoomType.NORMAL;
1677 if ((IsClimbingLadder() && Math.AbsInt(m_MovementState.m_iMovement) == 2) || (IsSwimming() && m_MovementState.m_iMovement == 3))
1678 m_CameraEyeZoomLevel = ECameraZoomType.SHALLOW;
1679 else if (!IsClimbingLadder() && !IsSwimming() && !IsInVehicle())
1680 {
1681 float pSpeed;
1683 hic.GetMovement(pSpeed, pLocalDirection);
1684
1685 if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT && pSpeed == 3)
1686 m_CameraEyeZoomLevel = ECameraZoomType.SHALLOW;
1687 }
1688 }
1689 else
1690 m_CameraEyeZoomLevel = ECameraZoomType.NONE;
1691
1692 if (m_MovementState.IsRaisedInProne())
1693 {
1694 float headingAngle = MiscGameplayFunctions.GetHeadingAngle(this);
1695 float headingAngleDiffBlock = Math.AbsFloat(m_LastHeadingAngleBlock - headingAngle);
1696 float headingAngleDiffBlock2 = Math.AbsFloat(m_LastHeadingAngleBlock2 - headingAngle);
1697 float headingAngleDiff = 0.0;
1698
1699 if (m_LastHeadingAngle * headingAngle < 0.0)
1700 headingAngleDiff = Math.AbsFloat(m_LastHeadingAngle + headingAngle);
1701 else
1702 headingAngleDiff = Math.AbsFloat(m_LastHeadingAngle - headingAngle);
1703
1704 if (headingAngleDiff > 0.2)
1705 {
1706 int time = GetGame().GetTime();
1707
1708 float timefilterconstant = 400 - (headingAngleDiff * 100);
1709
1710 if (headingAngleDiffBlock > 0.8 && time - m_LastBackSoundTime > timefilterconstant)
1711 {
1712 float volume = headingAngleDiff / 0.5;
1713 if (volume > 1)
1714 volume = 1;
1715 if (volume < 0.25)
1716 volume = 0.25;
1717
1718 m_SoundOffset = headingAngleDiff / 2;
1719 if (m_SoundOffset > 0.25)
1720 m_SoundOffset = 0.25;
1721
1722 string soundSetName = "Cloth_Body_longmove_TShirt_Soundset";
1723
1724 string bodyClothName = "";
1725 EntityAI attachment = GetInventory().FindAttachment(InventorySlots.BODY);
1726 if (attachment)
1727 bodyClothName = attachment.GetAttachmentSoundType();
1728
1729 if (bodyClothName != "")
1730 {
1731 string path = "CfgSoundTables CfgAttachmentSoundTables Cloth_Body_Longmove_LookupTable";
1732 int soundCount = GetGame().ConfigGetChildrenCount(path);
1733
1734 for (int i = 0; i < soundCount; i++)
1735 {
1736 string name = "";
1737 GetGame().ConfigGetChildName(path, i, name);
1738
1739 if (name == bodyClothName)
1740 {
1742 GetGame().ConfigGetTextArray(path + " " + name + " soundSets", stringArray);
1743 soundSetName = stringArray.Get(0);
1744
1745 delete stringArray;
1746 }
1747 }
1748 }
1749
1752
1753 if (soundObjectBuilder != NULL)
1754 {
1755 SoundObject soundObject = soundObjectBuilder.BuildSoundObject();
1756
1757 if (soundObject != NULL)
1758 {
1759 soundObject.SetPosition(GetPosition());
1760
1761 AbstractWave wave = GetGame().GetSoundScene().Play3D(soundObject, soundObjectBuilder);
1762 wave.SetStartOffset(m_SoundOffset);
1763 wave.SetVolumeRelative(volume);
1764
1765 m_LastBackSoundTime = GetGame().GetTime();
1766 m_LastHeadingAngleBlock = headingAngle;
1767 }
1768 }
1769 }
1770
1771 if (headingAngleDiffBlock2 > 1.5 && time - m_LastBackSoundTime2 > (timefilterconstant * 2))
1772 {
1773 float volume2 = headingAngleDiff * 2;
1774 if (volume2 > 1)
1775 volume2 = 1;
1776
1777 m_SoundOffset = headingAngleDiff / 1.8;
1778 if (m_SoundOffset < 0.1)
1779 m_SoundOffset = 0.1;
1780 if (m_SoundOffset > 0.3)
1781 m_SoundOffset = 0.3;
1782
1783 string soundSetName2 = "walkProne_noHS_asphalt_ext_Char_SoundSet";
1784 string surfaceType = GetSurfaceType();
1785
1786 if (surfaceType != "")
1787 {
1788 string movementSurfaceType = "walkProne_" + surfaceType;
1789
1790 string path2 = "CfgSoundTables CfgStepSoundTables walkProne_noHS_Char_LookupTable";
1791 int soundCount2 = GetGame().ConfigGetChildrenCount(path2);
1792
1793 for (int i2 = 0; i2 < soundCount2; i2++)
1794 {
1795 string name2 = "";
1796 GetGame().ConfigGetChildName(path2, i2, name2);
1797
1799 {
1801 GetGame().ConfigGetTextArray(path2 + " " + name2 + " soundSets", stringArray2);
1802 soundSetName2 = stringArray2.Get(0);
1803
1804 delete stringArray2;
1805 }
1806 }
1807 }
1808
1811
1813 {
1814 SoundObject soundObject2 = soundObjectBuilder2.BuildSoundObject();
1815
1816 if (soundObject2 != NULL)
1817 {
1818 soundObject2.SetPosition(GetPosition());
1819
1820 AbstractWave wave2 = GetGame().GetSoundScene().Play3D(soundObject2, soundObjectBuilder2);
1821 wave2.SetStartOffset(m_SoundOffset);
1822 wave2.SetVolumeRelative(volume2);
1823
1824 m_LastBackSoundTime2 = GetGame().GetTime();
1825 m_LastHeadingAngleBlock2 = headingAngle;
1826 }
1827 }
1828 }
1829
1830 m_LastHeadingAngle = headingAngle;
1831 }
1832 }
1833 }
1834
1835 float m_LastHeadingAngleBlock;
1836 float m_LastHeadingAngleBlock2;
1837 float m_LastHeadingAngle;
1838 int m_LastBackSoundTime;
1839 int m_LastBackSoundTime2;
1840 float m_SoundOffset;
1841
1842
1843 //-------------------------------------------------------------
1847 // these functions are for modded overide in script command mods
1848
1850 {
1851 return false;
1852 }
1853
1855 {
1856 return false;
1857 }
1858
1860 {
1861 return false;
1862 }
1863
1864 //-------------------------------------------------------------
1868
1869
1871 override void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
1872 {
1873 m_dT = pDt;
1874
1876 return;
1877
1879 EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
1881
1882 bool isRaisedNow = m_MovementState.IsRaised();
1883 bool isWeapon = entityInHands && entityInHands.IsInherited(Weapon);
1884
1885 bool updateAimingMdfr = false;
1886 if (isWeapon != m_IsWeapon)
1887 {
1888 m_IsWeapon = isWeapon;
1889 updateAimingMdfr = true;
1890 }
1891
1892 if (isRaisedNow != m_IsRaised)
1893 {
1894 updateAimingMdfr = true;
1895 m_IsRaised = m_MovementState.IsRaised();
1896 }
1897
1898 if (updateAimingMdfr)
1899 {
1900 if (isRaisedNow && isWeapon)
1901 GetUApi().ActivateModificator("aiming");
1902 else
1903 GetUApi().DeactivateModificator("aiming");
1904 }
1905
1906 // handle ADS ironsights/optics transition logic
1907 HandleADS();
1908
1909 // handle weapons
1910 if (hic)
1911 {
1913 if (isWeapon && (!m_ProcessFirearmMeleeHit || !m_ContinueFirearmMelee))
1914 {
1915 m_ProcessFirearmMeleeHit = false;
1916 bool exitIronSights = false;
1917 HandleWeapons(pDt, entityInHands, hic, exitIronSights);
1918 }
1919 else if (IsHandheldOpticsInUse() && m_CameraOptics && opticInHands)
1920 {
1921 bool exitOptic = false;
1922 HandleOptic(opticInHands, true, hic, exitOptic);
1923 }
1924 }
1925
1927 HandleView();
1928
1929 if (m_MovementState.m_iMovement != m_MovementState.m_LocalMovement)
1930 {
1931 OnMovementChanged();
1932 m_MovementState.m_LocalMovement = m_MovementState.m_iMovement;
1933 }
1934
1936 if (HandleDeath(pCurrentCommandID))
1937 return;
1938
1941 {
1942 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
1943 {
1944 if ((m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE) && (m_TransportCache != null))
1945 {
1946 int crew_index = m_TransportCache.CrewMemberIndex(this);
1947 int seat = m_TransportCache.GetSeatAnimationType(crew_index);
1948 StartCommand_Vehicle(m_TransportCache, crew_index, seat, true);
1949 m_TransportCache = null;
1950 return;
1951 }
1952 }
1953 // start moving
1954
1955 // start falling ? (could happen after climbing)
1956 if (PhysicsIsFalling(true))
1957 {
1959 SetFallYDiff(GetPosition()[1]);
1960 return;
1961 }
1962
1964 if (m_Swimming.m_bWasSwimming)
1965 {
1967 return;
1968 }
1969
1971
1972 if (GetHumanInventory().GetEntityInHands())
1973 ForceStandUpForHeavyItems(GetHumanInventory().GetEntityInHands());
1974
1975 return;
1976 }
1977
1978
1979 //--------------------------------------------
1981
1983 return;
1984
1985
1986 //--------------------------------------------
1987 // vehicle handling
1988 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_VEHICLE)
1989 {
1991 if (hcv.WasGearChange())
1992 {
1994 cb.SetVehicleCommand(hcv);
1995 }
1996
1997 return;
1998 }
1999
2001 //--------------------------------------------
2003 if (hcm && hcm.GetCurrentMovementSpeed() > 2.99 && m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
2004 {
2005 m_SprintedTime += pDt;
2006 if (m_SprintedTime > m_SprintedTimePerStanceMin)
2007 {
2008 m_SprintFull = true;
2009 m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_DEFAULT;
2010 }
2011 else
2012 m_SprintFull = false;
2013 }
2014 else
2015 {
2016 m_SprintedTime = 0.0;
2017 m_SprintFull = false;
2018 }
2019
2020 //--------------------------------------------
2021 // swimming handling
2022 if (m_Swimming.HandleSwimming(pCurrentCommandID, hcm, m_MovementState))
2023 {
2024 m_JumpClimb.CheckAndFinishJump();
2025 return;
2026 }
2027
2028 //--------------------------------------------
2029 // ladder handling
2030 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_LADDER)
2031 {
2032 OnLadder(pDt, m_MovementState);
2033 return;
2034 }
2035
2036 //--------------------------------------------
2037 // climb handling
2038 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_CLIMB)
2039 return;
2040
2041 //--------------------------------------------
2042 // fall handling
2043
2044 if (IsAlreadyInFallingCommand(pCurrentCommandID))
2045 {
2046 if (IsLanded(pCurrentCommandID))
2047 {
2050
2052 fallDamageData.m_Height = m_FallYDiff - GetPosition()[1];
2053
2054 // land
2055 if (fallDamageData.m_Height < 0.5)
2056 {
2057 fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_NONE;
2059 npar = type.GetNoiseParamsLandLight();
2060 AddNoise(npar);
2061 }
2062 else if (fallDamageData.m_Height < 3.0)
2063 {
2064 if (m_MovementState.IsInProne() || m_MovementState.IsInRaisedProne())
2065 fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_NONE;
2066 else
2067 fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_LIGHT;
2068
2070 npar = type.GetNoiseParamsLandLight();
2071 AddNoise(npar);
2072 }
2073 else if (fallDamageData.m_Height < 5.0)
2074 {
2075 fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_MEDIUM;
2077 npar = type.GetNoiseParamsLandHeavy();
2078 AddNoise(npar);
2079 }
2080 else
2081 {
2082 fallDamageData.m_LandType = HumanCommandFall.LANDTYPE_HEAVY;
2084 npar = type.GetNoiseParamsLandHeavy();
2085 AddNoise(npar);
2086 }
2087
2088 if (fallDamageData.m_Height >= DayZPlayerImplementFallDamage.HEALTH_HEIGHT_LOW && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2089 OnPlayerRecievedHit();
2090
2091 m_FallDamage.HandleFallDamage(fallDamageData);
2092 m_JumpClimb.CheckAndFinishJump(fallDamageData.m_LandType);
2093 }
2094
2096 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL)
2097 return;
2098 }
2099 else if (PhysicsIsFalling(false))
2100 {
2101 // Not in a falling command but the controller is falling, start default fall
2103 SetFallYDiff(GetPosition()[1]);
2104 return;
2105 }
2106
2107 //--------------------------------------------
2108 // handle jumping
2109
2110#ifndef NO_GUI
2111#ifdef DEVELOPER
2113
2114 if (DiagMenu.GetEngineValue(DayZPlayerConstants.DEBUG_ENABLEJUMP))
2115 {
2116 SHumanCommandClimbSettings hcls = GetDayZPlayerType().CommandClimbSettingsW();
2117
2118 if (m_MovementState.m_iMovement != DayZPlayerConstants.MOVEMENTIDX_IDLE)
2119 hcls.m_fFwMaxDistance = 3;
2120 else
2121 hcls.m_fFwMaxDistance = 1.2;
2122
2124
2126 HumanCommandClimb.DoClimbTest(this, ret, 0x3);
2127 }
2128
2129#endif
2130#endif
2131
2132 // start jump
2133 if (hic.IsJumpClimb())
2134 {
2135 m_JumpClimb.JumpOrClimb();
2136
2137 if (m_JumpClimb.WasSuccessful())
2138 return;
2139 }
2140
2142
2143 bool force = false;
2144#ifndef NO_GUI
2145#ifdef DEVELOPER
2147 force = DiagMenu.GetEngineValue(DayZPlayerConstants.DEBUG_ENABLETALKING);
2148#endif
2149#endif
2150 float amplitude = IsPlayerSpeaking();
2151
2152 if (amplitude > 0.1 || force)
2153 {
2154 if (ad)
2155 ad.SetTalking(true);
2156
2157 // add noises on server
2158 if (GetGame().IsServer())
2159 {
2160 int now = GetGame().GetTime();
2161 if (now >= m_NextVoNNoiseTime)
2162 {
2163 m_NextVoNNoiseTime = now + 1000;
2164
2165 int voiceLevel = GetGame().GetVoiceLevel(this);
2167
2168 // add noise every second while talking
2170 switch (voiceLevel)
2171 {
2172 case VoiceLevelWhisper:
2173 vonpar = pt.GetNoiseParamsWhisper();
2174 break;
2175 case VoiceLevelTalk:
2176 vonpar = pt.GetNoiseParamsTalk();
2177 break;
2178 case VoiceLevelShout:
2179 vonpar = pt.GetNoiseParamsShout();
2180 break;
2181 }
2183 }
2184 }
2185 }
2186 else
2187 {
2188 if (ad)
2189 ad.SetTalking(false);
2190 }
2191
2192 //--------------------------------------------
2193 // anything whats handled by InputController
2194
2196
2197 if (hic)
2198 {
2201 m_Throwing.HandleThrowing(hic, hcw, entityInHands, pDt);
2202
2204 if (m_MeleeFightLogic.CanFight())
2205 {
2206 if (m_MeleeFightLogic.HandleFightLogic(pCurrentCommandID, hic, entityInHands, m_MovementState, m_ContinueFirearmMelee))
2207 {
2208 m_ProcessFirearmMeleeHit = isWeapon && (hic.IsMeleeWeaponAttack() || m_ProcessFirearmMeleeHit) || m_ContinueFirearmMelee;
2209 return;
2210 }
2211 }
2212 }
2213
2214
2217 return;
2218 }
2219
2220 void HideClothing(ItemOptics optic, bool state) {}
2221
2222 //-------------------------------------------------------------
2226
2227 float m_TestDamageCounter = -1;
2228 float m_DebugDirectionVal = -180;
2229 bool m_DebugTypeVal = false;
2230
2231 int m_DebugWeaponChangeStage = 0;
2232 string m_DebugWeaponChangeItem;
2233 int m_DebugWeaponChangeShowSlot;
2234
2236 void CommandHandlerDebug(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
2237 {
2238 if (GetPluginManager())
2239 {
2241 if (playerDebug)
2242 {
2243 playerDebug.CommandHandler();
2244
2246 if (m_DebugWeaponChangeStage == 0)
2247 {
2248
2249 // debug weapon change
2250 int hideSlot;
2251
2252 if (playerDebug.IsWeaponChange(m_DebugWeaponChangeItem, hideSlot, m_DebugWeaponChangeShowSlot))
2253 {
2254 //Print("Change Weapon started: " + m_DebugWeaponChangeItem + "," + hideSlot.ToString() + "," + m_DebugWeaponChangeShowSlot.ToString());
2255
2257 w.StartAction(WeaponActions.HIDE, hideSlot);
2258
2259 m_DebugWeaponChangeStage = 1;
2260 }
2261 }
2262 else if (m_DebugWeaponChangeStage == 1)
2263 {
2264 // wait for weapon hide to meet event
2266 if (w2 && w2.GetRunningAction() == WeaponActions.HIDE)
2267 {
2268 if (w2.IsEvent() == WeaponEvents.CHANGE_HIDE)
2269 {
2271 //Print("Change Weapon - hidden: ");
2272
2274 PlayerBase player = PlayerBase.Cast(this);
2275 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
2276 if (item_in_hands != NULL && player.CanDropEntity(item_in_hands) && GetGame().GetPlayer().GetHumanInventory().CanRemoveEntityInHands())
2277 player.PredictiveDropEntity(item_in_hands);
2278
2279 if (m_DebugWeaponChangeItem != "")
2280 {
2282 dst.SetHands(this, NULL);
2283 EntityAI item = SpawnEntity(m_DebugWeaponChangeItem, dst, ECE_IN_INVENTORY, RF_DEFAULT);
2284 }
2285
2287 w2.StartAction(WeaponActions.SHOW, 3);
2288
2289 m_DebugWeaponChangeStage = 2;
2290 }
2291 }
2292 }
2293 else if (m_DebugWeaponChangeStage == 2)
2294 {
2296 if (w3 && w3.IsActionFinished())
2297 m_DebugWeaponChangeStage = 0;
2298 }
2299 }
2300 }
2301
2302
2304 if (m_TestDamageCounter >= 0)
2305 {
2306 if (m_TestDamageCounter > 3)
2307 {
2308 m_DebugDirectionVal = m_DebugDirectionVal + 90;
2309 m_TestDamageCounter = 0;
2310
2311 if (m_DebugDirectionVal > 90)
2312 {
2313 m_DebugDirectionVal = -180;
2314 m_DebugTypeVal = !m_DebugTypeVal;
2315 }
2316
2317 if (m_DebugTypeVal)
2318 {
2319 AddCommandModifier_Damage(0, m_DebugDirectionVal); // starts light
2320 }
2321 else
2322 {
2323 StartCommand_Damage(0, m_DebugDirectionVal); // starts heavy (full body)
2324 }
2325 // 0.. types
2326 // from: -180 back, -90 left, 0 front, 90 right, 180 back
2327 //AddCommandModifier_Damage(0, directionVal); // starts light
2328 //StartCommand_Damage(0, 0); // starts heavy (full body)
2329 }
2330
2331 m_TestDamageCounter += pDt;
2332 }
2333
2334
2335#ifndef NO_GUI
2336#ifdef DEVELOPER
2337
2338 // injury / exhaustion
2339 {
2341
2343 float v = DiagMenu.GetEngineRangeValue(DayZPlayerConstants.DEBUG_SHOWINJURY);
2344 if (v > 0)
2345 ad.SetInjured(v, true);
2346
2348 v = DiagMenu.GetEngineRangeValue(DayZPlayerConstants.DEBUG_SHOWEXHAUSTION);
2349 if (v > 0)
2350 ad.SetExhaustion(v, true);
2351 }
2352#endif
2353#endif
2354
2355 }
2356
2357
2358 //-------------------------------------------------------------
2362 override int CameraHandler(int pCameraMode)
2363 {
2365 if (!m_LiftWeapon_player)
2366 {
2368 EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
2370 if (weapon)
2371 optics = weapon.GetAttachedOptics();
2372 else if (entityInHands)
2374
2375 if (m_CameraOptics && optics)
2377 else if (m_CameraIronsight && weapon)
2379 }
2380
2381 // If the logic above doesn't reach optics nor ironsights camera,
2382 // yet weapon is still raised and ads is wanted, enforce 1pv camera
2383 // as this will reduce erratic behaviour of camera switching in 3pv
2385 if (m_Camera3rdPerson && m_IsWeapon && m_IsRaised && hic && hic.WeaponADS())
2387
2388 //uncon
2389 if (GetCurrentCommandID() == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
2391
2393
2394 if (!m_Camera3rdPerson)
2395 {
2396 if (vehicleCommand)
2398
2400 }
2401 else
2402 {
2403 if (vehicleCommand)
2404 {
2405 Transport transport = vehicleCommand.GetTransport();
2406 if (transport && GetParent())
2407 return transport.Get3rdPersonCameraType();
2408 }
2409
2412
2416
2418
2420
2421 if (m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_CLIMB)
2423
2424 if (m_JumpClimb.m_bIsJumpInProgress)
2426
2427 int targetStanceIndex = m_MovementState.m_iStanceIdx;
2428
2431 if (commandMove && commandMove.IsChangingStance() && m_MovementState.IsRaised())
2432 targetStanceIndex = m_MovementState.m_iStanceIdx - DayZPlayerConstants.STANCEIDX_RAISED;
2433
2434 //
2435 // normal movement cameras
2436 if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_CROUCH)
2438 else if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
2440 else if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_PRONE)
2442 else if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
2444
2445 if (targetStanceIndex == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
2446 {
2447 if (m_IsWeapon)
2449 else
2451 }
2452 else if (targetStanceIndex == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
2454
2455 // DayZPlayerConstants.STANCEIDX_ERECT
2457 }
2458
2460 }
2461
2463 void OnMovementChanged()//(int state_old, int state_new)
2464 {
2465 switch (m_MovementState.m_LocalMovement)
2466 {
2467 case DayZPlayerConstants.MOVEMENTIDX_CROUCH_RUN:
2468 {
2469 //OnCrouchRunEnd();
2470 break;
2471 }
2472 case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
2473 {
2474 OnSprintEnd();
2475 break;
2476 }
2477 case DayZPlayerConstants.MOVEMENTIDX_RUN:
2478 {
2479 //OnRunEnd();
2480 break;
2481 }
2482 case DayZPlayerConstants.MOVEMENTIDX_WALK:
2483 {
2484 //OnWalkEnd();
2485 break;
2486 }
2487 case DayZPlayerConstants.MOVEMENTIDX_IDLE:
2488 {
2489 //OnIdleEnd();
2490 break;
2491 }
2492 case DayZPlayerConstants.MOVEMENTIDX_SLIDE:
2493 {
2494 //OnSlideEnd();
2495 break;
2496 }
2497 }
2498
2499 switch (m_MovementState.m_iMovement)
2500 {
2501 case DayZPlayerConstants.MOVEMENTIDX_CROUCH_RUN:
2502 {
2503 //OnCrouchRunStart();
2504 break;
2505 }
2506 case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
2507 {
2508 OnSprintStart();
2509 break;
2510 }
2511 case DayZPlayerConstants.MOVEMENTIDX_RUN:
2512 {
2513 //OnRunStart();
2514 break;
2515 }
2516 case DayZPlayerConstants.MOVEMENTIDX_WALK:
2517 {
2518 //OnWalkStart();
2519 break;
2520 }
2521 case DayZPlayerConstants.MOVEMENTIDX_IDLE:
2522 {
2523 //OnIdleStart();
2524 break;
2525 }
2526 case DayZPlayerConstants.MOVEMENTIDX_SLIDE:
2527 {
2528 //OnSlideStart();
2529 break;
2530 }
2531 }
2532 }
2533
2534 void OnSprintStart()
2535 {
2536 if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2537 {
2538 GetUApi().GetInputByID(UALeanLeft).Lock();
2539 GetUApi().GetInputByID(UALeanRight).Lock();
2540 }
2541 }
2542
2543 void OnSprintEnd()
2544 {
2545 if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2546 {
2547 GetUApi().GetInputByID(UALeanLeft).Unlock();
2548 GetUApi().GetInputByID(UALeanRight).Unlock();
2549 }
2550 }
2551 //-------------------------------------------------------------
2555
2556 void OnInputUserDataReceived(ParamsReadContext ctx)
2557 {
2558 int userDataTypeParam = 0;
2559 if (!ctx.Read(userDataTypeParam))
2560 {
2561 Error("DayZPlayerImplement: cannot read input type");
2562 return;
2563 }
2564
2566 }
2567
2569 {
2570 m_MeleeCombat.SetTargetObject(null);
2571 m_MeleeCombat.SetHitPos(vector.Zero);
2572 m_MeleeCombat.SetHitZoneIdx(-1);
2573 m_MeleeCombat.SetFinisherType(-1);
2574
2576 {
2578 if (ctx.Read(target))
2579 m_MeleeCombat.SetTargetObject(target);
2580
2582 if (ctx.Read(hitPos))
2583 m_MeleeCombat.SetHitPos(hitPos);
2584
2585 int hitZoneIdx = -1;
2586 if (ctx.Read(hitZoneIdx))
2587 m_MeleeCombat.SetHitZoneIdx(hitZoneIdx);
2588
2589 int finisherType = -1;
2590 if (ctx.Read(finisherType))
2591 m_MeleeCombat.SetFinisherType(finisherType);
2592
2593 return true;
2594 }
2595
2596 return false;
2597 }
2598
2599 //-------------------------------------------------------------
2604 {
2605 switch (pJunctureID)
2606 {
2608 if (m_DeathAnimType == -2)
2609 DayZPlayerSyncJunctures.ReadDeathParams(pCtx, m_DeathAnimType, m_DeathHitDir);
2610 break;
2611
2615 m_SyncedHitDataArray.Insert(data);
2616 break;
2617 }
2618 }
2619
2620 AnimBootsType GetBootsType()
2621 {
2622 EntityAI boots = GetInventory().FindAttachment(InventorySlots.FEET);
2623 if (boots)
2624 {
2625 switch (boots.GetAttachmentSoundType())
2626 {
2627 case "Sneakers":
2628 return AnimBootsType.Sneakers;
2629 case "Boots":
2630 return AnimBootsType.Boots;
2631 }
2632 }
2633
2634 return AnimBootsType.None;
2635 }
2636
2637 //Get top body clothes
2638 AnimUpperBodyType GetBodyAttachmentType()
2639 {
2640 EntityAI attachment = GetInventory().FindAttachment(InventorySlots.BODY);
2641 if (attachment)
2642 {
2643 switch (attachment.GetAttachmentSoundType())
2644 {
2645 case "NylonJacket":
2646 return AnimUpperBodyType.NylonJacket;
2647 case "TShirt":
2648 return AnimUpperBodyType.TShirt;
2649 case "WoolShirt":
2650 return AnimUpperBodyType.WoolShirt;
2651 case "HeavyJacket":
2652 return AnimUpperBodyType.HeavyJacket;
2653 case "LeatherJacket":
2654 return AnimUpperBodyType.LeatherJacket;
2655 case "Coat":
2656 return AnimUpperBodyType.Coat;
2657 case "ChemlonDress":
2658 return AnimUpperBodyType.ChemlonDress;
2659 case "Ghillie":
2660 return AnimUpperBodyType.Ghillie;
2661 case "Chainmail":
2662 return AnimUpperBodyType.Chainmail;
2663 }
2664 }
2665
2666 return AnimUpperBodyType.None;
2667 }
2668
2669 AnimBackType GetBackAttachmentType()
2670 {
2671 EntityAI back = GetInventory().FindAttachment(InventorySlots.BACK);
2672 if (back)
2673 {
2674 switch (back.GetAttachmentSoundType())
2675 {
2676 case "Small":
2677 return AnimBackType.Small;
2678 case "Military":
2679 return AnimBackType.Military;
2680 case "Outdoor":
2681 return AnimBackType.Outdoor;
2682 case "Ghillie":
2683 return AnimBackType.Ghillie;
2684 }
2685 }
2686
2687 return AnimBackType.None;
2688 }
2689
2690 //Get weapon on back
2691 AnimRangedWeaponType GetShoulderAttachmentType()
2692 {
2693 EntityAI shoulderAttachment = GetInventory().FindAttachment(InventorySlots.SHOULDER);
2694 EntityAI meleeAttachment = GetInventory().FindAttachment(InventorySlots.MELEE);
2695
2698
2700 {
2701 switch (shoulderAttachment.GetAttachmentSoundType())
2702 {
2703 case "Shotgun":
2704 {
2706 break;
2707 }
2708 case "Rifle":
2709 {
2711 break;
2712 }
2713 }
2714 }
2715 if (meleeAttachment)
2716 {
2717 switch (meleeAttachment.GetAttachmentSoundType())
2718 {
2719 case "Shotgun":
2720 {
2722 break;
2723 }
2724 case "Rifle":
2725 {
2727 break;
2728 }
2729 }
2730 }
2731
2733 return AnimRangedWeaponType.Shotgun;
2734
2736 return AnimRangedWeaponType.Rifle;
2737
2738 return AnimRangedWeaponType.None;
2739 }
2740
2741 string GetSurfaceType(SurfaceAnimationBone limbType)
2742 {
2743 string surfaceType;
2744 int liquidType;
2745
2746 g_Game.SurfaceUnderObjectByBone(this, limbType, surfaceType, liquidType);
2747
2748 return surfaceType;
2749 }
2750
2751 //-------------------------------------------------------------
2755
2757 {
2758 if (so == null)
2759 return null;
2760
2761 so.SetPosition(GetPosition());
2762 AbstractWave wave = GetGame().GetSoundScene().Play3D(so, sob);
2763 return wave;
2764 }
2765
2766 void AddNoise(NoiseParams noisePar, float noiseMultiplier = 1.0)
2767 {
2768 if (noisePar != null)
2769 GetGame().GetNoiseSystem().AddNoise(this, noisePar, noiseMultiplier);
2770 }
2771
2772 //-------------------------------------------------------------
2776
2777 void OnStepEvent(string pEventType, string pUserString, int pUserInt)
2778 {
2782
2783#ifndef SERVER
2784 DayZPlayerTypeStepSoundLookupTable table = type.GetStepSoundLookupTable();
2786 if (pUserInt < 100)
2787 {
2788 string surface;
2789 if (pUserInt % 2 == 1)
2790 {
2791 surface = GetSurfaceType(SurfaceAnimationBone.LeftBackLimb);
2792 if (surface.Length() == 0)//if no surface found, try other leg
2793 surface = GetSurfaceType(SurfaceAnimationBone.RightBackLimb);
2794 }
2795 else
2796 {
2797 surface = GetSurfaceType(SurfaceAnimationBone.RightBackLimb);
2798 if (surface.Length() == 0)//if no surface found, try other leg
2799 surface = GetSurfaceType(SurfaceAnimationBone.LeftBackLimb);
2800 }
2801
2802 if (surface.Length() != 0)
2803 m_LastSurfaceUnderHash = surface.Hash();
2804
2805 soundBuilder = table.GetSoundBuilder(pUserInt, state.m_iMovement, m_LastSurfaceUnderHash, GetBootsType());
2806 }
2807 else
2808 {
2809 string surface2 = GetSurfaceType();
2810 if (surface2.Length() != 0)
2811 m_LastSurfaceUnderHash = surface2.Hash();
2812
2813 soundBuilder = table.GetSoundBuilder(pUserInt, state.m_iMovement, m_LastSurfaceUnderHash, GetBootsType());
2814 }
2815
2816 if (soundBuilder != NULL && GetGame().GetPlayer())
2817 {
2818 vector orientation = Vector(0, 0, 0);
2819 vector edgeLength = Vector(1.5, 3.0, 1.5);
2822
2824 {
2825 for (int i = 0; i < collidedObjects.Count(); ++i)
2826 {
2827 string objectClass = collidedObjects.Get(i).GetType();
2828
2829 if (objectClass.Contains("BushSoft") || objectClass.Contains("BushHard"))
2830 {
2831 for (int j = 0; j < type.GetVegetationSounds().Count(); ++j)
2832 {
2833 VegetationSound vegetationSound = type.GetVegetationSounds().Get(j);
2834
2835 if (vegetationSound.GetAnimEventIds().Find(pUserInt) >= 0)
2836 {
2838 SoundObject vegSoundObject = vegetationSound.GetSoundObjectBuilder().BuildSoundObject();
2839
2840 if (vegSoundObject != NULL)
2841 {
2842 AttenuateSoundIfNecessary(vegSoundObject);
2844 }
2845
2846 break;
2847 }
2848 }
2849
2850 break;
2851 }
2852 }
2853 }
2854
2855 SoundObject soundObject = soundBuilder.BuildSoundObject();
2856 if (soundObject != NULL)
2857 {
2858 AttenuateSoundIfNecessary(soundObject);
2860 }
2861 }
2862#endif
2863
2864 if (GetGame().IsServer())
2865 {
2866 m_StepCounter++;//move outside of server condition if needed on client as well
2867
2868 float noiseMultiplier = 0;
2869
2871 if (state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT || state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
2872 noiseParams = type.GetNoiseParamsStand();
2873 else if (state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH || state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
2874 noiseParams = type.GetNoiseParamsCrouch();
2875 else if (state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || state.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
2876 noiseParams = type.GetNoiseParamsProne();
2877 else
2878 {
2879 Debug.Log(string.Format("Wrong stance, id: %1 using backup with stand stance (id: 0)", state.m_iStanceIdx));
2880 noiseParams = type.GetNoiseParamsStand();
2881 }
2882
2884
2886
2887 if ((m_StepCounter % PlayerConstants.CHECK_EVERY_N_STEP) == 0)
2888 ProcessFeetDamageServer(pUserInt);
2889 }
2890 }
2891
2892 void OnSoundEvent(string pEventType, string pUserString, int pUserInt)
2893 {
2894 if (pEventType == "Sound")
2895 ProcessSoundEvent(pEventType, pUserString, pUserInt);
2896 else if (pEventType == "SoundWeapon")
2897 ProcessWeaponEvent(pEventType, pUserString, pUserInt);
2898 else if (pEventType == "SoundAttachment")
2899 ProcessAttachmentEvent(pEventType, pUserString, pUserInt);
2900 else if (pEventType == "SoundVoice")
2901 {
2902 if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE)
2903 {
2904 int event_id = m_PlayerSoundEventHandler.ConvertAnimIDtoEventID(pUserInt);
2905 if (event_id > 0)
2906 {
2907 PlaySoundEvent(event_id);
2908 return;
2909 }
2910 }
2911 ProcessVoiceEvent(pEventType, pUserString, pUserInt);
2912 }
2913 else
2914 Debug.Log("OnSoundEvent: Unknown sound event \"" + pEventType + "\"");
2915 }
2916
2917 void OnParticleEvent(string pEventType, string pUserString, int pUserInt)
2918 {
2919
2920 }
2921
2922
2923 void ProcessWeaponEvent(string pEventType, string pUserString, int pUserInt)
2924 {
2927
2928 float quantity = 0;
2929
2930 EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
2931 if (entityInHands && entityInHands.IsInherited(ItemBase))
2932 {
2933 ItemBase item;
2935 if (item.HasQuantity())
2936 quantity = (float)item.GetQuantity() / (item.GetQuantityMax() - item.GetQuantityMin());
2937 InventoryItemType invItemType = item.GetInventoryItemType();
2938 soundEvent = invItemType.GetSoundEvent(pUserInt);
2939 }
2940
2941 if (soundEvent == null)
2942 {
2943 quantity = 0;
2944 soundEvent = type.GetSoundWeaponEvent(pUserInt);
2945 }
2946
2947 if (soundEvent != null)
2948 {
2949 if (!GetGame().IsDedicatedServer())
2950 {
2951 SoundObjectBuilder builder = soundEvent.GetSoundBuilderEx(m_ActionSoundCategoryHash);
2952 if (builder)
2953 {
2954 builder.AddVariable("quantity", quantity);
2955 builder.AddVariable("interior", IsSoundInsideBuilding());
2956
2957 SoundObject soundObject = builder.BuildSoundObject();
2958 if (soundObject != NULL)
2959 {
2960 AttenuateSoundIfNecessary(soundObject);
2962 }
2963 }
2964 else
2965 {
2966 //TODO:Userful error message
2967 }
2968 }
2969
2970 if (GetGame().IsServer())
2971 AddNoise(soundEvent.m_NoiseParams);
2972 }
2973 }
2974
2975 void ProcessAttachmentEvent(string pEventType, string pUserString, int pUserInt)
2976 {
2978 DayZPlayerTypeAttachmentSoundLookupTable table = type.GetAttachmentSoundLookupTable();
2979
2981 pUserString.Split(",", attachments);
2982 for (int i = 0; i < attachments.Count(); i++)
2983 {
2984 int attachmentHash = -1;
2985 if (attachments[i] == "shoulder")
2986 attachmentHash = GetShoulderAttachmentType();
2987 else if (attachments[i] == "body")
2988 attachmentHash = GetBodyAttachmentType();
2989 else if (attachments[i] == "back")
2990 attachmentHash = GetBackAttachmentType();
2991
2993
2994 if (soundBuilder != NULL)
2995 {
2996 SoundObject soundObject = soundBuilder.BuildSoundObject();
2997 if (soundObject != NULL)
2998 {
2999 AttenuateSoundIfNecessary(soundObject);
3001 }
3002 }
3003 }
3004 }
3005
3006 void SetVariablesLadderSoundObjectBuilder(SoundObjectBuilder soundObjectBuilder)
3007 {
3008 if (m_ClimbingLadderType == "wood")
3009 soundObjectBuilder.AddVariable("laddertype", 1);
3010 else
3011 soundObjectBuilder.AddVariable("laddertype", 0);
3012
3013 AnimBootsType pBoots = GetBootsType();
3014
3015 if (pBoots == AnimBootsType.None)
3016 {
3017 soundObjectBuilder.AddVariable("bare", 1);
3018 soundObjectBuilder.AddVariable("sneakers", 0);
3019 soundObjectBuilder.AddVariable("boots", 0);
3020 }
3021 else if (pBoots == AnimBootsType.Sneakers)
3022 {
3023 soundObjectBuilder.AddVariable("bare", 0);
3024 soundObjectBuilder.AddVariable("sneakers", 1);
3025 soundObjectBuilder.AddVariable("boots", 0);
3026 }
3027 else if (pBoots == AnimBootsType.Boots)
3028 {
3029 soundObjectBuilder.AddVariable("bare", 0);
3030 soundObjectBuilder.AddVariable("sneakers", 0);
3031 soundObjectBuilder.AddVariable("boots", 1);
3032 }
3033 }
3034
3035 void ProcessSoundEvent(string pEventType, string pUserString, int pUserInt)
3036 {
3038 DayZPlayerTypeAnimTable table = type.GetSoundTable();
3040 if (table)
3041 soundEvent = table.GetSoundEvent(pUserInt);
3042
3043 if (soundEvent != NULL)
3044 {
3045 if (!GetGame().IsDedicatedServer())
3046 {
3047 SoundObjectBuilder objectBuilder = soundEvent.GetSoundBuilder();
3048 if (GetCommand_Ladder())
3049 SetVariablesLadderSoundObjectBuilder(objectBuilder);
3050 objectBuilder.AddEnvSoundVariables(GetPosition());
3051
3052 SoundObject soundObject = objectBuilder.BuildSoundObject();
3053 if (soundObject != NULL)
3054 {
3055 AttenuateSoundIfNecessary(soundObject);
3057 }
3058 }
3059
3060 if (GetGame().IsServer())
3061 {
3062 if (soundEvent.m_NoiseParams != NULL)
3063 GetGame().GetNoiseSystem().AddNoise(this, soundEvent.m_NoiseParams);
3064 }
3065 }
3066 }
3067
3068
3069 AbstractWave ProcessVoiceEvent(string pEventType, string pUserString, int pUserInt)
3070 {
3071#ifdef SERVER//none of this code needs to run on server, ifdef put here rather than before the method call to maintain mod compatibility
3072 return null;
3073#endif
3075 DayZPlayerTypeVoiceSoundLookupTable table = type.GetVoiceSoundLookupTable();
3076 if (!table)
3077 return null;
3079 EntityAI mask = GetInventory().FindAttachment(InventorySlots.MASK);
3080 EntityAI head_gear = GetInventory().FindAttachment(InventorySlots.HEADGEAR);
3081
3082 string category;
3083 if (mask || head_gear)
3084 {
3085 string category_mask;
3086 string category_headgear;
3087
3088 int priority_mask;
3090
3091 if (mask)
3092 {
3093 category_mask = mask.ConfigGetString("soundVoiceType");
3094 priority_mask = mask.ConfigGetInt("soundVoicePriority");
3095 }
3096 if (head_gear)
3097 {
3098 category_headgear = head_gear.ConfigGetString("soundVoiceType");
3099 priority_headgear = head_gear.ConfigGetInt("soundVoicePriority");
3100 }
3101
3104 else
3106 }
3107
3108 if (category == "")
3109 category = "none";
3110
3111 SoundObjectBuilder soundBuilder = table.GetSoundBuilder(pUserInt, category.Hash());
3112
3113 if (soundBuilder)
3114 {
3115 PlayerBase player = PlayerBase.Cast(this);
3116 //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
3117 int maleVoiceType = 0;
3118 int femaleVoiceType = 0;
3119 if (player.IsMale())
3120 maleVoiceType = player.GetVoiceType();
3121 else
3122 femaleVoiceType = player.GetVoiceType();
3123
3124 soundBuilder.AddVariable("male", maleVoiceType);
3125 soundBuilder.AddVariable("female", femaleVoiceType);
3126
3127 // end of weirdness
3128 SoundObject soundObject = soundBuilder.BuildSoundObject();
3129 if (soundObject != NULL)
3130 {
3131 AttenuateSoundIfNecessary(soundObject);
3133 }
3134
3135 }
3136
3137 return wave;
3138 }
3139
3140 void ProcessFeetDamageServer(int pUserInt);
3141
3142
3143 //-------------------------------------------------------------
3147
3148 bool CheckForTakeItem(EntityAI item)
3149 {
3150 bool restrained = IsRestrained(); // IsRestrained()
3151 bool unconscious = IsUnconscious(); // IsRestrained()
3152
3153 ItemBase ib = ItemBase.Cast(item);
3154 if (ib && (PlayerBase.DEBUG_INVENTORY_ACCESS || !IsAlive() || restrained || unconscious || ib.CanBeMovedOverride()))
3155 return true;
3156 return false;
3157 }
3158
3159 bool CheckForDropItem(EntityAI item)
3160 {
3161 /*
3162 bool restrained = IsRestrained(); // IsRestrained()
3163 bool unconscious = IsUnconscious(); // IsRestrained()
3164
3165 ItemBase ib = ItemBase.Cast(item);
3166 if (!IsAlive() || restrained || unconscious || ib.CanBeMovedOverride())
3167 return true;
3168 return false;
3169 */
3170 return CheckForTakeItem(item); //the two functions are currently identical
3171 }
3172
3173 //-------------------------------------------------------------
3177 bool CheckForRespawn(EntityAI item)
3178 {
3179 PlayerBase player = PlayerBase.Cast(this);
3180 if (!player)
3181 return true;
3182
3183 if (!IsAlive() || player.IsUnconscious())
3184 return true;
3185 return false;
3186 }
3187
3188#ifdef DEVELOPER
3189
3190 // -------------------------------------------------------------------------
3192 {
3193 super.OnRPC(sender, rpc_type, ctx);
3194
3195 if (rpc_type == ERPCs.RPC_DAYZPLAYER_DEBUGSERVERWALK)
3196 {
3197 Print("ERPCs.RPC_DAYZPLAYER_DEBUGSERVERWALK");
3198
3199 Param1<bool> rp = new Param1<bool>(false);
3200 ctx.Read(rp);
3201
3202 GetInputController().OverrideMovementSpeed(rp.param1, 1);
3203 GetInputController().OverrideAimChangeX(rp.param1, 0.01);
3204
3205 }
3206 }
3207
3208#endif
3209
3210 bool IsLanded(int pCurrentCommandID)
3211 {
3212 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL)
3213 {
3215
3216 if (fall)
3217 return fall.PhysicsLanded();
3218 }
3219
3220 return false;
3221 }
3222
3224 {
3225 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL)
3226 {
3228
3229 if (fall)
3230 {
3231 fall.Land(fallDamageData.m_LandType);
3232 return true;
3233 }
3234 }
3235
3236 return false;
3237 }
3238
3239 bool IsAlreadyInFallingCommand(int pCurrentCommandID)
3240 {
3241 return pCurrentCommandID == DayZPlayerConstants.COMMANDID_FALL;
3242 }
3243
3245 void OverrideSlidePoseAngle(float value)
3246 {
3247 if (!m_MoveSettings)
3248 m_MoveSettings = GetDayZPlayerType().CommandMoveSettingsW();
3249 if (m_MoveSettings.m_fSlidingPoseAngle != value)
3250 {
3251 m_MoveSettings.m_fSlidingPoseAngle = value;
3252 StartCommand_Move(); //nescessary, re-initializes with adjusted values
3253 }
3254 }
3255
3256 float GetSlidePoseAngle()
3257 {
3258 return GetDayZPlayerType().CommandMoveSettingsW().m_fSlidingPoseAngle;
3259 }
3260
3261 void CheckAnimationOverrides()
3262 {
3263 }
3264
3265 bool IsPlayerSelected()
3266 {
3267 return m_PlayerSelected;
3268 }
3269
3270 bool IsRestrained();
3271
3273 bool IsInFBEmoteState();
3274
3275 void SetSuicide(bool state)
3276 {
3277 m_Suicide = state;
3278 }
3279
3280 bool CommitedSuicide()
3281 {
3282 return m_Suicide;
3283 }
3284
3286 void OnLadder(float delta_time, HumanMovementState pState);
3287
3288 //-------------------------------------------------------------
3292
3293 override protected void EOnContact(IEntity other, Contact extra)
3294 {
3295 if (!IsAlive())
3296 return;
3297
3298 if (GetParent() == other)
3299 return;
3300
3302 if (transport)
3303 {
3304 if (GetGame().IsServer())
3305 RegisterTransportHit(transport);
3306 }
3307 }
3308
3309 protected void AttenuateSoundIfNecessary(SoundObject soundObject)
3310 {
3311 if (GetGame().GetPlayer() != NULL && (IsSoundInsideBuilding() != GetGame().GetPlayer().IsSoundInsideBuilding() || IsCameraInsideVehicle() != GetGame().GetPlayer().IsCameraInsideVehicle()))
3312 soundObject.SetKind(WaveKind.WAVEATTALWAYS);
3313 else
3314 soundObject.SetKind(WaveKind.WAVEEFFECTEX);
3315 }
3316
3317 void CheckLiftWeapon();
3318 void ProcessLiftWeapon();
3319
3320 void SetHandheldOpticsInUse(bool state)
3321 {
3322 m_HandheldOpticsInUse = state;
3323 }
3324
3325 bool IsHandheldOpticsInUse()
3326 {
3327 return m_HandheldOpticsInUse;
3328 }
3329
3330 bool IsLiftWeapon();
3331 bool IsRaised()
3332 {
3333 return m_IsRaised;
3334 }
3335
3336 bool IsFighting();
3337
3339 // Will return true when the item is not heavy as well
3340 bool CanPickupHeavyItem(notnull EntityAI item)
3341 {
3342 return !item.IsHeavyBehaviour() || (item.IsHeavyBehaviour() && DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_ERECT));
3343 }
3344
3345 bool CanPickupHeavyItemSwap(notnull EntityAI item1, notnull EntityAI item2)
3346 {
3347 return CanPickupHeavyItem(item1) && CanPickupHeavyItem(item2);
3348 }
3349
3350#ifdef DIAG_DEVELOPER
3351 Weapon_Base SpawnWeaponInHands(string type)
3352 {
3353 return Weapon_Base.Cast(GetHumanInventory().CreateInHands(type));
3354 }
3355#endif
3356
3358 //Obsolete stuff below this point//
3360
3361 protected bool m_CameraEyeZoom; //DEPRECATED
3362 ref Timer m_ADSAutomationTimer; //DEPRECATED
3363 protected bool m_ADSTimerLaunched; //DEPRECATED
3364 protected bool m_ProcessWeaponRaiseCompleted; //DEPRECATED
3365 protected bool m_IsFireWeaponRaised; //DEPRECATED, value still set for legacy reasons
3366 void SetReturnToOptics(bool state); //DEPRECATED
3367 void RunADSTimer(); //DEPRECATED
3368 void StopADSTimer(); //DEPRECATED
3369}
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()
Definition ActionBase.c:989
void OnJumpStart()
override void OnVariablesSynchronized()
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
const int RF_DEFAULT
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DamageType
exposed from C++ (do not change)
AnimBootsType
bool ModCommandHandlerInside(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition DayZAnimal.c:127
proto native void ResetDeathCooldown()
bool ModCommandHandlerBefore(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition DayZAnimal.c:122
bool ModCommandHandlerAfter(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
Definition DayZAnimal.c:132
DayZGame g_Game
Definition DayZGame.c:3528
ref HumanMovementState m_MovementState
movement state
void DayZPlayerImplementFallDamage(DayZPlayer pPlayer)
void DayZPlayerImplementMeleeCombat(DayZPlayerImplement player)
bool IsProcessing()
void AbortWeaponEvent()
ref DayZPlayerImplementMeleeCombat m_MeleeCombat
void DayZPlayerMeleeFightLogic_LightHeavy(DayZPlayerImplement player)
void DayZPlayerUtils()
cannot be instantiated
void OnRPC(ParamsReadContext ctx)
ECameraZoomType
ERPCs
Definition ERPCs.c:2
EStaminaConsumers
EStaminaModifiers
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
override void EEKilled(Object killer)
void PlaySound()
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override void EOnContact(IEntity other, Contact extra)
Definition ItemBase.c:5827
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition ItemBase.c:6103
PlayerBase GetPlayer()
string GetDebugText()
proto void AddNoise(EntityAI source_entity, NoiseParams noise_params, float external_strenght_multiplier=1.0)
class NoiseSystem NoiseParams()
Definition Noise.c:15
void PluginDayzPlayerDebug()
void CommandHandler()
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 SoundObjectBuilder(SoundParams soundParams)
proto native UAInputAPI GetUApi()
class JsonUndergroundAreaTriggerData GetPosition
Super root of all classes in Enforce script.
Definition EnScript.c:11
static const int DAYZCAMERA_OPTICS
optics
static const int DAYZCAMERA_1ST
1st person camera
static const int DAYZCAMERA_3RD_PRO_RAISED
3rd - laying raised
static const int DAYZCAMERA_3RD_CLIMB
climb / vault
static const int DAYZCAMERA_3RD_CRO_RAISED
3rd - crouch
static const int DAYZCAMERA_3RD_ERC_SPR
3rd - standing sprint
static const int DAYZCAMERA_3RD_PRO
3rd - laying
static const int DAYZCAMERA_3RD_ERC
3rd - standing
static const int DAYZCAMERA_IRONSIGHTS
ironsights camera
static const int DAYZCAMERA_3RD_CRO
3rd - crouch
static const int DAYZCAMERA_3RD_ERC_RAISED
3rd - standing raised
static const int DAYZCAMERA_1ST_UNCONSCIOUS
unconscious
static const int DAYZCAMERA_3RD_ERC_RAISED_MELEE
3rd - laying raised
static const int DAYZCAMERA_1ST_VEHICLE
vehicle 1st person
static const int DAYZCAMERA_3RD_JUMP
jump
static bool NoHeading(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
static bool RotateOrient(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
static bool ClampHeading(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
static void SendDamageHitEx(DayZPlayer pPlayer, int pType, float pHitDir, bool pFullbody, TotalDamageResult pDamageResult, int pDamageType, EntityAI pSource, string pComponent, string pAmmoType, vector pModelPos)
static bool ReadDamageHitParamsEx(ParamsReadContext pCtx, out SyncHitInfo pData)
static void SendDeath(DayZPlayer pPlayer, int pType, float pHitDir)
static bool ReadDeathParams(ParamsReadContext pCtx, out int pType, out float pHitDir)
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
command itself
Definition human.c:761
proto static native bool DoClimbTest(Human pHuman, SHumanCommandClimbResult pResult, int pDebugDrawLevel)
InventoryLocation.
provides access to slot configuration
Definition EnMath.c:7
static float GetNoiseMultiplier(DayZPlayerImplement playerImplement)
static void SetMultiplayState(bool state)
static const float WEAPON_RAISE_BLEND_DELAY
static const float FULL_SPRINT_DELAY_DEFAULT
static const float HEAVY_HIT_THRESHOLD
static const int CHECK_EVERY_N_STEP
The class that will be instanced (moddable)
Definition gameplay.c:376
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
script counterpart to engine's class Weapon
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static const vector Zero
Definition EnConvert.c:110
int CameraHandler(int pCameraMode)
-------------— camera handling ----------------------—
bool IsInThirdPerson()
return true if player is currently in 3pp, otherwise false
void DayZPlayerType()
Definition dayzplayer.c:507
void SDayZPlayerHeadingModel()
cannot be created from script
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:597
void OnInputForRemote(ParamsReadContext ctx)
void OnInputFromServer(ParamsReadContext ctx)
float GetCurrentWaterLevel()
void SetCurrentWaterLevel(float pWaterLevel)
bool AimingModel(float pDt, SDayZPlayerAimingModel pModel)
-------------— aiming model ----------------------—
int GetEyeZoomLevel()
returns eye zoom level, uses ECameraZoomType values
bool IsShootingFromCamera()
return true if shots are fired from camere, otherwise false
bool IsPlayerInStance(int pStanceMask)
-------------— camera additiona functions ----------------------—
bool IsEyeZoom()
DEPRICATED(use GetEyeZoomLevel()) returns true if player is using EyeZoom, otherwise false.
bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
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 int GetEngineValue(int id)
Get value at the given engine id.
static proto float GetEngineRangeValue(int id)
Get range 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:666
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 int AbsInt(int i)
Returns absolute value.
static const float RAD2DEG
Definition EnMath.c:16
static proto float AbsFloat(float f)
Returns absolute value.
proto native int Length()
Returns length of string.
proto native int Hash()
Returns hash of string.
const int CALL_CATEGORY_GUI
Definition tools.c:9
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389
bool IsRaised()
Definition human.c:1176
proto native void GetMovementState(HumanMovementState pState)
returns movement state (current command id, )
proto native int GetCurrentCommandID()
returns current command ID (see DayZPlayerConstants.COMMANDID_...)
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 --—
proto native HumanCommandMove GetCommand_Move()
proto native HumanCommandFall StartCommand_Fall(float pYVelocity)
--— FALL --—
proto native HumanCommandMove StartCommand_Move()
--— MOVE --—
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:796
WeaponEvents
events
Definition human.c:943
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 HumanCommandUnconscious GetCommand_Unconscious()
proto native HumanCommandDeathCallback StartCommand_Death(int pType, float pDirection, typename pCallbackClass, bool pKeepInLocalSpaceAfterLeave=false)
--— Death --—
proto native HumanCommandLadder GetCommand_Ladder()
proto native HumanCommandFullBodyDamage GetCommand_Damage()
proto native void PhysicsSetRagdoll(bool pEnable)
Sets and synchronize interaction layers 'RAGDOLL' and 'RAGDOLL_NO_CHARACTER' to prevent body stacking...
class HumanCommandMelee2 HumanCommandFall()
Definition human.c:571
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:1086
void HumanItemAccessor()
Definition humanitems.c:135
class HumanItemBehaviorCfg OnItemInHandsChanged(bool pInstant=false)
signalization from script to engine that item in hands changed
class SHumanCommandSwimSettings SHumanCommandClimbSettings()

Variable Documentation

◆ m_pPlayer

PlayerBase m_pPlayer

Definition at line 88 of file DayZPlayerImplement.c.

◆ OnSimulationEnd

override void OnSimulationEnd

Definition at line 1 of file DayZPlayerImplement.c.

53 {
54 m_pPlayer.PhysicsEnableGravity(true);
55 }
PlayerBase m_pPlayer