8 ref SCR_BTParamRef<BaseTarget> m_Target =
new SCR_BTParamRef<BaseTarget>(
SCR_AIActionTask.TARGET_PORT);
11 ref SCR_BTParam<float> m_fWaitTime =
new SCR_BTParam<float>(
"WaitTime");
14 SCR_AICombatComponent m_CombatComponent;
16 bool m_bSelected =
false;
19 protected static const float WAIT_TIME_UNEXPECTED = 0.25;
20 protected static const float WAIT_TIME_OVERTHREATENED = 0.8;
23 void InitParameters(
BaseTarget target,
float waitTime)
26 m_fWaitTime.Init(
this, waitTime);
30 override void OnActionSelected()
32 super.OnActionSelected();
34 EnableFriendlyFireCheck(
true);
38 override void OnActionDeselected()
40 super.OnActionDeselected();
41 EnableFriendlyFireCheck(
false);
45 override void OnActionCompleted()
47 super.OnActionCompleted();
48 EnableFriendlyFireCheck(
false);
52 override void OnActionFailed()
54 super.OnActionFailed();
55 EnableFriendlyFireCheck(
false);
59 override string GetActionDebugInfo()
61 return this.ToString() +
" attacking " +
m_Target.ValueToString();
67 InitParameters(target, 4);
72 SetPriority(PRIORITY_BEHAVIOR_ATTACK_NOT_SELECTED);
74 m_sBehaviorTree =
"AI/BehaviorTrees/Chimera/Soldier/Attack.bt";
77 SetIsUniqueInActionQueue(
false);
84 InitWaitTime(utility);
86 m_fWaitTime.m_Value = 0;
90 override float CustomEvaluate()
101 m_bUseCombatMove = !m_Utility.m_AIInfo.HasUnitState(EUnitState.IN_TURRET);
103 float targetScore = m_Utility.m_CombatComponent.m_WeaponTargetSelector.CalculateTargetScore(baseTarget);
105 if (baseTarget.IsEndangering() || baseTarget.GetTimeSinceEndangered() < SCR_AICombatComponent.TARGET_ENDANGERED_TIMEOUT_S)
106 targetScore *= SCR_AICombatComponent.ENDANGERING_TARGET_SCORE_MULTIPLIER;
108 if (targetScore >= SCR_AICombatComponent.TARGET_SCORE_HIGH_PRIORITY_ATTACK)
109 return PRIORITY_BEHAVIOR_ATTACK_HIGH_PRIORITY;
112 return PRIORITY_BEHAVIOR_ATTACK_SELECTED;
114 return PRIORITY_BEHAVIOR_ATTACK_NOT_SELECTED;
118 protected void InitWaitTime(SCR_AIUtilityComponent utility)
120 float threatMeasure = utility.m_ThreatSystem.GetThreatMeasure();
125 threatDelay = WAIT_TIME_UNEXPECTED;
129 threatDelay = WAIT_TIME_OVERTHREATENED;
137 float distance = vector.Distance(m_Utility.m_OwnerEntity.GetOrigin(),
m_Target.m_Value.GetLastSeenPosition());
140 m_fWaitTime.m_Value = threatDelay + distanceDelay;
143 void EnableFriendlyFireCheck(
bool enable)
145 if (m_Utility && m_Utility.m_PerceptionComponent)
146 m_Utility.m_PerceptionComponent.SetFriendlyFireCheck(enable);