Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDangerReaction_Explosion.c
Go to the documentation of this file.
3 {
4  private static const float EXPLOSION_OBSERVE_DISTANCE = 220; // Maximal distance from explosion to trigger observe behavior
5 
6  void CreateObserveUnknownBehavior(SCR_AIUtilityComponent utility, vector observeReactionPosition)
7  {
8  if (observeReactionPosition == vector.Zero || utility.m_CombatComponent.GetCurrentTarget() != null)
9  return;
10 
11  vector myOrigin = utility.m_OwnerEntity.GetOrigin();
12 
15 
16  // Exit if investigating
17  if (investigateBehavior && investigateBehavior.GetActionState() == EAIActionState.RUNNING)
18  return;
19 
20  // Exit if already observing something else
21  if (oldObserveBehavior)
22  return;
23 
24  SCR_AIObserveUnknownFireBehavior observeBehavior = new SCR_AIObserveUnknownFireBehavior(utility, null, posWorld: observeReactionPosition, useMovement: false);
25  utility.AddAction(observeBehavior);
26  }
27 
28  //------------------------------------------------------------------------------------------------
29  override bool PerformReaction(notnull SCR_AIUtilityComponent utility, notnull SCR_AIThreatSystem threatSystem, AIDangerEvent dangerEvent)
30  {
31  IEntity ownerEntity = utility.m_OwnerEntity;
32 
33  if (!ownerEntity)
34  return false;
35 
36  vector position = dangerEvent.GetPosition();
37  float distance = vector.Distance(ownerEntity.GetOrigin(), position);
38 
39  if (distance > SCR_AIThreatSystem.EXPLOSION_MAX_DISTANCE)
40  return false;
41 
42  // Increase threat level
43  threatSystem.ThreatExplosion(distance);
44 
45  // Look at explosion
46  utility.m_LookAction.LookAt(position, SCR_AILookAction.PRIO_UNKNOWN_TARGET, 1.5);
47 
48  // Observe if not investigating or already observing something else
49  if (distance <= EXPLOSION_OBSERVE_DISTANCE)
50  CreateObserveUnknownBehavior(utility, position);
51 
52  return true;
53  }
54 };
SCR_AIDangerReaction_Explosion
Definition: SCR_AIDangerReaction_Explosion.c:2
SCR_AILookAction
Definition: SCR_AILookAction.c:1
SCR_AIObserveUnknownFireBehavior
Definition: SCR_AIObserveUnknownFireBehavior.c:8
SCR_AIDangerReaction
Definition: SCR_AIDangerReaction.c:4
distance
float distance
Definition: SCR_DestructibleTreeV2.c:29
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
EAIActionState
EAIActionState
Definition: EAIActionState.c:12
SCR_AIMoveAndInvestigateBehavior
Definition: SCR_AIMoveBehavior.c:53
SCR_AIThreatSystem
Definition: SCR_AIThreatSystem.c:17
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