DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
EmoteManager.c
См. документацию.
2{
4 int m_callbackID; //Animation cmd ID
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 (m_callbackID == DayZPlayerConstants.CMD_GESTUREFB_SURRENDERIN)
43 m_Manager.m_ItemToBeCreated = true;
44 break;
45
47 if (GetGame().IsServer())
48 m_Manager.CreateBleedingEffect(m_callbackID);
49 break;
50
52 if (GetGame().IsServer())
53 {
54 EntityAI itemInHands = m_player.GetHumanInventory().GetEntityInHands();
55 if (itemInHands)
56 {
57 vector m4[4];
58 itemInHands.GetTransform(m4);
59 m_player.GetInventory().DropEntityWithTransform(InventoryMode.SERVER, m_player, itemInHands, m4);
60 }
61 }
62
63 m_player.StartDeath();
64 break;
65 }
66 }
67
68 override bool IsGestureCallback()
69 {
70 return true;
71 }
72};
73
75{
76 static const int FORCE_NONE = 0;
77 static const int FORCE_DIFFERENT = 1;
78 static const int FORCE_ALL = 2;
79
81 protected int m_ForcePlayEmote;
82 protected int m_ID;
83
84 void EmoteLauncher(int emoteID, bool interrupts_same)
85 {
86 m_ID = emoteID;
87 m_InterruptsSameIDEmote = interrupts_same;
89 }
90
91 void SetForced(int mode)
92 {
93 m_ForcePlayEmote = mode;
94 }
95
97 {
98 return m_ForcePlayEmote;
99 }
100
101 int GetID()
102 {
103 return m_ID;
104 }
105}
106
107class EmoteManager
108{
124 protected bool m_ItemToHands; //deprecated
125 protected bool m_ItemIsOn;
126 protected bool m_MouseButtonPressed;
127 protected bool m_PlayerDies;
128 protected bool m_controllsLocked;
130 protected bool m_EmoteLockState;
132 protected int m_GestureID;
133 protected int m_PreviousGestureID;
134 protected int m_CurrentGestureID;
135 protected int m_LastMask;
136 protected int m_RPSOutcome;
138 protected const int CALLBACK_CMD_INVALID = -1;
139 protected const int CALLBACK_CMD_END = -2;
140 protected const int CALLBACK_CMD_GESTURE_INTERRUPT = -3;
141 protected const int CALLBACK_CMD_INSTACANCEL = -4;
142 PluginAdminLog m_AdminLog;
144
145 protected ref map<int, ref EmoteBase> m_NameEmoteMap; //<emote_ID,EmoteBase>
146 protected ref array<ref EmoteBase> m_EmoteClassArray; //registered 'EmoteBase' object refs
147 protected ref array<int> m_EmoteIDs; //IDs of registered emotes (found in 'EmoteConstants'). For quick access.
148 protected ref array<int> m_EmoteInputIDs; //input IDs for the registered 'EmoteBase' objects
150
152 {
153 m_Player = player;
154 m_HIC = m_Player.GetInputController();
155 m_ItemIsOn = false;
156 m_controllsLocked = false;
158 m_RPSOutcome = -1;
160
162 m_InterruptInputs.Insert("UAMoveForward");
163 m_InterruptInputs.Insert("UAMoveBack");
164 m_InterruptInputs.Insert("UATurnLeft");
165 m_InterruptInputs.Insert("UATurnRight");
166 m_InterruptInputs.Insert("UAMoveLeft");
167 m_InterruptInputs.Insert("UAMoveRight");
168 m_InterruptInputs.Insert("UAStand");
169 m_InterruptInputs.Insert("UACrouch");
170 m_InterruptInputs.Insert("UAProne");
171 m_InterruptInputs.Insert("UAGetOver");
172
174 m_HandInventoryLocation.SetHands(m_Player, null);
175
176 if (GetGame().IsServer())
177 {
178 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
179 }
180
182 m_ReservationTimer.Run(8, this, "CheckEmoteLockedState", null, true);
183
184 m_HumanSwimSettings = m_Player.GetDayZPlayerType().CommandSwimSettingsW();
185
187 }
188
190 {
191 if (m_ReservationTimer && m_ReservationTimer.IsRunning())
192 m_ReservationTimer.Stop();
193 }
194
196 {
198 if (!m_NameEmoteMap)
199 {
204 int inputID;
205 int count = m_NameEmoteMap.Count();
206 UAInput inp;
207
208 for (int i = 0; i < count; i++)
209 {
210 m_EmoteClassArray.Insert(m_NameEmoteMap.GetElement(i));
211 m_EmoteIDs.Insert(m_NameEmoteMap.GetElement(i).GetID());
212 inp = GetUApi().GetInputByName(m_NameEmoteMap.GetElement(i).GetInputActionName());
213 inputID = inp.ID();
214 m_EmoteInputIDs.Insert(inputID);
215 }
216
217 if (m_EmoteInputIDs.Count() != m_EmoteClassArray.Count())
218 {
219 ErrorEx("Faulty emote data detected in 'ConstructData' method!",ErrorExSeverity.WARNING);
220 }
221 }
222 }
223
224 void SetGesture(int id)
225 {
226 m_GestureID = id;
227 }
228
230 {
231 return m_GestureID;
232 }
233
235 {
236 int count = m_EmoteInputIDs.Count();
237 for (int i = 0; i < count; ++i)
238 {
239 if (GetUApi().GetInputByID(m_EmoteInputIDs[i]).LocalPress())
240 {
241 return m_EmoteIDs[i];
242 }
243 }
244
245 return 0;
246 }
247
249 bool DetermineEmoteData(EmoteBase emote, out int callback_ID, out int stancemask, out bool is_fullbody)
250 {
251 if (emote.DetermineOverride(callback_ID, stancemask, is_fullbody))
252 {
253 return emote.EmoteFBStanceCheck(stancemask);
254 }
255 else if (emote.GetAdditiveCallbackUID() != 0 && m_Player.IsPlayerInStance(emote.GetStanceMaskAdditive()))
256 {
257 callback_ID = emote.GetAdditiveCallbackUID();
258 stancemask = emote.GetStanceMaskAdditive();
259 is_fullbody = false;
260 return true;
261 }
262 else if (emote.GetFullbodyCallbackUID() != 0 && emote.EmoteFBStanceCheck(emote.GetStanceMaskFullbody()))
263 {
264 callback_ID = emote.GetFullbodyCallbackUID();
265 stancemask = emote.GetStanceMaskFullbody();
266 is_fullbody = true;
267 return true;
268 }
269
270 return false;
271 }
272
273 //Called from players commandhandler each frame, checks input
274 void Update(float deltaT)
275 {
276 // no updates on restrained characters
277 if (m_Player.IsRestrained())
278 return;
279
281 {
282 if (GetGame().IsServer() && m_Callback && !m_Player.GetItemInHands())
283 {
284 m_Player.GetHumanInventory().CreateInHands("SurrenderDummyItem");
285 }
286 m_ItemToBeCreated = false;
287 }
288
289 int gestureSlot = 0;
290 #ifndef SERVER
291 gestureSlot = DetermineGestureIndex();
292 #endif
293 //deferred emote cancel
294 if (m_InstantCancelEmote) //'hard' cancel
295 {
296 if (m_Callback)
297 {
298 m_Callback.Cancel();
299 }
300
301 if (m_MenuEmote)
302 {
303 m_MenuEmote = null;
304 }
306 m_InstantCancelEmote = false;
308 if (m_IsSurrendered)
310 else
311 SetEmoteLockState(false);
312 }
313 else if (m_CancelEmote) //'soft' cancel
314 {
315 if (m_IsSurrendered)
316 {
318 }
319 else if (m_Callback)
320 {
321 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
322 }
323
325 m_CancelEmote = false;
326 }
327
328 if (m_MenuEmote && m_MenuEmote.GetForced() > EmoteLauncher.FORCE_NONE && !GetGame().IsDedicatedServer()) //forced emote playing
329 {
331 }
332 else if (m_Callback)
333 {
334 bool uiGesture = false;
335 if (!GetGame().IsDedicatedServer())
336 {
338
340 {
342 }
343
345 {
347 }
348 }
349
350 if (gestureSlot > 0 || m_GestureInterruptInput || (m_HIC.IsSingleUse() && !uiGesture) || (m_HIC.IsContinuousUseStart() && !uiGesture) || (m_Callback.m_IsFullbody && !uiGesture && m_HIC.IsWeaponRaised()))
351 {
353 {
354 if (m_Callback.GetState() == m_Callback.STATE_LOOP_LOOP)
355 {
357 }
358 else
359 {
360 return;
361 }
362 }
364 {
365 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_ACTION);
366 }
368 {
369 if (m_RPSOutcome != -1)
370 {
371 if (m_RPSOutcome == 0)
372 {
373 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_ROCK);
374 }
375 else if (m_RPSOutcome == 1)
376 {
377 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_PAPER);
378 }
379 else if (m_RPSOutcome == 2)
380 {
381 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_RPS_SCISSORS);
382 }
383 m_RPSOutcome = -1;
384 }
385 else
386 {
387 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
388 }
389 }
391 {
393 }
395 {
397 }
398 }
399
400 if (m_LastMask != -1 && m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE))
401 {
402 m_Callback.Cancel();
403 }
404
406 {
408 }
409
411 {
413 }
414
416 {
418 }
419 }
420 //no m_Callback exists
421 else
422 {
423 if (m_bEmoteIsRequestPending && (m_Player.IsUnconscious() || !m_Player.IsAlive()))
424 {
426 }
427
429 {
430 OnEmoteEnd();
431 }
432 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
433 {
434 PlaySurrenderInOut(false);
435 return;
436 }
437 // getting out of surrender state
438 else if (m_IsSurrendered && m_Player.GetItemInHands() && (m_HIC.IsSingleUse() || m_HIC.IsContinuousUseStart() || m_HIC.IsWeaponRaised()))
439 {
440 if (m_Player.GetItemInHands())
441 m_Player.GetItemInHands().DeleteSafe();//Note, this keeps item 'alive' until it is released by all the systems (inventory swapping etc.)
442 return;
443 }
444 // fallback in case lock does not end properly
445 else if (m_IsSurrendered && (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && m_Player.GetItemInHands().GetType() != "SurrenderDummyItem" && m_EmoteLockState)))
446 {
448 return;
449 }
450 //actual emote launch
452 {
454 }
455 //client-side emote launcher
456 else if (!m_bEmoteIsPlaying && m_MenuEmote && !GetGame().IsDedicatedServer())
457 {
459 }
460 else if (!m_MenuEmote && gestureSlot > 0)
461 {
462 CreateEmoteCBFromMenu(gestureSlot,true); //translation no longer needed
463 }
464 }
465 }
466
468 {
470
471 if (m_PlayerDies)
472 {
473 m_Player.SetHealth(0.0);
474 return;
475 }
476
477 //surrender "state" OFF switch only
479 {
480 if (m_IsSurrendered && !m_Player.GetItemInHands())
481 {
482 m_IsSurrendered = false;
483 }
484 }
485
487 m_bEmoteIsPlaying = false;
489
490 if (m_IsSurrendered)
491 return;
492
494 SetEmoteLockState(false);
495
496 // back to the default - shoot from camera - if not set already
497 if (!m_Player.IsShootingFromCamera())
498 m_Player.OverrideShootFromCamera(true);
499 }
500
501 //server-side
502 bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
503 {
504 if (userDataType == INPUT_UDT_GESTURE)
505 {
506 int forced = EmoteLauncher.FORCE_NONE;
507 int gestureID = -1;
508 int random = -1;
509
510 if (ctx.Read(gestureID))
511 {
512 ctx.Read(forced);
513 if (ctx.Read(random))
514 {
515 m_RPSOutcome = random;
516 }
517
518 //server-side check, sends CALLBACK_CMD_INSTACANCEL as a fail
519 if (forced == EmoteLauncher.FORCE_NONE && !CanPlayEmote(gestureID))
520 gestureID = CALLBACK_CMD_INSTACANCEL;
521
523 pCtx.Write(gestureID);
524 pCtx.Write(forced);
527 }
528 return true;
529 }
530 return false;
531 }
532
533 //server and client
534 void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
535 {
536 int forced;
537 int gesture_id;
538 if (!m_CancelEmote)
539 {
540 pCtx.Read(gesture_id);
541 pCtx.Read(forced);
542
543 EmoteBase emoteData;
544 if ((m_Callback || m_IsSurrendered) && (forced == EmoteLauncher.FORCE_ALL || (forced == EmoteLauncher.FORCE_DIFFERENT && m_CurrentGestureID != gesture_id)))
545 {
546 if (m_Callback)
547 {
548 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && emoteData.CanBeCanceledNormally(m_Callback))
549 m_CancelEmote = true;
550 else
551 return;
552 }
553 m_CancelEmote = true;
554 }
555
556 if (gesture_id == CALLBACK_CMD_INSTACANCEL)
557 {
558 if (m_Callback)
559 {
560 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && !emoteData.CanBeCanceledNormally(m_Callback))
561 {
562 m_InstantCancelEmote = false;
563 return;
564 }
565 }
567 }
568
569 m_DeferredEmoteExecution = gesture_id;
570 }
571 else
572 m_CancelEmote = false;
573 }
574
576 {
577 EmoteBase emoteData;
578 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData))
579 emoteData.OnCallbackEnd();
580 }
581
583 {
584 if (m_Player.GetItemInHands() && SurrenderDummyItem.Cast(m_Player.GetItemInHands()))
585 m_Player.GetItemInHands().Delete();
586 }
587
588 bool PlayEmote(int id)
589 {
592
593 if (CanPlayEmote(id))
594 {
595 EmoteBase emote;
596 m_NameEmoteMap.Find(id,emote);
597
598 if (m_AdminLog)
599 m_AdminLog.OnEmote(m_Player, emote);
600
603 if (id > 0)
604 {
605 if (emote)
606 {
607 int callback_ID;
608 int stancemask;
609 bool is_fullbody;
610 if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody))
611 {
612 if (!emote.EmoteStartOverride(EmoteCB,callback_ID,stancemask,is_fullbody))
613 {
614 emote.OnBeforeStandardCallbackCreated(callback_ID,stancemask,is_fullbody);
615 CreateEmoteCallback(EmoteCB,callback_ID,stancemask,is_fullbody);
616 }
617
618 if (emote.GetHideItemInHands())
619 {
621 }
622 }
623 else
624 {
625 ErrorEx("EmoteManager | DetermineEmoteData failed!");
626 }
627 }
628 }
629 }
630
632 return m_bEmoteIsPlaying;
633 }
634
635 //creates Emote callback
636 protected void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
637 {
638 if (m_Player)
639 {
640 m_LastMask = -1;
641
642 if (fullbody)
643 {
644 Class.CastTo(m_Callback, m_Player.StartCommand_Action(id,callbacktype,mask));
645 m_Callback.m_IsFullbody = true;
646 m_Callback.EnableCancelCondition(true);
647 }
648 else if (m_Player.IsPlayerInStance(mask))
649 {
650 m_LastMask = mask; //character is probably not prone now
651 Class.CastTo(m_Callback, m_Player.AddCommandModifier_Action(id,callbacktype));
652 }
653
654 if (m_Callback)
655 {
656 m_bEmoteIsPlaying = true;
657 m_Callback.m_callbackID = id;
658 m_Callback.m_player = m_Player;
659 m_Callback.m_Manager = this;
660 }
661 }
662 }
663
664 protected void HideItemInHands()
665 {
666 m_item = m_Player.GetItemInHands();
667 if (m_Callback && m_item)
668 {
669 m_Player.TryHideItemInHands(true);
670 }
671 }
672
673 protected void ShowItemInHands()
674 {
675 if (m_item)
676 {
677 m_Player.TryHideItemInHands(false);
678 }
679 }
680
682 {
683 if (!GetGame().IsClient())
685 }
686
687 protected void CommitSuicide()
688 {
689 Weapon_Base weapon;
690 WeaponEventBase weapon_event = new WeaponEventTrigger;
691
692 if (Weapon_Base.CastTo(weapon,m_Player.GetItemInHands()))
693 {
694 if (weapon.CanFire())
695 {
696 m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
697 m_Player.SetSuicide(true);
698 weapon.ProcessWeaponEvent(weapon_event);
699 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
700 if (m_Player.IsAlive())
701 {
702 EntityAI helm = m_Player.FindAttachmentBySlotName("Headgear");
703 if (helm && GetGame().IsServer())
704 {
705 float damage = helm.GetMaxHealth("","");
706 helm.AddHealth("","", -damage/2);
707 }
709 if (m_AdminLog)
710 {
711 m_AdminLog.Suicide(m_Player);
712 }
713 }
714 }
715 else
716 {
717 if (!weapon.IsDamageDestroyed())
718 {
719 weapon.ProcessWeaponEvent(weapon_event);
720 }
721 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
722 }
723 }
724 else if (m_Player.GetItemInHands() && m_Player.GetItemInHands().ConfigIsExisting("suicideAnim"))
725 {
726 m_Callback.RegisterAnimationEvent("Death",EmoteConstants.EMOTE_SUICIDE_DEATH);
727 m_Callback.RegisterAnimationEvent("Bleed",EmoteConstants.EMOTE_SUICIDE_BLEED);
728 m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
729 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
730 m_Player.SetSuicide(true);
731 }
732 else
733 {
734 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
735 }
736 }
737
739 {
740 if (GetGame().IsServer())
741 {
742 m_Player.SetHealth(0);
743 }
744 }
745
747 {
748 if (GetGame().IsServer())
749 {
750 PlayerIdentity identity = m_Player.GetIdentity();
751 if (identity)
752 {
753 if (m_AdminLog)
754 m_AdminLog.Suicide(m_Player);
755 }
756 }
757 }
758
759 void CreateEmoteCBFromMenu(int id, bool interrupts_same = false)
760 {
761 m_MenuEmote = new EmoteLauncher(id,interrupts_same);
762 }
763
765 {
766 return m_MenuEmote;
767 }
768
770 {
771 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
772
773 if (m_MenuEmote)
774 m_MenuEmote = null;
775
777 }
778
780 {
782 {
783 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
784 }
785 else
786 {
787 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
788 }
789
790 if (m_MenuEmote)
791 m_MenuEmote = null;
793 }
794
795 //sends request (client)
797 {
798 int forced = EmoteLauncher.FORCE_NONE;
799 if (m_MenuEmote)
800 {
801 forced = m_MenuEmote.GetForced();
802 }
803
804 m_RPSOutcome = -1;
805 switch (id)
806 {
809 break;
810
812 m_RPSOutcome = 0;
813 break;
814
816 m_RPSOutcome = 1;
817 break;
818
820 m_RPSOutcome = 2;
821 break;
822 }
823
825 if (GetGame().IsMultiplayer() && GetGame().IsClient())
826 {
827 bool canProceed = true; //running callbacks in certain state can block additional actions
829 if (m_Callback && emoteData)
830 {
831 canProceed = emoteData.CanBeCanceledNormally(m_Callback);
832 }
833
834 if (ctx.CanStoreInputUserData() && ((CanPlayEmote(id) && CanPlayEmoteClientCheck(id)) || forced) && canProceed)
835 {
837 ctx.Write(id);
838 ctx.Write(forced);
839 if (m_RPSOutcome != -1)
840 {
841 ctx.Write(m_RPSOutcome);
842 }
843 ctx.Send();
845 }
846 else
847 {
849 }
850 m_MenuEmote = NULL;
852 }
853 else if (!GetGame().IsMultiplayer())
854 {
855 if (id == CALLBACK_CMD_END)
856 {
858 }
859 else if (id == CALLBACK_CMD_GESTURE_INTERRUPT)
860 {
862 }
863 else if (CanPlayEmote(id) && CanPlayEmoteClientCheck(id))
864 {
865 PlayEmote(id);
866 }
867 else
868 {
870 }
871 m_MenuEmote = NULL;
872 }
873 }
874
876 {
877 return m_controllsLocked;
878 }
879
880 bool CanPlayEmote(int id)
881 {
882 //special cases
884 {
885 return true;
886 }
887
888 if (!m_Player || !m_Player.IsAlive() || (!IsEmotePlaying() && (m_Player.GetCommand_Action() || m_Player.GetCommandModifier_Action())) || m_Player.GetThrowing().IsThrowingModeEnabled())
889 {
890 //Debug.Log("!CanPlayEmote | reason: 1");
891 return false;
892 }
893
894 ItemBase item = m_Player.GetItemInHands();
895 if (item)
896 {
897 if (item.IsHeavyBehaviour() && id != EmoteConstants.ID_EMOTE_SURRENDER)
898 {
899 //Debug.Log("!CanPlayEmote | reason: 2");
900 return false;
901 }
902
903 SurrenderDummyItem sda;
904 if (m_Player.IsItemsToDelete() && Class.CastTo(sda,item) && !sda.IsSetForDeletion())
905 {
906 //Debug.Log("!CanPlayEmote | reason: 3");
907 return false;
908 }
909 }
910
911 if ((m_Player.GetWeaponManager() && m_Player.GetWeaponManager().IsRunning()) || (m_Player.GetActionManager() && m_Player.GetActionManager().GetRunningAction()))
912 {
913 //Debug.Log("!CanPlayEmote | reason: 4");
914 return false;
915 }
916
917 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?
918 {
919 //Debug.Log("!CanPlayEmote | reason: 5");
920 return false;
921 }
922
923 if (m_Player.GetCommand_Vehicle())
924 {
925 //Debug.Log("!CanPlayEmote | reason: 6");
926 return false;
927 }
928
929 HumanCommandMove cm = m_Player.GetCommand_Move();
930 if (cm)
931 {
933 return false;
934 if (cm.IsChangingStance())
935 return false;
936 }
937
938 //"locks" player in surrender state
940 {
941 //Debug.Log("!CanPlayEmote | reason: 8");
942 return false;
943 }
944
945 if (m_Player.GetDayZPlayerInventory().IsProcessing())
946 {
947 //Debug.Log("!CanPlayEmote | reason: 9");
948 return false;
949 }
950
951 EmoteBase emote;
952 if (m_NameEmoteMap.Find(id,emote))
953 {
954 int callback_ID;
955 int stancemask;
956 bool is_fullbody;
957 if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody) && emote.EmoteCondition(stancemask))
958 {
959 return true;
960 }
961 //Debug.Log("!CanPlayEmote | reason: 10");
962 }
963
964 return false;
965 }
966
968 {
969 if (!GetGame().IsClient())
970 return true;
971
972 if (GetGame().GetUIManager().FindMenu(MENU_INVENTORY))
973 {
974 //Debug.Log("!CanPlayEmoteClientCheck | reason: 1");
975 return false;
976 }
977
978 return true;
979 }
980
981 void PlaySurrenderInOut(bool state)
982 {
985
986 if (state)
987 {
988 ItemBase item = m_Player.GetItemInHands();
989 if (item)
990 {
991 if (!m_Player.CanDropEntity(item))
992 return;
993
994 if (m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
995 m_Player.GetInventory().ClearInventoryReservationEx(null, m_HandInventoryLocation);
996
997 if (GetGame().IsMultiplayer())
998 {
999 if (GetGame().IsServer())
1000 m_Player.ServerDropEntity(item);
1001 }
1002 else
1003 {
1004 m_Player.PhysicalPredictiveDropItem(item); //SP only
1005 }
1006 }
1007
1008 CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDERIN,DayZPlayerConstants.STANCEMASK_ALL,true);
1009
1010 if (m_Callback)
1011 {
1012 m_Callback.RegisterAnimationEvent("ActionExec", UA_ANIM_EVENT);
1013 m_IsSurrendered = true; //sets state immediately on anim start
1014 }
1015 }
1016 else
1017 {
1018 if (m_Player.IsAlive() && !m_Player.IsUnconscious())
1019 {
1020 CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDEROUT,DayZPlayerConstants.STANCEMASK_ALL,true);
1021 }
1022 else
1023 {
1024 OnEmoteEnd();
1025 }
1026 }
1027 }
1028
1030 void SetEmoteLockState(bool state)
1031 {
1032 //separate inventory access locking
1033 if (state != m_InventoryAccessLocked)
1034 {
1035 m_Player.SetInventorySoftLock(state);
1037 }
1038
1039 if (GetGame().IsClient() && m_InventoryAccessLocked && GetGame().GetUIManager().FindMenu(MENU_INVENTORY))
1040 m_Player.CloseInventoryMenu();
1041
1042 //Movement lock in fullbody anims
1043 if (state && m_Callback && m_Callback.m_IsFullbody)
1044 m_controllsLocked = true;
1045 else
1046 m_controllsLocked = false;
1047
1048 if (state == m_EmoteLockState)
1049 return;
1050
1052 {
1054 m_HandInventoryLocation.SetHands(m_Player,null);
1055 }
1056
1057 if (!state)
1058 {
1059 if (m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
1060 m_Player.GetInventory().ClearInventoryReservationEx(null, m_HandInventoryLocation);
1061
1062 if (m_Player.GetActionManager())
1063 m_Player.GetActionManager().EnableActions(true);
1064 }
1065 else
1066 {
1067 if (!m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
1068 m_Player.GetInventory().AddInventoryReservationEx(null, m_HandInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1069
1070 if (m_Player.GetActionManager())
1071 m_Player.GetActionManager().EnableActions(false);
1072 }
1073 m_EmoteLockState = state;
1074 }
1075
1077 {
1078 if (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && !SurrenderDummyItem.Cast(m_Player.GetItemInHands())))
1079 return;
1080
1081 //refreshes reservation in case of unwanted timeout
1083 {
1084 m_Player.GetInventory().ExtendInventoryReservationEx(null, m_HandInventoryLocation, 10000);
1085 }
1086 }
1087
1090 {
1091 if (m_IsSurrendered && data)
1092 {
1094 data.End();
1095 }
1096 }
1097
1099 protected void ClearSurrenderState()
1100 {
1101 if (m_IsSurrendered)
1102 {
1103 SurrenderDummyItem dummyItem = SurrenderDummyItem.Cast(m_Player.GetItemInHands());
1104 if (dummyItem)
1105 dummyItem.DeleteSafe();
1106 m_IsSurrendered = false;
1108 }
1109 }
1110
1111 void ForceSurrenderState(bool state)
1112 {
1113 m_IsSurrendered = state;
1115 }
1116
1119 {
1120 if ((GetGame().IsMultiplayer() && GetGame().IsServer()) || !GetGame().IsMultiplayer())
1121 {
1125 m_Player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_GESTURE_REQUEST, pCtx);
1126 }
1127 }
1128
1129 //sent from server to cancel generic emote callback
1137
1139 {
1140 //init pass
1142 {
1145
1146 for (int i = 0; i < m_InterruptInputsCount; i++)
1147 {
1148 m_InterruptInputDirect.Insert(GetUApi().GetInputByName(m_InterruptInputs[i]).GetPersistentWrapper());
1149 }
1150 }
1151
1152 //interrupts any callback if restrain action is in progress, takes priority
1153 if (!m_Callback.m_IsFullbody)
1154 return false;
1155
1156 for (int idx = 0; idx < m_InterruptInputsCount; idx++)
1157 {
1158 if (m_InterruptInputDirect[idx].InputP().LocalPress())
1159 {
1160 return true;
1161 }
1162 }
1163
1164 return false;
1165 }
1166
1168 {
1169 float waterLevel = m_Player.GetCurrentWaterLevel();
1170
1171 if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_PRONE) && waterLevel >= m_HumanSwimSettings.m_fToCrouchLevel)
1172 {
1173 return true;
1174 }
1175 else if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEIDX_RAISEDCROUCH) && waterLevel >= m_HumanSwimSettings.m_fToErectLevel)
1176 {
1177 return true;
1178 }
1179
1180 return m_Player.GetModifiersManager() && m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_DROWNING);
1181 }
1182
1187
1192
1193 void CreateBleedingEffect(int Callback_ID)
1194 {
1195 if (GetGame().IsServer() && m_Player.IsAlive())
1196 {
1197 switch (Callback_ID)
1198 {
1199 case DayZPlayerConstants.CMD_SUICIDEFB_1HD :
1200 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Neck");
1201 break;
1202
1203 case DayZPlayerConstants.CMD_SUICIDEFB_FIREAXE :
1204 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1205 break;
1206
1207 case DayZPlayerConstants.CMD_SUICIDEFB_PITCHFORK :
1208 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1209 break;
1210
1211 case DayZPlayerConstants.CMD_SUICIDEFB_SWORD :
1212 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1213 break;
1214
1215 case DayZPlayerConstants.CMD_SUICIDEFB_SPEAR :
1216 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Head");
1217 break;
1218
1219 case DayZPlayerConstants.CMD_SUICIDEFB_WOODAXE :
1220 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1221 break;
1222
1223 default :
1224 ErrorEx("EmoteManager.c | CreateBleedingEffect | WRONG ID",ErrorExSeverity.INFO);
1225 break;
1226 }
1227 }
1228 }
1229
1232 protected void PickEmote(int gestureslot)
1233 {
1234 }
1235};
1236
1238{
1240 void End();
1241}
1242
1243/**@class ChainedDropAndKillPlayerLambda
1244 * @brief drops weapon in hands to ground and then calls kill
1245 **/
1247{
1249
1250 void ChainedDropAndKillPlayerLambda (EntityAI old_item, string new_item_type, PlayerBase player)
1251 {
1252 m_Player = player;
1254 vector mtx[4];
1255 old_item.GetTransform(mtx);
1256 gnd.SetGround(old_item, mtx);
1257
1258 OverrideNewLocation(gnd);
1259 }
1260
1261 override void Execute (HumanInventoryWithFSM fsm_to_notify = null)
1262 {
1263 if (PrepareLocations())
1264 {
1265 vector transform[4];
1266
1267 m_Player.GetInventory().TakeToDst(InventoryMode.SERVER, m_OldLocation, m_NewLocation);
1268 m_Player.OnItemInHandsChanged();
1269 }
1270
1271 m_Player.SetHealth(0);
1272
1273 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[syncinv] player=" + Object.GetDebugName(m_Player) + " STS = " + m_Player.GetSimulationTimeStamp() + " ChainedDropAndKillPlayerLambda");
1274 }
1275}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_GESTURE
map
Определения ControlsXboxNew.c:4
override void OnCallbackEnd()
Определения EmoteClasses.c:866
void ChainedDropAndKillPlayerLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Определения EmoteManager.c:1250
bool m_ItemToHands
Определения EmoteManager.c:124
EmoteCB m_Callback
Определения EmoteManager.c:111
ref Timer m_ReservationTimer
Определения EmoteManager.c:143
ref array< int > m_EmoteInputIDs
Определения EmoteManager.c:148
const int CALLBACK_CMD_END
Определения EmoteManager.c:139
void ForceSurrenderState(bool state)
Определения EmoteManager.c:1111
void RequestCommitSuicide()
Определения EmoteManager.c:681
int m_InterruptInputsCount
Определения EmoteManager.c:137
void HideItemInHands()
Определения EmoteManager.c:664
void CheckEmoteLockedState()
Определения EmoteManager.c:1076
bool m_controllsLocked
Определения EmoteManager.c:128
void EmoteManager(PlayerBase player)
Определения EmoteManager.c:151
int m_RPSOutcome
Определения EmoteManager.c:136
void CreateEmoteCBFromMenu(int id, bool interrupts_same=false)
Определения EmoteManager.c:759
void AfterStoreLoad()
Определения EmoteManager.c:582
const int CALLBACK_CMD_INVALID
Определения EmoteManager.c:138
int m_CurrentGestureID
Определения EmoteManager.c:134
ref array< string > m_InterruptInputs
Определения EmoteManager.c:113
bool m_CancelEmote
Определения EmoteManager.c:121
bool CanPlayEmoteClientCheck(int id)
Определения EmoteManager.c:967
ref array< int > m_EmoteIDs
Определения EmoteManager.c:147
bool CanPlayEmote(int id)
Определения EmoteManager.c:880
int m_DeferredEmoteExecution
Определения EmoteManager.c:131
bool IsControllsLocked()
Определения EmoteManager.c:875
void ShowItemInHands()
Определения EmoteManager.c:673
ItemBase m_item
Определения EmoteManager.c:110
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
ref InventoryLocation m_HandInventoryLocation
Определения EmoteManager.c:115
void InterruptCallbackCommand()
Определения EmoteManager.c:769
void ConstructData()
Определения EmoteManager.c:195
void PostSurrenderRequestServer()
server only
Определения EmoteManager.c:1118
int m_LastMask
Определения EmoteManager.c:135
void PlaySurrenderInOut(bool state)
Определения EmoteManager.c:981
int DetermineGestureIndex()
Определения EmoteManager.c:234
void CreateBleedingEffect(int Callback_ID)
Определения EmoteManager.c:1193
void SetGesture(int id)
Определения EmoteManager.c:224
map< int, ref EmoteBase > GetNameEmoteMap()
Определения EmoteManager.c:1188
void CommitSuicide()
Определения EmoteManager.c:687
bool m_GestureInterruptInput
Определения EmoteManager.c:123
void ClearSurrenderState()
clears surrender state only
Определения EmoteManager.c:1099
bool m_InventoryAccessLocked
Определения EmoteManager.c:129
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Определения EmoteManager.c:502
const int CALLBACK_CMD_INSTACANCEL
Определения EmoteManager.c:141
void KillPlayer()
Определения EmoteManager.c:738
void OnEmoteEnd()
Определения EmoteManager.c:467
void ServerRequestEmoteCancel()
Определения EmoteManager.c:1130
void ~EmoteManager()
Определения EmoteManager.c:189
void EndSurrenderRequest(SurrenderData data=null)
directly force-ends surrender state AND requests hard cancel
Определения EmoteManager.c:1089
void SetEmoteLockState(bool state)
Определения EmoteManager.c:1030
ref EmoteLauncher m_MenuEmote
Определения EmoteManager.c:116
void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
Определения EmoteManager.c:636
bool InterruptGestureCheck()
Определения EmoteManager.c:1138
bool m_PlayerDies
Определения EmoteManager.c:127
bool InterruptWaterCheck()
Определения EmoteManager.c:1167
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
Определения EmoteManager.c:534
int m_GestureID
Определения EmoteManager.c:132
void PickEmote(int gestureslot)
Deprecated.
Определения EmoteManager.c:1232
bool IsEmotePlaying()
Определения EmoteManager.c:1183
bool DetermineEmoteData(EmoteBase emote, out int callback_ID, out int stancemask, out bool is_fullbody)
Also includes a stance check for FB callbacks.
Определения EmoteManager.c:249
bool m_EmoteLockState
Определения EmoteManager.c:130
SHumanCommandSwimSettings m_HumanSwimSettings
Определения EmoteManager.c:149
override void Execute(HumanInventoryWithFSM fsm_to_notify=null)
Определения EmoteManager.c:1261
bool m_ItemToBeCreated
Определения EmoteManager.c:120
bool m_IsSurrendered
Определения EmoteManager.c:119
const int CALLBACK_CMD_GESTURE_INTERRUPT
Определения EmoteManager.c:140
ref map< int, ref EmoteBase > m_NameEmoteMap
Определения EmoteManager.c:145
HumanInputController m_HIC
Определения EmoteManager.c:112
ref array< ref EmoteBase > m_EmoteClassArray
Определения EmoteManager.c:146
void EndCallbackCommand()
Определения EmoteManager.c:779
bool m_bEmoteIsPlaying
Определения EmoteManager.c:118
void LogSuicide()
Определения EmoteManager.c:746
bool m_MouseButtonPressed
Определения EmoteManager.c:126
bool m_InstantCancelEmote
Определения EmoteManager.c:122
EmoteLauncher GetEmoteLauncher()
Определения EmoteManager.c:764
bool m_bEmoteIsRequestPending
Определения EmoteManager.c:117
bool m_ItemIsOn
Определения EmoteManager.c:125
void SendEmoteRequestSync(int id)
Определения EmoteManager.c:796
int m_PreviousGestureID
Определения EmoteManager.c:133
int GetGesture()
Определения EmoteManager.c:229
bool PlayEmote(int id)
Определения EmoteManager.c:588
ref array< UAIDWrapper > m_InterruptInputDirect
Определения EmoteManager.c:114
DayZPlayer m_Player
Определения Hand_Events.c:42
void hndDebugPrint(string s)
Определения HandFSM.c:1
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
proto native UAInputAPI GetUApi()
proto native UIManager GetUIManager()
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
drops weapon in hands to ground and then calls kill
Определения EmoteManager.c:1238
Super root of all classes in Enforce script.
Определения EnScript.c:11
static const int SJ_GESTURE_REQUEST
Определения DayZPlayerSyncJunctures.c:22
void OnCallbackEnd()
bool EmoteFBStanceCheck(int stancemask)
Checks for valid stance mask.
Определения EmoteBase.c:23
bool CanBeCanceledNormally(notnull EmoteCB callback)
Определения EmoteBase.c:17
bool DetermineOverride(out int callback_ID, out int stancemask, out bool is_fullbody)
Определения EmoteBase.c:39
int GetAdditiveCallbackUID()
Определения EmoteBase.c:85
int GetFullbodyCallbackUID()
Определения EmoteBase.c:90
int GetStanceMaskAdditive()
Определения EmoteBase.c:75
bool EmoteStartOverride(typename callbacktype, int id, int mask, bool fullbody)
Определения EmoteBase.c:47
int GetStanceMaskFullbody()
Определения EmoteBase.c:80
bool EmoteCondition(int stancemask)
Определения EmoteBase.c:12
void OnBeforeStandardCallbackCreated(int callback_ID, int stancemask, bool is_fullbody)
bool GetHideItemInHands()
Определения EmoteBase.c:95
Определения EmoteBase.c:2
bool IsEmoteCallback()
Определения EmoteManager.c:24
EmoteManager m_Manager
Определения EmoteManager.c:6
override void OnAnimationEvent(int pEventID)
Определения EmoteManager.c:29
void ~EmoteCB()
Определения EmoteManager.c:8
bool m_IsFullbody
Определения EmoteManager.c:3
PlayerBase m_player
Определения EmoteManager.c:5
bool CancelCondition()
Определения EmoteManager.c:19
override bool IsGestureCallback()
Определения EmoteManager.c:68
int m_callbackID
Определения EmoteManager.c:4
Определения EmoteManager.c:2
bool ConstructEmotes(PlayerBase player, out map< int, ref EmoteBase > emoteMap)
Определения EmoteConstructor.c:3
static const int FORCE_ALL
Определения EmoteManager.c:78
static const int FORCE_NONE
Определения EmoteManager.c:76
int GetID()
Определения EmoteManager.c:101
void SetForced(int mode)
Определения EmoteManager.c:91
int m_ID
Определения EmoteManager.c:82
bool m_InterruptsSameIDEmote
Определения EmoteManager.c:80
static const int FORCE_DIFFERENT
Определения EmoteManager.c:77
int GetForced()
Определения EmoteManager.c:96
int m_ForcePlayEmote
Определения EmoteManager.c:81
void EmoteLauncher(int emoteID, bool interrupts_same)
Определения EmoteManager.c:84
Определения EmoteManager.c:75
const int c_InventoryReservationTimeoutMS
reservations
script counterpart to engine's class Inventory
proto native bool IsOnBack()
return true if prone is on back
proto native bool IsChangingStance()
returns true if character is changing stance
Определения human.c:434
Определения human.c:18
HumanInventory... with FSM (synchronous, no anims)
Определения HumanInventoryWithFSM.c:6
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
InventoryLocation.
Определения InventoryLocation.c:29
static bool IsInventoryHFSMLogEnable()
Определения 3_Game/tools/Debug.c:668
Определения 3_Game/tools/Debug.c:594
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
The class that will be instanced (moddable)
Определения gameplay.c:389
base class for transformation operations (creating one item from another)
Определения ReplaceItemWithNewLambdaBase.c:5
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 native void Send()
proto static native bool CanStoreInputUserData()
Returns true when the channel is free, AND the InputBuffer is NOT full (same as '!...
Определения gameplay.c:121
Определения gameplay.c:152
proto bool Write(void value_out)
proto bool Read(void value_in)
void End()
called on surrender end request end
Определения EmoteManager.c:1238
Определения DayZPlayerImplement.c:63
proto native UAInput GetInputByName(string sInputName)
proto native int ID()
Определения UAInput.c:24
bool IsMenuOpen(int id)
Returns true if menu with specific ID is opened (see MenuID)
Определения UIManager.c:154
shorthand
Определения BoltActionRifle_Base.c:6
signalize mechanism manipulation
Определения Events.c:35
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
eModifiers
Определения eModifiers.c:2
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
const int EMOTE_SUICIDE_SIMULATION_END
Определения 3_Game/constants.c:410
const int EMOTE_SUICIDE_BLEED
Определения 3_Game/constants.c:409
const int EMOTE_SUICIDE_DEATH
Определения 3_Game/constants.c:408
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
const int ID_EMOTE_RPS_P
Определения 3_Game/constants.c:394
const int ID_EMOTE_RPS
Определения 3_Game/constants.c:383
const int ID_EMOTE_SURRENDER
Определения 3_Game/constants.c:399
const int ID_EMOTE_THUMB
Определения 3_Game/constants.c:368
const int ID_EMOTE_DANCE
Определения 3_Game/constants.c:371
const int ID_EMOTE_RPS_S
Определения 3_Game/constants.c:395
const int ID_EMOTE_SUICIDE
Определения 3_Game/constants.c:370
const int ID_EMOTE_RPS_R
Определения 3_Game/constants.c:393
const int ID_EMOTE_THUMBDOWN
Определения 3_Game/constants.c:375
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
Определения 3_Game/constants.c:194
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/tools/tools.c:10
const int UA_ANIM_EVENT
Определения 3_Game/constants.c:473
proto native volatile void Update()
Определения PlayerSoundManager.c:125