7 void PerformReaction(notnull SCR_AIUtilityComponent utility, notnull
SCR_AIThreatSystem threatSystem,
BaseTarget baseTarget, vector lastSeenPosition) {}
14 void PerformReaction(notnull SCR_AIUtilityComponent utility,
BaseTarget prevTarget,
BaseTarget newTarget);
27 IEntity targetEntity = baseTarget.GetTargetEntity();
29 utility.m_LookAction.LookAt(targetEntity,
SCR_AILookAction.PRIO_UNKNOWN_TARGET, 2.0);
36 override void PerformReaction(notnull SCR_AIUtilityComponent utility, notnull
SCR_AIThreatSystem threatSystem,
BaseTarget baseTarget, vector lastSeenPosition)
45 utility.AddAction(behavior);
57 AddDebugMessage(utility,
string.Format(
"Prev Target: %1, New Target: %2", prevTarget, newTarget));
62 ReportPreviousTarget(utility, prevTarget, newTarget);
70 CreateAttackActionForTarget(utility, newTarget, prevTarget);
72 IEntity targetEntity = newTarget.GetTargetEntity();
74 utility.m_LookAction.LookAt(targetEntity,
SCR_AILookAction.PRIO_ENEMY_TARGET);
79 protected void CreateAttackActionForTarget(notnull SCR_AIUtilityComponent utility, notnull
BaseTarget target,
BaseTarget prevTarget)
82 AddDebugMessage(utility,
"CreateAttackActionForTarget()");
85 IEntity targetEntity = target.GetTargetEntity();
93 utility.AddAction(behavior);
96 if (!utility.m_AIInfo.HasUnitState(EUnitState.IN_TURRET))
97 utility.WrapBehaviorOutsideOfVehicle(behavior);
102 protected void ReportPreviousTarget(notnull SCR_AIUtilityComponent utility, notnull
BaseTarget prevTarget,
BaseTarget newTarget)
105 AddDebugMessage(utility,
"ReportPreviousTarget()");
108 IEntity targetEntity = prevTarget.GetTargetEntity();
115 AddDebugMessage(utility,
" Target is now friendly");
118 else if (!targetEntity)
121 AddDebugMessage(utility,
" Target entity is null, not reporting");
124 else if (prevTarget.IsDisarmed() || (damageMgr && damageMgr.IsDestroyed()))
128 AddDebugMessage(utility,
" Target is destroyed or disarmed");
132 if (!utility.m_CommsHandler.CanBypass())
135 utility.m_CommsHandler.AddRequest(rq);
138 else if (!newTarget &&
139 (prevTarget.GetTimeSinceSeen() > SCR_AICombatComponent.TARGET_MAX_LAST_SEEN) &&
140 (prevTarget.GetUnitType() & utility.m_CombatComponent.GetUnitTypesCanAttack() != 0))
144 AddDebugMessage(utility,
string.Format(
" Target is lost, time since seen: %1", prevTarget.GetTimeSinceSeen()));
148 if (!utility.m_CommsHandler.CanBypass())
151 utility.m_CommsHandler.AddRequest(rq);
157 protected void AddDebugMessage(notnull SCR_AIUtilityComponent utility,
string str, LogLevel logLevel = LogLevel.NORMAL)
159 SCR_AIInfoBaseComponent infoComp = utility.m_AIInfo;
160 infoComp.AddDebugMessage(
"SCR_AITargetReaction_SelectedTargetChanged: " + str, msgType:
EAIDebugMsgType.COMBAT, logLevel);