DayZ 1.27
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 (!m_Player.GetItemInHands() && GetGame().IsServer())
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 SetEmoteLockState(false);
309 }
310 else if (m_CancelEmote) //'soft' cancel
311 {
312 if (m_IsSurrendered)
313 {
315 }
316 else if (m_Callback)
317 {
318 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
319 }
320
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 {
420 if (m_bEmoteIsRequestPending && (m_Player.IsUnconscious() || !m_Player.IsAlive()))
421 {
423 }
424
426 {
427 OnEmoteEnd();
428 }
429 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
430 {
431 PlaySurrenderInOut(false);
432 return;
433 }
434 // getting out of surrender state - hard cancel
435 else if (m_IsSurrendered && (m_HIC.IsSingleUse() || m_HIC.IsContinuousUseStart() || m_HIC.IsWeaponRaised()))
436 {
437 if (m_Player.GetItemInHands())
438 m_Player.GetItemInHands().DeleteSafe();//Note, this keeps item 'alive' until it is released by all the systems (inventory swapping etc.)
439 return;
440 }
441 // fallback in case lock does not end properly
442 else if (m_IsSurrendered && (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && m_Player.GetItemInHands().GetType() != "SurrenderDummyItem" && m_EmoteLockState)))
443 {
444 m_IsSurrendered = false;
445 SetEmoteLockState(false);
446 return;
447 }
448 //actual emote launch
450 {
452 }
453 //client-side emote launcher
454 else if (!m_bEmoteIsPlaying && m_MenuEmote && !GetGame().IsDedicatedServer())
455 {
457 }
458 else if (!m_MenuEmote && gestureSlot > 0)
459 {
460 CreateEmoteCBFromMenu(gestureSlot,true); //translation no longer needed
461 }
462 }
463 }
464
466 {
468
469 if (m_PlayerDies)
470 {
471 m_Player.SetHealth(0.0);
472 return;
473 }
474
475 //surrender "state" switch
477 {
480 }
481
483
484 m_bEmoteIsPlaying = false;
486
487 if (m_IsSurrendered)
488 {
489 return;
490 }
492 SetEmoteLockState(false);
493
494 // back to the default - shoot from camera - if not set already
495 if (!m_Player.IsShootingFromCamera())
496 m_Player.OverrideShootFromCamera(true);
497 }
498
499 //server-side
500 bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
501 {
502 if (userDataType == INPUT_UDT_GESTURE)
503 {
504 int forced = EmoteLauncher.FORCE_NONE;
505 int gestureID = -1;
506 int random = -1;
507
508 if (ctx.Read(gestureID))
509 {
510 ctx.Read(forced);
511 if (ctx.Read(random))
512 {
513 m_RPSOutcome = random;
514 }
515
516 //server-side check, sends CALLBACK_CMD_INSTACANCEL as a fail
517 if (forced == EmoteLauncher.FORCE_NONE && !CanPlayEmote(gestureID))
518 gestureID = CALLBACK_CMD_INSTACANCEL;
519
521 pCtx.Write(gestureID);
522 pCtx.Write(forced);
525 }
526 return true;
527 }
528 return false;
529 }
530
531 //server and client
532 void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
533 {
534 int forced;
535 int gesture_id;
536 if (!m_CancelEmote)
537 {
538 pCtx.Read(gesture_id);
539 pCtx.Read(forced);
540
541 EmoteBase emoteData;
542 if ((m_Callback || m_IsSurrendered) && (forced == EmoteLauncher.FORCE_ALL || (forced == EmoteLauncher.FORCE_DIFFERENT && m_CurrentGestureID != gesture_id)))
543 {
544 if (m_Callback)
545 {
546 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && emoteData.CanBeCanceledNormally(m_Callback))
547 m_CancelEmote = true;
548 else
549 return;
550 }
551 m_CancelEmote = true;
552 }
553
554 if (gesture_id == CALLBACK_CMD_INSTACANCEL)
555 {
556 if (m_Callback)
557 {
558 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && !emoteData.CanBeCanceledNormally(m_Callback))
559 {
560 m_InstantCancelEmote = false;
561 return;
562 }
563 }
565 }
566
567 m_DeferredEmoteExecution = gesture_id;
568 }
569 else
570 m_CancelEmote = false;
571 }
572
574 {
575 EmoteBase emoteData;
576 if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData))
577 emoteData.OnCallbackEnd();
578 }
579
581 {
582 if (m_Player.GetItemInHands() && SurrenderDummyItem.Cast(m_Player.GetItemInHands()))
583 m_Player.GetItemInHands().Delete();
584 }
585
586 bool PlayEmote(int id)
587 {
590
591 if (CanPlayEmote(id))
592 {
593 EmoteBase emote;
594 m_NameEmoteMap.Find(id,emote);
595
596 if (m_AdminLog)
597 m_AdminLog.OnEmote(m_Player, emote);
598
601 if (id > 0)
602 {
603 if (emote)
604 {
605 int callback_ID;
606 int stancemask;
607 bool is_fullbody;
608 if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody))
609 {
610 if (!emote.EmoteStartOverride(EmoteCB,callback_ID,stancemask,is_fullbody))
611 {
612 emote.OnBeforeStandardCallbackCreated(callback_ID,stancemask,is_fullbody);
613 CreateEmoteCallback(EmoteCB,callback_ID,stancemask,is_fullbody);
614 }
615
616 if (emote.GetHideItemInHands())
617 {
619 }
620 }
621 else
622 {
623 ErrorEx("EmoteManager | DetermineEmoteData failed!");
624 }
625 }
626 }
627 }
628
630 return m_bEmoteIsPlaying;
631 }
632
633 //creates Emote callback
634 protected void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
635 {
636 if (m_Player)
637 {
638 m_LastMask = -1;
639
640 if (fullbody)
641 {
642 Class.CastTo(m_Callback, m_Player.StartCommand_Action(id,callbacktype,mask));
643 m_Callback.m_IsFullbody = true;
644 m_Callback.EnableCancelCondition(true);
645 }
646 else if (m_Player.IsPlayerInStance(mask))
647 {
648 m_LastMask = mask; //character is probably not prone now
649 Class.CastTo(m_Callback, m_Player.AddCommandModifier_Action(id,callbacktype));
650 }
651
652 if (m_Callback)
653 {
654 m_bEmoteIsPlaying = true;
655 m_Callback.m_callbackID = id;
656 m_Callback.m_player = m_Player;
657 m_Callback.m_Manager = this;
658 }
659 }
660 }
661
662 protected void HideItemInHands()
663 {
664 m_item = m_Player.GetItemInHands();
665 if (m_Callback && m_item)
666 {
667 m_Player.TryHideItemInHands(true);
668 }
669 }
670
671 protected void ShowItemInHands()
672 {
673 if (m_item)
674 {
675 m_Player.TryHideItemInHands(false);
676 }
677 }
678
680 {
681 if (!GetGame().IsClient())
683 }
684
685 protected void CommitSuicide()
686 {
687 Weapon_Base weapon;
688 WeaponEventBase weapon_event = new WeaponEventTrigger;
689
690 if (Weapon_Base.CastTo(weapon,m_Player.GetItemInHands()))
691 {
692 if (weapon.CanFire())
693 {
694 m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
695 m_Player.SetSuicide(true);
696 weapon.ProcessWeaponEvent(weapon_event);
697 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
698 if (m_Player.IsAlive())
699 {
700 EntityAI helm = m_Player.FindAttachmentBySlotName("Headgear");
701 if (helm && GetGame().IsServer())
702 {
703 float damage = helm.GetMaxHealth("","");
704 helm.AddHealth("","", -damage/2);
705 }
707 if (m_AdminLog)
708 {
709 m_AdminLog.Suicide(m_Player);
710 }
711 }
712 }
713 else
714 {
715 if (!weapon.IsDamageDestroyed())
716 {
717 weapon.ProcessWeaponEvent(weapon_event);
718 }
719 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
720 }
721 }
722 else if (m_Player.GetItemInHands() && m_Player.GetItemInHands().ConfigIsExisting("suicideAnim"))
723 {
724 m_Callback.RegisterAnimationEvent("Death",EmoteConstants.EMOTE_SUICIDE_DEATH);
725 m_Callback.RegisterAnimationEvent("Bleed",EmoteConstants.EMOTE_SUICIDE_BLEED);
726 m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
727 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
728 m_Player.SetSuicide(true);
729 }
730 else
731 {
732 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
733 }
734 }
735
737 {
738 if (GetGame().IsServer())
739 {
740 m_Player.SetHealth(0);
741 }
742 }
743
745 {
746 if (GetGame().IsServer())
747 {
748 PlayerIdentity identity = m_Player.GetIdentity();
749 if (identity)
750 {
751 if (m_AdminLog)
752 m_AdminLog.Suicide(m_Player);
753 }
754 }
755 }
756
757 void CreateEmoteCBFromMenu(int id, bool interrupts_same = false)
758 {
759 m_MenuEmote = new EmoteLauncher(id,interrupts_same);
760 }
761
763 {
764 return m_MenuEmote;
765 }
766
768 {
769 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
770
771 if (m_MenuEmote)
772 m_MenuEmote = null;
773
775 }
776
778 {
780 {
781 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
782 }
783 else
784 {
785 m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
786 }
787
788 if (m_MenuEmote)
789 m_MenuEmote = null;
791 }
792
793 //sends request (client)
795 {
796 int forced = EmoteLauncher.FORCE_NONE;
797 if (m_MenuEmote)
798 {
799 forced = m_MenuEmote.GetForced();
800 }
801
802 m_RPSOutcome = -1;
803 switch (id)
804 {
807 break;
808
810 m_RPSOutcome = 0;
811 break;
812
814 m_RPSOutcome = 1;
815 break;
816
818 m_RPSOutcome = 2;
819 break;
820 }
821
823 if (GetGame().IsMultiplayer() && GetGame().IsClient())
824 {
825 bool canProceed = true; //running callbacks in certain state can block additional actions
826 EmoteBase emoteData;
827 if (m_Callback && m_NameEmoteMap.Find(m_CurrentGestureID,emoteData))
828 {
829 canProceed = emoteData.CanBeCanceledNormally(m_Callback);
830 }
831
832 if (ctx.CanStoreInputUserData() && ((CanPlayEmote(id) && CanPlayEmoteClientCheck(id)) || forced) && canProceed)
833 {
835 ctx.Write(id);
836 ctx.Write(forced);
837 if (m_RPSOutcome != -1)
838 {
839 ctx.Write(m_RPSOutcome);
840 }
841 ctx.Send();
843 }
844 else
845 {
847 }
848 m_MenuEmote = NULL;
850 }
851 else if (!GetGame().IsMultiplayer())
852 {
853 if (id == CALLBACK_CMD_END)
854 {
856 }
857 else if (id == CALLBACK_CMD_GESTURE_INTERRUPT)
858 {
860 }
861 else if (CanPlayEmote(id) && CanPlayEmoteClientCheck(id))
862 {
863 PlayEmote(id);
864 }
865 else
866 {
868 }
869 m_MenuEmote = NULL;
870 }
871 }
872
874 {
875 return m_controllsLocked;
876 }
877
878 bool CanPlayEmote(int id)
879 {
880 //special cases
882 {
883 return true;
884 }
885
886 if (!m_Player || !m_Player.IsAlive() || (!IsEmotePlaying() && (m_Player.GetCommand_Action() || m_Player.GetCommandModifier_Action())) || m_Player.GetThrowing().IsThrowingModeEnabled())
887 {
888 //Debug.Log("!CanPlayEmote | reason: 1");
889 return false;
890 }
891
892 ItemBase item = m_Player.GetItemInHands();
893 if (item)
894 {
895 if (item.IsHeavyBehaviour() && id != EmoteConstants.ID_EMOTE_SURRENDER)
896 {
897 //Debug.Log("!CanPlayEmote | reason: 2");
898 return false;
899 }
900
901 SurrenderDummyItem sda;
902 if (m_Player.IsItemsToDelete() && Class.CastTo(sda,item) && !sda.IsSetForDeletion())
903 {
904 //Debug.Log("!CanPlayEmote | reason: 3");
905 return false;
906 }
907 }
908
909 if ((m_Player.GetWeaponManager() && m_Player.GetWeaponManager().IsRunning()) || (m_Player.GetActionManager() && m_Player.GetActionManager().GetRunningAction()))
910 {
911 //Debug.Log("!CanPlayEmote | reason: 4");
912 return false;
913 }
914
915 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?
916 {
917 //Debug.Log("!CanPlayEmote | reason: 5");
918 return false;
919 }
920
921 if (m_Player.GetCommand_Vehicle())
922 {
923 //Debug.Log("!CanPlayEmote | reason: 6");
924 return false;
925 }
926
927 HumanCommandMove cm = m_Player.GetCommand_Move();
928 if (cm)
929 {
931 return false;
932 if (cm.IsChangingStance())
933 return false;
934 }
935
936 //"locks" player in surrender state
938 {
939 //Debug.Log("!CanPlayEmote | reason: 8");
940 return false;
941 }
942
943 if (m_Player.GetDayZPlayerInventory().IsProcessing())
944 {
945 //Debug.Log("!CanPlayEmote | reason: 9");
946 return false;
947 }
948
949 EmoteBase emote;
950 if (m_NameEmoteMap.Find(id,emote))
951 {
952 int callback_ID;
953 int stancemask;
954 bool is_fullbody;
955 if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody) && emote.EmoteCondition(stancemask))
956 {
957 return true;
958 }
959 //Debug.Log("!CanPlayEmote | reason: 10");
960 }
961
962 return false;
963 }
964
966 {
967 if (!GetGame().IsClient())
968 return true;
969
970 if (GetGame().GetUIManager().FindMenu(MENU_INVENTORY))
971 {
972 //Debug.Log("!CanPlayEmoteClientCheck | reason: 1");
973 return false;
974 }
975
976 return true;
977 }
978
979 void PlaySurrenderInOut(bool state)
980 {
983 if (state)
984 {
985 if (m_Player.GetItemInHands() && !m_Player.CanDropEntity(m_Player.GetItemInHands()))
986 return;
987
988 if (m_Player.GetItemInHands() && GetGame().IsClient())
989 {
990 if (m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
991 m_Player.GetInventory().ClearInventoryReservationEx(null, m_HandInventoryLocation);
992 m_Player.PhysicalPredictiveDropItem(m_Player.GetItemInHands());
993 }
994
995 CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDERIN,DayZPlayerConstants.STANCEMASK_ALL,true);
996
997 if (m_Callback)
998 m_Callback.RegisterAnimationEvent("ActionExec", UA_ANIM_EVENT);
999 }
1000 else
1001 {
1002 if (m_Player.IsAlive() && !m_Player.IsUnconscious())
1003 {
1004 CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDEROUT,DayZPlayerConstants.STANCEMASK_ALL,true);
1005 }
1006 else
1007 {
1008 OnEmoteEnd();
1009 }
1010 }
1011 }
1012
1014 void SetEmoteLockState(bool state)
1015 {
1016 //separate inventory access locking
1017 if (state != m_InventoryAccessLocked)
1018 {
1019 m_Player.SetInventorySoftLock(state);
1021 }
1022
1023 //Movement lock in fullbody anims
1024 if (state && m_Callback && m_Callback.m_IsFullbody)
1025 m_controllsLocked = true;
1026 else
1027 m_controllsLocked = false;
1028
1029 if (state == m_EmoteLockState)
1030 return;
1031
1033 {
1035 m_HandInventoryLocation.SetHands(m_Player,null);
1036 }
1037
1038 if (!state)
1039 {
1040 if (m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
1041 m_Player.GetInventory().ClearInventoryReservationEx(null, m_HandInventoryLocation);
1042
1043 if (m_Player.GetActionManager())
1044 m_Player.GetActionManager().EnableActions(true);
1045 }
1046 else
1047 {
1048 if (!m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
1049 m_Player.GetInventory().AddInventoryReservationEx(null, m_HandInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1050
1051 if (m_Player.GetActionManager())
1052 m_Player.GetActionManager().EnableActions(false);
1053 }
1054 m_EmoteLockState = state;
1055 }
1056
1058 {
1059 if (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && !SurrenderDummyItem.Cast(m_Player.GetItemInHands())))
1060 return;
1061
1062 //refreshes reservation in case of unwanted timeout
1064 {
1065 m_Player.GetInventory().ExtendInventoryReservationEx(null, m_HandInventoryLocation, 10000);
1066 }
1067 }
1068
1071 {
1072 if (m_IsSurrendered && data)
1073 {
1074 if (m_Player.GetItemInHands())
1075 m_Player.GetItemInHands().DeleteSafe();//Note, this keeps item 'alive' until it is released by all the systems (inventory swapping etc.)
1076
1077 m_IsSurrendered = false;
1079 data.End();
1080 }
1081 }
1082
1083 //sent from server to cancel generic emote callback
1091
1093 {
1094 //init pass
1096 {
1099
1100 for (int i = 0; i < m_InterruptInputsCount; i++)
1101 {
1102 m_InterruptInputDirect.Insert(GetUApi().GetInputByName(m_InterruptInputs[i]));
1103 }
1104 }
1105
1106 //interrupts any callback if restrain action is in progress, takes priority
1107 if (!m_Callback.m_IsFullbody)
1108 return false;
1109
1110 for (int idx = 0; idx < m_InterruptInputsCount; idx++)
1111 {
1112 if (m_InterruptInputDirect[idx].LocalPress())
1113 {
1114 return true;
1115 }
1116 }
1117
1118 return false;
1119 }
1120
1122 {
1123 float waterLevel = m_Player.GetCurrentWaterLevel();
1124
1125 if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_PRONE) && waterLevel >= m_HumanSwimSettings.m_fToCrouchLevel)
1126 {
1127 return true;
1128 }
1129 else if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEIDX_RAISEDCROUCH) && waterLevel >= m_HumanSwimSettings.m_fToErectLevel)
1130 {
1131 return true;
1132 }
1133
1134 return m_Player.GetModifiersManager() && m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_DROWNING);
1135 }
1136
1141
1146
1147 void CreateBleedingEffect(int Callback_ID)
1148 {
1149 if (GetGame().IsServer() && m_Player.IsAlive())
1150 {
1151 switch (Callback_ID)
1152 {
1153 case DayZPlayerConstants.CMD_SUICIDEFB_1HD :
1154 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Neck");
1155 break;
1156
1157 case DayZPlayerConstants.CMD_SUICIDEFB_FIREAXE :
1158 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1159 break;
1160
1161 case DayZPlayerConstants.CMD_SUICIDEFB_PITCHFORK :
1162 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1163 break;
1164
1165 case DayZPlayerConstants.CMD_SUICIDEFB_SWORD :
1166 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1167 break;
1168
1169 case DayZPlayerConstants.CMD_SUICIDEFB_SPEAR :
1170 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Head");
1171 break;
1172
1173 case DayZPlayerConstants.CMD_SUICIDEFB_WOODAXE :
1174 m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1175 break;
1176
1177 default :
1178 ErrorEx("EmoteManager.c | CreateBleedingEffect | WRONG ID",ErrorExSeverity.INFO);
1179 break;
1180 }
1181 }
1182 }
1183
1186 protected void PickEmote(int gestureslot)
1187 {
1188 }
1189};
1190
1192{
1194 void End();
1195}
1196
1197/**@class ChainedDropAndKillPlayerLambda
1198 * @brief drops weapon in hands to ground and then calls kill
1199 **/
1201{
1203
1204 void ChainedDropAndKillPlayerLambda (EntityAI old_item, string new_item_type, PlayerBase player)
1205 {
1206 m_Player = player;
1208 vector mtx[4];
1209 old_item.GetTransform(mtx);
1210 gnd.SetGround(old_item, mtx);
1211
1212 OverrideNewLocation(gnd);
1213 }
1214
1215 override void Execute (HumanInventoryWithFSM fsm_to_notify = null)
1216 {
1217 if (PrepareLocations())
1218 {
1219 vector transform[4];
1220
1221 m_Player.GetInventory().TakeToDst(InventoryMode.SERVER, m_OldLocation, m_NewLocation);
1222 m_Player.OnItemInHandsChanged();
1223 }
1224
1225 m_Player.SetHealth(0);
1226
1227 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[syncinv] player=" + Object.GetDebugName(m_Player) + " STS = " + m_Player.GetSimulationTimeStamp() + " ChainedDropAndKillPlayerLambda");
1228 }
1229}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
const int INPUT_UDT_GESTURE
Определения _constants.c:18
map
Определения ControlsXboxNew.c:4
override void OnCallbackEnd()
Определения EmoteClasses.c:869
void ChainedDropAndKillPlayerLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Определения EmoteManager.c:1204
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
ref array< UAInput > m_InterruptInputDirect
Определения EmoteManager.c:114
void RequestCommitSuicide()
Определения EmoteManager.c:679
int m_InterruptInputsCount
Определения EmoteManager.c:137
void HideItemInHands()
Определения EmoteManager.c:662
void CheckEmoteLockedState()
Определения EmoteManager.c:1057
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:757
void AfterStoreLoad()
Определения EmoteManager.c:580
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:965
ref array< int > m_EmoteIDs
Определения EmoteManager.c:147
bool CanPlayEmote(int id)
Определения EmoteManager.c:878
int m_DeferredEmoteExecution
Определения EmoteManager.c:131
bool IsControllsLocked()
Определения EmoteManager.c:873
void ShowItemInHands()
Определения EmoteManager.c:671
ItemBase m_item
Определения EmoteManager.c:110
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
ref InventoryLocation m_HandInventoryLocation
Определения EmoteManager.c:115
void InterruptCallbackCommand()
Определения EmoteManager.c:767
void ConstructData()
Определения EmoteManager.c:195
int m_LastMask
Определения EmoteManager.c:135
void PlaySurrenderInOut(bool state)
Определения EmoteManager.c:979
int DetermineGestureIndex()
Определения EmoteManager.c:234
void CreateBleedingEffect(int Callback_ID)
Определения EmoteManager.c:1147
void SetGesture(int id)
Определения EmoteManager.c:224
map< int, ref EmoteBase > GetNameEmoteMap()
Определения EmoteManager.c:1142
void CommitSuicide()
Определения EmoteManager.c:685
bool m_GestureInterruptInput
Определения EmoteManager.c:123
bool m_InventoryAccessLocked
Определения EmoteManager.c:129
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Определения EmoteManager.c:500
const int CALLBACK_CMD_INSTACANCEL
Определения EmoteManager.c:141
void KillPlayer()
Определения EmoteManager.c:736
void OnEmoteEnd()
Определения EmoteManager.c:465
void ServerRequestEmoteCancel()
Определения EmoteManager.c:1084
void ~EmoteManager()
Определения EmoteManager.c:189
void EndSurrenderRequest(SurrenderData data=null)
directly force-ends surrender state from outside of normal flow
Определения EmoteManager.c:1070
void SetEmoteLockState(bool state)
Определения EmoteManager.c:1014
ref EmoteLauncher m_MenuEmote
Определения EmoteManager.c:116
void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
Определения EmoteManager.c:634
bool InterruptGestureCheck()
Определения EmoteManager.c:1092
bool m_PlayerDies
Определения EmoteManager.c:127
bool InterruptWaterCheck()
Определения EmoteManager.c:1121
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
Определения EmoteManager.c:532
int m_GestureID
Определения EmoteManager.c:132
void PickEmote(int gestureslot)
Deprecated.
Определения EmoteManager.c:1186
bool IsEmotePlaying()
Определения EmoteManager.c:1137
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:1215
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:777
bool m_bEmoteIsPlaying
Определения EmoteManager.c:118
void LogSuicide()
Определения EmoteManager.c:744
bool m_MouseButtonPressed
Определения EmoteManager.c:126
bool m_InstantCancelEmote
Определения EmoteManager.c:122
EmoteLauncher GetEmoteLauncher()
Определения EmoteManager.c:762
bool m_bEmoteIsRequestPending
Определения EmoteManager.c:117
bool m_ItemIsOn
Определения EmoteManager.c:125
void SendEmoteRequestSync(int id)
Определения EmoteManager.c:794
int m_PreviousGestureID
Определения EmoteManager.c:133
int GetGesture()
Определения EmoteManager.c:229
bool PlayEmote(int id)
Определения EmoteManager.c:586
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:1192
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
Определения constants.c:359
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
Определения Building.c:6
const int c_InventoryReservationTimeoutMS
reservations
Определения Inventory.c:712
script counterpart to engine's class Inventory
Определения Inventory.c:79
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
Определения InventoryItem.c:731
static bool IsInventoryHFSMLogEnable()
Определения Debug.c:668
Определения 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:1192
Определения 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
Определения constants.c:410
const int EMOTE_SUICIDE_BLEED
Определения constants.c:409
const int EMOTE_SUICIDE_DEATH
Определения constants.c:408
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
const int ID_EMOTE_RPS_P
Определения constants.c:394
const int ID_EMOTE_RPS
Определения constants.c:383
const int ID_EMOTE_SURRENDER
Определения constants.c:399
const int ID_EMOTE_THUMB
Определения constants.c:368
const int ID_EMOTE_DANCE
Определения constants.c:371
const int ID_EMOTE_RPS_S
Определения constants.c:395
const int ID_EMOTE_SUICIDE
Определения constants.c:370
const int ID_EMOTE_RPS_R
Определения constants.c:393
const int ID_EMOTE_THUMBDOWN
Определения 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
Определения constants.c:194
const int MENU_INVENTORY
Определения constants.c:180
const int CALL_CATEGORY_GAMEPLAY
Определения tools.c:10
const int UA_ANIM_EVENT
Определения constants.c:471
proto native volatile void Update()
Определения PlayerSoundManager.c:125