Question about Terrain and Hills

yeah it doesn't seem very logical this way. Again, I found it by looking through the map scripts. If you want to change terrain they're a good place to look how it works...

Of course, you can also ask here, so that I get to answer and humanity can profit from my infinite Python/Civ4 Modding wisdom gathered in three days work ;)
 
Code:
def spellTsunami(caster,target):
	doCast(caster)
	pPlot = target
	if pPlot.isOwned():
		startWar(caster.getOwner(), pPlot.getOwner())
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if isResisted(pUnit,caster,0) == False:
			iDmg = pUnit.getDamage() + 10 + CyGame().getSorenRandNum(20, "Bob")
			if iDmg > 100:
				pUnit.kill(True,0)
			else:
				pUnit.setDamage(iDmg, True)
	#if CyGame().getSorenRandNum(100, "Bob") <= gc.getDefineINT('TSUNAMI_FLOOD_CHANCE'):
	if pPlot.isCity():
		if pPlot.getPlotCity().getPopulation() > 2:
			pPlot.getPlotCity().changePopulation(-2)
		else:
			pPlot.getPlotCity().kill()
	else:
		pPlot.setImprovementType(-1)
		iniPlotType = pPlot.getPlotType()
		pPlot.setFeatureType(-1, -1)
		if iniPlotType == 0:
			pPlot.setPlotType(PlotTypes.PLOT_HILLS, True, True)
		if iniPlotType == 1:
			pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
		if iniPlotType == 2:
			pPlot.setBonusType(-1)
			pPlot.setPlotType(PlotTypes.PLOT_OCEAN, True, True)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				pPlot2 = findClearPlot(pUnit)
				if pPlot2 == -1:
					pUnit.kill(True,0)
				else:
					pUnit.setXY(pPlot2.getX(),pPlot2.getY())

thats the change i did for the tsunami spell, atm it kills a city 2 population at a time, then once its destroyed it it starts terraforming.

personally im gonna do more on it later, but trying to figure out how to know if the city has walls has not been intuitive to me. also i want to do the same for one of the earth 3 spells but in reverse, but tremor and earthquake both seem to be AoE spells, not targetted.
 
Sureshot said:
personally im gonna do more on it later, but trying to figure out how to know if the city has walls has not been intuitive to me.

This should do the trick:
Code:
pPlot.getPlotCity().hasBuilding(gc.getInfoTypeForString('BUILDING_WALLS'))
 
I'm not sure, but I think that there are more than just those types of walls. I'd have to look into the code myself, but I think that the walls that a mage adds (via "walls of stone" or some such similiar spell) would also need to be asked for then. It makes the code nastier (having to explicitly ask for each type), but I think that it probably would need to be done.
 
Back
Top Bottom