Original owner and Austrian Diplo-Annex problem

krolac

Chieftain
Joined
Mar 12, 2015
Messages
19
I'm trying to give Austria additional votes in WC for each City State that they have annexed (or conquered), using a dummy building with <ExtraLeagueVotes>1</ExtraLeagueVotes> that i insert into the city with the following Lua script:

Code:
----------------------------------------------------------------------------------------------------------------------------
--City State vote bonus [AUSTRIA]
-------------------------------------------------------------------------------------------------------------------------
local CSVoteBuildingID = GameInfoTypes["BUILDING_AUSTRIA_CS_VOTE"]
local RenaissanceEraID = GameInfoTypes["ERA_RENAISSANCE"] 
local IndustrialEraID = GameInfoTypes["ERA_INDUSTRIAL"] 
local ModernEraID = GameInfoTypes["ERA_MODERN"] 
local AtomicEraID = GameInfoTypes["ERA_POSTMODERN"] 
local FutureEraID = GameInfoTypes["ERA_FUTURE"] 


function CityStateVoteBonus(iPlayer)
	local pPlayer = Players[iPlayer]
	if pPlayer:IsAlive() and pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_AUSTRIA"] then
		local GameEraID = Game.GetCurrentEra()
		local pCapital = pPlayer:GetCapitalCity()
		local iNumExtraVotes = 0
		local iTotExtraVotes = 0
		if GameEraID == RenaissanceEraID then iNumExtraVotes = 1 end
		if GameEraID == IndustrialEraID then iNumExtraVotes = 1.5 end
		if GameEraID == ModernEraID then iNumExtraVotes = 2 end
		if GameEraID == AtomicEraID then iNumExtraVotes = 3 end
		if GameEraID == FutureEraID then iNumExtraVotes = 4 end

		for pCity in pPlayer:Cities() do
			local OriginalOwner = Players[pCity:GetOriginalOwner()]
			if OriginalOwner:IsMinorCiv() then
				iTotExtraVotes = iTotExtraVotes + iNumExtraVotes
			end
		end
		iTotExtraVotes = math.ceil(iTotExtraVotes - 0.1)  --rounding fragments up
		pCapital:SetNumRealBuilding(CSVoteBuildingID, iTotExtraVotes)
	end
end

GameEvents.PlayerDoTurn.Add(CityStateVoteBonus)

The script seems to work fine but there is a problem with the Diplo-Annex function. When Austria Diplo-Annexes a City State, the Original Owner ID of that City State is changed to the Austrian ID (I can see this with the Live Tuner), so the pCity:GetOriginalOwner() method will refer to Austria, and I cannot tell the difference between a Diplo-Annexed city and a "real Austrian" city. If i conquer the City State outright, everything works fine.

Anyone knows a good workaround or other way of doing this?
 
Use SaveUtils or a dummy building to save it on the first turn that the city was originally a city state, then just check if the city has that dummy building/has the fact that it was originally a city state saved instead.
 
Thanks, that was fast!

Great tip, works like a charm (I went with dummy identifier building). Thanks a lot!
 
just be sure to set <ConquestProb> at 100 to ensure the building survives the city being captured by conquest. And if you use the same dummy for all minor civs, you can simply use pPlayer:GetBuildingClassCount(iDummyBuildingClassID) to quickly get the number of dummy buildings that are owned by the player (ie, the number of original City-State cities in the empire).

You can also do it like: pPlayer:GetBuildingClassCount(GameInfoTypes.BUILDINGCLASS_DUMMY_BUILDING)
 
Top Bottom