Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetAllowedLookRange.c
Go to the documentation of this file.
1 class SCR_AIGetAllowedLookRange : AITaskScripted
2 {
3  protected static const string RANGE_PORT = "AngularRangeDeg";
4  protected static const string LOOK_AXIS_PORT = "LookAxis";
5  protected static const string IS_FREE_LOOK = "IsFreeLook";
6  protected static const float FREE_LOOK_ANGLE = 30.0;
7 
8  [Attribute("20", UIWidgets.EditBox, "Distance for looking" )]
9  protected float m_fDistance;
10 
11 
12 
13  protected static ref TStringArray s_aVarsOut = { LOOK_AXIS_PORT, RANGE_PORT, IS_FREE_LOOK };
14  override TStringArray GetVariablesOut() { return s_aVarsOut; }
15 
16  //----------------------------------------------------------------------------------------------------------------------------------------
17  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
18  {
19  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(owner.GetControlledEntity());
20  if (!character)
21  return ENodeResult.FAIL;
22  if (!character.IsInVehicle())
23  return ENodeResult.FAIL;
24  CompartmentAccessComponent compAcc = character.GetCompartmentAccessComponent();
25  if (!compAcc)
26  return ENodeResult.FAIL;
27  BaseCompartmentSlot comp = compAcc.GetCompartment();
28  if (!comp)
29  return ENodeResult.FAIL;
30  vector aimingLimitHoriz, aimingLimitVert, forwardVec;
31  IEntity vehicle = comp.GetVehicle();
32  forwardVec = vehicle.GetTransformAxis(2).Normalized();
33  float angleBound;
34  bool isFreeLook = true;
35 
36  TurretCompartmentSlot turret = TurretCompartmentSlot.Cast(comp);
37  if (turret)
38  {
39  TurretControllerComponent turretController = TurretControllerComponent.Cast(turret.GetController());
40  if (!turretController)
41  return ENodeResult.FAIL;
42  TurretComponent turretComponent = turretController.GetTurretComponent();
43  if (!turretComponent)
44  return ENodeResult.FAIL;
45  turretComponent.GetAimingLimits(aimingLimitHoriz,aimingLimitVert);
46  angleBound = aimingLimitHoriz[1];
47  isFreeLook = false;
48  }
49  else
50  {
51  angleBound = FREE_LOOK_ANGLE;
52  }
53 
54  SetVariableOut(LOOK_AXIS_PORT, comp.GetPosition() + forwardVec * m_fDistance);
55  SetVariableOut(RANGE_PORT, angleBound);
56  SetVariableOut(IS_FREE_LOOK, isFreeLook);
57 
58  return ENodeResult.SUCCESS;
59  }
60 
61  //----------------------------------------------------------------------------------------------------------------------------------------
62  override bool VisibleInPalette() { return true; }
63 
64  //----------------------------------------------------------------------------------------------------------------------------------------
65  override string GetOnHoverDescription()
66  {
67  return "GetAllowedLookRange: Gets the range of look for character in vehicle";
68  }
69 };
m_fDistance
float m_fDistance
Definition: SCR_AIGroupTargetCluster.c:38
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
Attribute
typedef Attribute
Post-process effect of scripted camera.
TurretCompartmentSlot
Definition: TurretCompartmentSlot.c:12
SCR_AIGetAllowedLookRange
Definition: SCR_AIGetAllowedLookRange.c:1
TurretControllerComponent
Definition: TurretControllerComponent.c:12