DayZ 1.24
Loading...
Searching...
No Matches
ActionInput.c
Go to the documentation of this file.
2{
3 AIT_CONTINUOUS, //React to hold input and release after it
4 AIT_SINGLE, //React to click input - single use actions
5 AIT_DOUBLECLICK, //React to double click input - single use actions
6 AIT_HOLDSINGLE, //React to hold input - single use actions
7 AIT_CLICKCONTINUOUS, //React to click input for start and click for end
9 AIT_INVENTORYINPUT, //Inventory specific actions
10}
11
13{
14 ActionBase m_Action;
15 ref ActionTarget m_Target;
17}
18
20{
21 UAIDWrapper m_input; //Input ID automaticly generated from name.
22 int m_InputType; //Use from action manager for handling input
24 bool m_DetectFromItem; //Can be used action from item in hands?
25 bool m_DetectFromTarget; //Can be used action from target in vicinity?
26 bool m_DetectFromPlayer; //Can be used action from player?
30
32
33 ref ActionTarget m_ForcedTarget;
34
36
37 ref ActionTarget m_Target;
40
42
44 {
45 m_Active = false;
46 m_Enabled = true;
49
50 m_HasTarget = false;
51
52 m_JustActivate = false;
53 m_DetectFromTarget = false;
54 m_DetectFromItem = true;
55 m_DetectFromPlayer = true;
56
57 m_Priority = 100;
58 }
59
61 {
63
65 Debug.ActionLog("n/a", this.ToString(), "n/a", "Init()", player.ToString());
66
67 }
68
69 void SetEnablity(bool value)
70 {
72 }
73
74 protected void SetInput(string input_name)
75 {
76 m_input = GetUApi().GetInputByName(input_name).GetPersistentWrapper();
77
79 {
80 if (m_input && m_input.InputP())
81 Debug.ActionLog("(+) input set to " + input_name, this.ToString(), "n/a", "SetInput()", "n/a");
82 else
83 Debug.ActionLog("(-) input is not set to " + input_name, this.ToString(), "n/a", "SetInput()", "n/a");
84 }
85 }
86
88 {
89 return m_InputType;
90 }
91
93 {
94 return m_input.InputP();
95 }
96
98 {
99 return m_JustActivate;
100 }
101
102 bool IsActive()
103 {
104 return m_Active;
105 }
106
107 bool WasEnded()
108 {
109 return !m_Active;
110 }
111
112 void Update()
113 {
114 if (!m_Enabled)
115 {
116 m_Active = false;
117 m_JustActivate = false;
118 return;
119 }
120
121 switch (m_InputType)
122 {
123 case ActionInputType.AIT_CONTINUOUS:
124 m_JustActivate = false;
125 if (m_Active)
126 m_Active = m_input.InputP().LocalHold();
127 else
128 {
129 m_Active = m_input.InputP().LocalHoldBegin();
131 }
132 break;
133 case ActionInputType.AIT_SINGLE:
134 m_Active = m_input.InputP().LocalClick();
136 break;
137 case ActionInputType.AIT_DOUBLECLICK:
138 m_Active = m_input.InputP().LocalDoubleClick();
140 break;
141 break;
142 case ActionInputType.AIT_HOLDSINGLE:
143 m_Active = m_input.InputP().LocalHoldBegin();
145 break;
146 break;
147 case ActionInputType.AIT_CLICKCONTINUOUS:
148 m_JustActivate = false;
149 if (m_Active)
150 {
151 if (m_input.InputP().LocalClick())
152 m_Active = false;
153 }
154 else
155 {
156 m_Active = m_input.InputP().LocalClick();
158 }
159 break;
160 break;
161 default:
162 break;
163 }
164 }
165
166 void Reset()
167 {
168 m_Active = false;
170 }
171
175
176 ActionBase GetAction()
177 {
178 return NULL;
179 }
180
181 ActionTarget GetUsedActionTarget()
182 {
183 return m_Target;
184 }
185
187 {
188 return m_MainItem;
189 }
190
192 {
193 return NULL;
194 }
195
196 ActionBase GetPossibleAction()
197 {
198 return NULL;
199 }
200
202 {
203 return -1;
204 }
205
207 {
208 return false;
209 }
210
212 {
214 }
215
217 {
218 Reset();
219 }
220
222 {}
223
224 void ForceAction(ActionBase action, ActionTarget target, ItemBase item)
225 {
227 m_ForcedActionData.m_Action = action;
228 m_ForcedActionData.m_Target = target;
229 m_ForcedActionData.m_Item = item;
230 }
231
232 void ForceActionTarget(ActionTarget target)
233 {
235 }
236
238 {
240 }
241
243 {
245 }
246
248 {
250 {
251 if (m_ForcedActionData.m_Action.Can(player, m_ForcedActionData.m_Target, m_ForcedActionData.m_Item))
252 {
254 m_Target = m_ForcedActionData.m_Target;
255 return true;
256 }
257 }
258 return false;
259 }
260
262 {
263 }
264
266 {}
267
269 {
270 return -1;
271 }
272
273 bool HasInput()
274 {
275 return m_input != NULL;
276 }
277
279 {
280 return m_Priority;
281 }
282}
283
284class StandardActionInput : ActionInput
285{
288
294
295 override void ForceAction(ActionBase action, ActionTarget target, ItemBase item)
296 {
297 super.ForceAction(action, target, item);
298
300 }
301
303 {
305 return;
306
309 action_source_object.GetActions(this.Type(), possible_actions);
310 ActionBase action;
311
313 {
314 for (int i = 0; i < possible_actions.Count(); i++)
315 {
316 action = ActionBase.Cast(possible_actions.Get(i));
317
318 if (action.HasVariants())
319 {
320 action.UpdateVariants(m_MainItem, m_Target.GetObject(), m_Target.GetComponentIndex());
321 action.GetVariants(variant_actions);
322 for (int j = 0; j < variant_actions.Count(); j++)
323 {
326 {
328 if (action.HasTarget())
330 }
331 }
332 }
333 else
334 {
336 {
338 if (action.HasTarget())
340 }
341 }
342 }
343 }
344 }
345
347 {
348 if (ForceActionCheck(player))
349 {
350 m_SelectActions.Clear();
351 m_SelectActions.Insert(m_ForcedActionData.m_Action);
352 return;
353 }
354
355 if (m_ForcedTarget)
356 target = m_ForcedTarget;
357
359 int i, last_index;
360 bool change = false;
361 m_HasTarget = false;
362
366
367
368 if (m_DetectFromItem)
370
371
372 if (m_DetectFromTarget)
373 {
374 _GetSelectedActions(target.GetObject(), select_actions_all, m_HasTarget);
375 _GetSelectedActions(target.GetParent(), select_actions_all, m_HasTarget);
376 }
377
378 if (m_DetectFromPlayer)
380
381 if (select_actions_all.Count())
382 {
383 last_index = 0;
384 for (i = 0; i < select_actions_all.Count(); i++)
385 {
386 ActionBase action = select_actions_all[i];
387 if (m_HasTarget)
388 {
389 if (action.HasTarget())
390 {
391 if (m_SelectActions.Count() > last_index)
392 {
394 {
395 change = true;
397 }
398 }
399 else
400 {
401 change = true;
402 m_SelectActions.Insert(action);
403 }
404 action.OnActionInfoUpdate(player, target, item);
405 last_index++;
406 }
407 }
408 else
409 {
410 if (m_SelectActions.Count() > last_index)
411 {
413 {
414 change = true;
416 }
417 }
418 else
419 {
420 change = true;
421 m_SelectActions.Insert(action);
422 }
423 action.OnActionInfoUpdate(player, target, item);
424 last_index++;
425 }
426 }
427 }
428 else
429 {
431 m_SelectActions.Clear();
432 }
433
434 if (m_SelectActions.Count() > last_index)
435 {
436 change = true;
437 for (i = last_index; i < m_SelectActions.Count(); i++)
439 }
440
441 if (change)
442 {
444 m_Player.GetActionManager().SelectFirstActionCategory();
445 }
446 }
447
449 {
450 return m_SelectActions;
451 }
452
454 {
455 return m_SelectActions.Count();
456 }
457
458 override bool HasTarget()
459 {
460 return m_HasTarget;
461 }
462
464 {
466 }
467
468 override ActionBase GetAction()
469 {
470 if (m_SelectActions.Count() > 0)
472 return null;
473 }
474
475 override void ActionsSelectReset()
476 {
477 m_SelectActions.Clear();
479 }
480
481 override void SelectNextAction()
482 {
483 if (m_SelectActions.Count())
484 {
488 }
489 }
490
491 override void SelectPrevAction()
492 {
493 if (m_SelectActions.Count())
494 {
496 if (0 > m_selectedActionIndex)
498 }
499 }
500
501}
502
503class ContinuousInteractActionInput : StandardActionInput
504{
506 {
507 SetInput("UAAction");
508 m_Priority = 60;
509 m_InputType = ActionInputType.AIT_CONTINUOUS;
510 m_DetectFromTarget = true;
511 m_DetectFromItem = false;
512 m_DetectFromPlayer = true;
513 }
514};
515
517{
519 {
520 m_InputType = ActionInputType.AIT_SINGLE;
521 m_Priority = 80;
522 }
523
524 override void OnActionStart()
525 {
526 super.OnActionStart();
527 m_Active = false;
528 }
529
530 override bool WasEnded()
531 {
532 return false;
533 }
534};
535
537{
542
549
550 override ActionBase GetAction()
551 {
553 return m_ForcedActionData.m_Action;
554
555 if (m_MainItem)
556 {
558 ActionBase action;
559
560 m_MainItem.GetActions(this.Type(), possible_actions);
562 {
563 for (int i = 0; i < possible_actions.Count(); i++)
564 {
565 action = ActionBase.Cast(possible_actions.Get(i));
567 return action;
568 }
569 }
570
571 }
572 return NULL;
573 }
574
575 override ActionBase GetPossibleAction()
576 {
577 return GetAction();
578 }
579}
580
581
582class ContinuousDefaultActionInput : StandardActionInput
583{
584 protected ActionBase m_SelectAction; //Do nothing only for back compatibilit, relevant only for inherited class
586 {
587 SetInput("UADefaultAction");
588 m_InputType = ActionInputType.AIT_CONTINUOUS;
589 m_Priority = 20;
590 m_DetectFromTarget = false;
591 m_DetectFromItem = true;
592 m_DetectFromPlayer = true;
593
595 }
596
597 override ActionBase GetPossibleAction()
598 {
599 return m_SelectAction;
600 }
601
602 override void ActionsSelectReset()
603 {
604 super.ActionsSelectReset();
606 }
607};
608
609class DefaultActionInput : ContinuousDefaultActionInput
610{
612 {
613 m_InputType = ActionInputType.AIT_SINGLE;
614 m_Priority = 40;
615 }
616
617 override void OnActionStart()
618 {
619 super.OnActionStart();
620 m_Active = false;
621 }
622
623 override bool WasEnded()
624 {
625 return false;
626 }
627};
628
630{
632 {
633 SetInput("UADropitem");
634 m_InputType = ActionInputType.AIT_HOLDSINGLE;
635 }
636};
637
638class CarHornShortActionInput : ContinuousDefaultActionInput
639{
640 ref ActionTarget targetNew;
641
643 {
644 SetInput("UACarHorn");
645 m_InputType = ActionInputType.AIT_SINGLE;
646 m_Priority = 100;
647 m_DetectFromItem = false;
648 m_DetectFromTarget = false;
649 m_DetectFromPlayer = false;
650 }
651
653 {
654 if (ForceActionCheck(player))
655 {
656 m_SelectAction = m_ForcedActionData.m_Action;
657 return;
658 }
659
662 ActionBase action;
663 int i;
664
666 if (player && player.IsInVehicle())
667 {
668 HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
669 if (vehCommand)
670 {
671 Transport trans = vehCommand.GetTransport();
672 if (trans)
673 {
674 targetNew = new ActionTarget(trans, null, -1, vector.Zero, -1);
675 ForceActionTarget(targetNew);
676 }
677 }
678
679 if (!targetNew)
680 ClearForcedTarget();
681 }
682
683 target = m_ForcedTarget;
684 m_Target = m_ForcedTarget;
685
686 if (target && target.GetObject())
687 {
688 target.GetObject().GetActions(this.Type(), possibleActions);
689 if (possibleActions)
690 {
691 for (i = 0; i < possibleActions.Count(); i++)
692 {
693 action = ActionBase.Cast(possibleActions.Get(i));
695 {
697 return;
698 }
699 }
700 }
701 }
702 }
703
704 override ActionBase GetAction()
705 {
706 return m_SelectAction;
707 }
708}
709
711{
714 SetInput("UACarHorn");
715 m_InputType = ActionInputType.AIT_CONTINUOUS;
716 m_Priority = 101;
717 m_DetectFromItem = false;
718 m_DetectFromTarget = false;
719 m_DetectFromPlayer = false;
720 }
721}
722
724{
725 ref ActionTarget target_new;
726
728 {
729 SetInput("UAToggleHeadlight");
730 m_InputType = ActionInputType.AIT_SINGLE;
731 m_Priority = 100;
732 }
733
735 {
736 if (ForceActionCheck(player))
737 {
738 m_SelectAction = m_ForcedActionData.m_Action;
739 return;
740 }
741 //ForceActionTarget(player.m_PlayerLightManager.
742
745 ActionBase action;
746 int i;
747
749 if (player && !player.IsInVehicle())
750 {
751 Clothing headgear = Clothing.Cast(player.FindAttachmentBySlotName("Headgear"));
752 Clothing eyewear = Clothing.Cast(player.FindAttachmentBySlotName("Eyewear"));
753 //TODO - extend this to allow for a switchable control over all possible light sources (depth 0 or 1 only?)
754
755 if (headgear && headgear.GetLightSourceItem())
756 {
758 ForceActionTarget(target_new);
759 }
760 else if (eyewear && eyewear.GetLightSourceItem())
761 {
763 ForceActionTarget(target_new);
764 }
765 else
766 ClearForcedTarget();
767 }
768 else if (player && player.IsInVehicle())
769 {
770 HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
771 if (vehCommand)
772 {
773 Transport trans = vehCommand.GetTransport();
774 if (trans)
775 {
776 target_new = new ActionTarget(trans, null, -1, vector.Zero, -1);
777 ForceActionTarget(target_new);
778 }
779 }
780
781 if (!target_new)
782 ClearForcedTarget();
783 }
784
785 target = m_ForcedTarget;
786 m_Target = m_ForcedTarget;
787
788 if (target && target.GetObject())
789 {
790 target.GetObject().GetActions(this.Type(), possible_actions);
792 {
793 for (i = 0; i < possible_actions.Count(); i++)
794 {
795 action = ActionBase.Cast(possible_actions.Get(i));
797 {
799 return;
800 }
801 }
802 }
803 }
804 }
805
806 override ActionBase GetAction()
807 {
808 return m_SelectAction;
809 }
811
813{
814 ref ActionTarget target_new;
815
817 {
818 SetInput("UAToggleNVG");
819 m_InputType = ActionInputType.AIT_HOLDSINGLE;
820 m_Priority = 100;
821 }
822
824 {
825 if (ForceActionCheck(player))
826 {
827 m_SelectAction = m_ForcedActionData.m_Action;
828 return;
829 }
830 //ForceActionTarget(player.m_PlayerLightManager.
831
834 ActionBase action;
835 int i;
836
838 if (player)
839 {
840 Mich2001Helmet helmet = Mich2001Helmet.Cast(player.FindAttachmentBySlotName("Headgear"));
841 NVGHeadstrap headstrap = NVGHeadstrap.Cast(player.FindAttachmentBySlotName("Eyewear"));
842 if (helmet)
843 {
844 //m_MainItem = Headtorch_ColorBase.Cast(player.FindAttachmentBySlotName("Headgear"));
845 target_new = new ActionTarget(helmet, null, -1, vector.Zero, -1);
846 ForceActionTarget(target_new);
847 }
848 else if (headstrap)
849 {
851 ForceActionTarget(target_new);
852 }
853 else
854 ClearForcedTarget();
855 }
856
857 target = m_ForcedTarget;
858 m_Target = m_ForcedTarget;
859
860 if (target && target.GetObject())
861 {
862 target.GetObject().GetActions(this.Type(), possible_actions);
864 {
865 for (i = 0; i < possible_actions.Count(); i++)
866 {
867 action = ActionBase.Cast(possible_actions.Get(i));
869 {
871 return;
872 }
873 }
874 }
875 }
876 }
877
878 override ActionBase GetAction()
879 {
880 return m_SelectAction;
881 }
882};
883
892
901
903{
905 {
906 //SetInput("UAReloadMagazine");
907 m_InputType = ActionInputType.AIT_NOINPUTCONTROL;
908 }
909};
910
912{
914 {
915 //SetInput("UAReloadMagazine");
916 m_InputType = ActionInputType.AIT_INVENTORYINPUT;
917 }
918};
919
923
int m_ConditionMask
Definition ActionBase.c:60
bool HasTarget()
Definition ActionBase.c:210
enum ActionConditionMask m_MainItem
void SetInput(ActionInput ai)
Definition ActionBase.c:186
ref ActionTarget m_Target
Definition ActionBase.c:17
void _GetSelectedActions(Object action_source_object, out array< ActionBase > select_actions_all, out bool has_any_action_target)
void ContinuousDefaultActionInput(PlayerBase player)
int m_selectedActionIndex
enum ActionInputType m_Action
override array< ActionBase > GetPossibleActions()
override void ForceAction(ActionBase action, ActionTarget target, ItemBase item)
NoIndicationActionInputBase m_SelectAction
override ActionBase GetPossibleAction()
void StandardActionInput(PlayerBase player)
override ActionBase GetAction()
override void ActionsSelectReset()
ActionInputType
Definition ActionInput.c:2
@ AIT_SINGLE
Definition ActionInput.c:4
@ AIT_CONTINUOUS
Definition ActionInput.c:3
@ AIT_DOUBLECLICK
Definition ActionInput.c:5
@ AIT_INVENTORYINPUT
Definition ActionInput.c:9
@ AIT_HOLDSINGLE
Definition ActionInput.c:6
@ AIT_NOINPUTCONTROL
Definition ActionInput.c:8
@ AIT_CLICKCONTINUOUS
Definition ActionInput.c:7
override int GetPossibleActionsCount()
override void SelectNextAction()
override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
override void SelectPrevAction()
override int GetPossibleActionIndex()
ActionInput m_SelectActions
ToggleLightsActionInput CarHornLongActionInput
ItemBase m_Item
Definition ActionInput.c:16
ref ActionTarget m_Target
Definition ActionInput.c:15
class ActionTargets ActionTarget
int m_Priority
proto string ToString()
DayZPlayer m_Player
Definition Hand_Events.c:42
string Type
proto native UAInputAPI GetUApi()
void ClearForcedTarget()
UAInput GetUAInput()
Definition ActionInput.c:92
void ActionInput()
Definition ActionInput.c:43
bool m_DetectFromItem
Definition ActionInput.c:24
void SetInput(string input_name)
Definition ActionInput.c:74
bool IsActive()
bool m_DetectFromPlayer
Definition ActionInput.c:26
int GetPossibleActionsCount()
void ActionsSelectReset()
void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
void Update()
void OnActionEnd()
ref ActionTarget m_ForcedTarget
Definition ActionInput.c:33
void SetEnablity(bool value)
Definition ActionInput.c:69
bool m_JustActivate
Definition ActionInput.c:28
array< ActionBase > GetPossibleActions()
bool HasTarget()
void OnActionStart()
void SelectPrevAction()
void ForceActionTarget(ActionTarget target)
ActionBase GetPossibleAction()
int m_ConditionMask
Definition ActionInput.c:39
bool HasInput()
UAIDWrapper m_input
Definition ActionInput.c:21
void ClearForcedAction()
void SelectNextAction()
int GetPossibleActionIndex()
ActionBase GetAction()
int GetPriority()
ref ForcedActionData m_ForcedActionData
Definition ActionInput.c:35
ItemBase m_MainItem
Definition ActionInput.c:38
bool m_DetectFromTarget
Definition ActionInput.c:25
void Init(PlayerBase player, ActionManagerClient am)
Definition ActionInput.c:60
bool WasEnded()
int GetInputType()
Definition ActionInput.c:87
void ForceAction(ActionBase action, ActionTarget target, ItemBase item)
ItemBase GetUsedMainItem()
bool m_HasTarget
Definition ActionInput.c:29
ref ActionTarget m_Target
Definition ActionInput.c:37
bool ForceActionCheck(PlayerBase player)
ActionTarget GetUsedActionTarget()
bool JustActivate()
Definition ActionInput.c:97
PlayerBase m_Player
Definition ActionInput.c:31
void CarHornShortActionInput(PlayerBase player)
override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
ref ActionTarget targetNew
override ActionBase GetAction()
void ContinuousInteractActionInput(PlayerBase player)
void ContinuousWeaponManipulationActionInput(PlayerBase player)
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:143
void DefaultActionInput(PlayerBase player)
override bool WasEnded()
override void OnActionStart()
void DropActionInput(PlayerBase player)
void ExternalControlledActionInput(PlayerBase player)
void InteractActionInput(PlayerBase player)
override void OnActionStart()
override bool WasEnded()
void InventoryOnlyActionInput(PlayerBase player)
static bool IsActionLogEnable()
Definition Debug.c:719
void NoIndicationActionInputBase(PlayerBase player)
override ActionBase GetPossibleAction()
override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
override ActionBase GetAction()
override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
ref ActionTarget target_new
override ActionBase GetAction()
void ToggleLightsActionInput(PlayerBase player)
ref ActionTarget target_new
void ToggleNVGActionInput(PlayerBase player)
override ActionBase GetAction()
override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
proto native UAInput InputP()
void WeaponManipulationActionInput(PlayerBase player)
static const vector Zero
Definition EnConvert.c:110