[GS] Need to find a way to reveal all natural wonders to a player

ChrisWJN

Chieftain
Joined
Mar 12, 2019
Messages
43
Location
Canada
I've been looking into how I can reveal all natural wonders to the player at game start, and there doesn't seem to be any pre-made modifiers or LUA functions that can do it for me. Currently, the best idea I've got is to just iterate through every plot on the map at the start of the game, and if it's a natural wonder tile reveal it to the civ. However, nothing really jumps out at me in terms of how I can get a list of all the plots in the game. This is my code currently.
Code:
hasRun = false
Events.PlayerTurnStarted.Add(function(_player)
    if (hasRun==false) then
        if (PlayerConfigurations[_player].GetLeaderTypeName() == "xxx") then
            hasRun = true
            local plots = **SOMEHOW GET A TABLE OF ALL PLOTS ON MAP?**
            for key, value in pairs(plots) do
                if value:isNaturalWonder() then
                    local pHumanVisibility = PlayersVisibility[_player]
                    local iPlotIndex = value:GetIndex()
                    pHumanVisibility:ChangeVisibilityCount(iPlotIndex, 0)
                end
            end
        end
    end)
If anyone has any ideas, please let me know! Thanks.
 
First I would suggest you use it at the creation of the first city or such, one shot to do it, and you store information in a variable or table.

How I would do it (you still have to make it recursive):

Code:
-- Get your first city plot

-- TODO: make this a function and make it recursive
 if (plot:IsNaturalWonder() == false and AdjacentToNaturalWonder(plot) == false) then
 for direction = 0, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
                local pAdjacentPlot= Map.GetAdjacentPlot(plot:GetX(), plot:GetY(), direction);
              

[CODE]
 
to get all plots:
Code:
    iW, iH = Map.GetGridSize()
    for i = 0, (iW * iH) - 1, 1 do
        pPlot = Map.GetPlotByIndex(i)
        -- your code
    end
 
Top Bottom