Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EffectModulePositionData_Rectangle.c
Go to the documentation of this file.
1
4[BaseContainerProps(configRoot: true), BaseContainerCustomStringTitleField("Rectangle")]
6{
7 [Attribute("5", desc: "Total width of the Zone. With the EffectsModule owner being the center", params: "0.25 inf")]
8 protected float m_fWidth;
9
10 [Attribute("5", desc: "Total lenght of the Zone. With the EffectsModule owner being the center", params: "0.25 inf")]
11 protected float m_fLength;
12
13 [Attribute("0.1", desc: "The % of the edge where entities are not allowed to spawn. Ignored for lenght value if m_bSpawnInRow is true as projectiles will be spawned at a set distance", params: "0 0.9")]
14 protected float m_fSpawnBufferPercentage;
15
16 [Attribute("0.6", desc: "Distance in percentage from average lenght (width * lenght * 0.5 * m_fDistanceSpreadPercentage). 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")]
18
19 [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")]
21
22 [Attribute("0.5", desc: "Percentage of zone percentage that is considered the center. 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 Center zone. If it is higher or equal to m_fCenterBias than it will spawn outside of the center zone. Note for Spawn in row only width is effected by Center zone", params: "0 1")]
23 protected float m_fCenterZonePercentage;
24
25 [Attribute("0.8", desc: "Percentage of chance to spawn entity in the center zone rather than in the entire zone. ignored if 1 or if m_fCenterZonePercentage is 0", params: "0 1")]
26 protected float m_fCenterBias;
27
28 [Attribute("1", desc: "If true will ignore m_fSpawnBufferPercentage and spawn projectile one after each other in the lenght of the zone (widght is still randomized) the distance between projectiles is lenght / projectile amount. Can only be used with barrages")]
29 protected bool m_bSpawnInRow;
30
31 [Attribute("0", desc: "If true the direction in which the barrage is moving will alternate with each barrage. Only applicable when SpawnInRow is true")]
33
34 [Attribute("0.1", desc: "Similar to m_fSpawnBufferPercentage but only used on lenght when SpawnInRow is true. Will add slight variation betwen the distance of spawning transforms from current to prev. (ZSpawnPosition + (ZSpawnPosition * Math.RandomFloat(-m_fSpawnInRowLenghtVariantPercentage, m_fSpawnInRowLenghtVariantPercentage))", params: "0 0.5")]
36
37 protected ref array<vector> m_aPreviousTargetPositions;
38 protected bool m_bIsMovingInAlternateDirection = false;
39
40 //~ Max amount of times the target position will be randomized if to close to previous. Never set below 1
41 protected const int MAX_TARGET_RERANDOMIZES = 10;
42
48 void GetDimensions2D(out float width, out float lenght)
49 {
50 width = m_fWidth;
51 lenght = m_fLength;
52 }
53
54 //------------------------------------------------------------------------------------------------
56 {
57 bool useCenterZone = false;
58
60 {
61 useCenterZone = Math.RandomFloat01() <= m_fCenterBias;
62 }
63
64 vector randomLocalPosition;
65 SCR_BarrageEffectsModule barrageEffect;
66
67 if (m_bSpawnInRow)
68 {
69 barrageEffect = SCR_BarrageEffectsModule.Cast(effectModule);
70 if (!barrageEffect)
71 Print("'SCR_EffectsModulePositionData_Rectangle' with 'm_bSpawnInRow' set to true cannot be used if not 'SCR_BarrageEffectsModule'", LogLevel.ERROR);
72 }
73
74 if (m_bSpawnInRow && barrageEffect)
75 {
76 if (useCenterZone)
77 {
78 float centerZoneStartX = m_fWidth * m_fCenterZonePercentage * 0.5;
79
80 randomLocalPosition[0] = Math.RandomFloatInclusive(-centerZoneStartX, centerZoneStartX);
81 }
82 else
83 {
84 float edgeStartX = (m_fWidth - m_fWidth * m_fSpawnBufferPercentage) * 0.5;
85
86 randomLocalPosition[0] = Math.RandomFloatInclusive(-edgeStartX, edgeStartX);
87 }
88
89 float edgeStartY = (m_fLength - m_fLength * m_fSpawnBufferPercentage) * 0.5;
90 float stepY = (m_fLength - m_fLength * m_fSpawnBufferPercentage) / (barrageEffect.GetTotalProjectilesInBarrage() - 1);
91
93 randomLocalPosition[2] = edgeStartY - stepY * (barrageEffect.GetTotalProjectilesInBarrage() - barrageEffect.GetProjectilesLeftInBarrage());
94 else
95 randomLocalPosition[2] = -edgeStartY + stepY * (barrageEffect.GetTotalProjectilesInBarrage() - barrageEffect.GetProjectilesLeftInBarrage());
96
97
99 randomLocalPosition[2] = randomLocalPosition[2] + (edgeStartY * 2 / barrageEffect.GetTotalProjectilesInBarrage()) * Math.RandomFloatInclusive(-m_fSpawnInRowLenghtVariantPercentage, m_fSpawnInRowLenghtVariantPercentage);
100
101 return randomLocalPosition;
102 }
103
104 int targetRandomizesLeft = MAX_TARGET_RERANDOMIZES;
105
106 float minDesiredDistanceSq = Math.Pow(m_fMinimalDistanceBetweenPositions, 2);
107 float minAchievableDistance = Math.Pow(m_fWidth * m_fLength * 0.5 * m_fDistanceSpreadPercentage, 2);
108 if (minDesiredDistanceSq > minAchievableDistance)
109 minDesiredDistanceSq = minAchievableDistance;
110
111 bool minDistanceAchived;
112 while (targetRandomizesLeft > 0)
113 {
114 targetRandomizesLeft--;
115
116 if (useCenterZone)
117 {
118 float centerZoneStartX = m_fWidth * m_fCenterZonePercentage / 2;
119 float centerZoneStartY = m_fLength * m_fCenterZonePercentage / 2;
120
121 randomLocalPosition[0] = Math.RandomFloatInclusive(-centerZoneStartX, centerZoneStartX);
122 randomLocalPosition[2] = Math.RandomFloatInclusive(-centerZoneStartY, centerZoneStartY);
123 }
124 else
125 {
126 float edgeStartX = (m_fWidth - m_fWidth * m_fSpawnBufferPercentage) / 2;
127 float edgeStartY = (m_fLength - m_fLength * m_fSpawnBufferPercentage) / 2;
128
129 randomLocalPosition[0] = Math.RandomFloatInclusive(-edgeStartX, edgeStartX);
130 randomLocalPosition[2] = Math.RandomFloatInclusive(-edgeStartY, edgeStartY);
131 }
132
133 if (minDesiredDistanceSq <= 0 || !m_aPreviousTargetPositions || m_aPreviousTargetPositions.IsEmpty())
134 break;
135
136 minDistanceAchived = true;
137 foreach (vector previousPosition : m_aPreviousTargetPositions)
138 {
139 if (vector.DistanceSq(previousPosition, randomLocalPosition) < minDesiredDistanceSq)
140 {
141 minDistanceAchived = false;
142 break;
143 }
144 }
145
146 if (minDistanceAchived)
147 break;
148 }
149
152
153 m_aPreviousTargetPositions.Insert(randomLocalPosition);
154
155 return randomLocalPosition;
156 }
157
158 //------------------------------------------------------------------------------------------------
159 override void ResetPositions(SCR_EffectsModule effectModule)
160 {
161 super.ResetPositions(effectModule);
162
166 }
167
168 //------------------------------------------------------------------------------------------------
170 {
172 {
173 Print(string.Format("'SCR_EffectsModulePositionData_Rectangle' m_fCenterBias is '%1' while m_fCenterZonePercentage is '%2' both values should either be 0 (ingore center bias) or more than 0 (use center bias)", m_fCenterBias, m_fCenterZonePercentage), LogLevel.WARNING);
174 }
175
177 {
179 Print(string.Format("'SCR_EffectsModulePositionData_Rectangle' m_fSpawnBufferPercentage + m_fCenterZonePercentage cannot exceed 1. So m_fCenterZonePercentage is decreased to %1!", m_fCenterZonePercentage), LogLevel.WARNING);
180 }
181 }
182};
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 vector GetNewPosition(SCR_EffectsModule effectModule)
void GetDimensions2D(out float width, out float lenght)
override void ResetPositions(SCR_EffectsModule effectModule)
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