1. Firaxis celebrates the "Asian American and Pacific Islander Heritage Month", and offers a give-away of a Civ6 anthology copy (5 in total)! For all the details, please check the thread here. .
    Dismiss Notice

[GS] Is there a desync free way to check is a city is building a wonder?

Discussion in 'Mod Creation Help' started by Bombermans, May 13, 2022.

  1. Bombermans

    Bombermans Chieftain

    Joined:
    May 5, 2022
    Messages:
    1
    Gender:
    Male
    Question: Is there a desync free way to check city by city if that city is building a wonder?

    Is there a way to check if a wonder is being built? For example I have this sample code from Sukritact's Egypt Rework but that mod gives desyncs online. :/ Is there a better way?

    Code:
        function OnCityProductionChanged(iPlayer, iCity)
           local pPlayer = g_Players_SetMaat[iPlayer]
           if not pPlayer then return end
    
           local pCity = pPlayer:GetCities():FindID(iCity)
           if not pCity then return end
    
           local bIsWonder = 0
           while true do
               local sBuilding = pCity:GetBuildQueue():CurrentlyBuilding()
               if not sBuilding then break end
               local tBuilding = GameInfo.Buildings[sBuilding]
               if not tBuilding then break end
    
               if tBuilding.IsWonder then
                   bIsWonder = 1
               end
               break
           end
    
           local pPlot = pCity:GetPlot()
           g_PlotPropertyHelper:SetProperty(pPlot, g_Property_SetMaat, bIsWonder)
    
           -- This is an easy way to force the City to refresh its modifiers!
           local sName = pCity:GetName()
           pCity:SetName(sName)
       end
    
       function OnPlayerTurnActivated(iPlayer)
           local pPlayer = g_Players_SetMaat[iPlayer]
           if not pPlayer then return end
    
           local pPlayerCities = pPlayer:GetCities()
           for _, pCity in pPlayerCities:Members() do
               local iCity = pCity:GetID()
               OnCityProductionChanged(iPlayer, iCity)
           end
       end
    
       Events.PlayerTurnActivated.Add(OnPlayerTurnActivated);
       Events.CityProductionChanged.Add(OnCityProductionChanged);
       Events.CityProductionCompleted.Add(OnCityProductionChanged);
    
    
    (This is just checking is player has the unique prod. district from Suk's mod. If player has that district, and the city is building a wonder, district gives double production).
     

Share This Page