Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LoiterUserAction.c
Go to the documentation of this file.
2 {
3  NONE,
4  SIT,
8  LOITERING,
10 }
11 
12 class SCR_LoiterUserAction: SCR_UserActionWithOccupancy
13 {
14  [Attribute( defvalue: "0", uiwidget: UIWidgets.EditBox, desc: "Provide index of related SmartActionSentinel" )]
15  protected int m_iSmartActionId;
16 
17  protected vector m_vActionTransform[4];
19 
20  override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
21  {
22  if (!GetGame().InPlayMode())
23  return;
24  array<Managed> aComponents = {};
25  pOwnerEntity.FindComponents(SCR_AISmartActionSentinelComponent, aComponents);
26  if (m_iSmartActionId > aComponents.Count() - 1)
27  Print("Invalid SmartAction id!",LogLevel.ERROR);
28  SCR_AISmartActionSentinelComponent smartAction = SCR_AISmartActionSentinelComponent.Cast(aComponents[m_iSmartActionId]);
29  if (smartAction)
30  {
31  vector mat[4];
32  pOwnerEntity.GetWorldTransform(mat);
33  vector desiredPos = mat[3] + smartAction.GetActionOffset().Multiply3(mat); // position of the action
34  vector desiredLookPos = mat[3] + smartAction.GetLookPosition().Multiply3(mat); // position to rotate to
35  vector actionEntityUp = mat[1]; // Up vector of entity that owns the action
36 
37  Math3D.DirectionAndUpMatrix(desiredLookPos - desiredPos, actionEntityUp, m_vActionTransform); // now I have rotation of entity to look towards desiredLookPos
38  m_vActionTransform[3] = desiredPos; // standing at desired desiredPos
39  m_eLoiteringType = LeaningTypeToLoiteringType(smartAction.GetLeaningType());
40  }
41  else
42  pOwnerEntity.GetWorldTransform(m_vActionTransform);
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  override void StartAction(IEntity pUserEntity)
47  {
49  if (!contr)
50  return;
51  contr.StartLoitering(m_eLoiteringType, false, true, true, m_vActionTransform);
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  override void StopAction(IEntity pUserEntity)
56  {
58  if (!contr)
59  return;
60  contr.StopLoitering(false);
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  override bool CanBeShownScript(IEntity user)
65  {
66  return true;
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  override bool CanBePerformedScript(IEntity user)
71  {
72  return !m_Occupant || m_Occupant == user;
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  override bool GetActionNameScript(out string outName)
77  {
78  outName = ("#AR-UserAction_Loiter");
79  return true;
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  override bool HasLocalEffectOnlyScript()
84  {
85  return true;
86  }
87 
88  //------------------------------------------------------------------------------------------------
90  {
91  switch (leaning)
92  {
93  case ELeaningType.NONE:
94  {
95  return ELoiteringType.SIT;
96  };
97  case ELeaningType.LEFT:
98  {
99  return ELoiteringType.LEAN_LEFT;
100  };
101  case ELeaningType.RIGHT:
102  {
103  return ELoiteringType.LEAN_RIGHT;
104  };
105  }
106  return ELoiteringType.NONE;
107  }
108 }
LOITERING
LOITERING
Definition: SCR_LoiterUserAction.c:7
LEAN_LEFT
LEAN_LEFT
Definition: SCR_LoiterUserAction.c:4
PUSHUPS
PUSHUPS
Definition: SCR_LoiterUserAction.c:9
m_vActionTransform
protected vector m_vActionTransform[4]
Definition: SCR_LoiterUserAction.c:17
ELoiteringType
ELoiteringType
Definition: SCR_LoiterUserAction.c:1
CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition: SCR_LoiterUserAction.c:64
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition: SCR_LoiterUserAction.c:70
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition: SCR_LoiterUserAction.c:20
HasLocalEffectOnlyScript
override bool HasLocalEffectOnlyScript()
Definition: SCR_LoiterUserAction.c:83
SIT
SIT
Definition: SCR_LoiterUserAction.c:3
Attribute
enum ELoiteringType Attribute(defvalue:"0", uiwidget:UIWidgets.EditBox, desc:"Provide index of related SmartActionSentinel")] protected int m_iSmartActionId
SCR_UserActionWithOccupancy
Definition: SCR_UserActionWithOccupancy.c:1
LEAN_RIGHT
LEAN_RIGHT
Definition: SCR_LoiterUserAction.c:5
SMOKING
SMOKING
Definition: SCR_LoiterUserAction.c:6
StopAction
override void StopAction(IEntity pUserEntity)
Definition: SCR_LoiterUserAction.c:55
StartAction
override void StartAction(IEntity pUserEntity)
Definition: SCR_LoiterUserAction.c:46
LeaningTypeToLoiteringType
ELoiteringType LeaningTypeToLoiteringType(ELeaningType leaning)
Definition: SCR_LoiterUserAction.c:89
m_eLoiteringType
protected ELoiteringType m_eLoiteringType
Definition: SCR_LoiterUserAction.c:18
GetActionNameScript
override bool GetActionNameScript(out string outName)
Definition: SCR_LoiterUserAction.c:76
NONE
NONE
Definition: SCR_LoiterUserAction.c:2