Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AIDangerReaction_MeleeDamageTaken.c
Go to the documentation of this file.
1
[
BaseContainerProps
()]
2
class
SCR_AIDangerReaction_MeleeDamageTaken
:
SCR_AIDangerReaction
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,
int
dangerEventCount)
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
42
SCR_AIRetreatWhileLookAtBehavior
behavior =
new
SCR_AIRetreatWhileLookAtBehavior
(utility, null);
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
};
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
AIDangerEvent
Event which gets broadcasted from danger-causing places to AI.
Definition
AIDangerEvent.c:14
IEntity::GetOrigin
proto external vector GetOrigin()
Math
Definition
Math.c:13
SCR_AIDangerReaction_MeleeDamageTaken
Definition
SCR_AIDangerReaction_MeleeDamageTaken.c:3
SCR_AIDangerReaction
Definition
SCR_AIDangerReaction.c:5
SCR_AIRetreatWhileLookAtBehavior
Definition
SCR_AIRetreatBehavior.c:2
SCR_AIThreatSystem
Definition
SCR_AIThreatSystem.c:18
vector
Definition
vector.c:13
scripts
Game
AI
Reaction
Danger
SCR_AIDangerReaction_MeleeDamageTaken.c
Generated by
1.17.0