C15's Golden Age Threshold Check Utility

Chrisy15

Flower, Beautiful
Joined
Jul 9, 2015
Messages
2,127
This is just a block of code that I found I used far too much, and that rewriting it every time was inefficient and boring. It's to be used after any code that adds Golden Age points, and it checks to see whether your GAP will surpass the threshold. This is needed because if you add GAP on PlayerDoTurn, that GAP won't trigger a Golden Age until the turn after. This will solve this problem; although it doesn't fire the Golden Age popup, it will create a finger notification, remove the GAP in the meter and set the Golden Age to the correct length.

Code:

Code:
function C15_GoldenAgeThresholdCheck(pPlayer)
    local iGoldAgeProg = pPlayer:GetGoldenAgeProgressMeter()
    local iGoldenAgeThreshold = pPlayer:GetGoldenAgeProgressThreshold()
    if iGoldAgeProg >= iGoldenAgeThreshold then
        pPlayer:ChangeGoldenAgeProgressMeter(-iGoldenAgeThreshold)
        pPlayer:ChangeGoldenAgeTurns(pPlayer:GetGoldenAgeLength())
    end
end

Nice and simple, but easier than duplicating code over and over :p Import into VFS, as you would with PlotIterators. (Or, y'know, just paste into your file. Shh, LeeS, I'm trying to be fancy :p)

Feel free to critique stuff or whatever - I'm wary that I've probably named it badly, meaning that Firaxis' flawless include system might not like it; if it will cause an issue then I'll rename it.

Hope this is of use to you!
 

Attachments

  • C15_GoldenAgeThresholdCheckUtil.7z
    388 bytes · Views: 125
Last edited:
Top Bottom