LoneGazebo / Community-Patch-DLL

Community Patch for Civilization V - Brave New World
Other
286 stars 158 forks source link

City:IsEverOwned() not working #8298

Closed pineappledan closed 3 years ago

pineappledan commented 3 years ago

1. Mod version (X.Y.Z, e.g. 1.0.0): 1.0.3

2. Mod list (if using Vox Populi only, leave blank): VP, Goths for VP

3. Error description: City:IsEverOwned() not working Everything fails the check if you try to see if you have ever captured a city before. Probably has something to do with @inkyant 's city capture logic changes

4. Steps to reproduce (optional): Capture city

It gets right up to the last print statement, but the Golden Age doesn't start in the code below. Everything works until that final check. This was all working last VP version; I haven't changed anything.

function SackerOfRomeUA(iOldOwner, bIsCapital, iX, iY, iNewOwner, iPop, bConquest)
    local pPlayer = Players[iNewOwner]
    if not (pPlayer and pPlayer:GetCivilizationType() == GothsID) then return end

    local plot = Map.GetPlot(iX, iY);   
    local cCity = plot:GetPlotCity();
    print("Captured a city:::")
    print("City belongs to the Goths:::")

    if iNewOwner ~= iOldOwner then
        local oPlayer = Players[iOldOwner]

        if (cCity:IsOriginalCapital() and not oPlayer:IsMinorCiv()) then
            print("City is an Original Capital:::")
            if not cCity:IsEverOwned(iNewOwner) then
                local iLengthModifier = ((100 + pPlayer:GetGoldenAgeModifier()) / 100)
                print(iLengthModifier)
                local iGameSpeedModifier = (GameInfo.GameSpeeds[ Game.GetGameSpeedType() ].GoldenAgePercent / 100)
                local iTurns = ((GameDefines.GOLDEN_AGE_LENGTH) * iLengthModifier * iGameSpeedModifier)
                local iValue = pPlayer:GetGoldenAgeProgressMeter()
                pPlayer:ChangeGoldenAgeTurns(iTurns, iValue)
            end
        end
    end
end
GameEvents.CityCaptureComplete.Add(SackerOfRomeUA)
LoneGazebo commented 3 years ago

@RecursiveVision I think you changed this?

RecursiveVision commented 3 years ago

@LoneGazebo We both did.

Problem is that the LUA code in acquireCity() fires after the city has changed hands and numtimesowned has been incremented.

@pineappledan You can use the new GetNumTimesOwned() function I added and check for > 1

Or perhaps we should just have isEverOwned return > 1? Misleading, but...

RecursiveVision commented 3 years ago

Yeah just use GetNumTimesOwned