What function can detect a civ's original capital

Craig_Sutter

Deity
Joined
Aug 13, 2002
Messages
2,773
Location
Calgary, Canada
As the question says, I need to detect if a city was the original capital of a civilization upon conquest. Just want it to fire for the only the original capital, not the current capital (for instance, the original capital has already been captured).

GameEvents.CityCaptureComplete.Add(oldPlayerID, bCapital, iX, iY, newPlayerID, bConquest)

has a boolean for capital, however, I strongly suspect that this would be for the current capital of the old player, not the original capital.

Could not find anything in the wiki... figure there must be something, as the game detects original capitals for domination victory determination.
 
Think I may have figured it out...

using the conquest function, I do the following...

Code:
if pCity ~= nil and (pCity:GetOwner() == iHRE) and OriginalOwner:IsMinorCiv()
	or pCity ~= nil and (pCity:GetOwner() == iHRE) and bCapital and not OriginalOwner:IsHasLostCapital() then

Does that make sense?

PS

The code in total is as follows...

Code:
-- when a city is captured by the HRE, and that city is originally owned by a minor civ or is the capital of a major civ
-- a Rathaus will be installed.

function HRERathaus (oldPlayerID, bCapital, iX, iY, newPlayerID, bConquest)

local newPlayer = Players[newPlayerID];
local oldPlayer = Players[oldPlayerID];
local plot = Map.GetPlot(iX, iY);
local pCity = plot:GetPlotCity();
local OriginalOwner = Players[pCity:GetOriginalOwner()]
local HRE
local iHRE

--Set up HRE

	for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do

	local pHRE = Players[iPlayer]

   		if (GameInfo.Civilizations.CIVILIZATION_PERSIA.ID == pHRE:GetCivilizationType()) then
	
		HRE = pHRE
		iHRE = iPlayer

		end
	end

-- City exists, was originally owned by a Minor or is a major power capital?

	if pCity ~= nil and (pCity:GetOwner() == iHRE) and OriginalOwner:IsMinorCiv()
	or pCity ~= nil and (pCity:GetOwner() == iHRE) and bCapital	and not OriginalOwner:IsHasLostCapital() and oldPlayer == OriginalOwner then
									
			pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_RATHAUS"], 1);
			print(pCity:GetName(), "...is spawning Rathaus...")

	end

end

GameEvents.CityCaptureComplete.Add(HRERathaus)

And I think I've answered my own question, unless someone sees a problem :).
 
I've changed the original function as follows:

Code:
-- when a city is captured by the HRE, and that city is originally owned by a minor civ or is the capital of a major civ
-- a Rathaus will be installed.

function HRERathaus (oldPlayerID, bCapital, iX, iY, newPlayerID, bConquest)

local newPlayer = Players[newPlayerID];
local oldPlayer = Players[oldPlayerID];
local plot = Map.GetPlot(iX, iY);
local pCity = plot:GetPlotCity();
local OriginalOwner = Players[pCity:GetOriginalOwner()]
local HRE
local iHRE

--Set up HRE

	for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do

	local pHRE = Players[iPlayer]

   		if (GameInfo.Civilizations.CIVILIZATION_PERSIA.ID == pHRE:GetCivilizationType()) then
	
		HRE = pHRE
		iHRE = iPlayer

		end
	end

-- City exists, was originally owned by a Minor or is a major power capital?

	if pCity ~= nil and (pCity:GetOwner() == iHRE) and OriginalOwner:IsMinorCiv()
	[COLOR="Red"]or pCity ~= nil and (pCity:GetOwner() == iHRE) and bCapital	and pCity:IsOriginalCapital() and oldPlayer == OriginalOwner then[/COLOR]
									
			pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_RATHAUS"], 1);
			print(pCity:GetName(), "...is spawning Rathaus...")

	end

end

GameEvents.CityCaptureComplete.Add(HRERathaus)
 
Back
Top Bottom