Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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, int dangerEventCount)
8 {
9 IEntity vehicleObject = dangerEvent.GetVictim();
10 if (!vehicleObject)
11 return false;
12
13 // Ignore if we are in same vehicle
14 IEntity parent = utility.m_OwnerEntity.GetParent();
15 while(parent)
16 {
17 if (parent == vehicleObject)
18 return false;
19 parent = parent.GetParent();
20 }
21
22 // Ignore if we already have an action to move from that vehicle
23 if (SCR_AIMoveFromDangerBehavior.ExistsBehaviorForEntity(utility, vehicleObject))
24 return false;
25
26 SCR_ChimeraAIAgent agent = SCR_ChimeraAIAgent.Cast(utility.GetOwner());
27
28 //Check distance
29 vector vehiclePos = vehicleObject.GetOrigin();
30 vector agentPos = utility.GetOrigin();
31 float distSq = vector.DistanceSq(vehiclePos, agentPos);
32
33 if (distSq >= REACTION_ENEMY_DIST_SQ)
34 return false;
35
36 //Enemy car
37 if(agent.IsPerceivedEnemy(vehicleObject))
38 {
39 //Orientate towards the sound origin
40 utility.m_LookAction.LookAt(dangerEvent.GetPosition(), utility.m_LookAction.PRIO_DANGER_EVENT);
41 return true;
42 }
43 //Ally car
44 else
45 {
46 if (distSq <= REACTION_FRIENDLY_DIST_SQ)
47 {
48 //Move away from danger
49 SCR_AIMoveFromDangerBehavior behavior = new SCR_AIMoveFromVehicleHornBehavior(utility, null, vector.Zero, dangerEntity: vehicleObject);
50 utility.AddAction(behavior);
51 return true;
52 }
53 }
54 return false;
55 }
56};
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Event which gets broadcasted from danger-causing places to AI.
proto external vector GetOrigin()
proto external IEntity GetParent()
bool IsPerceivedEnemy(IEntity entity)
Checks if this agent perceives the entity as enemy.