5 protected const static string PORT_COMBAT_MOVE_REQUEST =
"CombatMoveRequest";
8 protected const static string PORT_COVER_QUERY_PROPERTIES =
"CoverQueryProps";
10 protected ref CoverQueryProperties m_CoverQueryProps =
new CoverQueryProperties();
12 protected SCR_AICombatMoveState m_State;
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;
20 override void OnInit(AIAgent owner)
22 m_fMinCoverToTargetAngleCos = Math.Cos(Math.DEG2RAD * m_fMaxCoverToTargetAngleDeg);
24 SCR_AIUtilityComponent utilityComp = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
26 m_State = utilityComp.m_CombatMoveState;
30 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
32 IEntity ownerEntity = owner.GetControlledEntity();
34 return ENodeResult.FAIL;
37 GetVariableIn(PORT_COMBAT_MOVE_REQUEST, rqBase);
43 vector myPos = ownerEntity.GetOrigin();
45 CoverQueryProperties query = m_CoverQueryProps;
48 if (rq.m_eDirection == SCR_EAICombatMoveDirection.ANYWHERE)
51 query.m_vSectorDir = vector.Zero;
52 query.m_fScoreWeightDirection = 0;
53 query.m_fQuerySectorAngleCosMin = -1.0;
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);
63 if (rq.m_bUseCoverSearchDirectivity)
64 query.m_fScoreWeightDirection = 10.0;
66 query.m_fScoreWeightDirection = 0;
71 query.m_vSectorPos = myPos;
72 query.m_vAgentPos = myPos;
73 query.m_fSectorDistMin = rq.m_fCoverSearchDistMin;
74 query.m_fSectorDistMax = rq.m_fCoverSearchDistMax;
77 vector threatPos = ResolveThreatPos(myPos, rq);
78 query.m_vThreatPos = threatPos;
81 query.m_fScoreWeightDistance = 1.0;
84 query.m_fCoverHeightMin = 0;
85 query.m_fCoverHeightMax = 10.0;
86 query.m_fScoreWeightNavmeshRay = 2.0;
90 query.m_fCoverToThreatAngleCosMin = m_fMinCoverToTargetAngleCos;
91 query.m_bCheckVisibility = rq.m_bCheckCoverVisibility;
92 query.m_bSelectHighestScore =
false;
94 SetVariableOut(PORT_COVER_QUERY_PROPERTIES, query);
96 return ENodeResult.SUCCESS;
103 vector vToTarget = vector.Direction(myPos, request.m_vTargetPos).Normalized();
104 vector threatPos = request.m_vTargetPos - 1.2 * vToTarget;
109 override bool VisibleInPalette() {
return true; }
111 protected static ref TStringArray s_aVarsIn = {
112 PORT_COMBAT_MOVE_REQUEST
114 override TStringArray GetVariablesIn() {
return s_aVarsIn; }
116 protected static ref TStringArray s_aVarsOut = {
117 PORT_COVER_QUERY_PROPERTIES
119 override TStringArray GetVariablesOut() {
return s_aVarsOut; }