-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHBFeatureGeneratorRectangular3.6.lua
More file actions
572 lines (529 loc) · 21.7 KB
/
Copy pathHBFeatureGeneratorRectangular3.6.lua
File metadata and controls
572 lines (529 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
------------------------------------------------------------------------------
-- FILE: FeatureGenerator.lua
-- MODIFIED FOR CIV5: Bob Thomas
-- PYTHON TO LUA: Shaun Seckman
-- PURPOSE: Default method for feature generation
------------------------------------------------------------------------------
-- Copyright (c) 2009, 2010 Firaxis Games, Inc. All rights reserved.
------------------------------------------------------------------------------
include("HBMapmakerUtilities3.6");
------------------------------------------------------------------------------
FeatureGenerator = {};
------------------------------------------------------------------------------
function FeatureGenerator.Create(args)
--[[ Civ4's truncated "Climate" setting has been abandoned. Civ5 has returned to
Civ3-style map options for World Age, Temperature, and Rainfall. Control over the
terrain has been removed from the XML. - Bob Thomas, March 2010 ]]--
--
-- Sea Level and World Age map options affect only plot generation.
-- Temperature map options affect only terrain generation.
-- Rainfall map options affect only feature generation.
--
local args = args or {};
local rainfall = args.rainfall or 2; -- Default is Normal rainfall.
local jungle_grain = args.jungle_grain or 5;
local forest_grain = args.forest_grain or 6;
local clump_grain = args.clump_grain or 10;
local iJungleChange = args.iJungleChange or 20;
local iForestChange = args.iForestChange or 7;
local iClumpChange = args.iClumpChange or 5;
local iJungleFactor = args.iJungleFactor or 7;
local iAridFactor = args.iAridFactor or 6;
local iWetFactor = args.iWetFactor or 2;
local fMarshChange = args.fMarshChange or 2
local fOasisChange = args.fOasisChange or 1.5;
local fracXExp = args.fracXExp or -1;
local fracYExp = args.fracYExp or -1;
-- Set feature traits.
local iJunglePercent = args.iJunglePercent or 45;
local grassMoist = args.iGrassMoist or 2;
if grassMoist == 1 then
iJunglePercent = iJunglePercent - 5;
elseif grassMoist == 3 then
iJunglePercent = iJunglePercent + 5;
end
local iForestPercent = args.iForestPercent or 24;
local iClumpHeight = args.iClumpHeight or 75;
local fMarshPercent = args.fMarshPercent or 10;
local iOasisPercent = args.iOasisPercent or 25;
-- if MapShape == 3 then
-- iForestPercent = iForestPercent + 6;
-- iJunglePercent = iJunglePercent + 3;
-- fMarshPercent = fMarshPercent + 1;
-- end
-- Adjust foliage amounts according to user's Rainfall selection. (Which must be passed in by the map script.)
if rainfall == 1 then -- Rainfall is sparse, climate is Arid.
iJunglePercent = iJunglePercent - iJungleChange;
iJungleFactor = iAridFactor;
iForestPercent = iForestPercent - iForestChange;
iClumpHeight = iClumpHeight - iClumpChange;
fMarshPercent = fMarshPercent / fMarshChange;
iOasisPercent = iOasisPercent / fOasisChange;
elseif rainfall == 3 then -- Rainfall is abundant, climate is Wet.
iJunglePercent = iJunglePercent + iJungleChange;
iJungleFactor = iWetFactor;
iForestPercent = iForestPercent + iForestChange;
iClumpHeight = iClumpHeight + iClumpChange;
fMarshPercent = fMarshPercent * fMarshChange;
iOasisPercent = iOasisPercent * fOasisChange;
else -- Rainfall is Normal.
end
--[[ Activate printout for debugging only.
print("-"); print("--- Rainfall Readout ---");
print("- Rainfall Setting:", rainfall);
print("- Jungle Percentage:", iJunglePercent);
print("- Loose Forest %:", iForestPercent);
print("- Clump Forest %:", 100 - iClumpHeight);
print("- Marsh Percentage:", fMarshPercent);
print("- Oasis Percentage:", iOasisPercent);
print("- - - - - - - - - - - - - - -");
]]--
local gridWidth, gridHeight = Map.GetGridSize();
local world_info = GameInfo.Worlds[Map.GetWorldSize()];
jungle_grain = jungle_grain + world_info.FeatureGrainChange;
forest_grain = forest_grain + world_info.FeatureGrainChange;
-- create instance data
local instance = {
-- methods
__initFractals = FeatureGenerator.__initFractals,
__initFeatureTypes = FeatureGenerator.__initFeatureTypes,
AddFeatures = FeatureGenerator.AddFeatures,
GetLatitudeAtPlot = FeatureGenerator.GetLatitudeAtPlot,
AddFeaturesAtPlot = FeatureGenerator.AddFeaturesAtPlot,
AddOasisAtPlot = FeatureGenerator.AddOasisAtPlot,
AddIceAtPlot = FeatureGenerator.AddIceAtPlot,
AddMarshAtPlot = FeatureGenerator.AddMarshAtPlot,
AddJunglesAtPlot = FeatureGenerator.AddJunglesAtPlot,
AddForestsAtPlot = FeatureGenerator.AddForestsAtPlot,
AddAtolls = FeatureGenerator.AddAtolls,
AdjustTerrainTypes = FeatureGenerator.AdjustTerrainTypes,
-- members
iGridW = gridWidth,
iGridH = gridHeight,
iJunglePercent = iJunglePercent,
iJungleFactor = iJungleFactor,
iForestPercent = iForestPercent,
iClumpHeight = iClumpHeight,
fMarshPercent = fMarshPercent,
iOasisPercent = iOasisPercent,
jungle_grain = jungle_grain,
forest_grain = forest_grain,
clump_grain = clump_grain,
fractalFlags = Map.GetFractalFlags(),
fracXExp = fracXExp,
fracYExp = fracYExp,
};
-- initialize instance data
instance:__initFractals()
instance:__initFeatureTypes()
return instance;
end
------------------------------------------------------------------------------
function FeatureGenerator:__initFractals()
local width = self.iGridW;
local height = self.iGridH;
-- Create fractals
self.jungles = Fractal.Create(width, height, self.jungle_grain, self.fractalFlags, self.fracXExp, self.fracYExp);
self.forests = Fractal.Create(width, height, self.forest_grain, self.fractalFlags, self.fracXExp, self.fracYExp);
self.forestclumps = Fractal.Create(width, height, self.clump_grain, self.fractalFlags, self.fracXExp, self.fracYExp);
self.marsh = Fractal.Create(width, height, 4, self.fractalFlags, self.fracXExp, self.fracYExp);
-- Get heights
self.iJungleBottom = self.jungles:GetHeight((100 - self.iJunglePercent)/2)
self.iJungleTop = self.jungles:GetHeight((100 + self.iJunglePercent)/2)
self.iJungleRange = (self.iJungleTop - self.iJungleBottom) * self.iJungleFactor;
self.iForestLevel = self.forests:GetHeight(100 - self.iForestPercent)
self.iClumpLevel = self.forestclumps:GetHeight(self.iClumpHeight)
self.iMarshLevel = self.marsh:GetHeight(100 - self.fMarshPercent)
end
------------------------------------------------------------------------------
function FeatureGenerator:__initFeatureTypes()
self.featureFloodPlains = FeatureTypes.FEATURE_FLOOD_PLAINS;
self.featureIce = FeatureTypes.FEATURE_ICE;
self.featureJungle = FeatureTypes.FEATURE_JUNGLE;
self.featureForest = FeatureTypes.FEATURE_FOREST;
self.featureOasis = FeatureTypes.FEATURE_OASIS;
self.featureMarsh = FeatureTypes.FEATURE_MARSH;
self.terrainIce = TerrainTypes.TERRAIN_SNOW;
self.terrainTundra = TerrainTypes.TERRAIN_TUNDRA;
self.terrainPlains = TerrainTypes.TERRAIN_PLAINS;
end
------------------------------------------------------------------------------
function FeatureGenerator:AddFeatures(allow_mountains_on_coast)
local flag = allow_mountains_on_coast or false;
--[[ Removing mountains from coasts cannot be done during plot or terrain
generation, because the function that determines what is or isn't adjacent
to a salt water ocean requires both plot and terrain data to operate. So
even though this operation is, strictly speaking, a plot-type operation, I
have added it here in the default FeatureGenerator so I can easily call on
it for any script that needs it. - Bob Thomas, March 2010 ]]--
--
if allow_mountains_on_coast == false then -- remove any mountains from coastal plots
for x = 0, self.iGridW - 1 do
for y = 0, self.iGridH - 1 do
local plot = Map.GetPlot(x, y)
if plot:GetPlotType() == PlotTypes.PLOT_MOUNTAIN then
if plot:IsCoastalLand() then
plot:SetPlotType(PlotTypes.PLOT_HILLS, false, true); -- These flags are for recalc of areas and rebuild of graphics. Instead of recalc over and over, do recalc at end of loop.
end
end
end
end
-- This function needs to recalculate areas after operating. However, so does
-- adding feature ice, so the recalc was removed from here and put in MapGenerator()
end
self:AddAtolls(); -- Adds Atolls to oceanic maps.
-- Main loop, adds features to all plots as appropriate
for y = 0, self.iGridH - 1, 1 do
for x = 0, self.iGridW - 1, 1 do
self:AddFeaturesAtPlot(x, y);
end
end
self:AdjustTerrainTypes(); -- Sets terrain under jungles and softens arctic rivers
end
------------------------------------------------------------------------------
function FeatureGenerator:GetLatitudeAtPlot(iX, iY)
-- Latitude affects only jungles and ice by default.
-- However, you can make use of it in replacement methods for AddAtPlot if you wish.
-- Returns a value in the range of 0.0 (tropical) to 1.0 (polar)
return math.abs((self.iGridH/2) - iY)/(self.iGridH/2);
end
------------------------------------------------------------------------------
function FeatureGenerator:AddFeaturesAtPlot(iX, iY)
-- adds any appropriate features at the plot (iX, iY) where (0,0) is in the SW
local lat = self:GetLatitudeAtPlot(iX, iY);
local plot = Map.GetPlot(iX, iY);
if plot:CanHaveFeature(self.featureFloodPlains) then
-- All desert plots along river are set to flood plains.
plot:SetFeatureType(self.featureFloodPlains, -1)
end
if (plot:GetFeatureType() == FeatureTypes.NO_FEATURE) then
self:AddOasisAtPlot(plot, iX, iY, lat);
end
if (plot:GetFeatureType() == FeatureTypes.NO_FEATURE) then
self:AddIceAtPlot(plot, iX, iY, lat);
end
if (plot:GetFeatureType() == FeatureTypes.NO_FEATURE) then
self:AddMarshAtPlot(plot, iX, iY, lat);
end
if (plot:GetFeatureType() == FeatureTypes.NO_FEATURE) then
self:AddJunglesAtPlot(plot, iX, iY, lat);
end
if (plot:GetFeatureType() == FeatureTypes.NO_FEATURE) then
self:AddForestsAtPlot(plot, iX, iY, lat);
end
end
------------------------------------------------------------------------------
function FeatureGenerator:AddOasisAtPlot(plot, iX, iY, lat)
if(plot:CanHaveFeature(self.featureOasis)) then
if Map.Rand(100, "Add Oasis Lua") <= self.iOasisPercent then
plot:SetFeatureType(self.featureOasis, -1);
end
end
end
------------------------------------------------------------------------------
function FeatureGenerator:AddIceAtPlot(plot, iX, iY, lat)
if(plot:CanHaveFeature(self.featureIce)) then
if Map.IsWrapX() and (iY == 0 or iY == self.iGridH - 1) then
plot:SetFeatureType(self.featureIce, -1)
else
local rand = Map.Rand(200, "Add Ice Lua")/100.0;
if(rand < 8 * (lat - 0.875)) then
plot:SetFeatureType(self.featureIce, -1);
elseif(rand < 4 * (lat - 0.75)) then
plot:SetFeatureType(self.featureIce, -1);
end
end
end
end
------------------------------------------------------------------------------
function FeatureGenerator:AddMarshAtPlot(plot, iX, iY, lat)
local marsh_height = self.marsh:GetHeight(iX, iY)
if(marsh_height >= self.iMarshLevel) then
if(plot:CanHaveFeature(self.featureMarsh)) then
plot:SetFeatureType(self.featureMarsh, -1)
end
end
end
------------------------------------------------------------------------------
function FeatureGenerator:AddJunglesAtPlot(plot, iX, iY, lat)
local jungle_height = self.jungles:GetHeight(iX, iY);
local climate_info = GameInfo.Climates[Map.GetClimate()];
if jungle_height <= self.iJungleTop and jungle_height >= self.iJungleBottom + (self.iJungleRange * lat) then
if(plot:CanHaveFeature(self.featureJungle)) then
plot:SetFeatureType(self.featureJungle, -1);
end
end
end
------------------------------------------------------------------------------
function FeatureGenerator:AddForestsAtPlot(plot, iX, iY, lat)
if (self.forests:GetHeight(iX, iY) >= self.iForestLevel) or (self.forestclumps:GetHeight(iX, iY) >= self.iClumpLevel) then
if plot:CanHaveFeature(self.featureForest) then
plot:SetFeatureType(self.featureForest, -1)
end
end
end
------------------------------------------------------------------------------
function FeatureGenerator:AdjustTerrainTypes()
-- This function added April 2009 for Civ5, by Bob Thomas.
-- Purpose of this function is to turn terrain under jungles
-- into Plains, and to soften arctic terrain types at rivers.
local width = self.iGridW - 1;
local height = self.iGridH - 1;
for y = 0, height do
for x = 0, width do
local plot = Map.GetPlot(x, y);
if (plot:GetFeatureType() == self.featureJungle) then
plot:SetTerrainType(self.terrainPlains, false, true) -- These flags are for recalc of areas and rebuild of graphics. No need to recalc from any of these changes.
elseif (plot:IsRiver()) then
local terrainType = plot:GetTerrainType();
if (terrainType == self.terrainTundra) then
plot:SetTerrainType(self.terrainPlains, false, true)
elseif (terrainType == self.terrainIce) then
plot:SetTerrainType(self.terrainTundra, false, true)
end
end
end
end
end
------------------------------------------------------------------------------
function FeatureGenerator:AddAtolls()
-- This function added Feb 2011 by Bob Thomas.
-- Adds the new feature Atolls in to the game, for oceanic maps.
local iW, iH = Map.GetGridSize()
local biggest_ocean = Map.FindBiggestArea(true)
local iNumBiggestOceanPlots = 0;
if biggest_ocean ~= nil then
iNumBiggestOceanPlots = biggest_ocean:GetNumTiles()
end
if iNumBiggestOceanPlots <= (iW * iH) / 4 then -- No major oceans on this world.
return
end
-- World has oceans, proceed with adding Atolls.
local iNumAtollsPlaced = 0;
local direction_types = {
DirectionTypes.DIRECTION_NORTHEAST,
DirectionTypes.DIRECTION_EAST,
DirectionTypes.DIRECTION_SOUTHEAST,
DirectionTypes.DIRECTION_SOUTHWEST,
DirectionTypes.DIRECTION_WEST,
DirectionTypes.DIRECTION_NORTHWEST
};
local worldsizes = {
[GameInfo.Worlds.WORLDSIZE_DUEL.ID] = 2,
[GameInfo.Worlds.WORLDSIZE_TINY.ID] = 4,
[GameInfo.Worlds.WORLDSIZE_SMALL.ID] = 5,
[GameInfo.Worlds.WORLDSIZE_STANDARD.ID] = 7,
[GameInfo.Worlds.WORLDSIZE_LARGE.ID] = 9,
[GameInfo.Worlds.WORLDSIZE_HUGE.ID] = 12,
};
local atoll_target = worldsizes[Map.GetWorldSize()];
local atoll_number = atoll_target + Map.Rand(atoll_target, "Number of Atolls to place - LUA");
local feature_atoll;
for thisFeature in GameInfo.Features() do
if thisFeature.Type == "FEATURE_ATOLL" then
feature_atoll = thisFeature.ID;
end
end
-- Generate candidate plot lists.
local temp_one_tile_island_list, temp_alpha_list, temp_beta_list = {}, {}, {};
local temp_gamma_list, temp_delta_list, temp_epsilon_list = {}, {}, {};
for y = 0, iH - 1 do
for x = 0, iW - 1 do
local i = y * iW + x + 1; -- Lua tables/lists/arrays start at 1, not 0 like C++ or Python
local plot = Map.GetPlot(x, y)
local plotType = plot:GetPlotType()
if plotType == PlotTypes.PLOT_OCEAN then
local featureType = plot:GetFeatureType()
if featureType ~= FeatureTypes.FEATURE_ICE then
if not plot:IsLake() then
local terrainType = plot:GetTerrainType()
if terrainType == TerrainTypes.TERRAIN_COAST then
if plot:IsAdjacentToLand() then
-- Check all adjacent plots and identify adjacent landmasses.
local iNumLandAdjacent, biggest_adj_area = 0, 0;
local bPlotValid = true;
for loop, direction in ipairs(direction_types) do
local adjPlot = Map.PlotDirection(x, y, direction)
if adjPlot ~= nil then
local adjPlotType = adjPlot:GetPlotType()
if adjPlotType ~= PlotTypes.PLOT_OCEAN then -- Found land.
iNumLandAdjacent = iNumLandAdjacent + 1;
-- Avoid being adjacent to tundra, snow, or feature ice!
local adjTerrainType = adjPlot:GetTerrainType()
if adjTerrainType == TerrainTypes.TERRAIN_TUNDRA or adjTerrainType == TerrainTypes.TERRAIN_SNOW then
bPlotValid = false;
end
local adjFeatureType = adjPlot:GetFeatureType()
if adjFeatureType == FeatureTypes.FEATURE_ICE then
bPlotValid = false;
end
if adjPlotType == PlotTypes.PLOT_LAND or adjPlotType == PlotTypes.PLOT_HILLS then
local iArea = adjPlot:GetArea()
local adjArea = Map.GetArea(iArea)
local iNumAreaPlots = adjArea:GetNumTiles()
if iNumAreaPlots > biggest_adj_area then
biggest_adj_area = iNumAreaPlots;
end
end
end
end
end
-- Only plots with a single land plot adjacent can be eligible.
if iNumLandAdjacent == 1 and bPlotValid == true then
if biggest_adj_area >= 76 then
-- discard this site
elseif biggest_adj_area >= 41 then
table.insert(temp_epsilon_list, i);
elseif biggest_adj_area >= 17 then
table.insert(temp_delta_list, i);
elseif biggest_adj_area >= 8 then
table.insert(temp_gamma_list, i);
elseif biggest_adj_area >= 3 then
table.insert(temp_beta_list, i);
elseif biggest_adj_area >= 1 then
table.insert(temp_alpha_list, i);
--else -- Unexpected result
--print("** Area Plot Count =", biggest_adj_area);
end
end
end
end
end
end
end
end
end
local alpha_list = GetShuffledCopyOfTable(temp_alpha_list)
local beta_list = GetShuffledCopyOfTable(temp_beta_list)
local gamma_list = GetShuffledCopyOfTable(temp_gamma_list)
local delta_list = GetShuffledCopyOfTable(temp_delta_list)
local epsilon_list = GetShuffledCopyOfTable(temp_epsilon_list)
-- Determine maximum number able to be placed, per candidate category.
local max_alpha = math.ceil(table.maxn(alpha_list) / 4);
local max_beta = math.ceil(table.maxn(beta_list) / 5);
local max_gamma = math.ceil(table.maxn(gamma_list) / 4);
local max_delta = math.ceil(table.maxn(delta_list) / 3);
local max_epsilon = math.ceil(table.maxn(epsilon_list) / 4);
-- Place Atolls.
local plotIndex;
local i_alpha, i_beta, i_gamma, i_delta, i_epsilon = 1, 1, 1, 1, 1;
for loop = 1, atoll_number do
local able_to_proceed = true;
local diceroll = 1 + Map.Rand(100, "Atoll Placement Type - LUA");
if diceroll <= 40 and max_alpha > 0 then
plotIndex = alpha_list[i_alpha];
i_alpha = i_alpha + 1;
max_alpha = max_alpha - 1;
--print("- Alpha site chosen");
elseif diceroll <= 65 then
if max_beta > 0 then
plotIndex = beta_list[i_beta];
i_beta = i_beta + 1;
max_beta = max_beta - 1;
--print("- Beta site chosen");
elseif max_alpha > 0 then
plotIndex = alpha_list[i_alpha];
i_alpha = i_alpha + 1;
max_alpha = max_alpha - 1;
--print("- Alpha site chosen");
else -- Unable to place this Atoll
--print("-"); print("* Atoll #", loop, "was unable to be placed.");
able_to_proceed = false;
end
elseif diceroll <= 80 then
if max_gamma > 0 then
plotIndex = gamma_list[i_gamma];
i_gamma = i_gamma + 1;
max_gamma = max_gamma - 1;
--print("- Gamma site chosen");
elseif max_beta > 0 then
plotIndex = beta_list[i_beta];
i_beta = i_beta + 1;
max_beta = max_beta - 1;
--print("- Beta site chosen");
elseif max_alpha > 0 then
plotIndex = alpha_list[i_alpha];
i_alpha = i_alpha + 1;
max_alpha = max_alpha - 1;
--print("- Alpha site chosen");
else -- Unable to place this Atoll
--print("-"); print("* Atoll #", loop, "was unable to be placed.");
able_to_proceed = false;
end
elseif diceroll <= 90 then
if max_delta > 0 then
plotIndex = delta_list[i_delta];
i_delta = i_delta + 1;
max_delta = max_delta - 1;
--print("- Delta site chosen");
elseif max_gamma > 0 then
plotIndex = gamma_list[i_gamma];
i_gamma = i_gamma + 1;
max_gamma = max_gamma - 1;
--print("- Gamma site chosen");
elseif max_beta > 0 then
plotIndex = beta_list[i_beta];
i_beta = i_beta + 1;
max_beta = max_beta - 1;
--print("- Beta site chosen");
elseif max_alpha > 0 then
plotIndex = alpha_list[i_alpha];
i_alpha = i_alpha + 1;
max_alpha = max_alpha - 1;
--print("- Alpha site chosen");
else -- Unable to place this Atoll
--print("-"); print("* Atoll #", loop, "was unable to be placed.");
able_to_proceed = false;
end
else
if max_epsilon > 0 then
plotIndex = epsilon_list[i_epsilon];
i_epsilon = i_epsilon + 1;
max_epsilon = max_epsilon - 1;
--print("- Epsilon site chosen");
elseif max_delta > 0 then
plotIndex = delta_list[i_delta];
i_delta = i_delta + 1;
max_delta = max_delta - 1;
--print("- Delta site chosen");
elseif max_gamma > 0 then
plotIndex = gamma_list[i_gamma];
i_gamma = i_gamma + 1;
max_gamma = max_gamma - 1;
--print("- Gamma site chosen");
elseif max_beta > 0 then
plotIndex = beta_list[i_beta];
--print("- Beta site chosen");
i_beta = i_beta + 1;
max_beta = max_beta - 1;
elseif max_alpha > 0 then
plotIndex = alpha_list[i_alpha];
i_alpha = i_alpha + 1;
max_alpha = max_alpha - 1;
--print("- Alpha site chosen");
else -- Unable to place this Atoll
--print("-"); print("* Atoll #", loop, "was unable to be placed.");
able_to_proceed = false;
end
end
if able_to_proceed and plotIndex ~= nil then
local x = (plotIndex - 1) % iW;
local y = (plotIndex - x - 1) / iW;
local plot = Map.GetPlot(x, y)
plot:SetFeatureType(feature_atoll, -1);
iNumAtollsPlaced = iNumAtollsPlaced + 1;
--else
--print("** ERROR ** Atoll unable to be placed and/or chosen Plot Index was nil.");
end
end
--[[ Debug report
print("-"); print("- Atoll Target Number: ", atoll_number);
print("- Number of Atolls placed: ", iNumAtollsPlaced); print("-");
print("- Atolls placed in Alpha locations: ", i_alpha - 1);
print("- Atolls placed in Beta locations: ", i_beta - 1);
print("- Atolls placed in Gamma locations: ", i_gamma - 1);
print("- Atolls placed in Delta locations: ", i_delta - 1);
print("- Atolls placed in Epsilon locations: ", i_epsilon - 1);
]]--
end
------------------------------------------------------------------------------