Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
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
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
17
protected
static
ref
TStringArray
s_aVarsOut
= {
LOOK_AXIS_PORT
,
RANGE_PORT
,
IS_FREE_LOOK
};
18
override
TStringArray
GetVariablesOut
() {
return
s_aVarsOut
; }
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
47
TurretCompartmentSlot
turret =
TurretCompartmentSlot
.Cast(comp);
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
};
AITaskScripted
Definition
AITaskScripted.c:13
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
BaseCompartmentSlot::GetVehicle
IEntity GetVehicle()
Definition
BaseCompartmentSlot.c:83
IEntity
Definition
IEntity.c:13
IEntity::GetPhysics
proto external Physics GetPhysics()
IEntity::GetTransformAxis
proto external vector GetTransformAxis(int axis)
See IEntity::GetTransformAxis.
Math
Definition
Math.c:13
Node::SetVariableOut
proto void SetVariableOut(string name, void val)
Physics
Definition
Physics.c:22
SCR_AIGetAllowedLookRange
Definition
SCR_AIGetAllowedLookRange.c:2
SCR_AIGetAllowedLookRange::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIGetAllowedLookRange.c:87
SCR_AIGetAllowedLookRange::IS_FREE_LOOK
static const string IS_FREE_LOOK
Definition
SCR_AIGetAllowedLookRange.c:5
SCR_AIGetAllowedLookRange::m_fDistance
float m_fDistance
Definition
SCR_AIGetAllowedLookRange.c:13
SCR_AIGetAllowedLookRange::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AIGetAllowedLookRange.c:17
SCR_AIGetAllowedLookRange::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AIGetAllowedLookRange.c:18
SCR_AIGetAllowedLookRange::FREE_LOOK_ANGLE
static const float FREE_LOOK_ANGLE
Definition
SCR_AIGetAllowedLookRange.c:6
SCR_AIGetAllowedLookRange::MOVING_IN_VEHICLE_ANGLE
static const float MOVING_IN_VEHICLE_ANGLE
Definition
SCR_AIGetAllowedLookRange.c:7
SCR_AIGetAllowedLookRange::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AIGetAllowedLookRange.c:90
SCR_AIGetAllowedLookRange::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AIGetAllowedLookRange.c:21
SCR_AIGetAllowedLookRange::LOOK_AXIS_PORT
static const string LOOK_AXIS_PORT
Definition
SCR_AIGetAllowedLookRange.c:4
SCR_AIGetAllowedLookRange::RANGE_PORT
static const string RANGE_PORT
Definition
SCR_AIGetAllowedLookRange.c:3
SCR_AIGetAllowedLookRange::MIN_SPEED_MPS_SQ
const float MIN_SPEED_MPS_SQ
Definition
SCR_AIGetAllowedLookRange.c:10
TurretCompartmentSlot
Definition
TurretCompartmentSlot.c:13
TurretComponent
Definition
TurretComponent.c:13
TurretControllerComponent
Definition
TurretControllerComponent.c:13
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
TStringArray
array< string > TStringArray
Definition
Types.c:385
Vector
proto native vector Vector(float x, float y, float z)
scripts
Game
AI
ScriptedNodes
Vehicles
SCR_AIGetAllowedLookRange.c
Generated by
1.17.0