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_AICalculateCoverQueryProps_CombatMove.c
Go to the documentation of this file.
1
class
SCR_AICalculateCoverQueryProps_CombatMove
:
AITaskScripted
2
{
3
//---------------------------------------------------------------
4
// Inputs
5
protected
const
static
string
PORT_COMBAT_MOVE_REQUEST
=
"CombatMoveRequest"
;
6
7
// Outputs
8
protected
const
static
string
PORT_COVER_QUERY_PROPERTIES
=
"CoverQueryProps"
;
9
10
protected
ref
CoverQueryProperties
m_CoverQueryProps
=
new
CoverQueryProperties
();
11
12
protected
SCR_AICombatMoveState
m_State
;
13
14
[
Attribute
(
"60.0"
,
UIWidgets
.EditBox,
"Max angle between cover dir. and dir. to target, in degrees."
)]
15
protected
float
m_fMaxCoverToTargetAngleDeg
;
16
protected
float
m_fMinCoverToTargetAngleCos
;
17
18
19
//------------------------------------------------------------------------------------------------
20
override
void
OnInit
(AIAgent owner)
21
{
22
m_fMinCoverToTargetAngleCos
=
Math
.Cos(
Math
.DEG2RAD *
m_fMaxCoverToTargetAngleDeg
);
23
24
SCR_AIUtilityComponent utilityComp = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
25
if
(utilityComp)
26
m_State
= utilityComp.m_CombatMoveState;
27
}
28
29
//---------------------------------------------------------------
30
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
31
{
32
IEntity
ownerEntity = owner.GetControlledEntity();
33
if
(!ownerEntity)
34
return
ENodeResult
.FAIL;
35
36
SCR_AICombatMoveRequestBase
rqBase;
37
GetVariableIn
(
PORT_COMBAT_MOVE_REQUEST
, rqBase);
38
SCR_AICombatMoveRequest_Move
rq =
SCR_AICombatMoveRequest_Move
.Cast(rqBase);
39
40
if
(!rq)
41
return
SCR_AIErrorMessages
.NodeErrorCombatMoveRequest(
this
, owner, rqBase);
42
43
vector
myPos = ownerEntity.
GetOrigin
();
44
45
CoverQueryProperties
query =
m_CoverQueryProps
;
46
47
// Resolve direction of query
48
if
(rq.m_eDirection == SCR_EAICombatMoveDirection.ANYWHERE)
49
{
50
// Query in circle, don't use direction
51
query.m_vSectorDir =
vector
.Zero;
52
query.m_fScoreWeightDirection = 0;
53
query.m_fQuerySectorAngleCosMin = -1.0;
54
}
55
else
56
{
57
// Directional query is used
58
// Query in sector
59
vector
queryDirection =
SCR_AICombatMoveUtils
.CalculateMoveDirection(rq.m_eDirection, myPos, rq.m_vMovePos);
60
query.m_vSectorDir = queryDirection;
61
query.m_fQuerySectorAngleCosMin =
Math
.Cos(rq.m_fCoverSearchSectorHalfAngleRad);
62
63
if
(rq.m_bUseCoverSearchDirectivity)
64
query.m_fScoreWeightDirection = 10.0;
65
else
66
query.m_fScoreWeightDirection = 0;
67
}
68
69
70
// Query sector properties
71
query.m_vSectorPos = myPos;
72
query.m_fSectorDistMin = rq.m_fCoverSearchDistMin;
73
query.m_fSectorDistMax = rq.m_fCoverSearchDistMax;
74
75
// Threat pos
76
vector
threatPos =
ResolveThreatPos
(myPos, rq);
77
query.m_vThreatPos = threatPos;
78
79
// Weight distance
80
query.m_fScoreWeightDistance = 1.0;
81
82
// Other
83
query.m_vNearestPolyHalfExtend =
SCR_AIFindCover
.
NEAREST_POLY_HALF_EXTEND
;
84
query.m_fNmAreaCostScale =
SCR_AIFindCover
.
NAVMESH_AREA_COST_SCALE
;
85
query.m_fCoverHeightMin = 0;
86
query.m_fCoverHeightMax = 10.0;
87
query.m_iMaxCoversToCheck =
SCR_AIFindCover
.
MAX_COVERS_HIGH_PRIORITY
;
88
89
90
query.m_fCoverToThreatAngleCosMin =
m_fMinCoverToTargetAngleCos
;
91
query.m_bCheckVisibility = rq.m_bCheckCoverVisibility;
92
query.m_bSelectHighestScore =
false
;
// Select lowest score cover (nearest)
93
94
SetVariableOut
(
PORT_COVER_QUERY_PROPERTIES
, query);
95
96
return
ENodeResult
.SUCCESS;
97
}
98
99
//---------------------------------------------------------------
100
vector
ResolveThreatPos
(
vector
myPos,
SCR_AICombatMoveRequest_Move
request)
101
{
102
// Move threat pos slightly closer to us, to prevent the cover test from hitting the target
103
vector
vToTarget =
vector
.Direction(myPos, request.m_vTargetPos).Normalized();
104
vector
threatPos = request.m_vTargetPos - 1.2 * vToTarget;
// ! Todo improve this, might not work against vehicles
105
return
threatPos;
106
}
107
108
//---------------------------------------------------------------
109
static
override
bool
VisibleInPalette
() {
return
true
; }
110
111
protected
static
ref
TStringArray
s_aVarsIn
= {
112
PORT_COMBAT_MOVE_REQUEST
113
};
114
override
TStringArray
GetVariablesIn
() {
return
s_aVarsIn
; }
115
116
protected
static
ref
TStringArray
s_aVarsOut
= {
117
PORT_COVER_QUERY_PROPERTIES
118
};
119
override
TStringArray
GetVariablesOut
() {
return
s_aVarsOut
; }
120
}
AITaskScripted
Definition
AITaskScripted.c:13
CoverQueryProperties
Definition
CoverQueryProperties.c:2
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
Math
Definition
Math.c:13
Node::SetVariableOut
proto void SetVariableOut(string name, void val)
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AICalculateCoverQueryProps_CombatMove
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:2
SCR_AICalculateCoverQueryProps_CombatMove::ResolveThreatPos
vector ResolveThreatPos(vector myPos, SCR_AICombatMoveRequest_Move request)
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:100
SCR_AICalculateCoverQueryProps_CombatMove::PORT_COVER_QUERY_PROPERTIES
static const string PORT_COVER_QUERY_PROPERTIES
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:8
SCR_AICalculateCoverQueryProps_CombatMove::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:114
SCR_AICalculateCoverQueryProps_CombatMove::OnInit
override void OnInit(AIAgent owner)
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:20
SCR_AICalculateCoverQueryProps_CombatMove::PORT_COMBAT_MOVE_REQUEST
static const string PORT_COMBAT_MOVE_REQUEST
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:5
SCR_AICalculateCoverQueryProps_CombatMove::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:116
SCR_AICalculateCoverQueryProps_CombatMove::m_State
SCR_AICombatMoveState m_State
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:12
SCR_AICalculateCoverQueryProps_CombatMove::m_fMinCoverToTargetAngleCos
float m_fMinCoverToTargetAngleCos
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:16
SCR_AICalculateCoverQueryProps_CombatMove::m_CoverQueryProps
ref CoverQueryProperties m_CoverQueryProps
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:10
SCR_AICalculateCoverQueryProps_CombatMove::m_fMaxCoverToTargetAngleDeg
float m_fMaxCoverToTargetAngleDeg
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:15
SCR_AICalculateCoverQueryProps_CombatMove::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:119
SCR_AICalculateCoverQueryProps_CombatMove::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:109
SCR_AICalculateCoverQueryProps_CombatMove::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:30
SCR_AICalculateCoverQueryProps_CombatMove::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AICalculateCoverQueryProps_CombatMove.c:111
SCR_AICombatMoveRequest_Move
Definition
SCR_AICombatMoveRequest.c:88
SCR_AICombatMoveRequestBase
Definition
SCR_AICombatMoveRequest.c:46
SCR_AICombatMoveUtils
Definition
SCR_AICombatMoveUtils.c:6
SCR_AIErrorMessages
Definition
NodeError.c:31
SCR_AIFindCover
Definition
SCR_AIFindCover.c:2
SCR_AIFindCover::MAX_COVERS_HIGH_PRIORITY
const int MAX_COVERS_HIGH_PRIORITY
Definition
SCR_AIFindCover.c:19
SCR_AIFindCover::NAVMESH_AREA_COST_SCALE
const float NAVMESH_AREA_COST_SCALE
Definition
SCR_AIFindCover.c:21
SCR_AIFindCover::NEAREST_POLY_HALF_EXTEND
const vector NEAREST_POLY_HALF_EXTEND
Definition
SCR_AIFindCover.c:18
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
scripts
Game
AI
Movement
SCR_AICalculateCoverQueryProps_CombatMove.c
Generated by
1.17.0