Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
emotemanager.c
Go to the documentation of this file.
2 {
3  bool m_IsFullbody;
4  int m_callbackID;
5  PlayerBase m_player;
6  EmoteManager m_Manager;
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 
19  bool CancelCondition()
20  {
21  return false;
22  }
23 
24  bool IsEmoteCallback()
25  {
26  return IsGestureCallback();
27  }
28 
29  override void OnAnimationEvent(int pEventID)
30  {
31  switch (pEventID)
32  {
33  case EmoteConstants.EMOTE_SUICIDE_DEATH :
34 
35  if (GetGame().IsServer())
36  m_Manager.KillPlayer();
37 
38  m_Manager.LogSuicide();
39  break;
40 
41  case UA_ANIM_EVENT :
42  if (GetGame().IsServer())
43  {
44  if (m_player.GetItemInHands() && SurrenderDummyItem.Cast(m_player.GetItemInHands()))
45  m_player.GetItemInHands().Delete();
46 
47  if (m_player.GetItemInHands())
48  {
49  m_player.PhysicalPredictiveDropItem(m_player.GetItemInHands());
50  }
51  }
52  m_Manager.m_ItemToBeCreated = true;
53  break;
54 
55  case EmoteConstants.EMOTE_SUICIDE_BLEED :
56  if (GetGame().IsServer())
57  m_Manager.CreateBleedingEffect(m_callbackID);
58  break;
59 
60  case EmoteConstants.EMOTE_SUICIDE_SIMULATION_END :
61  if (GetGame().IsServer())
62  {
63  EntityAI itemInHands = m_player.GetHumanInventory().GetEntityInHands();
64  if (itemInHands)
65  {
66  vector m4[4];
67  itemInHands.GetTransform(m4);
68  m_player.GetInventory().DropEntityWithTransform(InventoryMode.SERVER, m_player, itemInHands, m4);
69  }
70  }
71 
72  m_player.StartDeath();
73  break;
74  }
75  }
76 
77  override bool IsGestureCallback()
78  {
79  return true;
80  }
81 };
82 
84 {
85  static const int FORCE_NONE = 0;
86  static const int FORCE_DIFFERENT = 1;
87  static const int FORCE_ALL = 2;
88 
89  protected bool m_InterruptsSameIDEmote;
90  protected int m_ForcePlayEmote;
91  protected int m_ID;
92 
93  void EmoteLauncher(int emoteID, bool interrupts_same)
94  {
95  m_ID = emoteID;
96  m_InterruptsSameIDEmote = interrupts_same;
97  m_ForcePlayEmote = FORCE_NONE;
98  }
99 
100  void SetForced(int mode)
101  {
102  m_ForcePlayEmote = mode;
103  }
104 
105  int GetForced()
106  {
107  return m_ForcePlayEmote;
108  }
109 
110  int GetID()
111  {
112  return m_ID;
113  }
114 }
115 
116 class EmoteManager
117 {
132  protected bool m_ItemToHands; //deprecated
133  protected bool m_ItemIsOn;
134  protected bool m_MouseButtonPressed;
135  protected bool m_PlayerDies;
136  protected bool m_controllsLocked;
137  protected bool m_InventoryAccessLocked;
138  protected bool m_EmoteLockState;
140  protected int m_GestureID;
141  protected int m_PreviousGestureID;
142  protected int m_CurrentGestureID;
143  protected int m_LastMask;
144  protected int m_RPSOutcome;
145  protected int m_InterruptInputsCount;
146  protected const int CALLBACK_CMD_INVALID = -1;
147  protected const int CALLBACK_CMD_END = -2;
148  protected const int CALLBACK_CMD_GESTURE_INTERRUPT = -3;
149  protected const int CALLBACK_CMD_INSTACANCEL = -4;
150  PluginAdminLog m_AdminLog;
151  protected ref Timer m_ReservationTimer;
152 
153  protected ref map<int, ref EmoteBase> m_NameEmoteMap; //<emote_ID,EmoteBase>
154  protected ref array<ref EmoteBase> m_EmoteClassArray; //registered 'EmoteBase' object refs
155  protected ref array<int> m_EmoteIDs; //IDs of registered emotes (found in 'EmoteConstants'). For quick access.
156  protected ref array<int> m_EmoteInputIDs; //input IDs for the registered 'EmoteBase' objects
158 
159  void EmoteManager(PlayerBase player)
160  {
161  m_Player = player;
162  m_HIC = m_Player.GetInputController();
163  m_ItemIsOn = false;
164  m_controllsLocked = false;
165  m_InventoryAccessLocked = false;
166  m_RPSOutcome = -1;
168 
170  m_InterruptInputs.Insert("UAMoveForward");
171  m_InterruptInputs.Insert("UAMoveBack");
172  m_InterruptInputs.Insert("UATurnLeft");
173  m_InterruptInputs.Insert("UATurnRight");
174  m_InterruptInputs.Insert("UAMoveLeft");
175  m_InterruptInputs.Insert("UAMoveRight");
176  m_InterruptInputs.Insert("UAStand");
177  m_InterruptInputs.Insert("UACrouch");
178  m_InterruptInputs.Insert("UAProne");
179  m_InterruptInputs.Insert("UAGetOver");
180 
182  m_HandInventoryLocation.SetHands(m_Player, null);
183 
184  if (GetGame().IsServer())
185  {
186  m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
187  }
188 
189  m_ReservationTimer = new Timer();
190  m_ReservationTimer.Run(8, this, "CheckEmoteLockedState", null, true);
191 
192  m_HumanSwimSettings = m_Player.GetDayZPlayerType().CommandSwimSettingsW();
193 
194  ConstructData();
195  }
196 
198  {
199  if (m_ReservationTimer && m_ReservationTimer.IsRunning())
200  m_ReservationTimer.Stop();
201  }
202 
204  {
206  if (!m_NameEmoteMap)
207  {
208  ec.ConstructEmotes(m_Player,m_NameEmoteMap);
210  m_EmoteIDs = new array<int>;
212  int inputID;
213  int count = m_NameEmoteMap.Count();
214  UAInput inp;
215 
216  for (int i = 0; i < count; i++)
217  {
218  m_EmoteClassArray.Insert(m_NameEmoteMap.GetElement(i));
219  m_EmoteIDs.Insert(m_NameEmoteMap.GetElement(i).GetID());
220  inp = GetUApi().GetInputByName(m_NameEmoteMap.GetElement(i).GetInputActionName());
221  inputID = inp.ID();
222  m_EmoteInputIDs.Insert(inputID);
223  }
224 
225  if (m_EmoteInputIDs.Count() != m_EmoteClassArray.Count())
226  {
227  ErrorEx("Faulty emote data detected in 'ConstructData' method!",ErrorExSeverity.WARNING);
228  }
229  }
230  }
231 
232  void SetGesture(int id)
233  {
234  m_GestureID = id;
235  }
236 
238  {
239  return m_GestureID;
240  }
241 
243  {
244  int count = m_EmoteInputIDs.Count();
245  for (int i = 0; i < count; ++i)
246  {
247  if (GetUApi().GetInputByID(m_EmoteInputIDs[i]).LocalPress())
248  {
249  return m_EmoteIDs[i];
250  }
251  }
252 
253  return 0;
254  }
255 
257  bool DetermineEmoteData(EmoteBase emote, out int callback_ID, out int stancemask, out bool is_fullbody)
258  {
259  if (emote.DetermineOverride(callback_ID, stancemask, is_fullbody))
260  {
261  return emote.EmoteFBStanceCheck(stancemask);
262  }
263  else if (emote.GetAdditiveCallbackUID() != 0 && m_Player.IsPlayerInStance(emote.GetStanceMaskAdditive()))
264  {
265  callback_ID = emote.GetAdditiveCallbackUID();
266  stancemask = emote.GetStanceMaskAdditive();
267  is_fullbody = false;
268  return true;
269  }
270  else if (emote.GetFullbodyCallbackUID() != 0 && emote.EmoteFBStanceCheck(emote.GetStanceMaskFullbody()))
271  {
272  callback_ID = emote.GetFullbodyCallbackUID();
273  stancemask = emote.GetStanceMaskFullbody();
274  is_fullbody = true;
275  return true;
276  }
277 
278  return false;
279  }
280 
281  //Called from players commandhandler each frame, checks input
282  void Update(float deltaT)
283  {
284  // no updates on restrained characters
285  if (m_Player.IsRestrained())
286  return;
287 
288  if (m_ItemToBeCreated)
289  {
290  if (!m_Player.GetItemInHands() && GetGame().IsServer())
291  {
292  m_Player.GetHumanInventory().CreateInHands("SurrenderDummyItem");
293  }
294  m_ItemToBeCreated = false;
295  }
296 
297  int gestureSlot = DetermineGestureIndex();
298 
299  //deferred emote cancel
300  if (m_InstantCancelEmote) //'hard' cancel
301  {
302  if (m_Callback)
303  {
304  m_Callback.Cancel();
305  }
306 
307  if (m_MenuEmote)
308  {
309  m_MenuEmote = null;
310  }
312  m_InstantCancelEmote = false;
313  }
314  else if (m_CancelEmote) //'soft' cancel
315  {
316  if (m_IsSurrendered)
317  {
319  }
320  else if (m_Callback)
321  {
322  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
323  }
324 
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  {
337  uiGesture = GetGame().GetUIManager().IsMenuOpen(MENU_GESTURES);
338 
339  if (InterruptGestureCheck())
340  {
342  }
343 
344  if (InterruptWaterCheck())
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  {
352  if (m_CurrentGestureID == EmoteConstants.ID_EMOTE_SUICIDE && m_HIC.IsSingleUse())
353  {
354  if (m_Callback.GetState() == m_Callback.STATE_LOOP_LOOP)
355  {
356  CommitSuicide();
357  }
358  else
359  {
360  return;
361  }
362  }
363  else if ((m_CurrentGestureID == EmoteConstants.ID_EMOTE_THUMB || m_CurrentGestureID == EmoteConstants.ID_EMOTE_THUMBDOWN) && m_HIC.IsSingleUse())
364  {
365  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_ACTION);
366  }
367  else if (m_HIC.IsSingleUse() && (m_CurrentGestureID == EmoteConstants.ID_EMOTE_RPS || m_CurrentGestureID == EmoteConstants.ID_EMOTE_RPS_R || m_CurrentGestureID == EmoteConstants.ID_EMOTE_RPS_P || m_CurrentGestureID == EmoteConstants.ID_EMOTE_RPS_S))
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  }
390  else if (m_CurrentGestureID != EmoteConstants.ID_EMOTE_SUICIDE || (m_CurrentGestureID == EmoteConstants.ID_EMOTE_SUICIDE && m_Callback.GetState() < 3))
391  {
393  }
394  else if (m_CurrentGestureID == EmoteConstants.ID_EMOTE_SUICIDE)
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_bEmoteIsPlaying)
424  {
425  m_bEmoteIsPlaying = false;
426  OnEmoteEnd();
427  }
428  else if (!m_Player.GetItemInHands() && m_IsSurrendered && !m_ItemToBeCreated)
429  {
430  PlaySurrenderInOut(false);
431  return;
432  }
433  // getting out of surrender state - hard cancel
434  else if (m_IsSurrendered && (m_HIC.IsSingleUse() || m_HIC.IsContinuousUseStart() || m_HIC.IsWeaponRaised()))
435  {
436  if (m_Player.GetItemInHands())
437  m_Player.GetItemInHands().Delete();
438  return;
439  }
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 
465  void OnEmoteEnd()
466  {
467  ShowItemInHands();
468 
469  if (m_PlayerDies)
470  {
471  m_Player.SetHealth(0.0);
472  return;
473  }
474 
475  //surrender "state" switch
476  if (m_CurrentGestureID == EmoteConstants.ID_EMOTE_SURRENDER)
477  {
480  }
481 
482  m_CurrentGestureID = 0;
483 
484  if (m_IsSurrendered)
485  {
486  return;
487  }
488  m_GestureInterruptInput = false;
489  SetEmoteLockState(false);
490 
491  // back to the default - shoot from camera - if not set already
492  if (!m_Player.IsShootingFromCamera())
493  m_Player.OverrideShootFromCamera(true);
494  }
495 
496  //server-side
497  bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
498  {
499  if (userDataType == INPUT_UDT_GESTURE)
500  {
501  int forced = EmoteLauncher.FORCE_NONE;
502  int gestureID = -1;
503  int random = -1;
504 
505  if (ctx.Read(gestureID))
506  {
507  ctx.Read(forced);
508  if (ctx.Read(random))
509  {
510  m_RPSOutcome = random;
511  }
512 
513  //server-side check
514  if (forced > EmoteLauncher.FORCE_NONE || CanPlayEmote(gestureID))
515  {
517  pCtx.Write(gestureID);
518  pCtx.Write(forced);
519 
520  m_Player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_GESTURE_REQUEST, pCtx);
521  }
522  }
523  return true;
524  }
525  return false;
526  }
527 
528  //server and client
529  void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
530  {
531  int forced;
532  int gesture_id;
533  if (!m_CancelEmote)
534  {
535  pCtx.Read(gesture_id);
536  pCtx.Read(forced);
537 
538  EmoteBase emoteData;
539  if ((m_Callback || m_IsSurrendered) && (forced == EmoteLauncher.FORCE_ALL || (forced == EmoteLauncher.FORCE_DIFFERENT && m_CurrentGestureID != gesture_id)))
540  {
541  if (m_Callback)
542  {
543  if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && emoteData.CanBeCanceledNormally(m_Callback))
544  m_CancelEmote = true;
545  else
546  return;
547  }
548  m_CancelEmote = true;
549  }
550 
551  if (gesture_id == CALLBACK_CMD_INSTACANCEL)
552  {
553  if (m_Callback)
554  {
555  if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData) && !emoteData.CanBeCanceledNormally(m_Callback))
556  {
557  m_InstantCancelEmote = false;
558  return;
559  }
560  }
561  m_InstantCancelEmote = true;
562  }
563 
564  m_DeferredEmoteExecution = gesture_id;
565  }
566  else
567  m_CancelEmote = false;
568  }
569 
571  {
572  EmoteBase emoteData;
573  if (m_NameEmoteMap.Find(m_CurrentGestureID,emoteData))
574  emoteData.OnCallbackEnd();
575  }
576 
578  {
579  //failsafe, deletes helper item after fully loading character
580  if (m_Player.GetItemInHands() && SurrenderDummyItem.Cast(m_Player.GetItemInHands()))
581  m_Player.GetItemInHands().Delete();
582  }
583 
584  bool PlayEmote(int id)
585  {
587 
588  if (!CanPlayEmote(id))
589  return false;
590 
591  if (m_AdminLog)
592  m_AdminLog.LogPrint("[emote] " + Object.GetDebugName(m_Player) + " play emote id=" + id + " IH=" + Object.GetDebugName(m_Player.GetItemInHands()));
593 
595  m_CurrentGestureID = id;
596  if (id > 0)
597  {
598  //-----------------------------------------------
599  EmoteBase emote;
600  if (m_NameEmoteMap.Find(id,emote))
601  {
602  int callback_ID;
603  int stancemask;
604  bool is_fullbody;
605  if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody))
606  {
607  if (!emote.EmoteStartOverride(EmoteCB,callback_ID,stancemask,is_fullbody))
608  {
609  emote.OnBeforeStandardCallbackCreated(callback_ID,stancemask,is_fullbody);
610  CreateEmoteCallback(EmoteCB,callback_ID,stancemask,is_fullbody);
611  }
612 
613  if (emote.GetHideItemInHands())
614  {
615  HideItemInHands();
616  }
617  }
618  else
619  {
620  ErrorEx("EmoteManager | DetermineEmoteData failed!");
621  }
622  }
623  }
624 
626  return m_bEmoteIsPlaying;
627  }
628 
629  //creates Emote callback
630  protected void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
631  {
632  if (m_Player)
633  {
634  m_LastMask = -1;
635 
636  if (fullbody)
637  {
638  Class.CastTo(m_Callback, m_Player.StartCommand_Action(id,callbacktype,mask));
639  m_Callback.m_IsFullbody = true;
640  m_Callback.EnableCancelCondition(true);
641  }
642  else if (m_Player.IsPlayerInStance(mask))
643  {
644  m_LastMask = mask; //character is probably not prone now
645  Class.CastTo(m_Callback, m_Player.AddCommandModifier_Action(id,callbacktype));
646  }
647 
648  if (m_Callback)
649  {
650  m_bEmoteIsPlaying = true;
651  m_Callback.m_callbackID = id;
652  m_Callback.m_player = m_Player;
653  m_Callback.m_Manager = this;
654  }
655  }
656  }
657 
658  protected void HideItemInHands()
659  {
660  m_item = m_Player.GetItemInHands();
661  if (m_Callback && m_item)
662  {
663  m_Player.TryHideItemInHands(true);
664  }
665  }
666 
667  protected void ShowItemInHands()
668  {
669  if (m_item)
670  {
671  m_Player.TryHideItemInHands(false);
672  }
673  }
674 
675  protected void CommitSuicide()
676  {
677  Weapon_Base weapon;
678  WeaponEventBase weapon_event = new WeaponEventTrigger;
679 
680  if (Weapon_Base.CastTo(weapon,m_Player.GetItemInHands()))
681  {
682  if (weapon.CanFire())
683  {
684  m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
685  m_Player.SetSuicide(true);
686  weapon.ProcessWeaponEvent(weapon_event);
687  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
688  if (m_Player.IsAlive())
689  {
690  EntityAI helm = m_Player.FindAttachmentBySlotName("Headgear");
691  if (helm && GetGame().IsServer())
692  {
693  float damage = helm.GetMaxHealth("","");
694  helm.AddHealth("","", -damage/2);
695  }
696  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(this.KillPlayer);
697  if (m_AdminLog)
698  {
699  m_AdminLog.Suicide(m_Player);
700  }
701  }
702  }
703  else
704  {
705  if (!weapon.IsDamageDestroyed())
706  {
707  weapon.ProcessWeaponEvent(weapon_event);
708  }
709  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
710  }
711  }
712  else if (m_Player.GetItemInHands() && m_Player.GetItemInHands().ConfigIsExisting("suicideAnim"))
713  {
714  m_Callback.RegisterAnimationEvent("Death",EmoteConstants.EMOTE_SUICIDE_DEATH);
715  m_Callback.RegisterAnimationEvent("Bleed",EmoteConstants.EMOTE_SUICIDE_BLEED);
716  m_Callback.RegisterAnimationEvent("Simulation_End",EmoteConstants.EMOTE_SUICIDE_SIMULATION_END);
717  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
718  m_Player.SetSuicide(true);
719  }
720  else
721  {
722  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
723  }
724  }
725 
726  void KillPlayer()
727  {
728  if (GetGame().IsServer())
729  {
730  m_Player.SetHealth(0);
731  }
732  }
733 
734  void LogSuicide()
735  {
736  if (GetGame().IsServer())
737  {
738  PlayerIdentity identity = m_Player.GetIdentity();
739  if (identity)
740  {
741  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().AdminLog, "Player '" + identity.GetName() + "' (id=" + identity.GetId() + ") committed suicide.");
742  }
743  }
744  }
745 
746  void CreateEmoteCBFromMenu(int id, bool interrupts_same = false)
747  {
748  m_MenuEmote = new EmoteLauncher(id,interrupts_same);
749  }
750 
752  {
753  return m_MenuEmote;
754  }
755 
757  {
758  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
759 
760  if (m_MenuEmote)
761  m_MenuEmote = null;
762 
764  }
765 
767  {
768  if (m_CurrentGestureID == EmoteConstants.ID_EMOTE_DANCE)
769  {
770  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
771  }
772  else
773  {
774  m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
775  }
776 
777  if (m_MenuEmote)
778  m_MenuEmote = null;
780  }
781 
782  //sends request
783  void SendEmoteRequestSync(int id)
784  {
785  int forced = EmoteLauncher.FORCE_NONE;
786  if (m_MenuEmote)
787  {
788  forced = m_MenuEmote.GetForced();
789  }
790 
791  m_RPSOutcome = -1;
792  switch (id)
793  {
794  case EmoteConstants.ID_EMOTE_RPS :
795  m_RPSOutcome = Math.RandomInt(0,3);
796  break;
797 
798  case EmoteConstants.ID_EMOTE_RPS_R :
799  m_RPSOutcome = 0;
800  break;
801 
802  case EmoteConstants.ID_EMOTE_RPS_P :
803  m_RPSOutcome = 1;
804  break;
805 
806  case EmoteConstants.ID_EMOTE_RPS_S :
807  m_RPSOutcome = 2;
808  break;
809  }
810 
812  if (GetGame().IsMultiplayer() && GetGame().IsClient())
813  {
814  bool canProceed = true; //running callbacks in certain state can block additional actions
815  EmoteBase emoteData;
816  if (m_Callback && m_NameEmoteMap.Find(m_CurrentGestureID,emoteData))
817  {
818  canProceed = emoteData.CanBeCanceledNormally(m_Callback);
819  }
820 
821  if (ctx.CanStoreInputUserData() && (CanPlayEmote(id) || forced) && canProceed)
822  {
823  ctx.Write(INPUT_UDT_GESTURE);
824  ctx.Write(id);
825  ctx.Write(forced);
826  if (m_RPSOutcome != -1)
827  {
828  ctx.Write(m_RPSOutcome);
829  }
830  ctx.Send();
831  }
832  m_MenuEmote = NULL;
833  }
834  else if (!GetGame().IsMultiplayer())
835  {
836  if (id == CALLBACK_CMD_END)
837  {
839  }
840  else if (id == CALLBACK_CMD_GESTURE_INTERRUPT)
841  {
843  }
844  else
845  {
846  PlayEmote(id);
847  }
848  m_MenuEmote = NULL;
849  }
850  }
851 
853  {
854  return m_controllsLocked;
855  }
856 
857  bool CanPlayEmote(int id)
858  {
859  //special cases
861  {
862  return true;
863  }
864 
865  if (GetGame().IsClient() && GetGame().GetUIManager().FindMenu(MENU_INVENTORY))
866  {
867  return false;
868  }
869 
870  if (!m_Player || !m_Player.IsAlive() || (!IsEmotePlaying() && m_Player.GetCommand_Action() || m_Player.GetCommandModifier_Action()) || m_Player.GetThrowing().IsThrowingModeEnabled() || m_Player.IsItemsToDelete())
871  {
872  return false;
873  }
874 
875  ItemBase item = m_Player.GetItemInHands();
876  if (item && item.IsHeavyBehaviour() && (id != EmoteConstants.ID_EMOTE_SURRENDER))
877  {
878  return false;
879  }
880 
881  if ((m_Player.GetWeaponManager() && m_Player.GetWeaponManager().IsRunning()) || (m_Player.GetActionManager() && m_Player.GetActionManager().GetRunningAction()))
882  {
883  return false;
884  }
885 
886  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?
887  {
888  return false;
889  }
890  if (m_Player.GetCommand_Vehicle())
891  {
892  if (m_Player.GetCommand_Vehicle().GetTransport())
893  {
894  return false;
895  }
896  }
897 
898  if (m_Player.GetCommand_Move() && m_Player.GetCommand_Move().IsOnBack() && id != EmoteConstants.ID_EMOTE_SURRENDER)
899  {
900  return false;
901  }
902 
903  //"locks" player in surrender state
904  if (m_IsSurrendered && (id != EmoteConstants.ID_EMOTE_SURRENDER))
905  {
906  return false;
907  }
908 
909  if (m_Player.GetDayZPlayerInventory().IsProcessing())
910  {
911  return false;
912  }
913 
914  EmoteBase emote;
915  if (m_NameEmoteMap.Find(id,emote))
916  {
917  int callback_ID;
918  int stancemask;
919  bool is_fullbody;
920  if (DetermineEmoteData(emote,callback_ID,stancemask,is_fullbody) && emote.EmoteCondition(stancemask))
921  {
922  return true;
923  }
924  }
925 
926  return false;
927  }
928 
929  void PlaySurrenderInOut(bool state)
930  {
932  m_CurrentGestureID = EmoteConstants.ID_EMOTE_SURRENDER;
933  if (state)
934  {
935  if (m_Player.GetItemInHands() && !m_Player.CanDropEntity(m_Player.GetItemInHands()))
936  return;
937 
938  if (m_Player.GetItemInHands() && GetGame().IsClient())
939  {
940  m_Player.PhysicalPredictiveDropItem(m_Player.GetItemInHands());
941  }
942 
943  CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDERIN,DayZPlayerConstants.STANCEMASK_ALL,true);
944 
945  if (m_Callback)
946  m_Callback.RegisterAnimationEvent("ActionExec", UA_ANIM_EVENT);
947  }
948  else
949  {
950  if (m_Player.IsAlive() && !m_Player.IsUnconscious())
951  {
952  CreateEmoteCallback(EmoteCB,DayZPlayerConstants.CMD_GESTUREFB_SURRENDEROUT,DayZPlayerConstants.STANCEMASK_ALL,true);
953  }
954  else
955  {
956  m_bEmoteIsPlaying = false;
957  OnEmoteEnd();
958  }
959  }
960  }
961 
963  void SetEmoteLockState(bool state)
964  {
965  //separate inventory access locking
966  if (state != m_InventoryAccessLocked)
967  {
968  m_Player.SetInventorySoftLock(state);
969  m_InventoryAccessLocked = state;
970  }
971 
972  //full emote locking (
973  if (state == m_EmoteLockState)
974  {
975  ErrorEx("emote lock state already set",ErrorExSeverity.INFO);
976  return;
977  }
978 
980  {
982  m_HandInventoryLocation.SetHands(m_Player,null);
983  }
984 
985  if (!state)
986  {
987  if (m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
988  m_Player.GetInventory().ClearInventoryReservationEx(null, m_HandInventoryLocation);
989 
990  if (m_Player.GetActionManager())
991  m_Player.GetActionManager().EnableActions(true);
992 
993  if (m_controllsLocked)
994  m_controllsLocked = false;
995  }
996  else
997  {
998  if (!m_Player.GetInventory().HasInventoryReservation(null, m_HandInventoryLocation))
999  m_Player.GetInventory().AddInventoryReservationEx(null, m_HandInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1000 
1001  if (m_Player.GetActionManager())
1002  m_Player.GetActionManager().EnableActions(false);
1003 
1004  //Movement lock in fullbody anims
1005  if (m_Callback && m_Callback.m_IsFullbody && !m_controllsLocked)
1006  m_controllsLocked = true;
1007  }
1008  m_EmoteLockState = state;
1009  }
1010 
1012  {
1013  if (!m_Player.GetItemInHands() || (m_Player.GetItemInHands() && !SurrenderDummyItem.Cast(m_Player.GetItemInHands())))
1014  return;
1015 
1016  //refreshes reservation in case of unwanted timeout
1018  {
1019  m_Player.GetInventory().ExtendInventoryReservationEx(null, m_HandInventoryLocation, 10000);
1020  }
1021  }
1022 
1025  {
1026  if (m_IsSurrendered && data)
1027  {
1028  SetEmoteLockState(false);
1029  if (m_Player.GetItemInHands())
1030  m_Player.GetItemInHands().Delete();
1031 
1032  m_IsSurrendered = false;
1033 
1034  data.End();
1035  }
1036  }
1037 
1038  //sent from server to cancel general emote callback
1040  {
1042  pCtx.Write(CALLBACK_CMD_GESTURE_INTERRUPT);
1043 
1044  m_Player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_GESTURE_REQUEST, pCtx);
1045  }
1046 
1048  {
1049  //init pass
1051  {
1054 
1055  for (int i = 0; i < m_InterruptInputsCount; i++)
1056  {
1057  m_InterruptInputDirect.Insert(GetUApi().GetInputByName(m_InterruptInputs[i]));
1058  }
1059  }
1060 
1061  //interrupts any callback if restrain action is in progress, takes priority
1062  if (!m_Callback.m_IsFullbody)
1063  return false;
1064 
1065  for (int idx = 0; idx < m_InterruptInputsCount; idx++)
1066  {
1067  if (m_InterruptInputDirect[idx].LocalPress())
1068  {
1069  return true;
1070  }
1071  }
1072 
1073  return false;
1074  }
1075 
1077  {
1078  float waterLevel = m_Player.GetCurrentWaterLevel();
1079 
1080  if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_PRONE) && waterLevel >= m_HumanSwimSettings.m_fToCrouchLevel)
1081  {
1082  return true;
1083  }
1084  else if (m_Player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEIDX_RAISEDCROUCH) && waterLevel >= m_HumanSwimSettings.m_fToErectLevel)
1085  {
1086  return true;
1087  }
1088 
1089  return m_Player.GetModifiersManager() && m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_DROWNING);
1090  }
1091 
1093  {
1095  }
1096 
1098  {
1099  return m_NameEmoteMap;
1100  }
1101 
1102  void CreateBleedingEffect(int Callback_ID)
1103  {
1104  if (GetGame().IsServer() && m_Player.IsAlive())
1105  {
1106  switch (Callback_ID)
1107  {
1108  case DayZPlayerConstants.CMD_SUICIDEFB_1HD :
1109  m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Neck");
1110  break;
1111 
1112  case DayZPlayerConstants.CMD_SUICIDEFB_FIREAXE :
1113  m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1114  break;
1115 
1116  case DayZPlayerConstants.CMD_SUICIDEFB_PITCHFORK :
1117  m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1118  break;
1119 
1120  case DayZPlayerConstants.CMD_SUICIDEFB_SWORD :
1121  m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Spine2");
1122  break;
1123 
1124  case DayZPlayerConstants.CMD_SUICIDEFB_SPEAR :
1125  m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("Head");
1126  break;
1127 
1128  case DayZPlayerConstants.CMD_SUICIDEFB_WOODAXE :
1129  m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
1130  break;
1131 
1132  default :
1133  ErrorEx("EmoteManager.c | CreateBleedingEffect | WRONG ID",ErrorExSeverity.INFO);
1134  break;
1135  }
1136  }
1137  }
1138 
1141  protected void PickEmote(int gestureslot)
1142  {
1143  }
1144 };
1145 
1147 {
1149  void End();
1150 }
1151 
1156 {
1158 
1159  void ChainedDropAndKillPlayerLambda (EntityAI old_item, string new_item_type, PlayerBase player)
1160  {
1161  m_Player = player;
1163  vector mtx[4];
1164  old_item.GetTransform(mtx);
1165  gnd.SetGround(old_item, mtx);
1166 
1167  OverrideNewLocation(gnd);
1168  }
1169 
1170  override void Execute (HumanInventoryWithFSM fsm_to_notify = null)
1171  {
1172  if (PrepareLocations())
1173  {
1174  vector transform[4];
1175 
1176  m_Player.GetInventory().TakeToDst(InventoryMode.SERVER, m_OldLocation, m_NewLocation);
1177  m_Player.OnItemInHandsChanged();
1178  }
1179 
1180  m_Player.SetHealth(0);
1181 
1182  if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[syncinv] player=" + Object.GetDebugName(m_Player) + " STS = " + m_Player.GetSimulationTimeStamp() + " ChainedDropAndKillPlayerLambda");
1183  }
1184 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
m_MouseButtonPressed
protected bool m_MouseButtonPressed
Definition: emotemanager.c:134
m_bEmoteIsPlaying
bool m_bEmoteIsPlaying
Definition: emotemanager.c:126
m_InterruptInputs
ref array< string > m_InterruptInputs
Definition: emotemanager.c:122
m_EmoteClassArray
protected ref array< ref EmoteBase > m_EmoteClassArray
Definition: emotemanager.c:154
IsControllsLocked
bool IsControllsLocked()
Definition: emotemanager.c:852
m_player
DayZPlayer m_player
Definition: randomgeneratorsyncmanager.c:15
m_Player
class EmoteLauncher m_Player
INPUT_UDT_GESTURE
const int INPUT_UDT_GESTURE
Definition: _constants.c:18
PlaySurrenderInOut
void PlaySurrenderInOut(bool state)
Definition: emotemanager.c:929
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
LogManager
Definition: debug.c:734
m_PlayerDies
protected bool m_PlayerDies
Definition: emotemanager.c:135
CommitSuicide
protected void CommitSuicide()
Definition: emotemanager.c:675
m_InstantCancelEmote
bool m_InstantCancelEmote
Definition: emotemanager.c:130
HideItemInHands
protected void HideItemInHands()
Definition: emotemanager.c:658
UAInput
Definition: uainput.c:23
m_InterruptInputDirect
ref array< UAInput > m_InterruptInputDirect
Definition: emotemanager.c:123
ChainedDropAndKillPlayerLambda
void ChainedDropAndKillPlayerLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Definition: emotemanager.c:1159
m_Manager
ModifiersManager m_Manager
Definition: modifierbase.c:12
InterruptGestureCheck
bool InterruptGestureCheck()
Definition: emotemanager.c:1047
CreateBleedingEffect
void CreateBleedingEffect(int Callback_ID)
Definition: emotemanager.c:1102
m_NameEmoteMap
protected ref map< int, ref EmoteBase > m_NameEmoteMap
Definition: emotemanager.c:153
UA_ANIM_EVENT
const int UA_ANIM_EVENT
Definition: constants.c:443
ScriptInputUserData
Definition: gameplay.c:120
m_MenuEmote
ref EmoteLauncher m_MenuEmote
Definition: emotemanager.c:125
CALLBACK_CMD_INVALID
const protected int CALLBACK_CMD_INVALID
Definition: emotemanager.c:146
m_AdminLog
PluginAdminLog m_AdminLog
Definition: emotemanager.c:150
m_InventoryAccessLocked
protected bool m_InventoryAccessLocked
Definition: emotemanager.c:137
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
SetEmoteLockState
void SetEmoteLockState(bool state)
Definition: emotemanager.c:963
CreateEmoteCBFromMenu
void CreateEmoteCBFromMenu(int id, bool interrupts_same=false)
Definition: emotemanager.c:746
m_EmoteIDs
protected ref array< int > m_EmoteIDs
Definition: emotemanager.c:155
ShowItemInHands
protected void ShowItemInHands()
Definition: emotemanager.c:667
CALLBACK_CMD_INSTACANCEL
const protected int CALLBACK_CMD_INSTACANCEL
Definition: emotemanager.c:149
CheckEmoteLockedState
void CheckEmoteLockedState()
Definition: emotemanager.c:1011
m_RPSOutcome
protected int m_RPSOutcome
Definition: emotemanager.c:144
m_EmoteLockState
protected bool m_EmoteLockState
Definition: emotemanager.c:138
CanPlayEmote
bool CanPlayEmote(int id)
Definition: emotemanager.c:857
Update
void Update(float deltaT)
Definition: emotemanager.c:282
CALLBACK_CMD_GESTURE_INTERRUPT
const protected int CALLBACK_CMD_GESTURE_INTERRUPT
Definition: emotemanager.c:148
m_ItemIsOn
protected bool m_ItemIsOn
Definition: emotemanager.c:133
PickEmote
protected void PickEmote(int gestureslot)
Deprecated.
Definition: emotemanager.c:1141
ScriptJunctureData
Definition: gameplay.c:150
PlayEmote
bool PlayEmote(int id)
Definition: emotemanager.c:584
ErrorEx
enum ShapeType ErrorEx
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:170
m_ItemToBeCreated
bool m_ItemToBeCreated
Definition: emotemanager.c:128
m_ReservationTimer
protected ref Timer m_ReservationTimer
Definition: emotemanager.c:151
OnEmoteEnd
void OnEmoteEnd()
Definition: emotemanager.c:465
HumanInventoryWithFSM
HumanInventory... with FSM (synchronous, no anims)
Definition: humaninventorywithfsm.c:5
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
EmoteBase
Definition: emotebase.c:1
OnInputUserDataProcess
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Definition: emotemanager.c:497
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
SurrenderData
Definition: emotemanager.c:1146
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
EmoteCB
Definition: emotemanager.c:1
vector
Definition: enconvert.c:105
MENU_GESTURES
const int MENU_GESTURES
Definition: constants.c:184
AfterStoreLoad
void AfterStoreLoad()
Definition: emotemanager.c:577
InterruptCallbackCommand
void InterruptCallbackCommand()
Definition: emotemanager.c:756
CreateEmoteCallback
protected void CreateEmoteCallback(typename callbacktype, int id, int mask, bool fullbody)
Definition: emotemanager.c:630
m_IsSurrendered
bool m_IsSurrendered
Definition: emotemanager.c:127
m_item
ItemBase m_item
Definition: emotemanager.c:119
KillPlayer
void KillPlayer()
Definition: emotemanager.c:726
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
ServerRequestEmoteCancel
void ServerRequestEmoteCancel()
Definition: emotemanager.c:1039
EndCallbackCommand
void EndCallbackCommand()
Definition: emotemanager.c:766
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
m_CurrentGestureID
protected int m_CurrentGestureID
Definition: emotemanager.c:142
m_GestureID
protected int m_GestureID
Definition: emotemanager.c:140
m_CancelEmote
bool m_CancelEmote
Definition: emotemanager.c:129
m_HIC
HumanInputController m_HIC
Definition: emotemanager.c:121
OnCallbackEnd
void OnCallbackEnd()
Definition: emotemanager.c:570
EndSurrenderRequest
void EndSurrenderRequest(SurrenderData data=null)
directly force-ends surrender state from outside of normal flow
Definition: emotemanager.c:1024
hndDebugPrint
void hndDebugPrint(string s)
Definition: handfsm.c:1
EmoteConstants
Definition: constants.c:348
ErrorExSeverity
ErrorExSeverity
Definition: endebug.c:61
Object
Definition: objecttyped.c:1
m_ItemToHands
protected bool m_ItemToHands
Definition: emotemanager.c:132
eModifiers
eModifiers
Definition: emodifiers.c:1
HumanCommandActionCallback
Definition: statecb.c:1
m_controllsLocked
protected bool m_controllsLocked
Definition: emotemanager.c:136
DayZPlayerSyncJunctures
Definition: dayzplayersyncjunctures.c:4
SetGesture
void SetGesture(int id)
Definition: emotemanager.c:232
HumanInputController
Definition: human.c:17
IsEmotePlaying
bool IsEmotePlaying()
Definition: emotemanager.c:1092
m_PreviousGestureID
protected int m_PreviousGestureID
Definition: emotemanager.c:141
ConstructData
void ConstructData()
Definition: emotemanager.c:203
DetermineEmoteData
bool DetermineEmoteData(EmoteBase emote, out int callback_ID, out int stancemask, out bool is_fullbody)
Also includes a stance check for FB callbacks.
Definition: emotemanager.c:257
array< string >
SendEmoteRequestSync
void SendEmoteRequestSync(int id)
Definition: emotemanager.c:783
LogSuicide
void LogSuicide()
Definition: emotemanager.c:734
DetermineGestureIndex
int DetermineGestureIndex()
Definition: emotemanager.c:242
EmoteConstructor
Definition: emoteconstructor.c:1
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
~EmoteManager
void ~EmoteManager()
Definition: emotemanager.c:197
GetGesture
int GetGesture()
Definition: emotemanager.c:237
m_LastMask
protected int m_LastMask
Definition: emotemanager.c:143
m_GestureInterruptInput
bool m_GestureInterruptInput
Definition: emotemanager.c:131
m_Callback
EmoteCB m_Callback
Definition: emotemanager.c:120
Timer
Definition: dayzplayerimplement.c:62
EmoteManager
void EmoteManager(PlayerBase player)
Definition: emotemanager.c:159
GetEmoteLauncher
EmoteLauncher GetEmoteLauncher()
Definition: emotemanager.c:751
m_InterruptInputsCount
protected int m_InterruptInputsCount
Definition: emotemanager.c:145
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition: replaceitemwithnewlambdabase.c:4
GetUApi
proto native UAInputAPI GetUApi()
OnSyncJuncture
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
Definition: emotemanager.c:529
EmoteLauncher
Definition: emotemanager.c:83
Execute
override void Execute(HumanInventoryWithFSM fsm_to_notify=null)
Definition: emotemanager.c:1170
m_HandInventoryLocation
ref InventoryLocation m_HandInventoryLocation
Definition: emotemanager.c:124
Math
Definition: enmath.c:6
InterruptWaterCheck
bool InterruptWaterCheck()
Definition: emotemanager.c:1076
m_HumanSwimSettings
protected SHumanCommandSwimSettings m_HumanSwimSettings
Definition: emotemanager.c:157
m_DeferredEmoteExecution
protected int m_DeferredEmoteExecution
Definition: emotemanager.c:139
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
GetNameEmoteMap
map< int, ref EmoteBase > GetNameEmoteMap()
Definition: emotemanager.c:1097
m_ID
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition: effect.c:49
EntityAI
Definition: building.c:5
ChainedDropAndKillPlayerLambda
drops weapon in hands to ground and then calls kill
Definition: emotemanager.c:1146
SHumanCommandSwimSettings
Definition: humansettings.c:45
m_EmoteInputIDs
protected ref array< int > m_EmoteInputIDs
Definition: emotemanager.c:156
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
CALLBACK_CMD_END
const protected int CALLBACK_CMD_END
Definition: emotemanager.c:147