7 static const float SNIPER_MIN_DISTANCE = 70.0;
8 static const float SNIPER_MAX_DISTANCE = 180.0;
9 static const float SNIPER_DURATION_S = 3*60.0;
11 ref SCR_BTParam<vector> m_vTargetPosition =
new SCR_BTParam<vector>(
"TargetPos");
12 ref SCR_BTParam<float> m_fMinDistance =
new SCR_BTParam<float>(
"MinDist");
13 ref SCR_BTParam<float> m_fMaxDistance =
new SCR_BTParam<float>(
"MaxDist");
14 ref SCR_BTParam<float> m_fDuration_s =
new SCR_BTParam<float>(
"Duration_s");
19 void InitParameters(vector targetPos,
float minDistance,
float maxDistance,
float duration)
21 m_vTargetPosition.Init(
this, targetPos);
22 m_fMinDistance.Init(
this, minDistance);
23 m_fMaxDistance.Init(
this, maxDistance);
24 m_fDuration_s.Init(
this, duration);
28 float minDistance,
float maxDistance,
EAIUnitType targetUnitType,
float duration,
float priorityLevel = PRIORITY_LEVEL_NORMAL)
30 InitParameters(targetPos, minDistance, maxDistance, duration);
34 m_sBehaviorTree =
"{905124EEBF36D180}AI/BehaviorTrees/Chimera/Soldier/FindFirePosition.bt";
35 SetPriority(PRIORITY_BEHAVIOR_FIND_FIRE_POSITION);
41 override float CustomEvaluate()
44 if (m_Utility.m_CombatComponent.GetCurrentTarget())
54 override void OnActionSelected()
56 super.OnActionSelected();
77 return ENodeResult.FAIL;
82 return ENodeResult.FAIL;
84 vector targetPos = behavior.m_vTargetPosition.m_Value;
85 IEntity myEntity = owner.GetControlledEntity();
86 vector myPos = myEntity.GetOrigin();
88 vector vFromTarget = vector.Direction(targetPos, myPos);
90 float distanceToTarget = vFromTarget.Length();
91 vector vDirFromTarget = vFromTarget.Normalized();
92 vDirFromTarget.Normalize();
95 float minDist = behavior.m_fMinDistance.m_Value;
96 float maxDist = behavior.m_fMaxDistance.m_Value;
97 if (distanceToTarget > minDist &&
98 distanceToTarget < maxDist)
105 float randomDistance = Math.RandomFloat(10, 20);
106 float dirMultiplier = 1;
107 if (distanceToTarget > maxDist)
113 vector nextMovePosCenter = myPos + dirMultiplier * randomDistance * vDirFromTarget;
119 return ENodeResult.SUCCESS;
133 override TStringArray GetVariablesOut() {
return s_aVarsOut; }
135 override bool VisibleInPalette() {
return true; }