Fixing Great People Spawning on Defensive Structures

Gothic_Empire

AKA, Ramen Empire
Joined
Aug 5, 2008
Messages
1,502
So, I am a huge fan of the colonial legacies mods, and especially of Vietnam, but I noticed that Vietnam doesn't actually get a benefit toward great cultural people from its defensive buildings the way it's supposed to.

In FireTuner, I found this error:

Code:
Runtime Error: C:\Users\WORD\Documents\My Games\Sid Meier's Civilization 5\MODS\[BNW] Colonialist Legacies - Vietnam ft. Trung Sisters (v 1)\Lua/DefensiveGWAMSpawn.lua:28: attempt to call method 'GetGreatPeopleUnitProgress' (a nil value)

I checked out steam, and the guys behind those mods are just... busy and frankly, his discussion threads for that mod attracted a lot of trolls (:confused::confused: why are people rude to people who make such great, free content?? But that's a different rant...), so while I did leave a note there about the bug, I also thought that I'd stretch my brain a little and try to fix the bug myself.

Here's that entire file:

Code:
function GetVietnameseGreatPeopleRateChange(city)
    local greatPeopleRateChange = 0
    if city:IsHasBuilding(GameInfoTypes["BUILDING_WALLS"]) then
        greatPeopleRateChange = greatPeopleRateChange + 10
    end
    
    if city:IsHasBuilding(GameInfoTypes["BUILDING_CASTLE"]) then
        greatPeopleRateChange = greatPeopleRateChange + 10
    end
    
    if city:IsHasBuilding(GameInfoTypes["BUILDING_ARSENAL"]) then
        greatPeopleRateChange = greatPeopleRateChange + 10
    end
    
    if city:IsHasBuilding(GameInfoTypes["BUILDING_MILITARY_BASE"]) then
        greatPeopleRateChange = greatPeopleRateChange + 10
    end
    
    return greatPeopleRateChange
end
 
function VietnameseGreatArtists(playerID)
    local player = Players[playerID]
    if player:IsAlive() and player:GetCivilizationType() == GameInfoTypes["CIVILIZATION_VIETNAM"] then
        for city in player:Cities() do
            local greatPeopleRateChange = GetVietnameseGreatPeopleRateChange(city)
            if greatPeopleRateChange > 0 then
				local currentArtistRate = city:GetGreatPeopleUnitProgress(GameInfoTypes["SPECIALIST_ARTIST"])
				local currentMusiciantRate = city:GetGreatPeopleUnitProgress(GameInfoTypes["SPECIALIST_MUSICIAN"])
				local currentWriterRate = city:GetGreatPeopleUnitProgress(GameInfoTypes["SPECIALIST_WRITER"])
				city:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes["SPECIALIST_ARTIST"], currentArtistRate * greatPeopleRateChange / 100)
				city:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes["SPECIALIST_MUSICIAN"], currentMusiciantRate * greatPeopleRateChange / 100)
				city:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes["SPECIALIST_WRITER"], currentWriterRate * greatPeopleRateChange / 100)
            end
        end
    end
end
GameEvents.PlayerDoTurn.Add(VietnameseGreatArtists)

I looked to line 28, and saw:

Code:
local currentArtistRate = city:GetGreatPeopleUnitProgress(GameInfoTypes["SPECIALIST_ARTIST"])

It seemed logical to me that GetGreatPeopleUnitProgress may need to reference a unit, so I changed lines 28, 29, and 39 to:

Code:
				local currentArtistRate = city:GetGreatPeopleUnitProgress(GameInfoTypes["[COLOR="RoyalBlue"]UNIT_GREAT_ARTIST[/COLOR]"])
				
local currentMusiciantRate = city:GetGreatPeopleUnitProgress(GameInfoTypes["[COLOR="RoyalBlue"]UNIT_GREAT_MUSICIAN[/COLOR]"])
				
local currentWriterRate = city:GetGreatPeopleUnitProgress(GameInfoTypes["[COLOR="RoyalBlue"]UNIT_GREAT_WRITER[/COLOR]"])

but to no effect. Reading along with this thread, I discovered that there is likely a problem with lines 31 through 33 as well, but to be perfectly honest, I'm so green at this that the problem and the stated solution just didn't make sense to me. :-)

If anyone could help shine some light on this for me, I'd be much obliged!

Thanks,

GE

Edit:

I SORT of fixed the problem.

I changed line 28 to this:

Code:
local currentArtistRate = city:[COLOR="RoyalBlue"]GetSpecialistGreatPersonProgress[/COLOR](GameInfoTypes["SPECIALIST_ARTIST"])

and found that there are, indeed, great people points now being added every turn. At extraordinarily low rates, that are being manipulated by the variables in the rest of the code that either generate exponentially absurdly large amounts of gpp, or the opposite. There doesn't seem to be a reasonable number.

It doesn't feel balanced, because having walls and a writer's guild doesn't really make your great writer come out meaningfully faster, because it's adding something like .04 of a gpp and then doubling that. It might be incredibly balanced and my sense of balance is screwed over because I'm not privy to this in a real game, and didn't compare a regular writer's guild to a Vietnamese one with walls.

My questions are these:

Is there anything I could do to make the interface that keeps track of gpp take the Vietnamese bonus into account?

How would I add a static number of gpp to the individual buildings? Say, 1 to walls, 2 to castles, 4 to the next one, 6 to the next one--as an example.

OR

How could I force it to round up to the nearest point?

Thanks again!

GE
 
The GetGreatPeopleUnitProgress() method on a city was removed in BNW - the value it was getting was never used anyway
 
The GetGreatPeopleUnitProgress() method on a city was removed in BNW - the value it was getting was never used anyway

EEEK! The man himself <3.

But yes--I found that =) I changed it to GetSpecialistGreatPersonProgress()

...and am now stumbling around as indicated in my edit.
 
because it's adding something like 0.04 of a gpp

I've not studied the posted code in depth, but a lot of the internal variables changed from "X" to "Xtimes100" between G&K and BNW, so you may just need to multiply by 100 (which would then add 4 and not 0.04) as the latter code is dividing by 100
 
Back
Top Bottom