Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AICalculateCoverQueryProps_CombatMove.c
Go to the documentation of this file.
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
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.")]
17
18
19 //------------------------------------------------------------------------------------------------
20 override void OnInit(AIAgent owner)
21 {
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
39
40 if (!rq)
41 return SCR_AIErrorMessages.NodeErrorCombatMoveRequest(this, owner, rqBase);
42
43 vector myPos = ownerEntity.GetOrigin();
44
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
95
96 return ENodeResult.SUCCESS;
97 }
98
99 //---------------------------------------------------------------
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 = {
113 };
114 override TStringArray GetVariablesIn() { return s_aVarsIn; }
115
116 protected static ref TStringArray s_aVarsOut = {
118 };
120}
proto external vector GetOrigin()
Definition Math.c:13
proto void SetVariableOut(string name, void val)
proto bool GetVariableIn(string name, out void val)
vector ResolveThreatPos(vector myPos, SCR_AICombatMoveRequest_Move request)
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
const int MAX_COVERS_HIGH_PRIORITY
const float NAVMESH_AREA_COST_SCALE
const vector NEAREST_POLY_HALF_EXTEND
ENodeResult
Definition ENodeResult.c:13
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385