Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDangerReaction_MeleeDamageTaken.c
Go to the documentation of this file.
3 {
4  static const float REACTION_DIST_SQ = 3.5;
5  static const float MIN_DIST_RUN = 10.0;
6  static const float MAX_DIST_RUN = 15.0;
7 
8  override bool PerformReaction(notnull SCR_AIUtilityComponent utility, notnull SCR_AIThreatSystem threatSystem, AIDangerEvent dangerEvent)
9  {
10  if (dangerEvent.GetVictim() != utility.m_OwnerEntity)
11  return false;
12  // amount of dmg to threatsystem
13 
14  vector shooterPos = dangerEvent.GetPosition();
15 
16  //position is
17  vector myPos = dangerEvent.GetVictim().GetOrigin();
18 
19  //distance
20  float distSq = vector.DistanceSq(myPos, shooterPos);
21  if (distSq >= REACTION_DIST_SQ)
22  return false;
23 
24  //Rotate towards it
25  utility.m_LookAction.LookAt(shooterPos, utility.m_LookAction.PRIO_DANGER_EVENT);
26 
27 
28  //get the direction from enemy to me = V
29  vector V = myPos - shooterPos;
30  V.Normalize();
31 
32  //take a random distance in range [d,D] = d'
33  float d = Math.RandomFloat(MIN_DIST_RUN,MAX_DIST_RUN);
34 
35  //Calculate the center of the pointer, at d' distance from my position in V direction = C
36  //Find correct operator
37  myPos += V * d;
38 
39  //Call to the BT (in it, it will get a random point, with center at C, and radius R. Then move to it WHILE looking at shooterPos)
40 
41  //Use the behaviour tree
43  behavior.m_Target.m_Value = myPos;
44  behavior.m_LookAt.m_Value = shooterPos;
45 
46  utility.AddAction(behavior);
47 
48  return true;
49  }
50 };
SCR_AIDangerReaction
Definition: SCR_AIDangerReaction.c:4
SCR_AIDangerReaction_MeleeDamageTaken
Definition: SCR_AIDangerReaction_MeleeDamageTaken.c:2
SCR_AIRetreatWhileLookAtBehavior
Definition: SCR_AIRetreatBehavior.c:1
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