Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDangerReaction_VehicleHorn.c
Go to the documentation of this file.
3 {
4  static const float REACTION_ENEMY_DIST_SQ = 50*50;
5  static const float REACTION_FRIENDLY_DIST_SQ = 12*12;
6 
7  override bool PerformReaction(notnull SCR_AIUtilityComponent utility, notnull SCR_AIThreatSystem threatSystem, AIDangerEvent dangerEvent)
8  {
9  IEntity vehicleObject = dangerEvent.GetVictim();
10  if (!vehicleObject)
11  return false;
12 
13  // Ignore if we already have an action to move from that vehicle
14  if (SCR_AIMoveFromDangerBehavior.ExistsBehaviorForEntity(utility, vehicleObject))
15  return false;
16 
17  SCR_ChimeraAIAgent agent = SCR_ChimeraAIAgent.Cast(utility.GetOwner());
18 
19  //Check distance
20  vector vehiclePos = vehicleObject.GetOrigin();
21  vector agentPos = utility.GetOrigin();
22  float distSq = vector.DistanceSq(vehiclePos, agentPos);
23 
24  if (distSq >= REACTION_ENEMY_DIST_SQ)
25  return false;
26 
27  //Enemy car
28  if(agent.IsEnemy(vehicleObject))
29  {
30  //Orientate towards the sound origin
31  utility.m_LookAction.LookAt(dangerEvent.GetPosition(), utility.m_LookAction.PRIO_DANGER_EVENT);
32  return true;
33  }
34  //Ally car
35  else
36  {
37  if (distSq <= REACTION_FRIENDLY_DIST_SQ)
38  {
39  //Move away from danger
40  SCR_AIMoveFromDangerBehavior behavior = new SCR_AIMoveFromVehicleHornBehavior(utility, null, vector.Zero, dangerEntity: vehicleObject);
41  utility.AddAction(behavior);
42  return true;
43  }
44  }
45  return false;
46  }
47 };
SCR_AIDangerReaction
Definition: SCR_AIDangerReaction.c:4
SCR_AIMoveFromVehicleHornBehavior
SCR_AIObserveUnknownFireBehavior SCR_AIMoveFromVehicleHornBehavior
SCR_ChimeraAIAgent
Definition: SCR_ChimeraAIAgent.c:5
SCR_AIMoveFromDangerBehavior
Definition: SCR_AIMoveFromDanger.c:4
SCR_AIThreatSystem
Definition: SCR_AIThreatSystem.c:17
SCR_AIDangerReaction_VehicleHorn
Definition: SCR_AIDangerReaction_VehicleHorn.c:2
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468