FfH modding questions

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,603
Location
Gent, Belgium
I thought perhaps a thread for FfH modding issues would be useful. Threads in Civ4 Creation & Customization are usually quickly drowned in the mass of other threads.


I'm wondering about something myself. :mischief: If the Barbarians or a player with the Barbarian trait razes a city, I'd like the barbarians spawning Ruins terrain improvement (instead of City Ruins) to be created on the city tile. However my attempts so far doesn't work. There still appear City Ruins. Does anyone have an idea what could be the problem?

Code:
	def onCityRazed(self, argsList):
		'City Razed'
		city, iPlayer = argsList
		
		owner = PyPlayer(city.getOwner())
		razor = PyPlayer(iPlayer)

		pPlayer = gc.getPlayer(iPlayer)

		if (pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_BARBARIAN')) or pPlayer == gc.getBARBARIAN_PLAYER()):
			city.plot().setImprovementType(-1) ; I tried with and without this line
			city.plot().setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_RUINS'))
 
You would need an SDK change to do this. The reason is that the python function you are intercepting is called before the city is deleted. Since the city is still there you can't drop an improvement on it.

The SDK change wouldn't need to be major, you would just need to reverse the order of the following 2 lines in acquireCity() in CvPlayer.cpp:

Code:
	gDLL->getEventReporterIFace()->cityRazed(pOldCity, getID());

	pOldCity->kill();
 
Ah thanks. :) SDK means it's out of my league unfortunately. :(

Hmm.. you could put it in the onMove function. If a barbarian unit enters a city ruins it turns it into a ruins tile.
 
Yeah I know. But I'm kinda wondering, since moving units is one of the most common actions you do, aren't lots of onMove events likely to slow the game down?

OnBeginGame/PlayerTurn when a unit is located on a city ruins would also work I guess, but then the unit may not have moved away yet after razing the city.
 
Yeah I know. But I'm kinda wondering, since moving units is one of the most common actions you do, aren't lots of onMove events likely to slow the game down?

OnBeginGame/PlayerTurn when a unit is located on a city ruins would also work I guess, but then the unit may not have moved away yet after razing the city.

well... we already have sentry towers
as city ruins are a far less strategic position than a city- you shouldn't get much overcrowding to trigger it
 
Back
Top Bottom