• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

City Defense +100% if Gold stays above X amount, how?

kingchris20

Wisdom Seeker
Joined
Jul 30, 2012
Messages
1,343
Location
Resident of Heaven; Currently in the Waiting Room
Wondering if someone could walk me through some coding, I guess it would need to be LUA?

I want to make city defense is +100% (doubled) so long as gold reserves stays above X amount of Gold, say 1,000 or so.

How could I accomplish this as either a trait (to each player city) or a building/wonder effect (that could be built in any city/apply to each player city), or a garrisoned unit effect (in which could be garrisoned in each city). I'm literally wide open on how it gets applied, I've just not worked in LUA enough to know where to begin or where to look.
 
Thoughts?
 
For use with a building that gives +100% defence:
Code:
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
	local pPlayer = Players[iPlayer]
	if not (pPlayer:GetCivilizationType() == GameInfoTypes.[B][COLOR="Blue"]CIVILIZATION_YOURCIVNAMEHERE[/COLOR][/B]) then return end
	for pCity in pPlayer:Cities() do
		if (pPlayer:GetGold() >= [B][COLOR="blue"]1000[/COLOR][/B]) then
			pCity:SetNumRealBuilding(GameInfoTypes.[B][COLOR="blue"]BUILDING_EBSAREJRWERJREIWEGUEWVGVH[/COLOR][/B], 1) -- I really hope you don't actually use this building name
		else
			pCity:SetNumRealBuilding(GameInfoTypes.[B][COLOR="blue"]BUILDING_EBSAREJRWERJREIWEGUEWVGVH[/COLOR][/B], 0)
		end
	end
end)
Replace bolded blue parts to suit your needs
 
Thanks! Really appreciate it.
 
Back
Top Bottom