DayZ 1.24
Loading...
Searching...
No Matches
EmoteManager.c
Go to the documentation of this file.
2{
7
8 void ~EmoteCB()
9 {
10 if (m_Manager)
11 m_Manager.OnCallbackEnd();
12
13 if (GetGame() && m_player)
14 m_player.RequestHandAnimationStateRefresh();
15 }
16
18 {
19 return false;
20 }
21
23 {
24 return IsGestureCallback();
25 }
26
27 override void OnAnimationEvent(int pEventID)
28 {
29 switch (pEventID)
30 {
32
33 if (GetGame().IsServer())
34 m_Manager.KillPlayer();
35
36 m_Manager.LogSuicide();
37 break;
38
39 case UA_ANIM_EVENT :
40 if (GetGame().IsServer())
41 {
42 if (m_player.GetItemInHands() && SurrenderDummyItem.Cast(m_player.GetItemInHands()))
43 m_player.GetItemInHands().DeleteSafe(); //Note, this keeps item 'alive' until it is released by all the systems (inventory swapping etc.)
44
45 if (m_player.GetItemInHands())
46 m_player.PhysicalPredictiveDropItem(m_player.GetItemInHands());
47 }
48 m_Manager.m_ItemToBeCreated = true;
49 break;
50
52 if (GetGame().IsServer())
53 m_Manager.CreateBleedingEffect(m_callbackID);
54 break;
55
57 if (GetGame().IsServer())
58 {
59 EntityAI itemInHands = m_player.GetHumanInventory().GetEntityInHands();
60 if (itemInHands)
61 {
62 vector m4[4];
63 itemInHands.GetTransform(m4);
64 m_player.GetInventory().DropEntityWithTransform(InventoryMode.SERVER, m_player, itemInHands, m4);
65 }
66 }
67
68 m_player.StartDeath();
69 break;
70 }
71 }
72
73 override bool IsGestureCallback()
74 {
75 return true;
76 }
77};
78
80{
81 static const int FORCE_NONE = 0;
82 static const int FORCE_DIFFERENT = 1;
83 static const int FORCE_ALL = 2;
84
86 protected int m_ForcePlayEmote;
87 protected int m_ID;
88
95
96 void SetForced(int mode)
97 {
99 }
100
102 {
103 return m_ForcePlayEmote;
104 }
105
106 int GetID()
107 {
108 return m_ID;
109 }
110}
111
112class EmoteManager
113{
129 protected bool m_ItemToHands; //deprecated
130 protected bool m_ItemIsOn;
131 protected bool m_MouseButtonPressed;
132 protected bool m_PlayerDies;
133 protected bool m_controllsLocked;
135 protected bool m_EmoteLockState;
137 protected int m_GestureID;
138 protected int m_PreviousGestureID;
139 protected int m_CurrentGestureID;
140 protected int m_LastMask;
141 protected int m_RPSOutcome;
143 protected const int CALLBACK_CMD_INVALID = -1;
144 protected const int CALLBACK_CMD_END = -2;
145 protected const int CALLBACK_CMD_GESTURE_INTERRUPT = -3;
146 protected const int CALLBACK_CMD_INSTACANCEL = -4;
147 PluginAdminLog m_AdminLog;
149
150 protected ref map<int, ref EmoteBase> m_NameEmoteMap; //<emote_ID,EmoteBase>
151 protected ref array<ref EmoteBase> m_EmoteClassArray; //registered 'EmoteBase' object refs
152 protected ref array<int> m_EmoteIDs; //IDs of registered emotes (found in 'EmoteConstants'). For quick access.
153 protected ref array<int> m_EmoteInputIDs; //input IDs for the registered 'EmoteBase' objects
155
157 {
159 m_HIC = m_Player.GetInputController();
160 m_ItemIsOn = false;
161 m_controllsLocked = 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 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
183
185 m_ReservationTimer.Run(8, this, "CheckEmoteLockedState", null, true);
186
187 m_HumanSwimSettings = m_Player.GetDayZPlayerType().CommandSwimSettingsW();
188
190 }
191
193 {
194 if (m_ReservationTimer && m_ReservationTimer.IsRunning())
195 m_ReservationTimer.Stop();
196 }
197
199 {
201 if (!m_NameEmoteMap)
202 {
203 ec.ConstructEmotes(m_Player, m_NameEmoteMap);
207 int inputID;
208 int count = m_NameEmoteMap.Count();
209 UAInput inp;
210
211 for (int i = 0; i < count; i++)
212 {
213 m_EmoteClassArray.Insert(m_NameEmoteMap.GetElement(i));
214 m_EmoteIDs.Insert(m_NameEmoteMap.GetElement(i).GetID());
215 inp = GetUApi().GetInputByName(m_NameEmoteMap.GetElement(i).GetInputActionName());
216 inputID = inp.ID();
217 m_EmoteInputIDs.Insert(inputID);
218 }
219
220 if (m_EmoteInputIDs.Count() != m_EmoteClassArray.Count())
221 ErrorEx("Faulty emote data detected in 'ConstructData' method!", ErrorExSeverity.WARNING);
222 }
223 }
224
225 void SetGesture(int id)
226 {
227 m_GestureID = id;
228 }
229
231 {
232 return m_GestureID;
233 }
234
236 {
237 int count = m_EmoteInputIDs.Count();
238 for (int i = 0; i < count; ++i)
239 {
240 if (GetUApi().GetInputByID(m_EmoteInputIDs[i]).LocalPress())
241 return m_EmoteIDs[i];
242 }
243
244 return 0;
245 }
246
249 {
250 if (emote.DetermineOverride(callback_ID, stancemask, is_fullbody))
251 return emote.EmoteFBStanceCheck(stancemask);
252 else if (emote.GetAdditiveCallbackUID() != 0 && m_Player.IsPlayerInStance(emote.GetStanceMaskAdditive()))
253 {
254 callback_ID = emote.GetAdditiveCallbackUID();
255 stancemask = emote.GetStanceMaskAdditive();
256 is_fullbody = false;
257 return true;
258 }
259 else if (emote.GetFullbodyCallbackUID() != 0 && emote.EmoteFBStanceCheck(emote.GetStanceMaskFullbody()))
260 {
261 callback_ID = emote.GetFullbodyCallbackUID();
262 stancemask = emote.GetStanceMaskFullbody();
263 is_fullbody = true;
264 return true;
265 }
266
267 return false;
268 }
269
270 //Called from players commandhandler each frame, checks input
271 void Update(float deltaT)
272 {
273 // no updates on restrained characters
275 return;
276
278 {
279 if (!m_Player.GetItemInHands() && GetGame().IsServer())
280 m_Player.GetHumanInventory().CreateInHands("SurrenderDummyItem");
281 m_ItemToBeCreated = false;
282 }
283
285
286 //deferred emote cancel
287 if (m_InstantCancelEmote) //'hard' cancel
288 {
289 if (m_Callback)
290 m_Callback.Cancel();
291
292 if (m_MenuEmote)
295 m_InstantCancelEmote = false;
297 SetEmoteLockState(false);
298 }
299 else if (m_CancelEmote) //'soft' cancel
300 {
301 if (m_IsSurrendered)
303 else if (m_Callback)
304 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
305
307 m_CancelEmote = false;
308 }
309
310 if (m_MenuEmote && m_MenuEmote.GetForced() > EmoteLauncher.FORCE_NONE && !GetGame().IsDedicatedServer()) //forced emote playing
312 else if (m_Callback)
313 {
314 bool uiGesture = false;
315 if (!GetGame().IsDedicatedServer())
316 {
317 uiGesture = GetGame().GetUIManager().IsMenuOpen(MENU_GESTURES);
318
321
324 }
325
327 {
329 {
330 if (m_Callback.GetState() == m_Callback.STATE_LOOP_LOOP)
332 else
333 return;
334 }
336 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_ACTION);
338 {
339 if (m_RPSOutcome != -1)
340 {
341 if (m_RPSOutcome == 0)
342 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_ROCK);
343 else if (m_RPSOutcome == 1)
344 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_PAPER);
345 else if (m_RPSOutcome == 2)
346 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_SCISSORS);
347 m_RPSOutcome = -1;
348 }
349 else
350 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
351 }
356 }
357
358 if (m_LastMask != -1 && m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE))
359 m_Callback.Cancel();
360
363
366
369 }
370 //no m_Callback exists
371 else
372 {
373 if (m_bEmoteIsRequestPending && (m_Player.IsUnconscious() || !m_Player.IsAlive()))
375
377 OnEmoteEnd();
378 else if (!m_Player.GetItemInHands() && m_IsSurrendered && !m_ItemToBeCreated && (!m_MenuEmote || m_MenuEmote.GetForced() != EmoteLauncher.FORCE_NONE)) //play only when there is time to do so
379 {
380 PlaySurrenderInOut(false);
381 return;
382 }
383 // getting out of surrender state - hard cancel
385 {
386 if (m_Player.GetItemInHands())
387 m_Player.GetItemInHands().DeleteSafe();//Note, this keeps item 'alive' until it is released by all the systems (inventory swapping etc.)
388 return;
389 }
390 // fallback in case lock does not end properly
391 else if (m_IsSurrendered && (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && m_Player.GetItemInHands().GetType() != "SurrenderDummyItem" && m_EmoteLockState)))
392 {
393 m_IsSurrendered = false;
394 SetEmoteLockState(false);
395 return;
396 }
397 //actual emote launch
400 //client-side emote launcher
401 else if (!m_bEmoteIsPlaying && m_MenuEmote && !GetGame().IsDedicatedServer())
403 else if (!m_MenuEmote && gestureSlot > 0)
404 {
405 CreateEmoteCBFromMenu(gestureSlot, true); //translation no longer needed
406 }
407 }
408 }
409
411 {
413
414 if (m_PlayerDies)
415 {
416 m_Player.SetHealth(0.0);
417 return;
418 }
419
420 //surrender "state" switch
422 {
425 }
426
428
429 m_bEmoteIsPlaying = false;
431
432 if (m_IsSurrendered)
433 return;
435 SetEmoteLockState(false);
436
437 // back to the default - shoot from camera - if not set already
440 }
441
442 //server-side
444 {
446 {
448 int gestureID = -1;
449 int random = -1;
450
451 if (ctx.Read(gestureID))
452 {
453 ctx.Read(forced);
454 if (ctx.Read(random))
456
457 //server-side check, sends CALLBACK_CMD_INSTACANCEL as a fail
460
462 pCtx.Write(gestureID);
463 pCtx.Write(forced);
466 }
467 return true;
468 }
469 return false;
470 }
471
472 //server and client
474 {
475 int forced;
476 int gesture_id;
477 if (!m_CancelEmote)
478 {
479 pCtx.Read(gesture_id);
480 pCtx.Read(forced);
481
484 {
485 if (m_Callback)
486 {
487 if (m_NameEmoteMap.Find(m_CurrentGestureID, emoteData) && emoteData.CanBeCanceledNormally(m_Callback))
488 m_CancelEmote = true;
489 else
490 return;
491 }
492 m_CancelEmote = true;
493 }
494
496 {
497 if (m_Callback)
498 {
499 if (m_NameEmoteMap.Find(m_CurrentGestureID, emoteData) && !emoteData.CanBeCanceledNormally(m_Callback))
500 {
501 m_InstantCancelEmote = false;
502 return;
503 }
504 }
506 }
507
509 }
510 else
511 m_CancelEmote = false;
512 }
513
515 {
518 emoteData.OnCallbackEnd();
519 }
520
522 {
523 if (m_Player.GetItemInHands() && SurrenderDummyItem.Cast(m_Player.GetItemInHands()))
524 m_Player.GetItemInHands().Delete();
525 }
526
527 bool PlayEmote(int id)
528 {
531
532 if (CanPlayEmote(id))
533 {
534 if (m_AdminLog)
535 m_AdminLog.LogPrint("[emote] " + Object.GetDebugName(m_Player) + " play emote id=" + id + " IH=" + Object.GetDebugName(m_Player.GetItemInHands()));
536
539 if (id > 0)
540 {
542 if (m_NameEmoteMap.Find(id, emote))
543 {
544 int callback_ID;
545 int stancemask;
546 bool is_fullbody;
548 {
549 if (!emote.EmoteStartOverride(EmoteCB, callback_ID, stancemask, is_fullbody))
550 {
551 emote.OnBeforeStandardCallbackCreated(callback_ID, stancemask, is_fullbody);
553 }
554
555 if (emote.GetHideItemInHands())
557 }
558 else
559 ErrorEx("EmoteManager | DetermineEmoteData failed!");
560 }
561 }
562 }
563
565 return m_bEmoteIsPlaying;
566 }
567
568 //creates Emote callback
569 protected void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
570 {
571 if (m_Player)
572 {
573 m_LastMask = -1;
574
575 if (fullbody)
576 {
577 Class.CastTo(m_Callback, m_Player.StartCommand_Action(id, callbacktype, mask));
579 m_Callback.EnableCancelCondition(true);
580 }
581 else if (m_Player.IsPlayerInStance(mask))
582 {
583 m_LastMask = mask; //character is probably not prone now
584 Class.CastTo(m_Callback, m_Player.AddCommandModifier_Action(id, callbacktype));
585 }
586
587 if (m_Callback)
588 {
589 m_bEmoteIsPlaying = true;
592 m_Callback.m_Manager = this;
593 }
594 }
595 }
596
597 protected void HideItemInHands()
598 {
599 m_item = m_Player.GetItemInHands();
600 if (m_Callback && m_item)
601 m_Player.TryHideItemInHands(true);
602 }
603
604 protected void ShowItemInHands()
605 {
606 if (m_item)
607 m_Player.TryHideItemInHands(false);
608 }
609
610 protected void CommitSuicide()
611 {
613 WeaponEventBase weapon_event = new WeaponEventTrigger;
614
615 if (Weapon_Base.CastTo(weapon, m_Player.GetItemInHands()))
616 {
617 if (weapon.CanFire())
618 {
619 m_Callback.RegisterAnimationEvent("Simulation_End", EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
620 m_Player.SetSuicide(true);
621 weapon.ProcessWeaponEvent(weapon_event);
622 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
623 if (m_Player.IsAlive())
624 {
625 EntityAI helm = m_Player.FindAttachmentBySlotName("Headgear");
626 if (helm && GetGame().IsServer())
627 {
628 float damage = helm.GetMaxHealth("", "");
629 helm.AddHealth("", "", -damage / 2);
630 }
631 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(this.KillPlayer);
632 if (m_AdminLog)
633 m_AdminLog.Suicide(m_Player);
634 }
635 }
636 else
637 {
638 if (!weapon.IsDamageDestroyed())
639 weapon.ProcessWeaponEvent(weapon_event);
640 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
641 }
642 }
643 else if (m_Player.GetItemInHands() && m_Player.GetItemInHands().ConfigIsExisting("suicideAnim"))
644 {
645 m_Callback.RegisterAnimationEvent("Death", EmoteConstants.EMOTE_SUICIDE_DEATH);
646 m_Callback.RegisterAnimationEvent("Bleed", EmoteConstants.EMOTE_SUICIDE_BLEED);
647 m_Callback.RegisterAnimationEvent("Simulation_End", EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
648 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
649 m_Player.SetSuicide(true);
650 }
651 else
652 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
653 }
654
656 {
657 if (GetGame().IsServer())
658 m_Player.SetHealth(0);
659 }
660
662 {
663 if (GetGame().IsServer())
664 {
665 PlayerIdentity identity = m_Player.GetIdentity();
666 if (identity)
667 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().AdminLog, "Player '" + identity.GetName() + "' (id=" + identity.GetId() + ") committed suicide.");
668 }
669 }
670
671 void CreateEmoteCBFromMenu(int id, bool interrupts_same = false)
672 {
674 }
675
677 {
678 return m_MenuEmote;
679 }
680
682 {
683 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
684
685 if (m_MenuEmote)
687
689 }
690
692 {
694 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
695 else
696 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
697
698 if (m_MenuEmote)
701 }
702
703 //sends request (client)
705 {
707 if (m_MenuEmote)
708 forced = m_MenuEmote.GetForced();
709
710 m_RPSOutcome = -1;
711 switch (id)
712 {
715 break;
716
718 m_RPSOutcome = 0;
719 break;
720
722 m_RPSOutcome = 1;
723 break;
724
726 m_RPSOutcome = 2;
727 break;
728 }
729
731 if (GetGame().IsMultiplayer() && GetGame().IsClient())
732 {
733 bool canProceed = true; //running callbacks in certain state can block additional actions
736 canProceed = emoteData.CanBeCanceledNormally(m_Callback);
737
738 if (ctx.CanStoreInputUserData() && ((CanPlayEmote(id) && CanPlayEmoteClientCheck(id)) || forced) && canProceed)
739 {
740 ctx.Write(INPUT_UDT_GESTURE);
741 ctx.Write(id);
742 ctx.Write(forced);
743 if (m_RPSOutcome != -1)
744 ctx.Write(m_RPSOutcome);
745 ctx.Send();
747 }
748 else
752 }
753 else if (!GetGame().IsMultiplayer())
754 {
755 if (id == CALLBACK_CMD_END)
757 else if (id == CALLBACK_CMD_GESTURE_INTERRUPT)
759 else if (CanPlayEmote(id) && CanPlayEmoteClientCheck(id))
760 PlayEmote(id);
761 else
764 }
765 }
766
768 {
769 return m_controllsLocked;
770 }
771
772 bool CanPlayEmote(int id)
773 {
774 //special cases
776 return true;
777
778 if (!m_Player || !m_Player.IsAlive() || (!IsEmotePlaying() && (m_Player.GetCommand_Action() || m_Player.GetCommandModifier_Action())) || m_Player.GetThrowing().IsThrowingModeEnabled())
779 {
780 //Debug.Log("!CanPlayEmote | reason: 1");
781 return false;
782 }
783
784 ItemBase item = m_Player.GetItemInHands();
785 if (item)
786 {
787 if (item.IsHeavyBehaviour() && id != EmoteConstants.ID_EMOTE_SURRENDER)
788 {
789 //Debug.Log("!CanPlayEmote | reason: 2");
790 return false;
791 }
792
794 if (m_Player.IsItemsToDelete() && Class.CastTo(sda, item) && !sda.IsSetForDeletion())
795 {
796 //Debug.Log("!CanPlayEmote | reason: 3");
797 return false;
798 }
799 }
800
801 if ((m_Player.GetWeaponManager() && m_Player.GetWeaponManager().IsRunning()) || (m_Player.GetActionManager() && m_Player.GetActionManager().GetRunningAction()))
802 {
803 //Debug.Log("!CanPlayEmote | reason: 4");
804 return false;
805 }
806
807 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?
808 {
809 //Debug.Log("!CanPlayEmote | reason: 5");
810 return false;
811 }
812
813 if (m_Player.GetCommand_Vehicle())
814 {
815 //Debug.Log("!CanPlayEmote | reason: 6");
816 return false;
817 }
818
819 if (m_Player.GetCommand_Move() && m_Player.GetCommand_Move().IsOnBack() && id != EmoteConstants.ID_EMOTE_SURRENDER)
820 {
821 //Debug.Log("!CanPlayEmote | reason: 7");
822 return false;
823 }
824
825 //"locks" player in surrender state
827 {
828 //Debug.Log("!CanPlayEmote | reason: 8");
829 return false;
830 }
831
832 if (m_Player.GetDayZPlayerInventory().IsProcessing())
833 {
834 //Debug.Log("!CanPlayEmote | reason: 9");
835 return false;
836 }
837
839 if (m_NameEmoteMap.Find(id, emote))
840 {
841 int callback_ID;
842 int stancemask;
843 bool is_fullbody;
845 return true;
846 //Debug.Log("!CanPlayEmote | reason: 10");
847 }
848
849 return false;
850 }
851
853 {
854 if (!GetGame().IsClient())
855 return true;
856
857 if (GetGame().GetUIManager().FindMenu(MENU_INVENTORY))
858 {
859 //Debug.Log("!CanPlayEmoteClientCheck | reason: 1");
860 return false;
861 }
862
863 return true;
864 }
865
867 {
870 if (state)
871 {
872 if (m_Player.GetItemInHands() && !m_Player.CanDropEntity(m_Player.GetItemInHands()))
873 return;
874
875 if (m_Player.GetItemInHands() && GetGame().IsClient())
876 m_Player.PhysicalPredictiveDropItem(m_Player.GetItemInHands());
877
878 CreateEmoteCallback(EmoteCB, DayZPlayerConstants.CMD_GESTUREFB_SURRENDERIN, DayZPlayerConstants.STANCEMASK_ALL, true);
879
880 if (m_Callback)
881 m_Callback.RegisterAnimationEvent("ActionExec", UA_ANIM_EVENT);
882 }
883 else
884 {
885 if (m_Player.IsAlive() && !m_Player.IsUnconscious())
886 CreateEmoteCallback(EmoteCB, DayZPlayerConstants.CMD_GESTUREFB_SURRENDEROUT, DayZPlayerConstants.STANCEMASK_ALL, true);
887 else
888 OnEmoteEnd();
889 }
890 }
891
894 {
895 //separate inventory access locking
897 {
898 m_Player.SetInventorySoftLock(state);
900 }
901
902 //full emote locking (
903 if (state == m_EmoteLockState)
904 {
905 //ErrorEx("emote lock state already set",ErrorExSeverity.INFO);
906 return;
907 }
908
910 {
913 }
914
915 if (!state)
916 {
917 if (m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
918 m_Player.GetInventory().ClearInventoryReservationEx(null, m_HandInventoryLocation);
919
920 if (m_Player.GetActionManager())
921 m_Player.GetActionManager().EnableActions(true);
922
924 m_controllsLocked = false;
925 }
926 else
927 {
928 if (!m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
929 m_Player.GetInventory().AddInventoryReservationEx(null, m_HandInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
930
931 if (m_Player.GetActionManager())
932 m_Player.GetActionManager().EnableActions(false);
933
934 //Movement lock in fullbody anims
936 m_controllsLocked = true;
937 }
939 }
940
942 {
943 if (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && !SurrenderDummyItem.Cast(m_Player.GetItemInHands())))
944 return;
945
946 //refreshes reservation in case of unwanted timeout
948 m_Player.GetInventory().ExtendInventoryReservationEx(null, m_HandInventoryLocation, 10000);
949 }
950
953 {
954 if (m_IsSurrendered && data)
955 {
956 if (m_Player.GetItemInHands())
957 m_Player.GetItemInHands().DeleteSafe();//Note, this keeps item 'alive' until it is released by all the systems (inventory swapping etc.)
958
959 m_IsSurrendered = false;
961 data.End();
962 }
963 }
964
965 //sent from server to cancel generic emote callback
973
975 {
976 //init pass
978 {
981
982 for (int i = 0; i < m_InterruptInputsCount; i++)
983 m_InterruptInputDirect.Insert(GetUApi().GetInputByName(m_InterruptInputs[i]));
984 }
985
986 //interrupts any callback if restrain action is in progress, takes priority
988 return false;
989
990 for (int idx = 0; idx < m_InterruptInputsCount; idx++)
991 {
992 if (m_InterruptInputDirect[idx].LocalPress())
993 return true;
994 }
995
996 return false;
997 }
998
1000 {
1002
1003 if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_PRONE) && waterLevel >= m_HumanSwimSettings.m_fToCrouchLevel)
1004 return true;
1005 else if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEIDX_RAISEDCROUCH) && waterLevel >= m_HumanSwimSettings.m_fToErectLevel)
1006 return true;
1007
1008 return m_Player.GetModifiersManager() && m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_DROWNING);
1009 }
1010
1015
1020
1022 {
1023 if (GetGame().IsServer() && m_Player.IsAlive())
1024 {
1025 switch (Callback_ID)
1026 {
1027 case DayZPlayerConstants.CMD_SUICIDEFB_1HD :
1028 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Neck");
1029 break;
1030
1031 case DayZPlayerConstants.CMD_SUICIDEFB_FIREAXE :
1032 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1033 break;
1034
1035 case DayZPlayerConstants.CMD_SUICIDEFB_PITCHFORK :
1036 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1037 break;
1038
1039 case DayZPlayerConstants.CMD_SUICIDEFB_SWORD :
1040 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1041 break;
1042
1043 case DayZPlayerConstants.CMD_SUICIDEFB_SPEAR :
1044 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Head");
1045 break;
1046
1047 case DayZPlayerConstants.CMD_SUICIDEFB_WOODAXE :
1048 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1049 break;
1050
1051 default :
1052 ErrorEx("EmoteManager.c | CreateBleedingEffect | WRONG ID", ErrorExSeverity.INFO);
1053 break;
1054 }
1055 }
1056 }
1057
1060 protected void PickEmote(int gestureslot)
1061 {
1062 }
1063};
1064
1066{
1068 void End();
1069}
1070
1075{
1077
1079 {
1080 m_Player = player;
1082 vector mtx[4];
1083 old_item.GetTransform(mtx);
1084 gnd.SetGround(old_item, mtx);
1085
1086 OverrideNewLocation(gnd);
1087 }
1088
1090 {
1091 if (PrepareLocations())
1092 {
1093 vector transform[4];
1094
1095 m_Player.GetInventory().TakeToDst(InventoryMode.SERVER, m_OldLocation, m_NewLocation);
1097 }
1098
1099 m_Player.SetHealth(0);
1100
1101 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[syncinv] player=" + Object.GetDebugName(m_Player) + " STS = " + m_Player.GetSimulationTimeStamp() + " ChainedDropAndKillPlayerLambda");
1102 }
1103}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
const int INPUT_UDT_GESTURE
Definition _constants.c:18
override void OnCallbackEnd()
void ChainedDropAndKillPlayerLambda(EntityAI old_item, string new_item_type, PlayerBase player)
bool m_ItemToHands
EmoteCB m_Callback
ref Timer m_ReservationTimer
ref array< int > m_EmoteInputIDs
const int CALLBACK_CMD_END
ref array< UAInput > m_InterruptInputDirect
int m_InterruptInputsCount
void HideItemInHands()
void CheckEmoteLockedState()
bool m_controllsLocked
void EmoteManager(PlayerBase player)
int m_RPSOutcome
void CreateEmoteCBFromMenu(int id, bool interrupts_same=false)
void AfterStoreLoad()
const int CALLBACK_CMD_INVALID
int m_CurrentGestureID
ref array< string > m_InterruptInputs
bool m_CancelEmote
bool CanPlayEmoteClientCheck(int id)
ref array< int > m_EmoteIDs
bool CanPlayEmote(int id)
int m_DeferredEmoteExecution
bool IsControllsLocked()
void ShowItemInHands()
ItemBase m_item
PluginAdminLog m_AdminLog
ref InventoryLocation m_HandInventoryLocation
void InterruptCallbackCommand()
void ConstructData()
int m_LastMask
void PlaySurrenderInOut(bool state)
int DetermineGestureIndex()
void CreateBleedingEffect(int Callback_ID)
void SetGesture(int id)
map< int, ref EmoteBase > GetNameEmoteMap()
void CommitSuicide()
bool m_GestureInterruptInput
bool m_InventoryAccessLocked
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
const int CALLBACK_CMD_INSTACANCEL
void KillPlayer()
void OnEmoteEnd()
void ServerRequestEmoteCancel()
void ~EmoteManager()
void EndSurrenderRequest(SurrenderData data=null)
directly force-ends surrender state from outside of normal flow
void SetEmoteLockState(bool state)
ref EmoteLauncher m_MenuEmote
void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
bool InterruptGestureCheck()
bool m_PlayerDies
bool InterruptWaterCheck()
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
int m_GestureID
void PickEmote(int gestureslot)
Deprecated.
bool IsEmotePlaying()
bool DetermineEmoteData(EmoteBase emote, out int callback_ID, out int stancemask, out bool is_fullbody)
Also includes a stance check for FB callbacks.
bool m_EmoteLockState
SHumanCommandSwimSettings m_HumanSwimSettings
override void Execute(HumanInventoryWithFSM fsm_to_notify=null)
bool m_ItemToBeCreated
bool m_IsSurrendered
const int CALLBACK_CMD_GESTURE_INTERRUPT
ref map< int, ref EmoteBase > m_NameEmoteMap
HumanInputController m_HIC
ref array< ref EmoteBase > m_EmoteClassArray
void EndCallbackCommand()
bool m_bEmoteIsPlaying
void LogSuicide()
bool m_MouseButtonPressed
bool m_InstantCancelEmote
EmoteLauncher GetEmoteLauncher()
bool m_bEmoteIsRequestPending
bool m_ItemIsOn
void SendEmoteRequestSync(int id)
int m_PreviousGestureID
int GetGesture()
bool PlayEmote(int id)
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()
drops weapon in hands to ground and then calls kill
Super root of all classes in Enforce script.
Definition EnScript.c:11
DayZPlayerImplementThrowing GetThrowing()
override bool IsShootingFromCamera()
void OverrideShootFromCamera(bool pState)
WeaponManager GetWeaponManager()
void SetSuicide(bool state)
override float GetCurrentWaterLevel()
override void OnItemInHandsChanged()
bool IsFighting()
DayZPlayerInventory GetDayZPlayerInventory()
bool IsRestrained()
bool IsEmoteCallback()
EmoteManager m_Manager
Definition EmoteManager.c:6
override void OnAnimationEvent(int pEventID)
void ~EmoteCB()
Definition EmoteManager.c:8
bool m_IsFullbody
Definition EmoteManager.c:3
PlayerBase m_player
Definition EmoteManager.c:5
bool CancelCondition()
override bool IsGestureCallback()
int m_callbackID
Definition EmoteManager.c:4
static const int FORCE_ALL
static const int FORCE_NONE
void SetForced(int mode)
bool m_InterruptsSameIDEmote
static const int FORCE_DIFFERENT
void EmoteLauncher(int emoteID, bool interrupts_same)
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
proto native bool IsWeaponRaised()
returns true if weapon is raised
proto native bool IsSingleUse()
single 'UADefaultAction' (== true for 1 tick only) + not raised
proto native bool IsContinuousUseStart()
is start of cont. 'UADefaultAction' (== true for 1 tick only) + not raised
HumanInventory... with FSM (synchronous, no anims)
InventoryLocation.
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749
Definition EnMath.c:7
The class that will be instanced (moddable)
Definition gameplay.c:376
base class for transformation operations (creating one item from another)
float m_fToCrouchLevel
when to crouch
float m_fToErectLevel
when to stand
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
void End()
called on surrender end request end
signalize mechanism manipulation
Definition Events.c:35
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
eModifiers
Definition eModifiers.c:2
proto native CGame GetGame()
const int EMOTE_SUICIDE_SIMULATION_END
Definition constants.c:400
const int EMOTE_SUICIDE_BLEED
Definition constants.c:399
const int EMOTE_SUICIDE_DEATH
Definition constants.c:398
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
const int ID_EMOTE_RPS_P
Definition constants.c:384
const int ID_EMOTE_RPS
Definition constants.c:373
const int ID_EMOTE_SURRENDER
Definition constants.c:389
const int ID_EMOTE_THUMB
Definition constants.c:358
const int ID_EMOTE_DANCE
Definition constants.c:361
const int ID_EMOTE_RPS_S
Definition constants.c:385
const int ID_EMOTE_SUICIDE
Definition constants.c:360
const int ID_EMOTE_RPS_R
Definition constants.c:383
const int ID_EMOTE_THUMBDOWN
Definition constants.c:365
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:184
const int MENU_INVENTORY
Definition constants.c:170
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
const int UA_ANIM_EVENT
Definition constants.c:443
proto native volatile void Update()