Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGetAllowedLookRange.c
Go to the documentation of this file.
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 protected static const float MOVING_IN_VEHICLE_ANGLE = 15;
8
9 // Used to test whether our vehicle is moving or not
10 protected const float MIN_SPEED_MPS_SQ = 0.5 * 0.5;
11
12 [Attribute("20", UIWidgets.EditBox, "Distance for looking" )]
13 protected float m_fDistance;
14
15
16
19
20 //----------------------------------------------------------------------------------------------------------------------------------------
21 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
22 {
23 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(owner.GetControlledEntity());
24 if (!character)
25 return ENodeResult.FAIL;
26 if (!character.IsInVehicle())
27 return ENodeResult.FAIL;
28 CompartmentAccessComponent compAcc = character.GetCompartmentAccessComponent();
29 if (!compAcc)
30 return ENodeResult.FAIL;
31 BaseCompartmentSlot comp = compAcc.GetCompartment();
32 if (!comp)
33 return ENodeResult.FAIL;
34 vector forwardVec;
35 IEntity vehicle = comp.GetVehicle();
36 forwardVec = vehicle.GetTransformAxis(2).Normalized();
37 float angleBound;
38 bool isFreeLook = true;
39
40 bool isMoving = false;
41 Physics phy = vehicle.GetPhysics();
42 bool phyActive = phy.IsActive(); // delete
43 vector phyVelo = phy.GetVelocity(); // delete
44 if (phy && phy.IsActive())
45 isMoving = phy.GetVelocity().LengthSq() > MIN_SPEED_MPS_SQ;
46
48 if (turret)
49 {
50 TurretControllerComponent turretController = TurretControllerComponent.Cast(turret.GetController());
51 if (!turretController)
52 return ENodeResult.FAIL;
53 TurretComponent turretComponent = turretController.GetTurretComponent();
54 if (!turretComponent)
55 return ENodeResult.FAIL;
56
57
58 vector aimingLimitHoriz, aimingLimitVert;
59 turretComponent.GetAimingLimits(aimingLimitHoriz,aimingLimitVert);
60
61 if (turretComponent.HasMoveableBase())
62 aimingLimitHoriz = Vector(-180, 180, 0);
63
64 if (isMoving)
65 {
66 // When moving, look forward
67 angleBound = Math.Min(aimingLimitHoriz[1], MOVING_IN_VEHICLE_ANGLE);
68 }
69 else
70 angleBound = aimingLimitHoriz[1];
71
72 isFreeLook = false;
73 }
74 else
75 {
76 angleBound = FREE_LOOK_ANGLE;
77 }
78
79 SetVariableOut(LOOK_AXIS_PORT, comp.GetPosition() + forwardVec * m_fDistance);
80 SetVariableOut(RANGE_PORT, angleBound);
81 SetVariableOut(IS_FREE_LOOK, isFreeLook);
82
83 return ENodeResult.SUCCESS;
84 }
85
86 //----------------------------------------------------------------------------------------------------------------------------------------
87 static override bool VisibleInPalette() { return true; }
88
89 //----------------------------------------------------------------------------------------------------------------------------------------
90 static override string GetOnHoverDescription()
91 {
92 return "GetAllowedLookRange: Gets the range of look for character in vehicle";
93 }
94};
proto external Physics GetPhysics()
proto external vector GetTransformAxis(int axis)
See IEntity::GetTransformAxis.
Definition Math.c:13
proto void SetVariableOut(string name, void val)
static override bool VisibleInPalette()
static ref TStringArray s_aVarsOut
override TStringArray GetVariablesOut()
static const float MOVING_IN_VEHICLE_ANGLE
static override string GetOnHoverDescription()
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
ENodeResult
Definition ENodeResult.c:13
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385
proto native vector Vector(float x, float y, float z)