4 protected static const string PORT_POSITION =
"Position";
7 protected static const string PORT_COMPLETE_ACTION =
"CompleteAction";
9 protected SCR_AICombatMoveState m_State;
12 override void OnInit(AIAgent owner)
14 SCR_AIUtilityComponent utility = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
16 m_State = utility.m_CombatMoveState;
21 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
24 return ENodeResult.FAIL;
27 GetVariableIn(PORT_POSITION, threatPos);
28 if (threatPos == vector.Zero)
29 return ENodeResult.FAIL;
31 bool completeAction =
false;
32 CombatMoveLogic(threatPos, completeAction);
34 SetVariableOut(PORT_COMPLETE_ACTION, completeAction);
36 return ENodeResult.SUCCESS;
40 void CombatMoveLogic(vector threatPos, out
bool outCompleteAction)
45 bool completeAction =
false;
47 if (ConditionPushMoveRequest(threatPos))
51 rq.m_eReason = SCR_EAICombatMoveReason.MOVE_FROM_DANGER;
53 rq.m_vTargetPos = threatPos;
54 rq.m_vMovePos = rq.m_vTargetPos;
55 rq.m_bTryFindCover =
true;
56 rq.m_bUseCoverSearchDirectivity =
true;
57 rq.m_bCheckCoverVisibility =
false;
58 rq.m_bFailIfNoCover =
false;
62 rq.m_fCoverSearchDistMax = 15;
63 rq.m_fCoverSearchDistMin = 4;
64 rq.m_fMoveDistance = rq.m_fCoverSearchDistMax;
65 rq.m_eDirection = SCR_EAICombatMoveDirection.BACKWARD;
66 rq.m_fCoverSearchSectorHalfAngleRad = Math.PI_HALF;
68 rq.m_bAimAtTarget =
false;
69 rq.m_bAimAtTargetEnd =
true;
73 else if (
m_State.m_bInCover &&
m_State.IsAssignedCoverValid() && IsCoverSafeAgainstGrenade(
m_State.GetAssignedCover(), threatPos))
76 completeAction =
true;
80 outCompleteAction = completeAction;
84 bool ConditionPushMoveRequest(vector tgtPos)
96 if (rqMove && rqMove.m_eReason == SCR_EAICombatMoveReason.MOVE_FROM_DANGER)
108 if (!IsCoverSafeAgainstGrenade(
m_State.GetAssignedCover(), tgtPos))
123 bool IsCoverSafeAgainstGrenade(notnull
SCR_AICoverLock coverLock, vector threatPos)
125 float coverDistToThreatSq = vector.DistanceSq(threatPos, coverLock.m_vCoverPos);
128 if (coverDistToThreatSq < 3*3)
132 float cosAngleCoverToTgt =
m_State.GetAssignedCover().CosAngleToThreat(threatPos);
133 return cosAngleCoverToTgt > 0.707;
137 protected static ref TStringArray s_aVarsIn = { PORT_POSITION };
138 override TStringArray GetVariablesIn() {
return s_aVarsIn; }
140 protected static ref TStringArray s_aVarsOut = { PORT_COMPLETE_ACTION };
141 override TStringArray GetVariablesOut() {
return s_aVarsOut; }
143 override bool VisibleInPalette() {
return true; }