Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EffectModulePositionData_Radius.c
Go to the documentation of this file.
1
6{
7 [Attribute("1", desc: "Radius in which the effects will either spawn in, or in case of a projectile will fly towards.", params: "1 inf")]
8 protected float m_fRadius;
9
10 [Attribute("0.1", desc: "The radius from the edge where entities are not allowed to spawn", params: "0 0.9")]
11 protected float m_fSpawnBufferPercentage;
12
13 [Attribute("0.6", desc: "Distance in percentage from total radius (or central radius) the next entity can be spawned. If the random position is within the marge than the system will randomize a new position. It will retry a finite amount of times the higher the value the more chance it will rerandomize. Set this to 0 to simply ignore it and ranzomize", params: "0 0.9", precision: 5, category: "Projectile in barrage")]
15
16 [Attribute("-1", desc: "Minimal distance in meters between spawn positions. If -1 or more than the outcome of m_fDistanceSpreadPercentage then outcome of m_fDistanceSpreadPercentage will be used.", params: "-1 inf", category: "Projectile in barrage")]
18
19 [Attribute("0", desc: "If true will apply m_fDistanceSpreadPercentage on all entities that where spawned before not just the last spawned entity. This should make for a better spread but takes more processing power depending on the amount of entities")]
21
22 [Attribute("0.5", desc: "Percentage of radius that is considered the center zone. If more than 0 and m_fCenterBias is more than 0 it will randomize a value between 0 and 1 and spawn the entity within the CenterCenter zone. If it is higher or equal to m_fCenterBias than it will spawn outside of the center zone", params: "0 1")]
24
25 [Attribute("0.8", desc: "Percentage of chance to spawn entity in the center zone rather than in the entire zone. ignored if 0 or if m_fCenterRadiusPercentage is 0", params: "0 1")]
26 protected float m_fCenterBias;
27
28 protected ref array<vector> m_aPreviousTargetPositions;
29
30 //~ Max amount of times the target position will be randomized if to close to previous. Never set below 1
31 protected const int MAX_TARGET_RERANDOMIZES = 10;
32
33 //------------------------------------------------------------------------------------------------
38 float GetRadius()
39 {
40 return m_fRadius;
41 }
42
43 //------------------------------------------------------------------------------------------------
49 {
51 }
52
53 //------------------------------------------------------------------------------------------------
55 {
57 return m_fRadius;
58 else
60 }
61
62 //------------------------------------------------------------------------------------------------
64 {
65 vector randomLocalPosition;
66
67 //~ Make sure it randomizes a x amount of time
68 int targetRandomizesLeft = MAX_TARGET_RERANDOMIZES;
69
70 float minDesiredDistanceSq = Math.Pow(m_fMinimalDistanceBetweenPositions, 2);
71 float minAchievableDistance;
72
73 bool minDistanceAchived;
74 bool useCenterRadius;
75 float maxRadius;
76 float minRadius;
77 while (targetRandomizesLeft > 0)
78 {
79 targetRandomizesLeft--;
80
81 minRadius = 0;
82 useCenterRadius = false;
83
84 //~ Has center radius
86 {
87 useCenterRadius = Math.RandomFloat01() <= m_fCenterBias;
88
89 //~ Spawn in center radius
90 if (useCenterRadius)
91 maxRadius = GetCenterRadius();
92 //~ Spawn in entire radius but center
93 else
94 minRadius = GetCenterRadius();
95 }
96
97 //~ Set max radius as total radius
98 if (!useCenterRadius)
99 maxRadius = GetSpawnRadius();
100
101 //~ Make sure GenerateRandomPointInRadius is valid
102 if (maxRadius <= minRadius)
103 maxRadius = minRadius + 0.001;
104
105 //~ Get random point on radius taking into account the buffer percentage
106 randomLocalPosition = SCR_Math2D.GenerateRandomPointInRadius(minRadius, maxRadius, vector.Zero, false);
107
108 //~ No spread percentage
110 break;
111
112 //no previous target positions thus there is nothing to compare to
114 break;
115
116 minAchievableDistance = Math.Pow(maxRadius * m_fDistanceSpreadPercentage, 2);
117 if (minDesiredDistanceSq > minAchievableDistance)
118 minDesiredDistanceSq = minAchievableDistance;
119
120 if (minDesiredDistanceSq <= 0)
121 break;
122
124 {
125 minDistanceAchived = true;
126 //check if we are not close to any previously choosen position
127 foreach(vector previousPosition : m_aPreviousTargetPositions)
128 {
129 if (vector.DistanceSq(previousPosition, randomLocalPosition) < minDesiredDistanceSq)
130 {
131 minDistanceAchived = false;
132 break;
133 }
134 }
135
136 if (minDistanceAchived)
137 break;
138 }
139 else
140 {
141 //check if there is enough distance between current and last location
142 if (vector.DistanceSq(m_aPreviousTargetPositions[m_aPreviousTargetPositions.Count() - 1], randomLocalPosition) >= minDesiredDistanceSq)
143 break;
144 }
145 }
146
149
150 m_aPreviousTargetPositions.Insert(randomLocalPosition);
151
152 return randomLocalPosition;
153 }
154
155 //------------------------------------------------------------------------------------------------
156 override void ResetPositions(SCR_EffectsModule effectModule)
157 {
159 }
160
161 //------------------------------------------------------------------------------------------------
163 {
165 {
166 Print(string.Format("'SCR_EffectsModulePositionData_Radius' m_fCenterBias is '%1' while m_fCenterRadiusPercentage is '%2' both values should either be 0 (ingore center bias) or more than 0 (use center bias)", m_fCenterBias, m_fCenterRadiusPercentage), LogLevel.WARNING);
167 }
168
170 {
172 Print(string.Format("'SCR_EffectsModulePositionData_Radius' m_fSpawnBufferPercentage + m_fCenterRadiusPercentage cannot exceed 1. So m_fCenterRadiusPercentage is decreased to %1!", m_fCenterRadiusPercentage), LogLevel.WARNING);
173 }
174 }
175};
params precision
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_HitZoneGroupNameHolder BaseContainerCustomStringTitleField("USE INHERITED VERSION ONLY!")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
override void ResetPositions(SCR_EffectsModule effectModule)
override vector GetNewPosition(SCR_EffectsModule effectModule)
static vector GenerateRandomPointInRadius(float minRadius, float maxRadius, vector center, bool uniform=true)
Definition SCR_Math2D.c:392
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute