So for some reason SetFeatureType crashes my game for any feature type with an ID greater than 6; that is, all ordinary features work, but any natural wonder does not.
Okay, I thought, I'll see if there's something I'm missing, so I went into AssignStartingPlots where AttemptToPlaceNaturalWonder exists, and seems to have no trouble placing them. I figured that they weren't being placed because the tile / surrounding tiles weren't right for that particular wonder, so I copied and modified some of the code from AttemptToPlaceNaturalWonder so that the necessary modifications to the nearby tiles were done for each wonder. That worked fine, all of the required terrain modifications were done; still, the game crashed.
Next I decided to completely manually ensure that everything was perfect for the Rock of Gibraltar to be placed with no problems. NWCustomEligibility in NaturalWondersCustomMethods.lua was able to ensure that the tile was completely eligible for the wonder, I had it returning true so I called NWCustomPlacement first to get it ready. plot:SetFeatureType(GameInfoTypes["FEATURE_GIBRALTAR"]) crashed the game, again.
I've spent the last 5 or so hours just screwing with everything I can think of to just get it to work a single damn time, and it hasn't yet once. Here's an extremely simple example script that will crash.
Any help is appreciated.
EDIT: Ugh, I think I've figured it out. All that needed to be done was a Map.RecalculateAreas() before wonders could be placed. Now I feel silly.
I'm not sure if I can delete this thread but I'm gonna leave it here just in case anyone else tries to place a wonder manually without that important step coming first.
Okay, I thought, I'll see if there's something I'm missing, so I went into AssignStartingPlots where AttemptToPlaceNaturalWonder exists, and seems to have no trouble placing them. I figured that they weren't being placed because the tile / surrounding tiles weren't right for that particular wonder, so I copied and modified some of the code from AttemptToPlaceNaturalWonder so that the necessary modifications to the nearby tiles were done for each wonder. That worked fine, all of the required terrain modifications were done; still, the game crashed.
Next I decided to completely manually ensure that everything was perfect for the Rock of Gibraltar to be placed with no problems. NWCustomEligibility in NaturalWondersCustomMethods.lua was able to ensure that the tile was completely eligible for the wonder, I had it returning true so I called NWCustomPlacement first to get it ready. plot:SetFeatureType(GameInfoTypes["FEATURE_GIBRALTAR"]) crashed the game, again.
I've spent the last 5 or so hours just screwing with everything I can think of to just get it to work a single damn time, and it hasn't yet once. Here's an extremely simple example script that will crash.
Code:
function GetMapScriptInfo()
return {
Name = "TestingMap",
Description = "TestingMap Description",
IsAdvancedMap = false,
IconIndex = 17,
CustomOptions = {},
}
end
function GenerateMap()
print("GenerateMap() begin");
-- Getting map dimensions
local iW, iH = Map.GetGridSize();
print("Map size: " .. iW .. "x" .. iH)
-- Filling the map with ordinary grass (don't know if it matters)
for i = 0, iW * iH - 1 do
Map.GetPlotByIndex(i):SetPlotType(PlotTypes.PLOT_LAND, false, false)
Map.GetPlotByIndex(i):SetTerrainType(GameInfoTypes.TERRAIN_GRASS, false, false)
end
-- Now, to try placing Uluru at (10, 10)
plot = Map.GetPlot(10, 10)
-- Make it a plains / mountain tile (don't know if it matters, I want to be able to force it on any tile anyway)
plot:SetPlotType(PlotTypes.PLOT_MOUNTAIN, false, false)
plot:SetTerrainType(GameInfoTypes.TERRAIN_PLAINS, false, false)
plot:SetFeatureType(GameInfoTypes.FEATURE_ULURU)
print("This is never executed, crash has occurred.")
end
Any help is appreciated.
EDIT: Ugh, I think I've figured it out. All that needed to be done was a Map.RecalculateAreas() before wonders could be placed. Now I feel silly.
I'm not sure if I can delete this thread but I'm gonna leave it here just in case anyone else tries to place a wonder manually without that important step coming first.