DayZ 1.24
Loading...
Searching...
No Matches
MapNavigationBehaviour.c File Reference

Go to the source code of this file.

Enumerations

enum  EMapNavigationType { BASIC = 0 , COMPASS = 1 , GPS = 2 , ALL = 4 }
 

Functions

void MapNavigationBehaviour (PlayerBase pPlayer, EMapNavigationType pNavigationType=EMapNavigationType.BASIC)
 
void SetNavigationType (EMapNavigationType pType)
 
void UnsetNavigationType (EMapNavigationType pType)
 
EMapNavigationType GetNavigationType ()
 
void OnItemInPlayerPossession (EntityAI item)
 
void OnItemNotInPlayerPossession (EntityAI item)
 
void RandomizePosition ()
 
float RandomizedDeviation ()
 
vector GetPositionRandomized ()
 
vector GetPositionReal ()
 
static array< intOrderedPositionNumbersFromGridCoords (EntityAI pEntity)
 
static array< intOrderedAltitudeNumbersPosition (EntityAI pEntity)
 
static bool IsOutOfMap (EntityAI pEntity)
 

Variables

enum EMapNavigationType RANDOM_DEVIATION_MIN = 4
 
const int RANDOM_DEVIATION_MAX = 15
 
static const int DISPLAY_GRID_POS_MAX_CHARS_COUNT = 3
 
static const int DISPLAY_ALT_MAX_CHARS_COUNT = 4
 
static const string GRID_SIZE_CFG_PATH = "CfgWorlds %1 Grid Zoom1 stepX"
 
int m_RandomPositionDeviationX
 
int m_RandomPositionDeviationZ
 
EMapNavigationType m_NavigationType
 
PlayerBase m_Player
 
ref array< EntityAIm_GPSInPossessionArr
 
ref array< EntityAIm_CompassInPossessionArr
 

Enumeration Type Documentation

◆ EMapNavigationType

Enumerator
BASIC 
COMPASS 
GPS 
ALL 

Definition at line 1 of file MapNavigationBehaviour.c.

2{
3 BASIC = 0,
4 COMPASS = 1,
5 GPS = 2,
6 ALL = 4
7}

Function Documentation

◆ GetNavigationType()

EMapNavigationType GetNavigationType ( )
protected

Definition at line 46 of file MapNavigationBehaviour.c.

47 {
48 return m_NavigationType;
49 }
EMapNavigationType m_NavigationType

References m_NavigationType.

◆ GetPositionRandomized()

vector GetPositionRandomized ( )
protected

Definition at line 104 of file MapNavigationBehaviour.c.

105 {
106 vector realPosition = m_Player.GetPosition();
108
109 return randomizedPosition;
110 }
int m_RandomPositionDeviationZ
PlayerBase m_Player
int m_RandomPositionDeviationX
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

References m_Player, m_RandomPositionDeviationX, m_RandomPositionDeviationZ, and Vector().

◆ GetPositionReal()

vector GetPositionReal ( )
protected

Definition at line 112 of file MapNavigationBehaviour.c.

113 {
114 return m_Player.GetPosition();
115 }

References m_Player.

◆ IsOutOfMap()

static bool IsOutOfMap ( EntityAI pEntity)
staticprotected

Definition at line 166 of file MapNavigationBehaviour.c.

167 {
168 vector worldPos = pEntity.GetPosition();
169
170 if (worldPos[0] < 0 || worldPos[0] > GetGame().GetWorld().GetWorldSize() || worldPos[2] < 0 || worldPos[2] > GetGame().GetWorld().GetWorldSize())
171 return true;
172
173 return false;
174 }
proto native CGame GetGame()

References GetGame().

Referenced by OrderedPositionNumbersFromGridCoords().

◆ MapNavigationBehaviour()

◆ OnItemInPlayerPossession()

void OnItemInPlayerPossession ( EntityAI item)
protected

Definition at line 51 of file MapNavigationBehaviour.c.

52 {
53 if (item.IsInherited(ItemGPS))
54 {
56 {
59 }
60 }
61
62 if (item.IsInherited(ItemCompass))
63 {
65 {
68 }
69 }
70 }
void SetNavigationType(EMapNavigationType pType)
const int INDEX_NOT_FOUND
Definition gameplay.c:13

References INDEX_NOT_FOUND, m_CompassInPossessionArr, m_GPSInPossessionArr, and SetNavigationType().

◆ OnItemNotInPlayerPossession()

void OnItemNotInPlayerPossession ( EntityAI item)
protected

Definition at line 72 of file MapNavigationBehaviour.c.

73 {
74 if (item.IsInherited(ItemGPS))
75 {
76 m_GPSInPossessionArr.RemoveItem(item);
77 if (m_GPSInPossessionArr.Count() == 0)
79 }
80
81 if (item.IsInherited(ItemCompass))
82 {
84 if (m_CompassInPossessionArr.Count() == 0)
86 }
87 }
void UnsetNavigationType(EMapNavigationType pType)

References m_CompassInPossessionArr, m_GPSInPossessionArr, and UnsetNavigationType().

◆ OrderedAltitudeNumbersPosition()

static array< int > OrderedAltitudeNumbersPosition ( EntityAI pEntity)
staticprotected

Definition at line 153 of file MapNavigationBehaviour.c.

154 {
156 float altF = pEntity.GetPosition()[1];
157 int altI = Math.Round(altF);
158 string altString = altI.ToStringLen(DISPLAY_ALT_MAX_CHARS_COUNT);
159
160 for (int i = 0; i < altString.Length(); ++i)
161 altArray.Insert(altString.Get(i).ToInt());
162
163 return altArray;
164 }
static const int DISPLAY_ALT_MAX_CHARS_COUNT
Definition EnMath.c:7
static proto float Round(float f)
Returns mathematical round of value.

References DISPLAY_ALT_MAX_CHARS_COUNT, and Math::Round().

◆ OrderedPositionNumbersFromGridCoords()

static array< int > OrderedPositionNumbersFromGridCoords ( EntityAI pEntity)
staticprotected

Definition at line 117 of file MapNavigationBehaviour.c.

118 {
119 float gridSize = GetGame().ConfigGetFloat(string.Format(GRID_SIZE_CFG_PATH, GetGame().GetWorldName()));
120 int gridX, gridZ;
121 GetGame().GetWorld().GetGridCoords(pEntity.GetPosition(), gridSize, gridX, gridZ);
122
125
127 string gridXStr = gridX.ToStringLen(DISPLAY_GRID_POS_MAX_CHARS_COUNT);
128 string gridZStr = gridZ.ToStringLen(DISPLAY_GRID_POS_MAX_CHARS_COUNT);
129
130 int i = 0;
131 int gridCoordNumber;
132 for (i = 0; i < gridXStr.Length(); ++i)
133 {
134 gridCoordNumber = gridXStr.Get(i).ToInt();
135 if (IsOutOfMap(pEntity))
136 gridCoordNumber = -1;
137
139 }
140
141 for (i = 0; i < gridZStr.Length(); ++i)
142 {
143 gridCoordNumber = gridZStr.Get(i).ToInt();
144 if (IsOutOfMap(pEntity))
145 gridCoordNumber = -1;
146
148 }
149
150 return positions;
151 }
static const string GRID_SIZE_CFG_PATH
static bool IsOutOfMap(EntityAI pEntity)
static const int DISPLAY_GRID_POS_MAX_CHARS_COUNT
static proto int AbsInt(int i)
Returns absolute value.

References Math::AbsInt(), DISPLAY_GRID_POS_MAX_CHARS_COUNT, GetGame(), GRID_SIZE_CFG_PATH, and IsOutOfMap().

◆ RandomizedDeviation()

float RandomizedDeviation ( )
protected

Definition at line 95 of file MapNavigationBehaviour.c.

96 {
98 if ((Math.RandomIntInclusive(0, 10) % 2) == 0)
100 else
102 }
enum EMapNavigationType RANDOM_DEVIATION_MIN
const int RANDOM_DEVIATION_MAX
static proto int Randomize(int seed)
Sets the seed for the random number generator.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54
proto native float GetWorldTime()

References GetWorldTime(), RANDOM_DEVIATION_MAX, RANDOM_DEVIATION_MIN, Math::RandomIntInclusive(), and Math::Randomize().

Referenced by RandomizePosition().

◆ RandomizePosition()

◆ SetNavigationType()

void SetNavigationType ( EMapNavigationType pType)
protected

Definition at line 36 of file MapNavigationBehaviour.c.

References m_NavigationType.

Referenced by OnItemInPlayerPossession().

◆ UnsetNavigationType()

void UnsetNavigationType ( EMapNavigationType pType)
protected

Definition at line 41 of file MapNavigationBehaviour.c.

References m_NavigationType.

Referenced by OnItemNotInPlayerPossession().

Variable Documentation

◆ DISPLAY_ALT_MAX_CHARS_COUNT

const int DISPLAY_ALT_MAX_CHARS_COUNT = 4
static

Definition at line 15 of file MapNavigationBehaviour.c.

Referenced by OrderedAltitudeNumbersPosition().

◆ DISPLAY_GRID_POS_MAX_CHARS_COUNT

const int DISPLAY_GRID_POS_MAX_CHARS_COUNT = 3
static

Definition at line 14 of file MapNavigationBehaviour.c.

Referenced by OrderedPositionNumbersFromGridCoords().

◆ GRID_SIZE_CFG_PATH

const string GRID_SIZE_CFG_PATH = "CfgWorlds %1 Grid Zoom1 stepX"
staticprotected

Definition at line 17 of file MapNavigationBehaviour.c.

Referenced by OrderedPositionNumbersFromGridCoords().

◆ m_CompassInPossessionArr

ref array<EntityAI> m_CompassInPossessionArr
protected

◆ m_GPSInPossessionArr

ref array<EntityAI> m_GPSInPossessionArr
protected

◆ m_NavigationType

EMapNavigationType m_NavigationType
protected

◆ m_Player

PlayerBase m_Player
protected

Definition at line 22 of file MapNavigationBehaviour.c.

◆ m_RandomPositionDeviationX

int m_RandomPositionDeviationX
protected

Definition at line 19 of file MapNavigationBehaviour.c.

Referenced by GetPositionRandomized(), and RandomizePosition().

◆ m_RandomPositionDeviationZ

int m_RandomPositionDeviationZ
protected

Definition at line 20 of file MapNavigationBehaviour.c.

Referenced by GetPositionRandomized(), and RandomizePosition().

◆ RANDOM_DEVIATION_MAX

const int RANDOM_DEVIATION_MAX = 15

Definition at line 12 of file MapNavigationBehaviour.c.

Referenced by RandomizedDeviation().

◆ RANDOM_DEVIATION_MIN

enum EMapNavigationType RANDOM_DEVIATION_MIN = 4

Referenced by RandomizedDeviation().