DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
EmoteManager.c
Go to the documentation of this file.
2{
7
8 void ~EmoteCB()
9 {
10 if (m_Manager)
11 {
12 m_Manager.OnCallbackEnd();
13 }
14
15 if (GetGame() && m_player)
16 m_player.RequestHandAnimationStateRefresh();
17 }
18
20 {
21 return false;
22 }
23
25 {
26 return IsGestureCallback();
27 }
28
29 override void OnAnimationEvent(int pEventID)
30 {
31 switch (pEventID)
32 {
34
35 if (GetGame().IsServer())
36 m_Manager.KillPlayer();
37
38 m_Manager.LogSuicide();
39 break;
40
41 case UA_ANIM_EVENT :
42 if (GetGame().IsServer())
43 {
44 if (m_player.GetItemInHands() && SurrenderDummyItem.Cast(m_player.GetItemInHands()))
45 m_player.GetItemInHands().Delete();
46
47 if (m_player.GetItemInHands())
48 {
49 m_player.PhysicalPredictiveDropItem(m_player.GetItemInHands());
50 }
51 }
52 m_Manager.m_ItemToBeCreated = true;
53 break;
54
56 if (GetGame().IsServer())
57 m_Manager.CreateBleedingEffect(m_callbackID);
58 break;
59
61 if (GetGame().IsServer())
62 {
63 EntityAI itemInHands = m_player.GetHumanInventory().GetEntityInHands();
64 if (itemInHands)
65 {
66 vector m4[4];
67 itemInHands.GetTransform(m4);
68 m_player.GetInventory().DropEntityWithTransform(InventoryMode.SERVER, m_player, itemInHands, m4);
69 }
70 }
71
72 m_player.StartDeath();
73 break;
74 }
75 }
76
77 override bool IsGestureCallback()
78 {
79 return true;
80 }
81};
82
84{
85 static const int FORCE_NONE = 0;
86 static const int FORCE_DIFFERENT = 1;
87 static const int FORCE_ALL = 2;
88
90 protected int m_ForcePlayEmote;
91 protected int m_ID;
92
93 void EmoteLauncher(int emoteID, bool interrupts_same)
94 {
95 m_ID = emoteID;
96 m_InterruptsSameIDEmote = interrupts_same;
98 }
99
100 void SetForced(int mode)
101 {
102 m_ForcePlayEmote = mode;
103 }
104
106 {
107 return m_ForcePlayEmote;
108 }
109
110 int GetID()
111 {
112 return m_ID;
113 }
114}
115
116class EmoteManager
117{
132 protected bool m_ItemToHands; //deprecated
133 protected bool m_ItemIsOn;
134 protected bool m_MouseButtonPressed;
135 protected bool m_PlayerDies;
136 protected bool m_controllsLocked;
137 protected bool m_EmoteLockState;
139 protected int m_GestureID;
140 protected int m_PreviousGestureID;
141 protected int m_CurrentGestureID;
142 protected int m_LastMask;
143 protected int m_RPSOutcome;
145 protected const int CALLBACK_CMD_INVALID = -1;
146 protected const int CALLBACK_CMD_END = -2;
147 protected const int CALLBACK_CMD_GESTURE_INTERRUPT = -3;
148 protected const int CALLBACK_CMD_INSTACANCEL = -4;
149 PluginAdminLog m_AdminLog;
151
152 protected ref map<int, ref EmoteBase> m_NameEmoteMap; //<emote_ID,EmoteBase>
153 protected ref array<ref EmoteBase> m_EmoteClassArray; //registered 'EmoteBase' object refs
154 protected ref array<int> m_EmoteIDs; //IDs of registered emotes (found in 'EmoteConstants'). For quick access.
155 protected ref array<int> m_EmoteInputIDs; //input IDs for the registered 'EmoteBase' objects
157
159 {
160 m_Player = player;
161 m_HIC = m_Player.GetInputController();
162 m_ItemIsOn = false;
163 m_RPSOutcome = -1;
165
167 m_InterruptInputs.Insert("UAMoveForward");
168 m_InterruptInputs.Insert("UAMoveBack");
169 m_InterruptInputs.Insert("UATurnLeft");
170 m_InterruptInputs.Insert("UATurnRight");
171 m_InterruptInputs.Insert("UAMoveLeft");
172 m_InterruptInputs.Insert("UAMoveRight");
173 m_InterruptInputs.Insert("UAStand");
174 m_InterruptInputs.Insert("UACrouch");
175 m_InterruptInputs.Insert("UAProne");
176 m_InterruptInputs.Insert("UAGetOver");
177
180
181 if (GetGame().IsServer())
182 {
183 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
184 }
185
187 m_ReservationTimer.Run(8, this, "CheckEmoteLockedState", null, true);
188
189 m_HumanSwimSettings = m_Player.GetDayZPlayerType().CommandSwimSettingsW();
190
192 }
193
195 {
196 if (m_ReservationTimer && m_ReservationTimer.IsRunning())
198 }
199
201 {
203 if (!m_NameEmoteMap)
204 {
209 int inputID;
210 int count = m_NameEmoteMap.Count();
211 UAInput inp;
212
213 for (int i = 0; i < count; i++)
214 {
215 m_EmoteClassArray.Insert(m_NameEmoteMap.GetElement(i));
216 m_EmoteIDs.Insert(m_NameEmoteMap.GetElement(i).GetID());
217 inp = GetUApi().GetInputByName(m_NameEmoteMap.GetElement(i).GetInputActionName());
218 inputID = inp.ID();
219 m_EmoteInputIDs.Insert(inputID);
220 }
221
222 if (m_EmoteInputIDs.Count() != m_EmoteClassArray.Count())
223 {
224 ErrorEx("Faulty emote data detected in 'ConstructData' method!",ErrorExSeverity.WARNING);
225 }
226 }
227 }
228
229 void SetGesture(int id)
230 {
231 m_GestureID = id;
232 }
233
235 {
236 return m_GestureID;
237 }
238
240 {
241 int count = m_EmoteInputIDs.Count();
242 for (int i = 0; i < count; ++i)
243 {
244 if (GetUApi().GetInputByID(m_EmoteInputIDs[i]).LocalPress())
245 {
246 return m_EmoteIDs[i];
247 }
248 }
249
250 return 0;
251 }
252
254 bool DetermineEmoteData(EmoteBase emote, out int callback_ID, out int stancemask, out bool is_fullbody)
255 {
256 if (emote.DetermineOverride(callback_ID, stancemask, is_fullbody))
257 {
258 return emote.EmoteFBStanceCheck(stancemask);
259 }
260 else if (emote.GetAdditiveCallbackUID() != 0 && m_Player.IsPlayerInStance(emote.GetStanceMaskAdditive()))
261 {
262 callback_ID = emote.GetAdditiveCallbackUID();
263 stancemask = emote.GetStanceMaskAdditive();
264 is_fullbody = false;
265 return true;
266 }
267 else if (emote.GetFullbodyCallbackUID() != 0 && emote.EmoteFBStanceCheck(emote.GetStanceMaskFullbody()))
268 {
269 callback_ID = emote.GetFullbodyCallbackUID();
270 stancemask = emote.GetStanceMaskFullbody();
271 is_fullbody = true;
272 return true;
273 }
274
275 return false;
276 }
277
278 //Called from players commandhandler each frame, checks input
279 void Update(float deltaT)
280 {
281 // no updates on restrained characters
283 return;
284
286 {
287 if (!m_Player.GetItemInHands() && GetGame().IsServer())
288 {
289 m_Player.GetHumanInventory().CreateInHands("SurrenderDummyItem");
290 }
291 m_ItemToBeCreated = false;
292 }
293
294 int gestureSlot = DetermineGestureIndex();
295
296 //deferred emote cancel
297 if (m_InstantCancelEmote) //'hard' cancel
298 {
299 if (m_Callback)
300 {
301 m_Callback.Cancel();
302 }
303
304 if (m_MenuEmote)
305 {
306 m_MenuEmote = null;
307 }
309 m_InstantCancelEmote = false;
310 }
311 else if (m_CancelEmote) //'soft' cancel
312 {
313 if (m_IsSurrendered)
314 {
316 }
317 else if (m_Callback)
318 {
319 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
320 }
321
322 m_CancelEmote = false;
323 }
324
325 if (m_MenuEmote && m_MenuEmote.GetForced() > EmoteLauncher.FORCE_NONE && !GetGame().IsDedicatedServer()) //forced emote playing
326 {
328 }
329 else if (m_Callback)
330 {
331 bool uiGesture = false;
332 if (!GetGame().IsDedicatedServer())
333 {
335
337 {
339 }
340
342 {
344 }
345 }
346
347 if (gestureSlot > 0 || m_GestureInterruptInput || (m_HIC.IsSingleUse() && !uiGesture) || (m_HIC.IsContinuousUseStart() && !uiGesture) || (m_Callback.m_IsFullbody && !uiGesture && m_HIC.IsWeaponRaised()))
348 {
350 {
351 if (m_Callback.GetState() == m_Callback.STATE_LOOP_LOOP)
352 {
354 }
355 else
356 {
357 return;
358 }
359 }
361 {
362 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_ACTION);
363 }
365 {
366 if (m_RPSOutcome != -1)
367 {
368 if (m_RPSOutcome == 0)
369 {
370 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_ROCK);
371 }
372 else if (m_RPSOutcome == 1)
373 {
374 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_PAPER);
375 }
376 else if (m_RPSOutcome == 2)
377 {
378 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_SCISSORS);
379 }
380 m_RPSOutcome = -1;
381 }
382 else
383 {
384 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
385 }
386 }
388 {
390 }
392 {
394 }
395 }
396
397 if (m_LastMask != -1 && m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE))
398 {
399 m_Callback.Cancel();
400 }
401
403 {
405 }
406
408 {
410 }
411
413 {
415 }
416 }
417 //no m_Callback exists
418 else
419 {
421 {
422 m_bEmoteIsPlaying = false;
423 OnEmoteEnd();
424 }
425 else if (!m_Player.GetItemInHands() && m_IsSurrendered && !m_ItemToBeCreated)
426 {
427 PlaySurrenderInOut(false);
428 return;
429 }
430 // getting out of surrender state - hard cancel
432 {
433 if (m_Player.GetItemInHands())
434 m_Player.GetItemInHands().Delete();
435 return;
436 }
437
438 // fallback in case lock does not end properly
439 else if (m_IsSurrendered && !m_Player.GetItemInHands() || (m_Player.GetItemInHands() && m_Player.GetItemInHands().GetType() != "SurrenderDummyItem" && m_EmoteLockState))
440 {
441 m_IsSurrendered = false;
442 SetEmoteLockState(false);
443 return;
444 }
445 //actual emote launch
447 {
449 }
450 //client-side emote launcher
451 else if (!m_bEmoteIsPlaying && m_MenuEmote && !GetGame().IsDedicatedServer())
452 {
454 }
455 else if (!m_MenuEmote && gestureSlot > 0)
456 {
457 CreateEmoteCBFromMenu(gestureSlot,true); //translation no longer needed
458 }
459 }
460 }
461
463 {
465
466 if (m_PlayerDies)
467 {
468 m_Player.SetHealth(0.0);
469 return;
470 }
471
472 //surrender "state" switch
474 {
477 }
478
480
481 if (m_IsSurrendered)
482 {
483 return;
484 }
486 SetEmoteLockState(false);
487
488 // back to the default - shoot from camera - if not set already
491 }
492
493 //server-side
494 bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
495 {
496 if (userDataType == INPUT_UDT_GESTURE)
497 {
498 int forced = EmoteLauncher.FORCE_NONE;
499 int gestureID = -1;
500 int random = -1;
501
502 if (ctx.Read(gestureID))
503 {
504 ctx.Read(forced);
505 if (ctx.Read(random))
506 {
507 m_RPSOutcome = random;
508 }
509
510 //server-side check
511 if (forced > EmoteLauncher.FORCE_NONE || CanPlayEmote(gestureID))
512 {
514 pCtx.Write(gestureID);
515 pCtx.Write(forced);
516
518 }
519 }
520 return true;
521 }
522 return false;
523 }
524
525 //server and client
526 void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
527 {
528 int forced;
529 int gesture_id;
530 if (!m_CancelEmote)
531 {
532 pCtx.Read(gesture_id);
533 pCtx.Read(forced);
534
535 EmoteBase emoteData;
536 if ((m_Callback || m_IsSurrendered) && (forced == EmoteLauncher.FORCE_ALL || (forced == EmoteLauncher.FORCE_DIFFERENT && m_CurrentGestureID != gesture_id)))
537 {
538 if (m_Callback)
539 {
540 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && emoteData.CanBeCanceledNormally(m_Callback))
541 m_CancelEmote = true;
542 else
543 return;
544 }
545 m_CancelEmote = true;
546 }
547
548 if (gesture_id == CALLBACK_CMD_INSTACANCEL)
549 {
550 if (m_Callback)
551 {
552 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && !emoteData.CanBeCanceledNormally(m_Callback))
553 {
554 m_InstantCancelEmote = false;
555 return;
556 }
557 }
559 }
560
561 m_DeferredEmoteExecution = gesture_id;
562 }
563 else
564 m_CancelEmote = false;
565 }
566
568 {
569 EmoteBase emoteData;
570 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData))
571 emoteData.OnCallbackEnd();
572 }
573
575 {
576 //failsafe, deletes helper item after fully loading character
577 if (m_Player.GetItemInHands() && SurrenderDummyItem.Cast(m_Player.GetItemInHands()))
578 m_Player.GetItemInHands().Delete();
579 }
580
581 bool PlayEmote(int id)
582 {
584
585 if (!CanPlayEmote(id))
586 {
587 m_Player.SetInventorySoftLock(false);
588 return false;
589 }
590
591 actionDebugPrint("[emote] " + Object.GetDebugName(m_Player) + " play emote id=" + id + " IH=" + Object.GetDebugName(m_Player.GetItemInHands()));
592
595 if (id > 0)
596 {
597 //-----------------------------------------------
598 EmoteBase emote;
599 if (m_NameEmoteMap.Find(id,emote))
600 {
601 int callback_ID;
602 int stancemask;
603 bool is_fullbody;
604 if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody))
605 {
606 if (!emote.EmoteStartOverride(EmoteCB,callback_ID,stancemask,is_fullbody))
607 {
608 emote.OnBeforeStandardCallbackCreated(callback_ID,stancemask,is_fullbody);
609 CreateEmoteCallback(EmoteCB,callback_ID,stancemask,is_fullbody);
610 }
611
612 if (emote.GetHideItemInHands())
613 {
615 }
616 }
617 else
618 {
619 Error("EmoteManager | DetermineEmoteData failed!");
620 }
621 }
622 }
623
625 {
626 m_Player.SetInventorySoftLock(true);
628 {
629 SetEmoteLockState(true);
630 }
631
632 return true;
633 }
634
635 return false;
636 }
637
638 //creates Emote callback
639 protected void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
640 {
641 if (m_Player)
642 {
643 m_LastMask = -1;
644
645 if (fullbody)
646 {
647 Class.CastTo(m_Callback, m_Player.StartCommand_Action(id,callbacktype,mask));
649 m_Callback.EnableCancelCondition(true);
650 }
651 else if (m_Player.IsPlayerInStance(mask))
652 {
653 m_LastMask = mask; //character is probably not prone now
654 Class.CastTo(m_Callback, m_Player.AddCommandModifier_Action(id,callbacktype));
655 }
656
657 if (m_Callback)
658 {
659 m_bEmoteIsPlaying = true;
662 m_Callback.m_Manager = this;
663 }
664 }
665 }
666
667 protected void HideItemInHands()
668 {
669 m_item = m_Player.GetItemInHands();
670 if (m_Callback && m_item)
671 {
672 m_Player.TryHideItemInHands(true);
673 }
674 }
675
676 protected void ShowItemInHands()
677 {
678 if (m_item)
679 {
680 m_Player.TryHideItemInHands(false);
681 }
682 }
683
684 protected void CommitSuicide()
685 {
686 Weapon_Base weapon;
687 WeaponEventBase weapon_event = new WeaponEventTrigger;
688
689 if (Weapon_Base.CastTo(weapon,m_Player.GetItemInHands()))
690 {
691 if (weapon.CanFire())
692 {
693 m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
694 m_Player.SetSuicide(true);
695 weapon.ProcessWeaponEvent(weapon_event);
696 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
697 if (m_Player.IsAlive())
698 {
699 EntityAI helm = m_Player.FindAttachmentBySlotName("Headgear");
700 if (helm && GetGame().IsServer())
701 {
702 float damage = helm.GetMaxHealth("","");
703 helm.AddHealth("","", -damage/2);
704 }
706 if (m_AdminLog)
707 {
708 m_AdminLog.Suicide(m_Player);
709 }
710 }
711 }
712 else
713 {
714 if (!weapon.IsDamageDestroyed())
715 {
716 weapon.ProcessWeaponEvent(weapon_event);
717 }
718 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
719 }
720 }
721 else if (m_Player.GetItemInHands() && m_Player.GetItemInHands().ConfigIsExisting("suicideAnim"))
722 {
723 m_Callback.RegisterAnimationEvent("Death",EmoteConstants.EMOTE_SUICIDE_DEATH);
724 m_Callback.RegisterAnimationEvent("Bleed",EmoteConstants.EMOTE_SUICIDE_BLEED);
725 m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
726 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
727 m_Player.SetSuicide(true);
728 }
729 else
730 {
731 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
732 }
733 }
734
736 {
737 if (GetGame().IsServer())
738 {
739 m_Player.SetHealth(0);
740 }
741 }
742
744 {
745 if (GetGame().IsServer())
746 {
747 PlayerIdentity identity = m_Player.GetIdentity();
748 if (identity)
749 {
750 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().AdminLog, "Player '" + identity.GetName() + "' (id=" + identity.GetId() + ") committed suicide.");
751 }
752 }
753 }
754
755 void CreateEmoteCBFromMenu(int id, bool interrupts_same = false)
756 {
757 m_MenuEmote = new EmoteLauncher(id,interrupts_same);
758 }
759
761 {
762 return m_MenuEmote;
763 }
764
766 {
767 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
768
769 if (m_MenuEmote)
770 m_MenuEmote = null;
771
773 }
774
776 {
778 {
779 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
780 }
781 else
782 {
783 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
784 }
785
786 if (m_MenuEmote)
787 m_MenuEmote = null;
789 }
790
791 //sends request
793 {
794 int forced = EmoteLauncher.FORCE_NONE;
795 if (m_MenuEmote)
796 {
797 forced = m_MenuEmote.GetForced();
798 }
799
800 m_RPSOutcome = -1;
801 switch (id)
802 {
805 break;
806
808 m_RPSOutcome = 0;
809 break;
810
812 m_RPSOutcome = 1;
813 break;
814
816 m_RPSOutcome = 2;
817 break;
818 }
819
821 if (GetGame().IsMultiplayer() && GetGame().IsClient())
822 {
823 bool canProceed = true; //running callbacks in certain state can block additional actions
824 EmoteBase emoteData;
825 if (m_Callback && m_NameEmoteMap.Find(m_CurrentGestureID,emoteData))
826 {
827 canProceed = emoteData.CanBeCanceledNormally(m_Callback);
828 }
829
830 if (ctx.CanStoreInputUserData() && (CanPlayEmote(id) || forced) && canProceed)
831 {
833 ctx.Write(id);
834 ctx.Write(forced);
835 if (m_RPSOutcome != -1)
836 {
837 ctx.Write(m_RPSOutcome);
838 }
839 ctx.Send();
840
841 if (id > 0)
842 {
843 m_Player.SetInventorySoftLock(true);
844 }
845 }
846 m_MenuEmote = NULL;
847 }
848 else if (!GetGame().IsMultiplayer())
849 {
850 if (id == CALLBACK_CMD_END)
851 {
853 }
854 else if (id == CALLBACK_CMD_GESTURE_INTERRUPT)
855 {
857 }
858 else
859 {
860 PlayEmote(id);
861 }
862 m_MenuEmote = NULL;
863 }
864 }
865
867 {
868 return m_controllsLocked;
869 }
870
871 bool CanPlayEmote(int id)
872 {
873 //special cases
875 {
876 return true;
877 }
878
879 if (GetGame().IsClient() && GetGame().GetUIManager().FindMenu(MENU_INVENTORY))
880 {
881 return false;
882 }
883
884 if (!m_Player || (!IsEmotePlaying() && m_Player.GetCommand_Action() || m_Player.GetCommandModifier_Action()) || m_Player.GetThrowing().IsThrowingModeEnabled() || m_Player.IsItemsToDelete())
885 {
886 return false;
887 }
888
889 ItemBase item = m_Player.GetItemInHands();
890 if (item && item.IsHeavyBehaviour() && (id != EmoteConstants.ID_EMOTE_SURRENDER))
891 {
892 return false;
893 }
894
895 if ((m_Player.GetWeaponManager() && m_Player.GetWeaponManager().IsRunning()) || (m_Player.GetActionManager() && m_Player.GetActionManager().GetRunningAction()))
896 {
897 return false;
898 }
899
900 if (m_HIC.IsWeaponRaised() || m_Player.IsRolling() || m_Player.IsClimbing() || m_Player.IsRestrainStarted() || m_Player.IsFighting() || m_Player.IsSwimming() || m_Player.IsClimbingLadder() || m_Player.IsFalling() || m_Player.IsUnconscious() || m_Player.IsJumpInProgress() || m_Player.IsRestrained()) // rework conditions into something better?
901 {
902 return false;
903 }
904 if (m_Player.GetCommand_Vehicle())
905 {
906 if (m_Player.GetCommand_Vehicle().GetTransport())
907 {
908 return false;
909 }
910 }
911
912 if (m_Player.GetCommand_Move() && m_Player.GetCommand_Move().IsOnBack() && id != EmoteConstants.ID_EMOTE_SURRENDER)
913 {
914 return false;
915 }
916
917 //"locks" player in surrender state
919 {
920 return false;
921 }
922
923 if (m_Player.GetDayZPlayerInventory().IsProcessing())
924 {
925 return false;
926 }
927
928 EmoteBase emote;
929 if (m_NameEmoteMap.Find(id,emote))
930 {
931 int callback_ID;
932 int stancemask;
933 bool is_fullbody;
934 if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody) && emote.EmoteCondition(stancemask))
935 {
936 return true;
937 }
938 }
939
940 return false;
941 }
942
943 void PlaySurrenderInOut(bool state)
944 {
947 if (state)
948 {
949 if (m_Player.GetItemInHands() && !m_Player.CanDropEntity(m_Player.GetItemInHands()))
950 return;
951
952 if (m_Player.GetItemInHands() && GetGame().IsClient())
953 {
954 m_Player.PhysicalPredictiveDropItem(m_Player.GetItemInHands());
955 }
956
957 CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDERIN,DayZPlayerConstants.STANCEMASK_ALL,true);
958
959 if (m_Callback)
960 m_Callback.RegisterAnimationEvent("ActionExec", UA_ANIM_EVENT);
961 }
962 else
963 {
964 if (m_Player.IsAlive() && !m_Player.IsUnconscious())
965 {
966 CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDEROUT,DayZPlayerConstants.STANCEMASK_ALL,true);
967 }
968 else
969 {
970 m_bEmoteIsPlaying = false;
971 OnEmoteEnd();
972 }
973 }
974 }
975
977 void SetEmoteLockState(bool state)
978 {
979 DayZPlayerCameraBase camera = DayZPlayerCameraBase.Cast(m_Player.GetCurrentCamera());
981 {
984 }
985
986 if (!state)
987 {
988 if (m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
989 {
990 m_Player.GetInventory().ClearInventoryReservationEx(null, m_HandInventoryLocation);
991 }
992
993 if (m_Player.GetActionManager())
994 m_Player.GetActionManager().EnableActions(true);
995
996 m_Player.SetInventorySoftLock(false);
997
999 {
1000 m_controllsLocked = false;
1001 }
1002 }
1003 else
1004 {
1005 if (!m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
1006 {
1007 m_Player.GetInventory().AddInventoryReservationEx(null, m_HandInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1008 }
1009
1010 if (m_Player.GetActionManager())
1011 m_Player.GetActionManager().EnableActions(false);
1012
1013 //Movement lock in fullbody anims
1015 {
1016 m_controllsLocked = true;
1017 }
1018 }
1019 m_EmoteLockState = state;
1020 }
1021
1023 {
1024 if (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && !SurrenderDummyItem.Cast(m_Player.GetItemInHands())))
1025 return;
1026
1027 //refreshes reservation in case of unwanted timeout
1029 {
1030 m_Player.GetInventory().ExtendInventoryReservationEx(null, m_HandInventoryLocation, 10000);
1031 }
1032 }
1033
1036 {
1037 if (m_IsSurrendered && data)
1038 {
1039 SetEmoteLockState(false);
1040 if (m_Player.GetItemInHands())
1041 m_Player.GetItemInHands().Delete();
1042
1043 m_IsSurrendered = false;
1044
1045 data.End();
1046 }
1047 }
1048
1049 //sent from server to cancel general emote callback
1051 {
1054
1055 m_Player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_GESTURE_REQUEST, pCtx);
1056 }
1057
1059 {
1060 //init pass
1062 {
1065
1066 for (int i = 0; i < m_InterruptInputsCount; i++)
1067 {
1068 m_InterruptInputDirect.Insert(GetUApi().GetInputByName(m_InterruptInputs[i]));
1069 }
1070 }
1071
1072 //interrupts any callback if restrain action is in progress, takes priority
1074 return false;
1075
1076 for (int idx = 0; idx < m_InterruptInputsCount; idx++)
1077 {
1078 if (m_InterruptInputDirect[idx].LocalPress())
1079 {
1080 return true;
1081 }
1082 }
1083
1084 return false;
1085 }
1086
1088 {
1089 float waterLevel = m_Player.GetCurrentWaterLevel();
1090
1091 if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_PRONE) && waterLevel >= m_HumanSwimSettings.m_fToCrouchLevel)
1092 {
1093 return true;
1094 }
1095 else if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEIDX_RAISEDCROUCH) && waterLevel >= m_HumanSwimSettings.m_fToErectLevel)
1096 {
1097 return true;
1098 }
1099
1100 return m_Player.GetModifiersManager() && m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_DROWNING);
1101 }
1102
1104 {
1106 }
1107
1109 {
1110 return m_NameEmoteMap;
1111 }
1112
1113 void CreateBleedingEffect(int Callback_ID)
1114 {
1115 if (GetGame().IsServer() && m_Player.IsAlive())
1116 {
1117 switch (Callback_ID)
1118 {
1119 case DayZPlayerConstants.CMD_SUICIDEFB_1HD :
1120 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Neck");
1121 break;
1122
1123 case DayZPlayerConstants.CMD_SUICIDEFB_FIREAXE :
1124 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1125 break;
1126
1127 case DayZPlayerConstants.CMD_SUICIDEFB_PITCHFORK :
1128 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1129 break;
1130
1131 case DayZPlayerConstants.CMD_SUICIDEFB_SWORD :
1132 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1133 break;
1134
1135 case DayZPlayerConstants.CMD_SUICIDEFB_SPEAR :
1136 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Head");
1137 break;
1138
1139 case DayZPlayerConstants.CMD_SUICIDEFB_WOODAXE :
1140 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1141 break;
1142
1143 default :
1144 ErrorEx("EmoteManager.c | CreateBleedingEffect | WRONG ID",ErrorExSeverity.INFO);
1145 break;
1146 }
1147 }
1148 }
1149
1152 protected void PickEmote(int gestureslot)
1153 {
1154 }
1155};
1156
1158{
1160 void End();
1161}
1162
1167{
1169
1170 void ChainedDropAndKillPlayerLambda (EntityAI old_item, string new_item_type, PlayerBase player)
1171 {
1172 m_Player = player;
1174 vector mtx[4];
1175 old_item.GetTransform(mtx);
1176 gnd.SetGround(old_item, mtx);
1177
1178 OverrideNewLocation(gnd);
1179 }
1180
1181 override void Execute (HumanInventoryWithFSM fsm_to_notify = null)
1182 {
1183 if (PrepareLocations())
1184 {
1185 vector transform[4];
1186
1187 m_Player.GetInventory().TakeToDst(InventoryMode.SERVER, m_OldLocation, m_NewLocation);
1189 }
1190
1191 m_Player.SetHealth(0);
1192
1193 hndDebugPrint("[syncinv] player=" + Object.GetDebugName(m_Player) + " STS = " + m_Player.GetSimulationTimeStamp() + " ChainedDropAndKillPlayerLambda");
1194 }
1195}
void actionDebugPrint(string s)
Definition Debug.c:10
InventoryMode
Definition Inventory.c:20
const int INPUT_UDT_GESTURE
Definition _constants.c:18
override void OnCallbackEnd()
EmoteCB m_Callback
protected const int CALLBACK_CMD_INSTACANCEL
ref array< UAInput > m_InterruptInputDirect
protected void CommitSuicide()
protected bool m_MouseButtonPressed
void CheckEmoteLockedState()
protected void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
void EmoteManager(PlayerBase player)
void CreateEmoteCBFromMenu(int id, bool interrupts_same=false)
void AfterStoreLoad()
protected int m_CurrentGestureID
ref array< string > m_InterruptInputs
bool m_CancelEmote
bool CanPlayEmote(int id)
bool IsControllsLocked()
protected bool m_controllsLocked
ItemBase m_item
PluginAdminLog m_AdminLog
protected ref array< ref EmoteBase > m_EmoteClassArray
ref InventoryLocation m_HandInventoryLocation
void InterruptCallbackCommand()
void ConstructData()
protected int m_PreviousGestureID
void PlaySurrenderInOut(bool state)
protected int m_DeferredEmoteExecution
int DetermineGestureIndex()
protected const int CALLBACK_CMD_GESTURE_INTERRUPT
void CreateBleedingEffect(int Callback_ID)
void SetGesture(int id)
map< int, ref EmoteBase > GetNameEmoteMap()
bool m_GestureInterruptInput
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
protected ref array< int > m_EmoteIDs
protected void PickEmote(int gestureslot)
Deprecated.
void KillPlayer()
void OnEmoteEnd()
void ServerRequestEmoteCancel()
protected void ShowItemInHands()
void ~EmoteManager()
void EndSurrenderRequest(SurrenderData data=null)
directly force-ends surrender state from outside of normal flow
void SetEmoteLockState(bool state)
protected int m_InterruptInputsCount
protected ref Timer m_ReservationTimer
ref EmoteLauncher m_MenuEmote
bool InterruptGestureCheck()
bool InterruptWaterCheck()
protected bool m_ItemIsOn
protected bool m_PlayerDies
protected int m_GestureID
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
bool IsEmotePlaying()
protected ref map< int, ref EmoteBase > m_NameEmoteMap
bool DetermineEmoteData(EmoteBase emote, out int callback_ID, out int stancemask, out bool is_fullbody)
Also includes a stance check for FB callbacks.
override void Execute(HumanInventoryWithFSM fsm_to_notify=null)
protected const int CALLBACK_CMD_END
protected bool m_EmoteLockState
bool m_ItemToBeCreated
bool m_IsSurrendered
HumanInputController m_HIC
void EndCallbackCommand()
bool m_bEmoteIsPlaying
void LogSuicide()
bool m_InstantCancelEmote
EmoteLauncher GetEmoteLauncher()
protected bool m_ItemToHands
protected int m_RPSOutcome
protected ref array< int > m_EmoteInputIDs
void SendEmoteRequestSync(int id)
protected void HideItemInHands()
protected SHumanCommandSwimSettings m_HumanSwimSettings
int GetGesture()
protected int m_LastMask
bool PlayEmote(int id)
protected const int CALLBACK_CMD_INVALID
DayZPlayer m_Player
Definition Hand_Events.c:42
void hndDebugPrint(string s)
Definition HandFSM.c:1
PluginBase GetPlugin(typename plugin_type)
proto native UAInputAPI GetUApi()
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
proto native UIManager GetUIManager()
drops weapon in hands to ground and then calls kill
Super root of all classes in Enforce script.
Definition EnScript.c:11
this is main camera class
override bool IsShootingFromCamera()
bool IsFighting()
void OverrideShootFromCamera(bool pState)
DayZPlayerInventory GetDayZPlayerInventory()
WeaponManager GetWeaponManager()
void SetSuicide(bool state)
override void OnItemInHandsChanged()
override float GetCurrentWaterLevel()
DayZPlayerImplementThrowing GetThrowing()
bool IsRestrained()
bool EmoteFBStanceCheck(int stancemask)
Checks for valid stance mask.
Definition EmoteBase.c:23
void OnBeforeStandardCallbackCreated(int callback_ID, int stancemask, bool is_fullbody)
int GetAdditiveCallbackUID()
Definition EmoteBase.c:85
int GetFullbodyCallbackUID()
Definition EmoteBase.c:90
void OnCallbackEnd()
bool EmoteStartOverride(typename callbacktype, int id, int mask, bool fullbody)
Definition EmoteBase.c:47
bool EmoteCondition(int stancemask)
Definition EmoteBase.c:12
bool CanBeCanceledNormally(notnull EmoteCB callback)
Definition EmoteBase.c:17
bool GetHideItemInHands()
Definition EmoteBase.c:95
bool DetermineOverride(out int callback_ID, out int stancemask, out bool is_fullbody)
Definition EmoteBase.c:39
int GetStanceMaskFullbody()
Definition EmoteBase.c:80
int GetStanceMaskAdditive()
Definition EmoteBase.c:75
override void OnAnimationEvent(int pEventID)
override bool IsGestureCallback()
bool m_IsFullbody
Definition EmoteManager.c:3
EmoteManager m_Manager
Definition EmoteManager.c:6
PlayerBase m_player
Definition EmoteManager.c:5
bool CancelCondition()
int m_callbackID
Definition EmoteManager.c:4
void ~EmoteCB()
Definition EmoteManager.c:8
bool IsEmoteCallback()
bool ConstructEmotes(PlayerBase player, out map< int, ref EmoteBase > emoteMap)
static const int FORCE_NONE
protected int m_ID
protected bool m_InterruptsSameIDEmote
void SetForced(int mode)
static const int FORCE_DIFFERENT
static const int FORCE_ALL
void EmoteLauncher(int emoteID, bool interrupts_same)
protected int m_ForcePlayEmote
script counterpart to engine's class Inventory
Definition Inventory.c:77
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:683
proto native bool IsContinuousUseStart()
is start of cont. 'UADefaultAction' (== true for 1 tick only) + not raised
proto native bool IsSingleUse()
single 'UADefaultAction' (== true for 1 tick only) + not raised
proto native bool IsWeaponRaised()
returns true if weapon is raised
HumanInventory... with FSM (synchronous, no anims)
InventoryLocation.
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
Definition EnMath.c:7
proto owned string GetId()
unique id of player (hashed steamID, database Xbox id...) can be used in database or logs
proto owned string GetName()
nick (short) name of player
The class that will be instanced (moddable)
Definition gameplay.c:378
base class for transformation operations (creating one item from another)
float m_fToCrouchLevel
when to crouch
float m_fToErectLevel
when to stand
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 ...
proto static native bool CanStoreInputUserData()
proto native void Send()
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
void End()
called on surrender end request end
override void Stop()
proto native UAInput GetInputByName(string sInputName)
proto native int ID()
bool IsMenuOpen(int id)
Returns true if menu with specific ID is opened (see MenuID)
Definition UIManager.c:155
signalize mechanism manipulation
Definition Events.c:35
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
eModifiers
Definition eModifiers.c:2
proto native CGame GetGame()
const int EMOTE_SUICIDE_SIMULATION_END
Definition constants.c:384
const int EMOTE_SUICIDE_BLEED
Definition constants.c:383
const int EMOTE_SUICIDE_DEATH
Definition constants.c:382
ErrorExSeverity
Definition EnDebug.c:62
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
enum ShapeType ErrorEx
const int ID_EMOTE_RPS_P
Definition constants.c:368
const int ID_EMOTE_RPS
Definition constants.c:357
const int ID_EMOTE_RPS_R
Definition constants.c:367
const int ID_EMOTE_THUMBDOWN
Definition constants.c:349
const int ID_EMOTE_THUMB
Definition constants.c:342
const int ID_EMOTE_SURRENDER
Definition constants.c:373
const int ID_EMOTE_RPS_S
Definition constants.c:369
const int ID_EMOTE_DANCE
Definition constants.c:345
const int ID_EMOTE_SUICIDE
Definition constants.c:344
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
const int MENU_GESTURES
Definition constants.c:172
const int MENU_INVENTORY
Definition constants.c:158
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
const int UA_ANIM_EVENT
Definition constants.c:427
proto native volatile void Update()