Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AICombatMoveUtils.c
Go to the documentation of this file.
1/*
2Class with misc functions for combat movement
3*/
4
6{
7 // Threshold distance beyond which it is considered we are in long range fight
8 static const float CLOSE_RANGE_COMBAT_DIST = 40.0;
9 static const float VERY_LONG_RANGE_COMBAT_DIST = 250;
10
11 // Character movement speeds
12 static const float CHARACTER_SPEED_STAND_SPRINT = 5.5;
13 static const float CHARACTER_SPEED_STAND_RUN = 3.6;
14 static const float CHARACTER_SPEED_CROUCH_SPRINT = 4;
15 static const float CHARACTER_SPEED_CROUCH_RUN = 2.6;
16 static const float CHARACTER_SPEED_PRONE_SPRINT = 1.1;
17 static const float CHARACTER_SPEED_PRONE_RUN = 0.9;
18
19 // Vehicle generic movement speed
20 static const float GROUND_VEHICLE_GENERIC_SPEED = 10.0;
21
22
24 static vector CalculateMoveDirection(SCR_EAICombatMoveDirection eDirection, vector myPos, vector movePos)
25 {
26 // Special cases
27 if (eDirection == SCR_EAICombatMoveDirection.ANYWHERE)
28 {
29 // Random direction
30 float bearing = Math.RandomFloat(0, Math.PI2);
31 vector dirOut = Vector(Math.Cos(bearing), 0, Math.Sin(bearing));
32 return dirOut;
33 }
34 else if (eDirection == SCR_EAICombatMoveDirection.CUSTOM_POS)
35 {
36 vector dirToTarget = vector.Direction(myPos, movePos);
37 dirToTarget.Normalize();
38 return dirToTarget;
39 }
40
41 // Generic directions
42
43 vector dirToTarget = vector.Direction(myPos, movePos);
44 dirToTarget.Normalize();
45 vector dirSideways = (dirToTarget * Vector(0, 1, 0));
46
47 switch (eDirection)
48 {
49 case SCR_EAICombatMoveDirection.FORWARD: return dirToTarget;
50 case SCR_EAICombatMoveDirection.BACKWARD: return -dirToTarget;
51 case SCR_EAICombatMoveDirection.RIGHT: return -dirSideways;
52 case SCR_EAICombatMoveDirection.LEFT: return dirSideways;
53 }
54 return vector.Zero;
55 }
56
57 //--------------------------------------------------------------------------------------------
58 static float GetEstimatedMoveSpeed(notnull SCR_AICombatMoveRequest_Move rq)
59 {
60 switch (rq.m_eUnitType)
61 {
62 case SCR_EAICombatMoveUnitType.CHARACTER: return CHARACTER_SPEED_STAND_SPRINT;
63 case SCR_EAICombatMoveUnitType.GROUND_VEHICLE: return GROUND_VEHICLE_GENERIC_SPEED;
64 }
65 return GROUND_VEHICLE_GENERIC_SPEED;
66 }
67
70 static bool IsAimingAndMovementPossible(ECharacterStance stance, EMovementType moveType)
71 {
72 if (stance == ECharacterStance.PRONE)
73 return false;
74
75 if (moveType == EMovementType.SPRINT)
76 return false;
77
78 return true;
79 }
80}
Definition Math.c:13
ECharacterStance
EMovementType
proto native vector Vector(float x, float y, float z)