[SDK]Units adding Happiness

Joined
Sep 15, 2006
Messages
511
Using the SDK how you I set it up so that a unit when in a city will add happiness to that city?

Example, if polotictian unit is in the city its happieness would automatival go up by one and where it tells why the people are happy make it print the polotictian makes us happy.
 
No need to use the SDK. You can create a new building that adds one happiness, and then create a python event which adds/removes that building depending on the presence of a unit.

For an example, check out the Guard Station event of Fall from Heaven.
 
So basically like a great person?? Thanks for the idea though I'll play around with it.
 
No something like this:

Code:
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		pPlot = pCity.plot()
		pPlayer = gc.getPlayer(iPlayer)

		iGuardStation = gc.getInfoTypeForString('BUILDING_GUARD_STATION')
		iGuardsman = gc.getInfoTypeForString('PROMOTION_GUARDSMAN')
		pCity.setHasRealBuilding(iGuardStation, False)
		for i in range(pPlot.getNumUnits()):
			pUnit = pPlot.getUnit(i)
			if pUnit.isHasPromotion(iGuardsman):
				pCity.setHasRealBuilding(iGuardStation, True)
 
Top Bottom