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_AIDecoTestIsMovingTowardsMe.c
Go to the documentation of this file.
1
/*
2
Returns true when velocity vector is aimed towards me (angle is below 90 degrees).
3
*/
4
class
SCR_AIDecoTestIsMovingTowardsMe
:
DecoratorTestScripted
5
{
6
protected
override
bool
TestFunction
(AIAgent agent,
IEntity
controlled)
7
{
8
if
(!controlled)
9
return
false
;
10
11
Physics
phy = controlled.
GetPhysics
();
12
13
if
(!phy)
14
return
false
;
15
16
// Bail if velocity is around zero
17
vector
velocityWorld = phy.GetVelocity();
18
float
velocityAbsSq = velocityWorld.LengthSq();
19
if
(velocityAbsSq <= 0.001)
20
return
false
;
21
22
vector
velocityDir = velocityWorld.Normalized();
23
24
IEntity
myEntity = agent.GetControlledEntity();
25
if
(!myEntity)
26
return
false
;
27
28
vector
vecToMe =
vector
.Direction(controlled.
GetOrigin
(), myEntity.
GetOrigin
());
29
vecToMe.Normalize();
30
31
float
cosAngle =
vector
.Dot(vecToMe, velocityDir);
32
33
return
cosAngle > 0;
34
}
35
};
DecoratorTestScripted
Definition
DecoratorTestScripted.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetPhysics
proto external Physics GetPhysics()
Physics
Definition
Physics.c:22
SCR_AIDecoTestIsMovingTowardsMe
Definition
SCR_AIDecoTestIsMovingTowardsMe.c:5
SCR_AIDecoTestIsMovingTowardsMe::TestFunction
override bool TestFunction(AIAgent agent, IEntity controlled)
Definition
SCR_AIDecoTestIsMovingTowardsMe.c:6
vector
Definition
vector.c:13
scripts
Game
AI
ScriptedNodes
Utils
SCR_AIDecoTestIsMovingTowardsMe.c
Generated by
1.17.0