Increasing wealth from Capturing a city

Xyth

History Rewritten
Joined
Jul 14, 2004
Messages
4,106
Location
Aotearoa
Sorry to bother this forum yet again but hopefully one of you can help me with this dilemma. I want a trait to double the amount of wealth received for capturing a city but the relevant procedure doesn't have any arguments that identify the conqueror. Can anyone think of some solution to achieve this?

Here's the procedure, currently it checks the trait of the conquered player not the conqueror:

Code:
	def doCityCaptureGold(self, argsList):
		"controls the gold result of capturing a city"
		pOldCity = argsList[0]

		iCaptureGold = 0
		iCaptureGold += gc.getDefineINT("BASE_CAPTURE_GOLD")
		iCaptureGold += (pOldCity.getPopulation() * gc.getDefineINT("CAPTURE_GOLD_PER_POPULATION"))
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND1"), "Capture Gold 1")
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND2"), "Capture Gold 2")

		if (gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS") > 0):
			iCaptureGold *= cyIntRange((CyGame().getGameTurn() - pOldCity.getGameTurnAcquired()), 0, gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS"))
			iCaptureGold /= gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS")

	###	BEGIN Increased Capture Gold
		pPlayer = gc.getPlayer(pOldCity.getOwner())
		iTraitAGG = gc.getInfoTypeForString('TRAIT_AGGRESSIVE')

		if pPlayer.hasTrait(iTraitAGG):
			iCaptureGold = iCaptureGold * 2
	###	END Increased Capture Gold

		return iCaptureGold

Alternately, is it possible to call doCityCaptureGold a second time from onCityAcquired so that you achieve the same effect by getting two lots of capture gold?
 
I guess the pOldCity instance is the once which does not longer exist, and that this here is triggered after the city has changed it's owner, right?
-> hack solution: Get the X and Y coordinates of the old city, and get via these the current city and get the owner from there.
 
The_J is on to something. You could also achieve this basic solution with CyCity.plot(), CyPlot.getPlotCity() and CyCity.getOwner(). Expressed, for instance, as:
Code:
pPlayer = gc.getPlayer(pOldCity.plot().getPlotCity().getOwner())
If this fails, try it without CyPlot.getPlotCity() and use CyPlot.getOwner() instead.
 
...and if all fails, you should be able to identify the conqueror by finding the first unit on the city tile at war with the previous owner. This involves iterating through all units using the return value of CyPlot.getNumUnits() as the range and using the index number with CyPlot.getUnit(). Each unit is then evaluated with CyUnit.getTeam(), via CyGlobalContext.getTeam() and finally CyTeam.isAtWar(). You will also need CyCity.getTeam() for the TeamType of the original city's owner.
 
Thanks for your ideas. Unfortunately after trying them out and some further testing I've determined that doCityCaptureGold is triggered before the city or the tile change ownership and before the conquering unit even moves into the tile. I guess I could iterate through units on the tiles surrounding the city but that's getting messy for such a small change. I'm going to try giving the extra gold in a separate sum via onCityAcquired instead.

Appreciate the help :)
 
This can be done with SDK modding. You should learn how to recompile a dll, the modding itself is easy.
 
Back
Top Bottom