Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionbase.c
Go to the documentation of this file.
2 {
8  ACM_RAISED = 16,
9  ACM_ON_BACK = 32,
11  ACM_LEANING = 128,
13 }
14 class ActionReciveData
15 {
18 }
19 
21 {
22  void ActionData()
23  {
24  m_State = UA_NONE;
25  }
26 
27  ref ActionBase m_Action;
28  ItemBase m_MainItem;
29  ActionBaseCB m_Callback;
30  ref CABase m_ActionComponent;
31  int m_State;
32  ref ActionTarget m_Target;
33  PlayerBase m_Player;
34  int m_PossibleStanceMask;
35  ref array<ref InventoryLocation> m_ReservedInventoryLocations;
36  int m_RefreshReservationTimer;
37  int m_RefreshJunctureTimer;
38  bool m_WasExecuted;
39  bool m_WasActionStarted;
40  bool m_ReciveEndInput;
41 }
42 
44 {
45  //STATIC DATA
46  protected int m_RefreshReservationTimerValue = 140;
47  // Configurable action parameters
48  protected string m_Sound; //sound played at the beggining of action
49  protected string m_Text;
50 
51  protected bool m_LockTargetOnUse; //this parameter sets wheter player can perform actions on target while other player is already performing action on it. defaulted as true
52  protected bool m_FullBody; //tells whether action is full body or additive
53  protected int m_StanceMask;
54  protected ref TStringArray m_Sounds; //User action sound is picked from this array randomly
55  ref CCIBase m_ConditionItem; //Condition Component
56  ref CCTBase m_ConditionTarget; //Condition Component
57  protected ActionInput m_Input;
58  protected int m_ActionID;
59  protected int m_VariantID;
62 
63  //RUNTIME DATA
64  protected ref Param1<string> m_MessageParam; //used for passing messages from server to client
65  //protected ref Param2<int,int> m_MessagesParam;
66 
67  //SOFT SKILLS
68  protected float m_SpecialtyWeight;
69 
70  //-----------------------------------------------------
71  // Action events and methods
72  //-----------------------------------------------------
73  void ActionBase()
74  {
75  // definable
76  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_PRONE;
77  m_FullBody = false;
78  m_Sound = "";
79  m_Text = "default action text";
81  // dont override
82  m_MessageParam = new Param1<string>("");
83  //m_MessagesParam = new Param2<int,int>(0,0);
84  m_Sounds = new TStringArray;
85  m_Input = null;
86  m_ActionID = 0;
88  }
89 
91  {
92  return m_LockTargetOnUse;
93  }
94 
96  {
97  m_ConditionMask = ActionConditionMask.ACM_NO_EXEPTION;
98  if (CanBeUsedInVehicle())
99  {
100  m_ConditionMask |= ActionConditionMask.ACM_IN_VEHICLE;
101  }
102 
103  if (CanBeUsedOnLadder())
104  {
105  m_ConditionMask |= ActionConditionMask.ACM_ON_LADDER;
106  }
107 
108  if (CanBeUsedSwimming())
109  {
110  m_ConditionMask |= ActionConditionMask.ACM_SWIMMING;
111  }
112 
113  if (CanBeUsedInRestrain())
114  {
115  m_ConditionMask |= ActionConditionMask.ACM_RESTRAIN;
116  }
117 
118  if (CanBeUsedRaised())
119  {
120  m_ConditionMask |= ActionConditionMask.ACM_RAISED;
121  }
122 
123  if (CanBeUsedOnBack())
124  {
125  m_ConditionMask |= ActionConditionMask.ACM_ON_BACK;
126  }
127 
128  if (CanBeUsedThrowing())
129  {
130  m_ConditionMask |= ActionConditionMask.ACM_THROWING;
131  }
132 
133  if (CanBeUsedLeaning())
134  {
135  m_ConditionMask |= ActionConditionMask.ACM_LEANING;
136  }
137 
139  {
140  m_ConditionMask |= ActionConditionMask.ACM_BROKEN_LEGS;
141  }
142  }
143 
144  bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL )
145  {
146  action_data = CreateActionData();
147  action_data.m_Action = this;
148  action_data.m_Player = player;
149  action_data.m_Target = target;
150  action_data.m_MainItem = item;
151  action_data.m_PossibleStanceMask = GetStanceMask(player);
152  action_data.m_ReservedInventoryLocations = new array<ref InventoryLocation>;
153  action_data.m_RefreshReservationTimer = m_RefreshReservationTimerValue;
154  action_data.m_WasExecuted = false;
155  action_data.m_WasActionStarted = false;
156  action_data.m_ReciveEndInput = false;
157 
158  ActionReciveData action_recive_data = player.GetActionManager().GetReciveData();
159  if ( action_recive_data )
160  {
161  HandleReciveData(action_recive_data,action_data);
162 
163  if ( UseMainItem() && MainItemAlwaysInHands() )
164  {
165  if ( player.GetItemInHands() != action_data.m_MainItem )
166  {
167  return false;
168  }
169  }
170  }
171 
172  if ( !Post_SetupAction( action_data ) )
173  return false;
174 
175  if ( (!GetGame().IsDedicatedServer()) && !IsInstant() )
176  {
177  if (!InventoryReservation(action_data))
178  {
179  ClearInventoryReservationEx(action_data);
180  return false;
181  }
182 
183  if ( LogManager.IsActionLogEnable() )
184  {
185  for ( int i = 0; i < action_data.m_ReservedInventoryLocations.Count(); i++)
186  {
187  Debug.ActionLog( InventoryLocation.DumpToStringNullSafe( action_data.m_ReservedInventoryLocations[i] ), action_data.m_Action.ToString() , "n/a", "LockInventoryList", action_data.m_Player.ToString() );
188  }
189  }
190  }
191 
192  return true;
193  }
194 
195  bool Post_SetupAction( ActionData action_data )
196  {
197  return true;
198  }
199 
200  void ActionCleanup( ActionData action_data )
201  {}
202 
203  typename GetInputType()
204  {
205  return DefaultActionInput;
206  }
207 
209  {
210  m_Input = ai;
211  }
212 
214  {
215  return new ActionData;
216  }
217 
218  void CreateConditionComponents() //Instantiates components, called once from ActionManager on actions construction
219  {
222  }
223 
225  {
226  return null;
227  }
228 
232  bool HasTarget()
233  {
234  return true;
235  }
236 
238  bool HasProgress()
239  {
240  return true;
241  }
242 
243  //Action isn't synchronize to server
244  bool IsLocal()
245  {
246  return false;
247  }
248 
249  //Action not using animation/callback action are executed instantly (OnStart)
250  bool IsInstant()
251  {
252  return false;
253  }
254 
257  {
258  return false;
259  }
260 
262  {
263  return true;
264  }
265 
267  {
268  return AC_UNCATEGORIZED;
269  }
270 
271  bool IsEat()
272  {
273  return false;
274  }
275 
276  bool IsDrink()
277  {
278  return false;
279  }
280 
281  bool IsShaveSelf()
282  {
283  return false;
284  }
285 
286  string GetText() //text game displays in HUD hint
287  {
288  return m_Text;
289  }
290 
292  {
293  return false;
294  }
295 
297  {
298  return false;
299  }
300 
302  {
303  return !CanBePerformedFromInventory();
304  }
305 
307  {
308  return false;
309  }
310 
312  {
313  return false;
314  }
315 
317  {
318  return false;
319  }
320 
322  {
323  return false;
324  }
325 
327  {
328  return false;
329  }
330 
332  {
333  return false;
334  }
335 
337  {
338  return false;
339  }
340 
342  {
343  return true;
344  }
345 
347  {
348  return true;
349  }
350 
353  {
354  return false;
355  }
356 
357  bool UseMainItem()
358  {
359  return true;
360  }
361 
363  {
364  return true;
365  }
366 
367  protected bool ActionConditionContinue( ActionData action_data ) //condition for action
368  {
369  return ActionCondition(action_data.m_Player,action_data.m_Target,action_data.m_MainItem);
370  }
371 
372  protected bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item ) //condition for action
373  {
374  return true;
375  }
376 
377  void ApplyModifiers(ActionData action_data);
378 
380  {
382  }
383 
385  {
386  int componentIndex = -1;
387  int proxyBoneIdx = -1;
388  vector cursorHitPos = vector.Zero;
389 
390  array<string> selectionNames = new array<string>();
391 
392  Object targetObject = null;
393  Object targetParent = null;
394 
395  if (UseMainItem())
396  {
397  ctx.Write(action_data.m_MainItem);
398  }
399 
400  if (HasTarget() && !IsUsingProxies())
401  {
402  // callback data
403  targetObject = action_data.m_Target.GetObject();
404  ctx.Write(targetObject);
405  targetParent = action_data.m_Target.GetParent();
406  ctx.Write(targetParent);
407  componentIndex = action_data.m_Target.GetComponentIndex();
408  ctx.Write(componentIndex);
409  cursorHitPos = action_data.m_Target.GetCursorHitPos();
410  ctx.Write(cursorHitPos);
411  }
412  else if( HasTarget() && IsUsingProxies() )
413  {
416  Entity entParent = Entity.Cast(action_data.m_Target.GetParent());
417  if (entParent)
418  {
419  action_data.m_Target.GetObject().GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selectionNames);
420  for (int s = 0; s < selectionNames.Count(); s++)
421  {
422  proxyBoneIdx = entParent.GetBoneIndex(selectionNames[s]);
423  if( proxyBoneIdx > -1 )
424  {
425  break;
426  }
427  }
428  }
429 
430  ctx.Write(proxyBoneIdx);
431  targetParent = action_data.m_Target.GetParent();
432  ctx.Write(targetParent);
433  componentIndex = action_data.m_Target.GetComponentIndex();
434  ctx.Write(componentIndex);
435  cursorHitPos = action_data.m_Target.GetCursorHitPos();
436  ctx.Write(cursorHitPos);
437  }
438  }
439 
440  bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
441  {
442  if ( !action_recive_data )
443  {
444  action_recive_data = new ActionReciveData;
445  }
446  Object actionTargetObject = null;
447  Object actionTargetParent = null;
448  int componentIndex = -1;
449  int proxyBoneIdx = -1;
450  vector cursorHitPos = vector.Zero;
451  ItemBase mainItem = null;
452 
453  ref ActionTarget target;
454 
455  if ( UseMainItem() )
456  {
457  if ( !ctx.Read(mainItem) )
458  return false;
459  }
460 
461  if ( HasTarget() && !IsUsingProxies() )
462  {
463  if ( !ctx.Read(actionTargetObject) )
464  return false;
465 
466  if ( !ctx.Read(actionTargetParent))
467  return false;
468 
469  if ( !ctx.Read(componentIndex) )
470  return false;
471 
472  if ( !ctx.Read(cursorHitPos) )
473  return false;
474 
475  target = new ActionTarget(actionTargetObject, actionTargetParent, componentIndex, cursorHitPos, 0);
476 
477  action_recive_data.m_Target = target;
478  }
479  else if( HasTarget() && IsUsingProxies() )
480  {
481  if ( !ctx.Read(proxyBoneIdx) )
482  return false;
483 
484  if ( !ctx.Read(actionTargetParent))
485  return false;
486 
487  if ( !ctx.Read(componentIndex) )
488  return false;
489 
490  if ( !ctx.Read(cursorHitPos) )
491  return false;
492 
494  if ( proxyBoneIdx > -1 )
495  {
496  Entity entParent = Entity.Cast(actionTargetParent);
497 
498  if (entParent)
499  {
500  actionTargetObject = entParent.GetBoneObject(proxyBoneIdx);
501  }
502  }
503  else
504  {
505  return false;
506  }
507 
508  target = new ActionTarget(actionTargetObject, actionTargetParent, componentIndex, cursorHitPos, 0);
509 
510  action_recive_data.m_Target = target;
511  }
512 
513  action_recive_data.m_MainItem = mainItem;
514  return true;
515  }
516 
517  void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
518  {
519  action_data.m_MainItem = action_recive_data.m_MainItem;
520 
521  if(HasTarget())
522  {
523  if (action_recive_data.m_Target)
524  {
525  action_data.m_Target = action_recive_data.m_Target;
526  }
527  else
528  {
529  Error("Action target not created.");
530  action_data.m_Target = new ActionTarget(NULL, NULL, -1, vector.Zero, 0);
531  }
532  }
533  }
534 
535  //----------------------------------------------------------------------------------------------
536  // Core methods don't override unless you know what you are doing
537  //----------------------------------------------------------------------------------------------
538  // COMMANDS -----------------------------------------------------------------------
539  protected int GetStanceMask(PlayerBase player)
540  {
541  if ( HasProneException() )
542  {
543  if ( player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_RAISEDERECT | DayZPlayerConstants.STANCEMASK_RAISEDCROUCH | DayZPlayerConstants.STANCEMASK_RAISEDPRONE))
544  return -1;
545  else if ( player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT))
546  return DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
547  else
548  return DayZPlayerConstants.STANCEMASK_PRONE;
549  }
550  return m_StanceMask;
551  }
552 
553  bool IsFullBody(PlayerBase player)
554  {
555  if ( HasProneException() )
556  {
557  return !( player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT) );
558  }
559  return m_FullBody;
560  }
561 
562  // if it is set to true if action have special fullbody animation for prone and additive for crouch and erect
563  protected bool HasProneException()
564  {
565  return false;
566  }
567 
568  // ACTION LOGIC -------------------------------------------------------------------
569  // called from actionmanager.c
570  void Start( ActionData action_data ) //Setup on start of action
571  {
572  action_data.m_State = UA_START;
573 
574  if ( LogManager.IsActionLogEnable() )
575  {
576  Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnStart", action_data.m_Player.ToString() );
577  }
578 
579  OnStart(action_data);
580 
581  if ( GetGame().IsServer() )
582  {
583  OnStartServer(action_data);
584 
585  string soundCat = GetSoundCategory(action_data);
586  if (soundCat)
587  action_data.m_Player.SetSoundCategoryHash(soundCat.Hash());
588  }
589  else
590  {
591  OnStartClient(action_data);
592  }
593 
594  InformPlayers(action_data.m_Player,action_data.m_Target,UA_START);
595  }
596 
597  void End( ActionData action_data )
598  {
599  if ( action_data.m_Player )
600  {
601  OnEnd(action_data);
602 
603  if ( GetGame().IsServer() )
604  {
605  OnEndServer(action_data);
606  }
607  else
608  {
609  OnEndClient(action_data);
610  }
611 
612  action_data.m_Player.GetActionManager().OnActionEnd();
613  }
614  }
615 
616  void Interrupt(ActionData action_data)
617  {
618  End(action_data);
619  }
620 
621  void OnEndInput(ActionData action_data)
622  {}
623 
624  void EndInput(ActionData action_data)
625  {
626  action_data.m_ReciveEndInput = true;
627  OnEndInput(action_data);
628  }
629 
630  void OnEndRequest(ActionData action_data)
631  {}
632 
633  void EndRequest(ActionData action_data)
634  {
635  OnEndRequest(action_data);
636  }
637 
639  {
640  bool result = true;
641  PlayerBase target_player = PlayerBase.Cast(target.GetObject());
642 
643  if (target_player)
644  {
645  result = !target_player.IsJumpInProgress();
646  result = result && !(target_player.GetCommand_Ladder() || target_player.GetCommand_Vehicle() || target_player.GetCommand_Swim());
647  }
648 
649  return result;
650  }
651 
652  static int ComputeConditionMask( PlayerBase player, ActionTarget target, ItemBase item )
653  {
654  int mask = 0;
655  if ( player.GetCommand_Vehicle() )
656  {
657  mask |= ActionConditionMask.ACM_IN_VEHICLE;
658  }
659 
660  if ( player.GetCommand_Ladder() )
661  {
662  mask |= ActionConditionMask.ACM_ON_LADDER;
663  }
664 
665  if ( player.IsRestrained() )
666  {
667  mask |= ActionConditionMask.ACM_RESTRAIN;
668  }
669 
670  if ( player.GetCommand_Swim() )
671  {
672  mask |= ActionConditionMask.ACM_SWIMMING;
673  }
674 
675  if ( player.IsRaised() )
676  {
677  mask |= ActionConditionMask.ACM_RAISED;
678  }
679 
680  if ( player.GetCommand_Move() && player.GetCommand_Move().IsOnBack() )
681  {
682  mask |= ActionConditionMask.ACM_ON_BACK;
683  }
684 
685  if ( player.GetThrowing().IsThrowingModeEnabled())
686  {
687  mask |= ActionConditionMask.ACM_THROWING;
688  }
689 
690  if (player.IsLeaning())
691  {
692  mask |= ActionConditionMask.ACM_LEANING;
693  }
694 
695  if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
696  {
697  mask |= ActionConditionMask.ACM_BROKEN_LEGS;
698  }
699 
700  return mask;
701  }
702 
703  bool Can( PlayerBase player, ActionTarget target, ItemBase item, int condition_mask )
704  {
705  if ( ( (condition_mask & m_ConditionMask) != condition_mask ) || ( !IsFullBody(player) && !player.IsPlayerInStance(GetStanceMask(player)) ) || player.IsRolling() )
706  return false;
707 
708  if ( HasTarget() )
709  {
710  if(!FirearmActionBase.Cast(this))
711  {
712  EntityAI entity = EntityAI.Cast(target.GetObject());
713  if ( entity && !target.GetObject().IsMan() )
714  {
715  Man man = entity.GetHierarchyRootPlayer();
716  if ( man && man != player )
717  return false;
718  }
719  }
720 
721  if ( m_ConditionTarget && !m_ConditionTarget.Can(player, target))
722  return false;
723  }
724 
725  if ( m_ConditionItem && !m_ConditionItem.Can(player, item))
726  return false;
727 
728  if ( !ActionCondition(player, target, item) )
729  return false;
730 
731  if ( IsFullBody(player) )
732  {
733  int stanceIdx = DayZPlayerUtils.ConvertStanceMaskToStanceIdx(GetStanceMask(player));
734  if (stanceIdx != -1 && !DayZPlayerUtils.PlayerCanChangeStance(player, stanceIdx ))
735  return false;
736  }
737 
738  return true;
739  }
740 
741  bool Can(PlayerBase player, ActionTarget target, ItemBase item)
742  {
743  int condition_mask = ComputeConditionMask(player, target, item);
744 
745  return Can( player, target, item, condition_mask);
746  }
747 
748  protected bool CanContinue( ActionData action_data )
749  {
750  if (!action_data.m_Player.IsPlayerInStance(action_data.m_PossibleStanceMask) || !m_ConditionItem || !m_ConditionItem.CanContinue(action_data.m_Player,action_data.m_MainItem) || !m_ConditionTarget || !m_ConditionTarget.CanContinue(action_data.m_Player,action_data.m_Target))
751  return false;
752 
753  return ActionConditionContinue(action_data);
754  }
755 
756  bool HasVariants()
757  {
758  return m_VariantManager != null;
759  }
760 
762  {
763  if (m_VariantManager)
764  return m_VariantManager.GetActionsCount();
765 
766  return 0;
767  }
768 
770  {
771  if (m_VariantManager)
772  return m_VariantManager.GetActions(variants);
773 
774  return 0;
775  }
776 
777  void SetVariantID(int ID)
778  {
779  m_VariantID = ID;
780  }
781 
783  {
784  return m_VariantID;
785  }
786 
787  void UpdateVariants(Object item, Object target, int componet_index)
788  {
789  if ( m_VariantManager )
790  {
791  m_VariantManager.UpdateVariants(item, target, componet_index);
792  }
793  }
794 
796  {
797  if ( !m_VariantManager )
799  return m_VariantManager;
800  }
801 
802  // call only on client side for lock inventory before action
803  // return if has successfuly reserved inventory
805  {
806  if ((IsLocal() || !UseAcknowledgment()) && IsInstant())
807  return true;
808 
809  //action_data.m_ReservedInventoryLocations = new array<ref InventoryLocation>;
810  bool success = true;
811  InventoryLocation targetInventoryLocation = NULL;
812  InventoryLocation handInventoryLocation = NULL;
813 
814  // lock target if it has target
815  if (HasTarget())
816  {
817  ItemBase targetItem;
818  if ( ItemBase.CastTo(targetItem,action_data.m_Target.GetObject()) )
819  {
820  targetInventoryLocation = new InventoryLocation;
821  targetItem.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
822  if ( action_data.m_Player.GetInventory().HasInventoryReservation( targetItem, targetInventoryLocation) )
823  {
824  success = false;
825  }
826  else
827  {
828  action_data.m_Player.GetInventory().AddInventoryReservationEx( targetItem, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
829  }
830  }
831  }
832 
833  handInventoryLocation = new InventoryLocation;
834  handInventoryLocation.SetHands(action_data.m_Player,action_data.m_Player.GetItemInHands());
835 
836  if (action_data.m_Player.GetInventory().HasInventoryReservation( action_data.m_Player.GetItemInHands(), handInventoryLocation))
837  {
838  if (HasTarget())
839  {
840  action_data.m_Player.GetInventory().ClearInventoryReservation(targetItem, targetInventoryLocation);
841  }
842 
843  success = false;
844  }
845  else
846  {
847  action_data.m_Player.GetInventory().AddInventoryReservationEx( action_data.m_Player.GetItemInHands(), handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
848  }
849 
850  if (success)
851  {
852  if (targetInventoryLocation)
853  action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
854 
855  if (handInventoryLocation)
856  action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
857  }
858 
859  return success;
860  }
861 
863  {
864  if (action_data.m_ReservedInventoryLocations)
865  {
867  for ( int i = 0; i < action_data.m_ReservedInventoryLocations.Count(); i++)
868  {
869  il = action_data.m_ReservedInventoryLocations.Get(i);
870  EntityAI entity = il.GetItem();
871  action_data.m_Player.GetInventory().ClearInventoryReservationEx( il.GetItem() , il );
872  }
873 
874  action_data.m_ReservedInventoryLocations.Clear();
875  }
876  }
877 
878  void RefreshReservations(ActionData action_data)
879  {
880  if (action_data.m_ReservedInventoryLocations)
881  {
883  for (int i = 0; i < action_data.m_ReservedInventoryLocations.Count(); i++)
884  {
885  il = action_data.m_ReservedInventoryLocations.Get(i);
886  EntityAI entity = il.GetItem();
887  action_data.m_Player.GetInventory().ExtendInventoryReservationEx(il.GetItem() , il, 10000);
888  }
889  }
890  }
891 
892  // action need first have permission from server before can start
894  {
895  return true;
896  }
897 
899  protected void InformPlayers( PlayerBase player, ActionTarget target, int state );
900 
901  void SendMessageToClient( Object reciever, string message ) //sends given string to client, don't use if not nescessary
902  {
903  PlayerBase man;
904  if (GetGame().IsServer() && Class.CastTo(man, reciever) && m_MessageParam && reciever.IsAlive() && message != "")
905  {
906  m_MessageParam.param1 = message;
907  GetGame().RPCSingleParam(man, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, man.GetIdentity());
908  }
909  }
910 
911  // ActionCondition Rules
912  // ------------------------------------------------------
913  protected bool IsDamageDestroyed(ActionTarget target)
914  {
915  return target.GetObject() && target.GetObject().IsDamageDestroyed();
916  }
917 
918  protected bool IsBuilding(ActionTarget target)
919  {
920  return target.GetObject() && target.GetObject().IsBuilding();
921  }
922 
923  protected bool IsTransport(ActionTarget target)
924  {
925  return target.GetObject() && target.GetObject().IsTransport();
926  }
927 
928  protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance = 1.0)
929  {
930  Object obj = target.GetObject();
931  if (!obj)
932  return false;
933 
934  float distanceRoot, distanceHead;
935  vector modelPos, worldPos, playerHeadPos;
936 
937  // we're using sq distance in comparison
938  maxDistance = maxDistance * maxDistance;
939 
940  // get position of Head bone
941  MiscGameplayFunctions.GetHeadBonePos(player, playerHeadPos);
942 
943  array<string> componentNames = new array<string>();
944  obj.GetActionComponentNameList(target.GetComponentIndex(), componentNames);
945  foreach (string componentName : componentNames)
946  {
947  if (componentName.Contains("doorstwin"))
948  continue;
949 
950  modelPos = obj.GetSelectionPositionMS(componentName);
951  worldPos = obj.ModelToWorld(modelPos);
952 
953  break;
954  }
955 
956  distanceRoot = vector.DistanceSq(worldPos, player.GetPosition());
957  distanceHead = vector.DistanceSq(worldPos, playerHeadPos);
958 
959  return distanceRoot <= maxDistance || distanceHead <= maxDistance;
960  }
961  // ------------------------------------------------------
962 
963 
964 
965  // SOUNDS ------------------------------------------------------
966  SoundOnVehicle PlayActionSound( PlayerBase player )
967  {
968  if ( GetGame().IsServer() && player )
969  {
970  if ( m_Sound != "" )
971  {
972  return GetGame().CreateSoundOnObject(player, m_Sound, 6, false);
973  }
974  else if ( m_Sounds && m_Sounds.Count() > 0 )
975  {
976  int rand_num = Math.RandomInt(0, m_Sounds.Count());
977  return GetGame().CreateSoundOnObject(player, m_Sounds.Get(rand_num), 6, false);
978  }
979  }
980 
981  return NULL;
982  }
983 
984  void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
985  {
986  }
987 
988  //sound category matches with a soundtable category in config, selects correct soundset
989  string GetSoundCategory(ActionData action_data)
990  {
991  return "";
992  }
993 
994  // EVENTS ------------------------------------------------
995  void OnUpdate(ActionData action_data)
996  {}
997 
998  void OnUpdateClient(ActionData action_data)
999  {
1000  if ( !GetGame().IsDedicatedServer() )
1001  {
1002  if (action_data.m_RefreshReservationTimer > 0)
1003  {
1004  action_data.m_RefreshReservationTimer--;
1005  }
1006  else
1007  {
1008  action_data.m_RefreshReservationTimer = m_RefreshReservationTimerValue;
1009  RefreshReservations(action_data);
1010  }
1011  }
1012  }
1013 
1014  void OnUpdateServer(ActionData action_data)
1015  {}
1016 
1017  void OnStart(ActionData action_data)
1018  {
1019  if (action_data.m_Player != NULL && action_data.m_Player.IsPlacingLocal() && !IsDeploymentAction())
1020  action_data.m_Player.PlacingCancelLocal();
1021  }
1022 
1023  void OnStartClient(ActionData action_data)
1024  {}
1025 
1026  void OnStartServer(ActionData action_data)
1027  {
1028 
1029  }
1030 
1031  void OnEnd(ActionData action_data)
1032  {
1033 
1034  }
1035 
1036  void OnEndClient(ActionData action_data)
1037  {}
1038 
1039  void OnEndServer(ActionData action_data)
1040  {
1041  }
1042 
1043  // SOFT SKILLS ------------------------------------------------
1045  {
1046  if(m_SpecialtyWeight == 0)
1047  {
1048 #ifdef DEVELOPER
1049  //Print("UserAction does not use SoftSkills");
1050 #endif
1051  }
1052 
1053  return m_SpecialtyWeight;
1054  }
1055 
1056  int GetState( ActionData action_data )
1057  {
1058  return action_data.m_State;
1059  }
1060 
1061  float GetProgress( ActionData action_data )
1062  {
1063  return -1;
1064  }
1065 
1067  {
1068  return m_Input;
1069  }
1070 
1071  void SetID(int actionId)
1072  {
1073  m_ActionID = actionId;
1074  }
1075 
1076  int GetID()
1077  {
1078  return m_ActionID;
1079  }
1080 
1081  string GetAdminLogMessage(ActionData action_data)
1082  {
1083  return "";
1084  }
1085 };
ItemBase
Definition: inventoryitem.c:730
OnEndInput
void OnEndInput(ActionData action_data)
Definition: actionbase.c:621
GetGame
proto native CGame GetGame()
RemoveForceTargetAfterUse
bool RemoveForceTargetAfterUse()
Definition: actionbase.c:261
ACM_RAISED
@ ACM_RAISED
Definition: actionbase.c:8
GetProgress
float GetProgress(ActionData action_data)
Definition: actionbase.c:1061
m_Target
ref ActionTarget m_Target
Definition: actionbase.c:17
IsShaveSelf
bool IsShaveSelf()
Definition: actionbase.c:281
ActionConditionContinue
protected bool ActionConditionContinue(ActionData action_data)
Definition: actionbase.c:367
GetVariants
int GetVariants(out array< ref ActionBase > variants)
Definition: actionbase.c:769
GetSpecialtyWeight
float GetSpecialtyWeight()
Definition: actionbase.c:1044
CanBeUsedWithBrokenLegs
bool CanBeUsedWithBrokenLegs()
Definition: actionbase.c:346
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
GetText
string GetText()
Definition: actionbase.c:286
CreateActionData
ActionData CreateActionData()
Definition: actionbase.c:213
LogManager
Definition: debug.c:734
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
CanBePerformedFromInventory
bool CanBePerformedFromInventory()
Definition: actionbase.c:296
IsFullBody
bool IsFullBody(PlayerBase player)
Definition: actionbase.c:553
Can
bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
Definition: actionbase.c:703
DayZPlayerUtils
private void DayZPlayerUtils()
cannot be instantiated
Definition: dayzplayerutils.c:461
IsUsingProxies
bool IsUsingProxies()
not using plane object - it's using multiple proxies
Definition: actionbase.c:256
Start
void Start(ActionData action_data)
Definition: actionbase.c:570
TStringArray
array< string > TStringArray
Definition: enscript.c:685
EndInput
void EndInput(ActionData action_data)
Definition: actionbase.c:624
OnEndClient
void OnEndClient(ActionData action_data)
Definition: actionbase.c:1036
ActionVariantManager
Definition: actionvariantsmanager.c:1
AC_UNCATEGORIZED
const int AC_UNCATEGORIZED
Definition: _constants.c:1
IsDamageDestroyed
protected bool IsDamageDestroyed(ActionTarget target)
Definition: actionbase.c:913
CanBeUsedRaised
bool CanBeUsedRaised()
Definition: actionbase.c:331
WriteToContext
void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
Definition: actionbase.c:384
GetVariantID
int GetVariantID()
Definition: actionbase.c:782
UseMainItem
bool UseMainItem()
Definition: actionbase.c:357
GetAdminLogMessage
string GetAdminLogMessage(ActionData action_data)
Definition: actionbase.c:1081
m_ConditionMask
int m_ConditionMask
Definition: actionbase.c:60
ACM_BROKEN_LEGS
@ ACM_BROKEN_LEGS
Definition: actionbase.c:12
CanBeUsedOnLadder
bool CanBeUsedOnLadder()
Definition: actionbase.c:326
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
m_ActionID
protected int m_ActionID
Definition: actionbase.c:58
CanBeUsedSwimming
bool CanBeUsedSwimming()
Definition: actionbase.c:321
CCIBase
Definition: ccibase.c:1
GetID
int GetID()
Definition: actionbase.c:1076
GetDisplayInteractObject
Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
Definition: actionbase.c:224
m_MessageParam
protected ref Param1< string > m_MessageParam
Definition: actionbase.c:64
DefaultActionInput
Definition: actioninput.c:630
OnEndRequest
void OnEndRequest(ActionData action_data)
Definition: actionbase.c:630
CCTBase
Definition: cctbase.c:1
ACM_THROWING
@ ACM_THROWING
Definition: actionbase.c:10
IsEat
bool IsEat()
Definition: actionbase.c:271
GetState
int GetState(ActionData action_data)
Definition: actionbase.c:1056
CABase
Definition: cabase.c:1
ACM_SWIMMING
@ ACM_SWIMMING
Definition: actionbase.c:6
ACM_IN_VEHICLE
@ ACM_IN_VEHICLE
Definition: actionbase.c:4
UseAcknowledgment
bool UseAcknowledgment()
Definition: actionbase.c:893
CanBePerformedFromQuickbar
bool CanBePerformedFromQuickbar()
Definition: actionbase.c:291
IsLockTargetOnUse
bool IsLockTargetOnUse()
Definition: actionbase.c:90
ActionConditionMask
ActionConditionMask
Definition: actionbase.c:1
SetID
void SetID(int actionId)
Definition: actionbase.c:1071
m_Sounds
protected ref TStringArray m_Sounds
Definition: actionbase.c:54
InformPlayers
protected void InformPlayers(PlayerBase player, ActionTarget target, int state)
DEPRECATED delivers message ids to clients based on given context.
ClearInventoryReservationEx
void ClearInventoryReservationEx(ActionData action_data)
Definition: actionbase.c:862
UpdateVariants
void UpdateVariants(Object item, Object target, int componet_index)
Definition: actionbase.c:787
CCIDummy
Definition: ccidummy.c:1
CCTDummy
Definition: cctdummy.c:1
IsTransport
protected bool IsTransport(ActionTarget target)
Definition: actionbase.c:923
HasTarget
bool HasTarget()
Definition: actionbase.c:232
ACM_LEANING
@ ACM_LEANING
Definition: actionbase.c:11
OnEnd
void OnEnd(ActionData action_data)
Definition: actionbase.c:1031
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
m_Input
protected ActionInput m_Input
Definition: actionbase.c:57
IsDrink
bool IsDrink()
Definition: actionbase.c:276
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
GetVariantsCount
int GetVariantsCount()
Definition: actionbase.c:761
m_RefreshReservationTimerValue
class ActionData m_RefreshReservationTimerValue
GetSoundCategory
string GetSoundCategory(ActionData action_data)
Definition: actionbase.c:989
GetStanceMask
protected int GetStanceMask(PlayerBase player)
Definition: actionbase.c:539
CanBeUsedInRestrain
bool CanBeUsedInRestrain()
Definition: actionbase.c:306
EndRequest
void EndRequest(ActionData action_data)
Definition: actionbase.c:633
GetInputType
GetInputType()
Definition: actionbase.c:203
OnUpdate
void OnUpdate(ActionData action_data)
Definition: actionbase.c:995
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
UA_START
const int UA_START
Definition: constants.c:439
OnEndServer
void OnEndServer(ActionData action_data)
Definition: actionbase.c:1039
ActionTarget
class ActionTargets ActionTarget
m_VariantID
protected int m_VariantID
Definition: actionbase.c:59
ActionData
Definition: actionbase.c:20
CanBeUsedOnBack
bool CanBeUsedOnBack()
Definition: actionbase.c:316
OnUpdateClient
void OnUpdateClient(ActionData action_data)
Definition: actionbase.c:998
CreateConditionComponents
void CreateConditionComponents()
Definition: actionbase.c:218
HandleReciveData
void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Definition: actionbase.c:517
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CanBeSetFromInventory
bool CanBeSetFromInventory()
Definition: actionbase.c:301
SendMessageToClient
void SendMessageToClient(Object reciever, string message)
Definition: actionbase.c:901
ActionCleanup
void ActionCleanup(ActionData action_data)
Definition: actionbase.c:200
Object
Definition: objecttyped.c:1
OnUpdateServer
void OnUpdateServer(ActionData action_data)
Definition: actionbase.c:1014
GetRefreshReservationTimerValue
int GetRefreshReservationTimerValue()
Definition: actionbase.c:379
InventoryReservation
bool InventoryReservation(ActionData action_data)
Definition: actionbase.c:804
Interrupt
void Interrupt(ActionData action_data)
Definition: actionbase.c:616
ActionInput
Definition: actioninput.c:19
ActionCondition
protected bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actionbase.c:372
HasVariants
bool HasVariants()
Definition: actionbase.c:756
CanContinue
protected bool CanContinue(ActionData action_data)
Definition: actionbase.c:748
ACM_RESTRAIN
@ ACM_RESTRAIN
Definition: actionbase.c:7
ApplyModifiers
void ApplyModifiers(ActionData action_data)
GetVariantManager
ActionVariantManager GetVariantManager()
Definition: actionbase.c:795
Post_SetupAction
bool Post_SetupAction(ActionData action_data)
Definition: actionbase.c:195
m_LockTargetOnUse
protected bool m_LockTargetOnUse
Definition: actionbase.c:51
IsInReach
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition: actionbase.c:928
array< ref InventoryLocation >
SetInput
void SetInput(ActionInput ai)
Definition: actionbase.c:208
ACM_NO_EXEPTION
@ ACM_NO_EXEPTION
Definition: actionbase.c:3
End
void End(ActionData action_data)
Definition: actionbase.c:597
ActionBase
void ActionBase()
Definition: actionbase.c:73
m_Sound
protected string m_Sound
Definition: actionbase.c:48
m_Text
protected string m_Text
Definition: actionbase.c:49
Debug
Definition: debug.c:13
Entity
Definition: camera.c:1
GetActionCategory
int GetActionCategory()
Definition: actionbase.c:266
ActionBase_Basic
Definition: actionbase_basic.c:1
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
IsInstant
bool IsInstant()
Definition: actionbase.c:250
ACM_ON_LADDER
@ ACM_ON_LADDER
Definition: actionbase.c:5
RefreshReservations
void RefreshReservations(ActionData action_data)
Definition: actionbase.c:878
Type
string Type
Definition: jsondatacontaminatedarea.c:11
CanBeUsedLeaning
bool CanBeUsedLeaning()
Definition: actionbase.c:341
OnStartClient
void OnStartClient(ActionData action_data)
Definition: actionbase.c:1023
ERPCs
ERPCs
Definition: erpcs.c:1
IsBuilding
protected bool IsBuilding(ActionTarget target)
Definition: actionbase.c:918
MainItemAlwaysInHands
bool MainItemAlwaysInHands()
Definition: actionbase.c:362
SetupAction
bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition: actionbase.c:144
ACM_ON_BACK
@ ACM_ON_BACK
Definition: actionbase.c:9
HasProneException
protected bool HasProneException()
Definition: actionbase.c:563
OnStartServer
void OnStartServer(ActionData action_data)
Definition: actionbase.c:1026
OnActionInfoUpdate
void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actionbase.c:984
UA_NONE
const int UA_NONE
Definition: constants.c:432
GetInput
ActionInput GetInput()
Definition: actionbase.c:1066
Math
Definition: enmath.c:6
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
ActionBaseCB
Definition: animatedactionbase.c:1
CanBeUsedInVehicle
bool CanBeUsedInVehicle()
Definition: actionbase.c:311
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
SetVariantID
void SetVariantID(int ID)
Definition: actionbase.c:777
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
FirearmActionBase
Definition: firearmactionbase.c:1
HasProgress
bool HasProgress()
For UI: hiding of progress bar.
Definition: actionbase.c:238
EntityAI
Definition: building.c:5
IsDeploymentAction
bool IsDeploymentAction()
Is an action directly related to deployment/advanced placing.
Definition: actionbase.c:352
PlayActionSound
SoundOnVehicle PlayActionSound(PlayerBase player)
Definition: actionbase.c:966
m_VariantManager
protected ref ActionVariantManager m_VariantManager
Definition: actionbase.c:61
ReadFromContext
bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
Definition: actionbase.c:440
IsLocal
bool IsLocal()
Definition: actionbase.c:244
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
CanReceiveAction
bool CanReceiveAction(ActionTarget target)
Definition: actionbase.c:638
InitConditionMask
void InitConditionMask()
Definition: actionbase.c:95
CanBeUsedThrowing
bool CanBeUsedThrowing()
Definition: actionbase.c:336
m_MainItem
enum ActionConditionMask m_MainItem
OnStart
void OnStart(ActionData action_data)
Definition: actionbase.c:1017