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");
14 m_DangerEntity.Init(
this, dangerEntity);
15 m_DangerPosition.Init(
this, dangerPos);
29 SetPriority(PRIORITY_BEHAVIOR_MOVE_FROM_DANGER);
30 InitParameters(dangerEntity, dangerPos);
34 m_DangerPosition.m_Value = dangerEntity.
GetOrigin();
37 m_sBehaviorTree =
"{D12937CF422B639B}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_Position.bt"
42 static bool ExistsBehaviorForEntity(SCR_AIUtilityComponent utility,
IEntity ent)
44 SCR_AIMoveFromDangerBehavior behavior = SCR_AIMoveFromDangerBehavior.Cast(utility.FindActionOfInheritedType(SCR_AIMoveFromDangerBehavior));
45 if (behavior && behavior.m_DangerEntity.m_Value == ent)
54 ref SCR_BTParam<float>
m_Distance =
new SCR_BTParam<float>(
"Distance");
61 m_sBehaviorTree =
"{9C0564CA979D57B1}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_UnsafeArea.bt";
65class SCR_AIMoveFromGrenadeBehavior : SCR_AIMoveFromDangerBehavior
67 static const float MAX_GRENADE_LOOKAT_TIMEOUT_MS = 600;
68 static const float DISTANCE_MAX_SQ = 13*13;
70 float m_fBehaviorTimeout = 0;
71 float m_fDistanceToGrenade = 0;
72 vector m_vObserveReactionPosition;
75 void SCR_AIMoveFromGrenadeBehavior(SCR_AIUtilityComponent utility,
SCR_AIActivityBase groupActivity,
vector dangerPos,
IEntity dangerEntity,
float behaviorDelay,
vector observePosition)
78 m_fBehaviorTimeout =
GetGame().GetWorld().GetWorldTime() + behaviorDelay;
79 m_sBehaviorTree =
"{478811D2295EAF3E}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_Grenade.bt";
81 m_fDistanceToGrenade =
vector.Distance(utility.m_OwnerEntity.GetOrigin(), dangerPos);
82 m_vObserveReactionPosition = observePosition;
92 if (CompleteActionCondition())
98 if (
GetGame().GetWorld().GetWorldTime() > m_fBehaviorTimeout)
99 return PRIORITY_BEHAVIOR_MOVE_FROM_DANGER;
104 bool CompleteActionCondition()
106 if (!m_DangerEntity.m_Value)
113 if (
vector.DistanceSq(myEntity.
GetOrigin(), m_DangerPosition.m_Value) > DISTANCE_MAX_SQ)
127 m_sBehaviorTree =
"{2488649728730886}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_Vehicle.bt";
128 SetPriority(PRIORITY_BEHAVIOR_MOVE_FROM_DANGER);
137 if (!ExecuteBehaviorCondition(
m_Utility, m_DangerEntity.m_Value))
148 static bool ExecuteBehaviorCondition(notnull SCR_AIUtilityComponent utilityComp,
IEntity vehicle)
154 IEntity myEntity = utilityComp.m_OwnerEntity;
155 if (!IsVehicleMovingTowardsMe(myEntity, vehicle))
159 SCR_AICombatMoveState cmStace = utilityComp.m_CombatMoveState;
160 SCR_AICoverLock cover = utilityComp.m_CombatMoveState.GetAssignedCover();
161 if (cmStace.m_bInCover && cover && cover.IsValid() && IsCoverSafeAgainstVehicle(cover, vehicle))
168 static bool IsCoverSafeAgainstVehicle(notnull SCR_AICoverLock cover, notnull
IEntity vehicle)
170 float cosAngleCoverToTgt = cover.CosAngleToThreat(vehicle.GetOrigin());
175 protected static bool IsVehicleMovingTowardsMe(notnull
IEntity myEntity, notnull
IEntity vehicle)
177 Physics phy = vehicle.GetPhysics();
183 vector velocityWorld = phy.GetVelocity();
184 float velocityAbsSq = velocityWorld.LengthSq();
185 if (velocityAbsSq <= 0.001)
188 vector velocityDir = velocityWorld.Normalized();
190 vector vecToMe = vector.Direction(vehicle.GetOrigin(), myEntity.GetOrigin());
193 float cosAngle = vector.Dot(vecToMe, velocityDir);
195 return cosAngle > 0.707;
199class SCR_AIMoveFromVehicleHornBehavior : SCR_AIMoveFromDangerBehavior
204 m_sBehaviorTree =
"{10A3DFFBC3629A79}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_VehicleHorn.bt";
205 SetPriority(PRIORITY_BEHAVIOR_MOVE_FROM_VEHICLE_HORN);
212 ref SCR_BTParam<vector>
m_vMovePos =
new SCR_BTParam<vector>(
"MovePos");
220 m_sBehaviorTree =
"{4CD41D1E2C9CD745}AI/BehaviorTrees/Chimera/Soldier/MoveFromDanger_PilotVehicle.bt";
228 if (!m_DangerEntity.m_Value)
242 Physics phyDanger = m_DangerEntity.m_Value.GetPhysics();
246 vector dangerVelocity = phyDanger.GetVelocity().Normalized();
248 vector myVelWorld = phy.GetVelocity();
254 float dot =
vector.DotXZ(dangerVelocity, myTransform[2]);
255 if (dot > 0.5 || dot < -0.5)
ArmaReforgerScripted GetGame()
TStringArray GetPortNames()
ResourceName m_sBehaviorTree
void Fail(bool doNotCompleteWaypoint)
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
enum SCR_EAIActivityCause m_Utility
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
const float SIDE_STEP_LEN
SCR_AIMoveFromGrenadeBehavior MIN_COS_ANGLE_COVER_TO_VEHICLE
void SCR_AIPilotMoveFromIncomingVehicleBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector dangerPos, IEntity dangerEntity)
void SCR_AIMoveFromIncomingVehicleBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector dangerPos, IEntity dangerEntity)
SCR_AIMoveFromDangerBehavior m_Distance
const float SIDE_STEP_FORWARD
SCR_AIMoveFromVehicleHornBehavior m_vMovePos
Special behavior for pilot when he's about to collide with another vehicle.
override void OnActionSelected()
const float EXTRAPOLATE_POS_FORWARD_TIME_S
override float CustomEvaluate()
void SCR_AIMoveFromUnsafeAreaBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector dangerPos, IEntity dangerEntity, float distance)
enum EVehicleType IEntity
proto external vector GetOrigin()
proto external Physics GetPhysics()
proto external void GetTransform(out vector mat[])
static override bool VisibleInPalette()
override TStringArray GetVariablesOut()
static ref TStringArray s_aVarsOut
array< string > TStringArray