6 ref SCR_BTParam<vector> m_DangerPosition =
new SCR_BTParam<vector>(
"DangerPosition");
7 ref SCR_BTParam<IEntity> m_DangerEntity =
new SCR_BTParam<IEntity>(
"DangerEntity");
8 ref SCR_BTParam<ECharacterStance> m_Stance =
new SCR_BTParam<ECharacterStance>(
"CharacterStance");
9 ref SCR_BTParam<EMovementType> m_MovementType =
new SCR_BTParam<EMovementType>(
"MovementType");
12 void InitParameters(IEntity dangerEntity, vector dangerPos)
14 m_DangerEntity.Init(
this, dangerEntity);
15 m_DangerPosition.Init(
this, dangerPos);
23 SetPriority(PRIORITY_BEHAVIOR_MOVE_FROM_DANGER);
24 InitParameters(dangerEntity, dangerPos);
28 m_DangerPosition.m_Value = dangerEntity.GetOrigin();
31 m_sBehaviorTree =
"{D12937CF422B639B}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_Position.bt"
36 static bool ExistsBehaviorForEntity(SCR_AIUtilityComponent utility, IEntity ent)
39 if (behavior && behavior.m_DangerEntity.m_Value == ent)
51 SetPriority(PRIORITY_BEHAVIOR_MOVE_FROM_UNKNOWN_FIRE);
54 m_bIsInterruptable =
false;
60 override float CustomEvaluate()
64 if (m_Utility.m_CombatComponent.GetCurrentTarget())
74 override void OnActionSelected()
76 super.OnActionSelected();
78 if (!m_Utility.m_CommsHandler.CanBypass())
81 m_Utility.m_CommsHandler.AddRequest(rq);
89 static const float DISTANCE_MAX_SQ = 13*13;
100 m_sBehaviorTree =
"{478811D2295EAF3E}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_Grenade.bt";
107 m_bUseCombatMove =
true;
115 vector myOrigin = m_Utility.m_OwnerEntity.GetOrigin();
118 bool addObserveBehavior =
false;
122 if (investigateBehavior && investigateBehavior.GetActionState() ==
EAIActionState.RUNNING)
125 addObserveBehavior =
true;
127 else if (oldObserveBehavior)
130 addObserveBehavior =
true;
132 else if (!oldObserveBehavior)
133 addObserveBehavior =
true;
135 if (addObserveBehavior)
138 m_Utility.AddAction(observeBehavior);
145 super.OnActionCompleted();
159 return PRIORITY_BEHAVIOR_MOVE_FROM_DANGER;
166 if (!m_DangerEntity.m_Value)
169 IEntity myEntity = m_Utility.m_OwnerEntity;
173 if (vector.DistanceSq(myEntity.GetOrigin(), m_DangerPosition.m_Value) > DISTANCE_MAX_SQ)
182 protected static const float MIN_COS_ANGLE_COVER_TO_VEHICLE = 0;
187 m_sBehaviorTree =
"{2488649728730886}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_Vehicle.bt";
188 SetPriority(PRIORITY_BEHAVIOR_MOVE_FROM_DANGER);
190 m_bUseCombatMove =
true;
194 override float CustomEvaluate()
196 if (!ExecuteBehaviorCondition(m_Utility, m_DangerEntity.m_Value))
207 static bool ExecuteBehaviorCondition(notnull SCR_AIUtilityComponent utilityComp, IEntity vehicle)
213 IEntity myEntity = utilityComp.m_OwnerEntity;
214 if (!IsVehicleMovingTowardsMe(myEntity, vehicle))
218 SCR_AICombatMoveState cmStace = utilityComp.m_CombatMoveState;
219 SCR_AICoverLock cover = utilityComp.m_CombatMoveState.GetAssignedCover();
220 if (cmStace.m_bInCover && cover && cover.IsValid() && IsCoverSafeAgainstVehicle(cover, vehicle))
227 static bool IsCoverSafeAgainstVehicle(notnull
SCR_AICoverLock cover, notnull IEntity vehicle)
229 float cosAngleCoverToTgt = cover.CosAngleToThreat(vehicle.GetOrigin());
230 return cosAngleCoverToTgt > MIN_COS_ANGLE_COVER_TO_VEHICLE;
234 protected static bool IsVehicleMovingTowardsMe(notnull IEntity myEntity, notnull IEntity vehicle)
236 Physics phy = vehicle.GetPhysics();
242 vector velocityWorld = phy.GetVelocity();
243 float velocityAbsSq = velocityWorld.LengthSq();
244 if (velocityAbsSq <= 0.001)
247 vector velocityDir = velocityWorld.Normalized();
249 vector vecToMe = vector.Direction(vehicle.GetOrigin(), myEntity.GetOrigin());
252 float cosAngle = vector.Dot(vecToMe, velocityDir);
263 m_sBehaviorTree =
"{10A3DFFBC3629A79}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_VehicleHorn.bt";
264 SetPriority(PRIORITY_BEHAVIOR_MOVE_FROM_VEHICLE_HORN);