DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionManagerClient.c
Go to the documentation of this file.
3
5{
6
7 //Last send AcknowledgmentID (client can send more requests before recive ackfor first action)
8 protected int m_LastAcknowledgmentID;
9 protected bool m_ActionPossible;
18
20
21 protected bool m_ActionWantEndRequest_Send; //Request to server was sended
23
25 {
29 m_Targets = new ActionTargets(player);
32
35 RegisterInputs(player);
37 }
38
39 override void Update(int pCurrentCommandID)
40 {
42 super.Update(pCurrentCommandID);
43 m_ActionPossible = ActionPossibilityCheck(pCurrentCommandID);
44
45 if (m_PendingActionData) //SP only
46 {
48
50
51 if (m_CurrentActionData.m_Action.IsInstant())
53
55 }
56
58 {
61
63 {
64 case UA_AM_PENDING:
65 break;
66
67 case UA_AM_ACCEPTED:
68 int condition_mask = ActionBase.ComputeConditionMask(m_Player, m_CurrentActionData.m_Target, m_CurrentActionData.m_MainItem);
69
70 m_CurrentActionData.m_Action.ClearInventoryReservationEx(m_CurrentActionData);
71 bool can_be_action_done = ((condition_mask & m_CurrentActionData.m_Action.m_ConditionMask) == condition_mask);
72 // check pCurrentCommandID before start or reject
73 if (m_ActionPossible && can_be_action_done && pCurrentCommandID != DayZPlayerConstants.COMMANDID_SWIM)
74 {
78
79 if (m_CurrentActionData.m_Action.IsInstant())
81 }
82 else
83 {
85 }
87 break;
88
89 case UA_AM_REJECTED:
92 break;
93
94 default:
97 break;
98 }
99 }
100
101#ifdef DEVELOPER
103 {
104 m_ActionPossible = false;
106 }
107 else
108 {
109#endif
111 {
112 bool isMenuOpen = false;
113#ifndef NO_GUI
115#endif
116 if (m_Player.IsRaised() || isMenuOpen)
117 {
119 }
120 else
121 {
123 }
124 FindContextualUserActions(pCurrentCommandID);
125 }
126
127 InputsUpdate();
128#ifdef DEVELOPER
129 }
130#endif
131
132 }
133
135 {
137 {
139
140 for (int i = 0; i < m_ActionsArray.Count(); i++)
141 {
142 ActionBase action = m_ActionsArray.Get(i);
143 typename input_type_name = action.GetInputType();
144 ref ActionInput ai;
145
146 ai = ActionInput.Cast(m_RegistredInputsMap.Get(input_type_name));
147 if (!ai)
148 {
149 ai = ActionInput.Cast(input_type_name.Spawn());
150 m_RegistredInputsMap.Insert(input_type_name, ai);
151 }
152 action.SetInput(ai);
153 }
154
155 for (int j = 0; j < m_RegistredInputsMap.Count(); j++)
156 {
157 m_RegistredInputsMap.GetElement(j).Init(player, this);
158 }
160 }
161
162 }
163
164 //Set order of inputs base of priority (output -> m_OrederedAllActionInput)
166 {
167 int i, j;
168 int priority;
169 ActionInput input;
171
173 array<int> array_of_priorities_to_sort = new array<int>;
174 ref array<ActionInput> same_priority_input_array;
175
176 for (i = 0; i < m_RegistredInputsMap.Count(); i++)
177 {
178 input = m_RegistredInputsMap.GetElement(i);
179 priority = input.GetPriority();
180 same_priority_input_array = temp_map_for_sort.Get(priority);
181 if (same_priority_input_array)
182 {
183 same_priority_input_array.Insert(input);
184 continue;
185 }
186
187 same_priority_input_array = new array<ActionInput>;
188 same_priority_input_array.Insert(input);
189 temp_map_for_sort.Insert(priority,same_priority_input_array);
190 array_of_priorities_to_sort.Insert(priority);
191 }
192 array_of_priorities_to_sort.Sort();
193
194 for (i = 0; i < array_of_priorities_to_sort.Count(); i++)
195 {
196 priority = array_of_priorities_to_sort[i];
197 same_priority_input_array = temp_map_for_sort.Get(priority);
198 for (j = 0; j < same_priority_input_array.Count(); j++)
199 {
200 input = same_priority_input_array.Get(j);
201 m_OrederedAllActionInput.Insert(input);
202 }
203 }
204
206 }
207
208 //Order for user action inputs - will be dynamically change base on context (more complex handling viz set m_OrderedStandartActionInputs in UpdateActionCategoryPriority())
210 {
211 int i, j;
215 if (input)
216 {
217 m_OrderedStandartActionInputs.Insert(input);
218 }
219
221 if (input)
222 {
223 m_OrderedStandartActionInputs.Insert(input);
224 }
225
227 if (input)
228 {;
229 m_OrderedStandartActionInputs.Insert(input);
230 }
231
233 if (input)
234 {
235 m_OrderedStandartActionInputs.Insert(input);
236 }
237
238 for (i = 0; i < m_OrederedAllActionInput.Count(); i++)
239 {
240 for (j = 0; j < m_OrderedStandartActionInputs.Count(); j++)
241 {
243 {
245 break;
246 }
247 }
248 }
249 }
250
251 static ActionVariantManager GetVariantManager(typename actionName)
252 {
253 ActionBase action = GetAction(actionName);
254 if (action)
255 {
256 return action.GetVariantManager();
257 }
258 //VME ACTION not exist typo most likely
259 return null;
260 }
261
262 override void RequestEndAction()
263 {
265 {
267 }
268 }
269
270 override void EndActionInput()
271 {
273 {
275 }
276 }
277
279 {
280 ActionInput ain;
282 {
284 {
286 ai.Update();
287 if (m_Player.IsQBControl())
288 {
289 if (ai.JustActivate())
290 m_Player.SetActionEndInput(m_CurrentActionData.m_Action);
291 }
292 else
293 {
294 if (ai.WasEnded() && (ai.GetInputType() == ActionInputType.AIT_CONTINUOUS || ai.GetInputType() == ActionInputType.AIT_CLICKCONTINUOUS))
295 {
297 }
298 }
299 }
300 }
301 else
302 {
304 {
305 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
306 {
307
309 ain.Update();
310
311 if (ain.JustActivate())
312 {
313 ActionBase action = ain.GetAction();
314 if (action)
315 {
316 ActionStart(action, ain.GetUsedActionTarget(), ain.GetUsedMainItem());
317 break;
318 }
319 }
320 }
321 }
322 }
323 }
324
326 {
328 {
329 if (GetGame().IsMultiplayer() && !m_CurrentActionData.m_Action.IsLocal())
330 {
332 {
334 {
335 Debug.ActionLog("Time stamp: " + m_Player.GetSimulationTimeStamp(), m_CurrentActionData.m_Action.ToString() , "n/a", "EndRequest", m_CurrentActionData.m_Player.ToString());
336 }
339 ctx.Send();
340
342
345 }
346 }
347 else
348 {
351 }
352 }
353 }
354
356 {
358 {
359 if (GetGame().IsMultiplayer() && !m_CurrentActionData.m_Action.IsLocal())
360 {
362 {
364 {
365 Debug.ActionLog("Time stamp: " + m_Player.GetSimulationTimeStamp(), m_CurrentActionData.m_Action.ToString() , "n/a", "EndInput", m_CurrentActionData.m_Player.ToString());
366 }
369 ctxi.Send();
370
372
373 m_ActionInputWantEnd = false;
375 }
376 }
377 else
378 {
380 {
382 m_ActionInputWantEnd = false;
384 }
385 }
386 }
387 }
388
389 ActionBase GetPossibleAction(typename inputType)
390 {
391 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
392 if (action_input)
393 {
394 return action_input.GetAction();
395 }
396 return NULL;
397 }
398
400 {
401 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
402 if (action_input)
403 {
404 return action_input.GetPossibleActions();
405 }
406 return NULL;
407 }
408
409 int GetPossibleActionIndex(typename inputType)
410 {
411 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
412 if (action_input)
413 {
414 return action_input.GetPossibleActionIndex();
415 }
416 return -1;
417 }
418
419 int GetPossibleActionCount(typename inputType)
420 {
421 ActionInput action_input = m_RegistredInputsMap.Get(inputType);
422 if (action_input)
423 {
424 return action_input.GetPossibleActionsCount();
425 }
426 return 0;
427 }
428
429 //--------------------------------------------------------
430 // Alows to set different action to current contextual one
431 //--------------------------------------------------------
432 void InjectAction(ActionBase action, ActionTarget target, ItemBase item)
433 {
434 ActionInput ai = action.GetInput();
435 ai.ForceAction(action, target, item);
436 }
437
438 void InjectAction(typename actionType, ActionTarget target, ItemBase item)
439 {
440 ActionBase action = GetAction(actionType);
441 InjectAction(action, target, item);
442 }
443
445 {
446 ActionInput ai = action.GetInput();
448 }
449
450 void EjectAction(typename actionType)
451 {
452 ActionBase action = GetAction(actionType);
453 EjectAction(action);
454 }
455
456 void ForceTarget(Object targetObject)
457 {
458 Object parent = null;
459 EntityAI targetEntity = EntityAI.Cast(targetObject);
460 if (targetEntity)
461 parent = targetEntity.GetHierarchyParent();
462 m_ForceTarget = new ActionTarget(targetObject, parent, -1, vector.Zero, -1);
463 }
464
466 {
467 m_ForceTarget = NULL;
468 }
469
470
471 //-------------------------------------------------------------------------
473 {
474 if (m_ForceTarget)
475 return m_ForceTarget;
476
477 ActionTarget action_target;
478 action_target = NULL;
479 int targetsCount = m_Targets.GetTargetsCount();
480 if (targetsCount)
481 {
482 for (int i = 0; i < targetsCount; ++i)
483 {
484 action_target = m_Targets.GetTarget(i);
485 Object targetObject = action_target.GetObject();
486 Object targetParent = action_target.GetParent();
487
488 if (targetParent && targetParent.IsEntityAI())
489 {
490 break;
491 }
492
493 if (targetObject && (targetObject.IsEntityAI() || targetObject.IsWoodBase() || targetObject.IsRock()))
494 {
495 break;
496 }
497 }
498 }
499 else
500 {
501 action_target = new ActionTarget(null, null, -1, vector.Zero, -1);
502 }
503 return action_target;
504 }
505
507 {
508 ItemBase item;
509 if (m_Player && m_Player.GetItemInHands() && m_Player.GetItemInHands().IsItemBase())
510 {
511 item = m_Player.GetItemInHands();
512 }
513 return item;
514 }
515
517 {
519 if (m_Player.GetHumanInventory().HasInventoryReservation(m_Player.GetItemInHands(),m_HandInventoryLocationTest))
520 return true;
521 return false;
522 }
523
524 protected void FindContextualUserActions(int pCurrentCommandID)
525 {
526 // TODO: NEEDS OPTIMIZATION (focus on UpdatePossibleActions > CraftingManager::OnUpdate)
527
528 m_ActionsAvaibale = false;
529 if (!m_ActionPossible || HasHandInventoryReservation() || GetGame().IsInventoryOpen())
530 {
532 return;
533 }
534
535 if (!GetRunningAction())
536 {
537 ActionBase action;
538 ActionTarget target;
539 ItemBase item;
540
541 // Gathering current inputs
542 m_ActionsAvaibale = true;
543
544 item = FindActionItem();
545 target = FindActionTarget();
546
547 int actionConditionMask = ActionBase.ComputeConditionMask(m_Player,target,item);
548 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
549 {
551 ain.UpdatePossibleActions(m_Player,target,item, actionConditionMask);
552 }
553 SetActionContext(target,item);
554 }
555 }
556
557 //TOOD MW In progress
558 protected bool LockInventory(ActionData action_data)
559 {
560 bool success = false;
561 if (action_data.m_Action.IsInstant())
562 {
564 {
565 Debug.ActionLog("(-) Inventory lock - Not Used", action_data.m_Action.ToString() , "n/a", "LockInventory", action_data.m_Player.ToString());
566 }
567 success = true;
568 }
569 else
570 {
572 {
573 Debug.ActionLog("(X) Inventory lock", action_data.m_Action.ToString() , "n/a", "LockInventory", action_data.m_Player.ToString());
574 }
575 if (action_data.m_Action)
576 {
577 success = action_data.m_Action.InventoryReservation(action_data);
578 }
579 }
580 return success;
581 }
582 void UnlockInventory(ActionData action_data)
583 {
585 {
586 Debug.ActionLog("(O) Inventory unlock", action_data.m_Action.ToString() , "n/a", "UnlockInventory", action_data.m_Player.ToString());
587 }
588 if (action_data.m_Action)
589 action_data.m_Action.ClearInventoryReservationEx(action_data);
590 }
591
592 protected void ActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data = NULL)
593 {
594 if (!m_CurrentActionData && action)
595 {
599 m_ActionInputWantEnd = false;
600
601 if (action.CanBePerformedFromQuickbar())
602 m_Player.SetActionEndInput(action);
603
605
607 {
608 Debug.ActionLog("Item = " + item + ", " + target.DumpToString(), action.ToString() , "n/a", "ActionStart", m_Player.ToString());
609 }
610 m_Interrupted = false;
611 if (GetGame().IsMultiplayer() && !action.IsLocal())
612 {
614 {
615 DPrint("ScriptInputUserData already posted - ActionManagerClient");
616
618 {
619 Debug.ActionLog("Cannot start because ScriptInputUserData is already used", action.ToString() , "n/a", "ActionStart", m_Player.ToString());
620 }
621 return;
622 }
623 }
624
625 if (!action.SetupAction(m_Player, target, item, m_CurrentActionData, extra_data))
626 {
627 DPrint("Can not inicialize action" + action + " - ActionManagerClient");
628 m_CurrentActionData = NULL;
629 return;
630 }
631
633 {
634 Debug.ActionLog("Action data created wait to start", action.ToString() , "n/a", "ActionStart", m_Player.ToString());
635 }
636
637 if (GetGame().IsMultiplayer() && !action.IsLocal())
638 {
641 ctx.Write(action.GetID());
642
643 action.WriteToContext(ctx, m_CurrentActionData);
644
645 if (action.UseAcknowledgment())
646 {
649
651 }
652
653 ctx.Send();
654
655 if (!action.UseAcknowledgment())
656 {
657 action.Start(m_CurrentActionData);
658 if (action.IsInstant())
659 OnActionEnd();
660 }
661 }
662 else
663 {
664 action.Start(m_CurrentActionData);
665 if (action.IsInstant())
666 OnActionEnd();
667 }
668 }
669 }
670
672 {
673 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
674 {
676 if (action.GetInput() == ain)
677 {
678 ain.OnActionStart();
679 }
680 else
681 {
682 ain.Reset();
683 }
684 }
685 }
686
688 {
690 }
691
693 {
694 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
695 {
697 ain.Reset();
698 }
699 }
700
702 {
703 for (int i = 0; i < m_OrederedAllActionInput.Count();i++)
704 {
706 ain.ActionsSelectReset();
707 }
708 }
709
710 override void OnJumpStart()
711 {
713 {
715 {
716 OnActionEnd();
718 }
719 else
720 {
722 }
723 }
724 }
725
726 //Instant Action (Debug Actions) ---------------------------------
727 override void OnInstantAction(typename user_action_type, Param data = NULL)
728 {
729 ActionBase action = GetAction(user_action_type);
730 if (action)
731 {
732 ActionStart(action,NULL,NULL, data);
733 }
734 }
735
736#ifdef BOT
738 void PerformAction(int user_action_id, ActionTarget target, ItemBase item, Param extraData = NULL)
739 {
740 ActionStart(GetAction(user_action_id), target, item, extraData);
741 }
742#endif
743
744 void PerformActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data = NULL)
745 {
746 if (!GetGame().IsMultiplayer())
747 {
749
750 if (!action.SetupAction(m_Player,target,item,m_PendingActionData,extra_data))
751 m_PendingActionData = null;
752 }
753 else
754 ActionStart(action, target, item, extra_data);
755 }
756
757 override void OnActionEnd()
758 {
760 {
762 if (m_CurrentActionData.m_Action.RemoveForceTargetAfterUse())
764
765 super.OnActionEnd();
767 }
768 }
769
770 void SetInventoryAction(ActionBase action_name, ItemBase target_item, ItemBase main_item)
771 {
772 m_InventoryActionHandler.SetAction(action_name, target_item, main_item);
773 }
774
775 void SetInventoryAction(ActionBase action_name, ActionTarget target, ItemBase main_item)
776 {
777 m_InventoryActionHandler.SetAction(action_name, target, main_item);
778 }
779
781 {
783 }
784
785 override typename GetSelectedActionCategory()
786 {
788 }
789
791 {
792 int i;
793 int last_target_index = 0;
794 for (i = 0; i < m_DefaultOrderOfActionInputs.Count(); i++)
795 {
797 {
799 last_target_index++;
800 }
801 }
802
803 for (i = 0; i < m_DefaultOrderOfActionInputs.Count(); i++)
804 {
806 {
808 last_target_index++;
809 }
810 }
811 }
812
814 {
817
818 for (int index = 0; index < m_OrderedStandartActionInputs.Count(); index++)
819 {
821 {
823 break;
824 }
825 }
826 }
827
829 {
830 int index;
831
833 {
834 if (++index >= m_OrderedStandartActionInputs.Count())
835 {
836 index = 0;
837 }
839 {
841 break;
842 }
843 }
844 }
845
847 {
848 int index;
849
851 {
852 if (--index < 0)
853 {
854 index = m_OrderedStandartActionInputs.Count() - 1;
855 }
856
858 {
860 break;
861 }
862 }
863 }
864
865
866 override void SelectNextAction()
867 {
868 ActionInput ai;
870 {
872 if (ai && ai.GetPossibleActionsCount() > 1)
873 {
874 ai.SelectNextAction();
875 }
876 }
877 }
878
879 override void SelectPrevAction()
880 {
881 ActionInput ai;
883 {
885 if (ai && ai.GetPossibleActionsCount() > 1)
886 {
887 ai.SelectPrevAction();
888 }
889 }
890 }
891
893 {
894 ItemBase itemInHand = m_Player.GetItemInHands();
895 ActionTarget target;
896 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
897 bool hasTarget = targetItem != NULL;
898
899 if (mainItem)
900 {
902 ActionBase picked_action;
903 int i;
904
905 mainItem.GetActions(QuickaBarActionInput, actions);
906 if (actions)
907 {
908 for (i = 0; i < actions.Count(); i++)
909 {
910 picked_action = ActionBase.Cast(actions[i]);
911 if (picked_action && picked_action.Can(m_Player,target, itemInHand))
912 {
913 if (hasTarget == picked_action.HasTarget())
914 return true;
915 }
916 }
917 }
918 //First check continuous actions
919 mainItem.GetActions(ContinuousDefaultActionInput, actions);
920 if (actions)
921 {
922 for (i = 0; i < actions.Count(); i++)
923 {
924 picked_action = ActionBase.Cast(actions[i]);
925 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
926 {
927 if (hasTarget == picked_action.HasTarget())
928 return true;
929 }
930 }
931 }
932 //second single use actions
933 mainItem.GetActions(DefaultActionInput, actions);
934 if (actions)
935 {
936 for (i = 0; i < actions.Count(); i++)
937 {
938 picked_action = ActionBase.Cast(actions[i]);
939 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
940 {
941 if (hasTarget == picked_action.HasTarget())
942 return true;
943 }
944 }
945 }
946 }
947 return false;
948 }
949
950 void PerformActionFromQuickbar(ItemBase mainItem, ItemBase targetItem)
951 {
952 ItemBase itemInHand = m_Player.GetItemInHands();
953 ActionTarget target;
954 ItemBase parent = null;
955 if (targetItem)
956 parent = ItemBase.Cast(targetItem.GetHierarchyParent());
957 target = new ActionTarget(targetItem, parent, -1, vector.Zero, -1);
958 bool hasTarget = targetItem != NULL;
959
960 if (mainItem)
961 {
962 ActionBase picked_action;
964 int i;
965
966 mainItem.GetActions(QuickaBarActionInput, actions);
967 if (actions)
968 {
969 for (i = 0; i < actions.Count(); i++)
970 {
971 picked_action = ActionBase.Cast(actions[i]);
972 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand))
973 {
974 if (hasTarget == picked_action.HasTarget())
975 {
976 ActionStart(picked_action, target, mainItem);
977 return;
978 }
979 }
980 }
981 }
982
983 //First continuous actions
984 mainItem.GetActions(ContinuousDefaultActionInput, actions);
985 if (actions)
986 {
987 for (i = 0; i < actions.Count(); i++)
988 {
989 picked_action = ActionBase.Cast(actions[i]);
990 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
991 {
992 if (hasTarget == picked_action.HasTarget())
993 {
994 ActionStart(picked_action, target, mainItem);
995 return;
996 }
997 }
998 }
999 }
1000 //Second check single use actions
1001 mainItem.GetActions(DefaultActionInput, actions);
1002 if (actions)
1003 {
1004 for (i = 0; i < actions.Count(); i++)
1005 {
1006 picked_action = ActionBase.Cast(actions[i]);
1007 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromQuickbar())
1008 {
1009 if (hasTarget == picked_action.HasTarget())
1010 {
1011 ActionStart(picked_action, target, mainItem);
1012 return;
1013 }
1014 }
1015 }
1016 }
1017
1018 }
1019 }
1020
1021 //TODO Variants support ???
1023 {
1024 ItemBase itemInHand = m_Player.GetItemInHands();
1025 ActionTarget target;
1026 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
1027 bool hasTarget = targetItem != NULL;
1028
1029 if (mainItem)
1030 {
1032 ActionBase picked_action;
1033 int i;
1034
1035 //First check single use actions
1036 mainItem.GetActions(DefaultActionInput, actions);
1037 if (actions)
1038 {
1039 for (i = 0; i < actions.Count(); i++)
1040 {
1041 picked_action = ActionBase.Cast(actions[i]);
1042 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromInventory())
1043 {
1044 if (hasTarget == picked_action.HasTarget())
1045 return true;
1046 }
1047 }
1048 }
1049
1050 //Inventory specific actions
1051 mainItem.GetActions(InventoryOnlyActionInput, actions);
1052 if (actions)
1053 {
1054 for (i = 0; i < actions.Count(); i++)
1055 {
1056 picked_action = ActionBase.Cast(actions[i]);
1057 if (picked_action && picked_action.Can(m_Player,target, itemInHand))
1058 {
1059 if (hasTarget == picked_action.HasTarget())
1060 return true;
1061 }
1062 }
1063 }
1064 }
1065 return false;
1066 }
1067
1068 //TODO Variants support ???
1070 {
1071 ItemBase itemInHand = m_Player.GetItemInHands();
1072 ActionTarget target;
1073 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
1074 bool hasTarget = targetItem != NULL;
1075
1076 if (mainItem)
1077 {
1078 ActionBase picked_action;
1080 int i;
1081
1082 //First check single use actions
1083 mainItem.GetActions(DefaultActionInput, actions);
1084 if (actions)
1085 {
1086 for (i = 0; i < actions.Count(); i++)
1087 {
1088 picked_action = ActionBase.Cast(actions[i]);
1089 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBePerformedFromInventory())
1090 {
1091 if (hasTarget == picked_action.HasTarget())
1092 {
1093 ActionStart(picked_action, target, mainItem);
1094 return;
1095 }
1096 }
1097 }
1098 }
1099
1100 //Inventory specific actions
1101 mainItem.GetActions(InventoryOnlyActionInput, actions);
1102 if (actions)
1103 {
1104 for (i = 0; i < actions.Count(); i++)
1105 {
1106 picked_action = ActionBase.Cast(actions[i]);
1107 if (picked_action && picked_action.Can(m_Player,target, itemInHand))
1108 {
1109 if (hasTarget == picked_action.HasTarget())
1110 {
1111 ActionStart(picked_action, target, mainItem);
1112 return;
1113 }
1114 }
1115 }
1116 }
1117 }
1118 }
1119
1121 {
1122 ItemBase itemInHand = m_Player.GetItemInHands();
1123 ActionTarget target;
1124 EntityAI parent = null;
1125 if (targetItem)
1126 {
1127 parent = targetItem.GetHierarchyParent();
1128 }
1129 target = new ActionTarget(targetItem, parent, -1, vector.Zero, -1);
1130 bool hasTarget = targetItem != NULL;
1131
1132 if (mainItem)
1133 {
1135 array<ref ActionBase> variant_actions;
1136 ActionBase picked_action;
1137 int variants_count,v;
1138
1139 //First check single use actions
1140 mainItem.GetActions(DefaultActionInput, actions);
1141 if (actions)
1142 {
1143 for (int i = 0; i < actions.Count(); i++)
1144 {
1145 picked_action = ActionBase.Cast(actions[i]);
1146 if (picked_action.HasVariants())
1147 {
1148 picked_action.UpdateVariants(itemInHand, targetItem, -1);
1149 picked_action.GetVariants(variant_actions);
1150 for (v = 0; v < variant_actions.Count(); v ++)
1151 {
1152 picked_action = variant_actions[v];
1153 if (picked_action && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1154 {
1155 if (hasTarget == picked_action.HasTarget())
1156 return true;
1157 }
1158 }
1159 }
1160 else
1161 {
1162 if (picked_action && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1163 {
1164 if (hasTarget == picked_action.HasTarget())
1165 return true;
1166 }
1167 }
1168 }
1169 }
1170 //second continuous actions
1171 mainItem.GetActions(ContinuousDefaultActionInput, actions);
1172 if (actions)
1173 {
1174 for (int j = 0; j < actions.Count(); j++)
1175 {
1176 picked_action = ActionBase.Cast(actions[j]);
1177 if (picked_action.HasVariants())
1178 {
1179 picked_action.UpdateVariants(itemInHand, targetItem, -1);
1180 picked_action.GetVariants(variant_actions);
1181 for (v = 0; v < variant_actions.Count(); v ++)
1182 {
1183 picked_action = variant_actions[v];
1184 if (picked_action && picked_action.HasTarget() && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1185 {
1186 if (hasTarget == picked_action.HasTarget())
1187 return true;
1188 }
1189 }
1190 }
1191 else
1192 {
1193 if (picked_action && picked_action.HasTarget() && picked_action.CanBeSetFromInventory() && picked_action.Can(m_Player,target, itemInHand))
1194 {
1195 if (hasTarget == picked_action.HasTarget())
1196 return true;
1197 }
1198 }
1199 }
1200 }
1201 }
1202 return false;
1203 }
1204
1205 //TODO fix for variants
1206 void SetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
1207 {
1208 ItemBase itemInHand = m_Player.GetItemInHands();
1209 ActionTarget target;
1210 target = new ActionTarget(targetItem, null, -1, vector.Zero, -1);
1211 bool hasTarget = targetItem != NULL;
1212
1213 if (mainItem)
1214 {
1216 ActionBase picked_action;
1217
1218 //First check single use actions
1219 mainItem.GetActions(DefaultActionInput, actions);
1220 if (actions)
1221 {
1222 for (int i = 0; i < actions.Count(); i++)
1223 {
1224 picked_action = ActionBase.Cast(actions[i]);
1225 if (picked_action && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBeSetFromInventory())
1226 {
1227 if (hasTarget == picked_action.HasTarget())
1228 {
1229 SetInventoryAction(picked_action, target, itemInHand);
1230 return;
1231 }
1232 }
1233 }
1234 }
1235 //second continuous actions
1236 mainItem.GetActions(ContinuousDefaultActionInput, actions);
1237 if (actions)
1238 {
1239 for (int j = 0; j < actions.Count(); j++)
1240 {
1241 picked_action = ActionBase.Cast(actions[j]);
1242 if (picked_action && picked_action.HasTarget() && picked_action.Can(m_Player,target, itemInHand) && picked_action.CanBeSetFromInventory())
1243 {
1244 if (hasTarget == picked_action.HasTarget())
1245 {
1246 SetInventoryAction(picked_action, target, itemInHand);
1247 return;
1248 }
1249 }
1250 }
1251 }
1252 }
1253 }
1254
1255 override void Interrupt()
1256 {
1257 super.Interrupt();
1258
1260 m_Interrupted = true;
1261 }
1262
1265 {
1267 {
1270 ctx.Write(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
1271 ctx.Send();
1272 }
1273 }
1274
1277};
const int INPUT_UDT_STANDARD_ACTION_END_REQUEST
Definition _constants.c:3
const int INPUT_UDT_STANDARD_ACTION_START
Definition _constants.c:2
const int INPUT_UDT_STANDARD_ACTION_INPUT_END
Definition _constants.c:4
bool HasTarget()
Definition ActionBase.c:232
void ActionBase()
Definition ActionBase.c:73
void ContinuousDefaultActionInput(PlayerBase player)
override ActionBase GetAction()
ActionInputType
Definition ActionInput.c:2
override int GetPossibleActionsCount()
bool m_Interrupted
protected bool m_ActionInputWantEnd
protected bool m_ActionsAvaibale
protected void SetActionContext(ActionTarget target, ItemBase item)
protected bool m_ActionWantEndRequest
bool ActionPossibilityCheck(int pCurrentCommandID)
static ref array< ref ActionBase > m_ActionsArray
void ActionManagerBase(PlayerBase player)
protected ref ActionData m_CurrentActionData
protected int m_PendingActionAcknowledgmentID
map< typename, ref array< ActionBase_Basic > > TInputActionMap
map< typename, ref ActionInput > TTypeNameActionInputMap
class ActionTargets ActionTarget
DayZPlayer m_Player
Definition Hand_Events.c:42
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionBase m_Action
Definition ActionBase.c:27
ref ActionTarget m_Target
Definition ActionBase.c:32
array< ActionBase > GetPossibleActions()
int GetPossibleActionsCount()
void ClearForcedAction()
ItemBase GetUsedMainItem()
bool WasEnded()
void SelectNextAction()
bool JustActivate()
Definition ActionInput.c:99
int GetPriority()
void ActionsSelectReset()
int GetInputType()
Definition ActionInput.c:89
void ForceAction(ActionBase action, ActionTarget target, ItemBase item)
ActionBase GetAction()
int GetPossibleActionIndex()
void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
ActionTarget GetUsedActionTarget()
void OnActionStart()
void Update()
void SelectPrevAction()
protected int m_SelectedActionInputToSrollIndex
void SetInventoryAction(ActionBase action_name, ItemBase target_item, ItemBase main_item)
void RequestInterruptAction()
client requests action interrupt
ActionBase GetPossibleAction(typename inputType)
override ActionTarget FindActionTarget()
void RegisterInputs(PlayerBase player)
void PerformActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data=NULL)
void ActionManagerClient(PlayerBase player)
protected int m_LastAcknowledgmentID
protected ref InventoryActionHandler m_InventoryActionHandler
override void SelectFirstActionCategory()
protected bool HasHandInventoryReservation()
override void RequestEndAction()
void SetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
protected ref InventoryLocation m_HandInventoryLocationTest
protected ref array< ActionInput > m_DefaultOrderOfActionInputs
bool CanPerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
override void OnActionEnd()
override void Update(int pCurrentCommandID)
protected ref ActionData m_PendingActionData
void PerformActionFromQuickbar(ItemBase mainItem, ItemBase targetItem)
protected void ActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data=NULL)
override void SelectPrevActionCategory()
protected bool m_ActionWantEndRequest_Send
array< ActionBase > GetPossibleActions(typename inputType)
protected ref array< ref InventoryLocation > m_ReservedInventoryLocations
protected ref TTypeNameActionInputMap m_RegistredInputsMap
static ActionVariantManager GetVariantManager(typename actionName)
int GetPossibleActionCount(typename inputType)
void EjectAction(ActionBase action)
void HandleInputsOnActionStart(ActionBase action)
void EjectAction(typename actionType)
protected bool m_ActionPossible
private ref ActionTargets m_Targets
void SetInventoryAction(ActionBase action_name, ActionTarget target, ItemBase main_item)
protected ref array< ActionInput > m_OrederedAllActionInput
protected ref array< ActionInput > m_OrderedStandartActionInputs
override void OnInstantAction(typename user_action_type, Param data=NULL)
bool CanPerformActionFromQuickbar(ItemBase mainItem, ItemBase targetItem)
protected void FindContextualUserActions(int pCurrentCommandID)
override void OnJumpStart()
void InjectAction(typename actionType, ActionTarget target, ItemBase item)
void PerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
override void EndActionInput()
override void SelectNextAction()
private ref ActionTarget m_ForceTarget
override void SelectPrevAction()
override void SelectNextActionCategory()
int GetPossibleActionIndex(typename inputType)
protected bool m_ActionInputWantEnd_Send
void InjectAction(ActionBase action, ActionTarget target, ItemBase item)
void UnlockInventory(ActionData action_data)
void ForceTarget(Object targetObject)
protected bool LockInventory(ActionData action_data)
int GetTargetsCount()
returns count of founded targets
ActionTarget GetTarget(int index)
returns action target at index
proto native UIManager GetUIManager()
Definition Debug.c:14
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:138
static bool IsFreeCameraEnabled()
Client only - manage set up crafting on client.
void SetAction(ActionBase action, ItemBase target_item, ItemBase main_item)
InventoryLocation.
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
static bool IsActionLogEnable()
Definition Debug.c:590
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
proto static native bool CanStoreInputUserData()
proto native void Send()
proto bool Write(void value_out)
bool IsMenuOpen(int id)
Returns true if menu with specific ID is opened (see MenuID)
Definition UIManager.c:155
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Definition EnConvert.c:110
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...
const int MENU_INVENTORY
Definition constants.c:158
const int UA_START
Definition constants.c:423
const int UA_AM_ACCEPTED
Definition constants.c:431
const int UA_AM_REJECTED
Definition constants.c:432
const int UA_AM_PENDING
Definition constants.c:430
proto native int GetRunningAction()
returns -1 when no action is running or RELOAD,MECHANISM, ....