Natural wonders development thread

well imagine scientists come and settle because they are researching unique animals or a prophet settles as he belives the site is holy. An artist settles as he wants o paint it. A engineer might be hired to build a statue in the city to comemorate it or maybe build a visitor centre. A merchant might be there to sell merchandise or profit from the wonder in some other way. Very believable

XML tag is easy, making it work is the hard bit. that would be voy's domain.

I thnk haver a 50% chance for happiness or random settled specialist. In python for the moment, it's easy, fast (you reeeealy won't tell the difference) and this has taken long enough, I can start work on friday and finish on friday as well.

That is the key point :D

When there are too many people trying to decide what to do, nothing gets done.
17 pages down the road and you guys are still debating what benefits to get, whether to do it SDK or python etc
Thus I decided to give it a little perk :D

Simplified version, pure python
 
done :D

This is pretty good, have a play with the variables at the top :D the specialists will not include spy as there is not reason for it! But it seems to work fie for me :D (don't fprget to change the wonder movies for uluru etc as they are still set as Parthenon!)

Spoiler :

Code:
#Natural Wonders Contants
def doNaturalWondersConstantsInit():
        global Game
        global iNumPermanentHappy
        global iHappyTurns
        global iChanceForHappy
        Game = CyGame()
        iModifier = gc.getGameSpeedInfo(Game.getGameSpeedType()).getUnitGreatWorkPercent()
        iNumPermanentHappy = 1 #Happy provided for ownership
        iHappyTurns = 10 #Number of turns happiness on discovery
        iChanceForHappy = 50 #This is the chance that the city will get happiness over specialist for ownership!

	def onGameStart(self, argsList):
		'Called at the start of the game'

# Natural Wonders - Start
		doNaturalWondersConstantsInit()
                # This is the code that spawns each natural wonder into the map to add new wonder see below!
		dNaturalWonders = {\
                #These are parameters for new wonders, you pick a type ie: "TERRAIN_DESERT" and then things about it
                # in order of appearance: is it a hill?, (if coast) is it next to a land tile? is it a river? is it a mountain?
                # (if water) is it a lake?, is the tile adjectent to lake or oasis?, is it next to the sea (possibly lake?)?, is it a water tile?
                # True for yes
                # False for no
                # None for doesn't matter (same for terrain, however in this case bWater will handle plot type (bWater CANNOT be None))
                #Wonder XML name:[TerrainType, bHills, bAdjecentLand, bRiver, bPeak, bLake, bFreshWater, bCostalLand, bWater (CANNOT BE NONE!)]
		"FEATURE_DEVILS_TABLE":["TERRAIN_PLAINS", True, None, None, None, None, None, None, False],\
		"FEATURE_LANDSCAPE_ARCH":["TERRAIN_DESERT", False, None, None, False, None, False, None, False],\
		"FEATURE_PAMUKKALE":["TERRAIN_GRASS", False, None, None, False, None, False, None, False],\
		"FEATURE_VICTORIA_FALLS":["TERRAIN_GRASS", False, None, False, False, None, False, None, False],\
		"FEATURE_SOPKA":["TERRAIN_TUNDRA", False, None, False, False, None, False, None, False],\
		"FEATURE_ULURU":["TERRAIN_DESERT", False, None, False, False, None, None, None, False],\
		"FEATURE_SUGARLOAF":["TERRAIN_COAST", None, True, None, None, None, None, None, True]\
		}
		iNumCivs = Game.countCivTeamsEverAlive()

                #check if all plots are revealed by default
		x = 0
		bAllRevealed = False
		for team in xrange(iNumCivs):
			if CyMap().plot(0, 0).isRevealed(team, False):
				x += 1
		if x == iNumCivs:
			bAllRevealed = True
                
		for wonder in dNaturalWonders.iterkeys():
			WonderType = gc.getInfoTypeForString(wonder)
			TerrainType = gc.getInfoTypeForString(dNaturalWonders[wonder][0])
			bHills = dNaturalWonders[wonder][1]
			bAdjacentLand = dNaturalWonders[wonder][2]
			bRiver = dNaturalWonders[wonder][3]
			bPeak = dNaturalWonders[wonder][4]
			bLake = dNaturalWonders[wonder][5]
			bFreshWater = dNaturalWonders[wonder][6]
			bCoastalLand = dNaturalWonders[wonder][7]
			bWater = dNaturalWonders[wonder][8]
                        #start checking plots
			lPlots = []
			for i in range(CyMap().numPlots()):
				pPlot = CyMap().plotByIndex(i)
				bPlotPerfect = False
				if (not pPlot.isWater() and not pPlot.isAdjacentToLand()) or pPlot.isGoody(): continue #This plot must be a one tile island or have a goody hut
				if not pPlot.getFeatureType() == -1:
					if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder(): continue #has a wonder already
				if pPlot.getBonusType(-1) != -1: continue
				for team in xrange(gc.getMAX_CIV_TEAMS()):
					if (pPlot.isRevealed(team, False) and not bAllRevealed):
						bPlotPerfect = True
						break
				if bPlotPerfect: continue
				if TerrainType != None:
					if pPlot.getTerrainType() != TerrainType: continue
				elif pPlot.isWater() != bWater: continue
				if bHills != None and pPlot.isHills() != bHills: continue
				if bAdjacentLand != None and pPlot.isAdjacentToLand() != bAdjacentLand: continue
				if bRiver != None and pPlot.isRiver() != bRiver: continue
				if bPeak != None and pPlot.isPeak() != bPeak: continue
				if bLake != None and pPlot.isLake() != bLake: continue
				if bFreshWater != None and pPlot.isFreshWater() != bFreshWater: continue
				if bCoastalLand != None and pPlot.isCoastalLand() != bCoastalLand: continue
				lPlots.append(pPlot)

			if len(lPlots) > 0:
				pPlot = lPlots[Game.getSorenRandNum(len(lPlots), "Random Plot")]
				pPlot.setFeatureType(WonderType, 0)
# Natural Wonders - End

	def onPlotRevealed(self, argsList):
		'Plot Revealed'
		pPlot = argsList[0]
		iTeam = argsList[1]
		
# Natural Wonders - Start
		iFeature = pPlot.getFeatureType()
		if iFeature != -1:
			iFeatureInfo = gc.getFeatureInfo(iFeature)
			if iFeatureInfo.isNaturalWonder():
				pTeam = gc.getTeam(iTeam)
				if not pTeam.isBarbarian():
					for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
						pPlayerX = gc.getPlayer(iPlayerX)
						if pPlayerX.getTeam() == iTeam:
							message = "TXT_KEY_WONDERDISCOVERED_YOU"
							tValues = (iFeatureInfo.getDescription(),)
							(loopCity, iter) = pPlayerX.firstCity(False)
							while(loopCity):
								loopCity.changeHappinessTimer(iHappyTurns)
								(loopCity, iter) = pPlayerX.nextCity(iter, false)
							if pPlayerX.isHuman():
								popupInfo = CyPopupInfo()
								popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
								popupInfo.setData1(iFeature)
								popupInfo.setData3(3)
								popupInfo.setText(u"showWonderMovie")
								popupInfo.addPopup(iPlayerX)
						else:
							message = "TXT_KEY_WONDERDISCOVERED_ELSE"
							leader = gc.getPlayer(pTeam.getLeaderID()).getName()
							tValues = (leader, iFeatureInfo.getDescription())
                                                                        
						message = localText.getText(message, tValues)
						CyInterface().addMessage(iPlayerX, True, 20, message, "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT,"", -1, -1, -1, False, False)
# Natural Wonders - End

	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]
		if (city.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(city, False)	
		CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
# Natural Wonders - Start
		for x in range(city.getX() - 1, city.getX() + 2): # To who ever removed my index loop: you do realise this is first ring tiles only?!
			for y in range(city.getY() - 1, city.getY() + 2): # Oh well I wanted that to happen now anyway :p
				pPlot = CyMap().plot(x, y)
				if pPlot.getFeatureType() > -1:
					if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
                                                if Game.getSorenRandNum(100, "Chance for happy") < iChanceForHappy:
                                                        city.changeExtraHappiness(iNumPermanentHappy)
                                                else:
                                                        city.changeFreeSpecialistCount(Game.getSorenRandNum(5, "Specialist") + 1, 1) #is this too risky? randomly picks between priest, artist, merchant, engineer and scientist
                                                
# Natural Wonders - End
	
	def onCityAcquired(self, argsList):
		'City Acquired'
		iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
# Natural Wonders - Start
                ##This code isn't needed as specialists and happiness are permanent effects!
		##for x in range(pCity.getX() - 1, pCity.getX() + 2):
                ##        for y in range(pCity.getY() - 1, pCity.getY() + 2):
		##	pPlot = CyMap().plot(x, y)
		##	if pPlot.getFeatureType() > -1:
		##		if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
		##			pCity.changeCulture(iPreviousOwner, - iCulture, True)
		##			if abs(pPlot.getX() - pCity.getX()) == 1 and abs(pPlot.getY() - pCity.getY()) == 1:
		##				pCity.changeCulture(iNewOwner, iCulture, True)
# Natural Wonders - End
		CvUtil.pyPrint('City Acquired Event: %s' %(pCity.getName()))
	
	def onCultureExpansion(self, argsList):
		'City Culture Expansion'
		pCity = argsList[0]
		iPlayer = argsList[1]
# Natural Wonders - Start
                ##This code isn't needed as specialists and happiness are permanent effects!
		##for iIndex in range(21):
		##	pPlot = pCity.getCityIndexPlot(iIndex)
		##	if pPlot.getFeatureType() > -1:
		##		if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
		##			if abs(pPlot.getX() - pCity.getX()) != 1 or abs(pPlot.getY() - pCity.getY()) != 1:
		##				if pCity.getCultureLevel() == 2: #has the city just gained it's full BFC?
		##					pCity.changeCulture(iPlayer, iCulture, True)
		##					gc.getPlayer(iPlayer).changeGold(iGold)
# Natural Wonders - End
		CvUtil.pyPrint("City %s's culture has expanded" %(pCity.getName(),))


checks are on GameStart, onPlotRevealed (now not only the first civilzation to discover wonder gets the 10 turns happiness) and onCityBuilt!!!

replace your methods with the respective ones in the spoiler!!!
 
great :D you should have the great barrier reef I think. Maybe just some coral in the sea make sure you check the adjecent to land conditon in the code for that one :D
 
I see you are still using the hard coded array in the Python rather than getting the values from the XML. Dosen't that sort of defeat the purpose of the XML?:mischief:
Code:
# Natural Wonders - Start
		doNaturalWondersConstantsInit()
                # This is the code that spawns each natural wonder into the map to add new wonder see below!
		dNaturalWonders = {\
                #These are parameters for new wonders, you pick a type ie: "TERRAIN_DESERT" and then things about it
                # in order of appearance: is it a hill?, (if coast) is it next to a land tile? is it a river? is it a mountain?
                # (if water) is it a lake?, is the tile adjectent to lake or oasis?, is it next to the sea (possibly lake?)?, is it a water tile?
                # True for yes
                # False for no
                # None for doesn't matter (same for terrain, however in this case bWater will handle plot type (bWater CANNOT be None))
                #Wonder XML name:[TerrainType, bHills, bAdjecentLand, bRiver, bPeak, bLake, bFreshWater, bCostalLand, bWater (CANNOT BE NONE!)]
		"FEATURE_DEVILS_TABLE":["TERRAIN_PLAINS", True, None, None, None, None, None, None, False],\
		"FEATURE_LANDSCAPE_ARCH":["TERRAIN_DESERT", False, None, None, False, None, False, None, False],\
		"FEATURE_PAMUKKALE":["TERRAIN_GRASS", False, None, None, False, None, False, None, False],\
		"FEATURE_VICTORIA_FALLS":["TERRAIN_GRASS", False, None, False, False, None, False, None, False],\
		"FEATURE_SOPKA":["TERRAIN_TUNDRA", False, None, False, False, None, False, None, False],\
		"FEATURE_ULURU":["TERRAIN_DESERT", False, None, False, False, None, None, None, False],\
		"FEATURE_SUGARLOAF":["TERRAIN_COAST", None, True, None, None, None, None, None, True]\
		}
 
nope :p

There are reasons for not using XML conditions:

1) I don't trust it.

When creating my City optimiser I needed to know what resources, features could be put where to add the same rules to the program. When I loaded up a game I found that the XML had in fact lied to me! Saying for example that corn cannot be riverside (it can :rolleyes:) So I don't trust it.

2) Plus the python way allows for way more possibilities of conditions that can't be achieved by XML (like must be next to land or next to sea). art, movie defines and the actual features are XML. The conditions are the python bits.

Spoiler :

elaborating on 1:

Code:
	public boolean canHaveBonus(Resources eBonus)
	{
		if (eBonus == Resources.NONE) { return true; }
		
		if (getTerrain() != Terrains.NONE && getTerrain().isWater() == eBonus.isWater())
		{
			switch (eBonus)
			{
			case ALUMINIUM:
				if ((getTerrain() == Terrains.TUNDRA || getTerrain() == Terrains.PLAINS || getTerrain() == Terrains.DESERT) && getPlotType() == Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case BANANA:
			case DYE:
				if ((getTerrain() == Terrains.GRASSLAND && getFeature() == Features.JUNGLE) && getPlotType() != Types.HILLS) { return true; } return false;
			
			case CLAM:
			case FISH:
			case CRAB:
				if (getTerrain() == Terrains.COAST  && getFeature() != Features.ICE) { return true; } return false;
			
			case WHALE:
			case OIL_SEA:
				if (getTerrain() == Terrains.OCEAN  && getFeature() != Features.ICE) { return true; } return false;
			
			case COPPER:
			case IRON:
				if (!(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case COAL:
				if ((getTerrain() == Terrains.GRASSLAND || getTerrain() == Terrains.PLAINS) && getPlotType() == Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case CORN:
				if (getTerrain() == Terrains.GRASSLAND && getPlotType() != Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case COW:
				if ((getTerrain() == Terrains.GRASSLAND || getTerrain() == Terrains.PLAINS) && !isRiverside() && getPlotType() != Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case DEER:
				if (getTerrain() == Terrains.TUNDRA && getFeature() != Features.JUNGLE) { return true; } return false;
			
			case FUR:
				if ((getTerrain() == Terrains.TUNDRA || getTerrain() == Terrains.SNOW) && getFeature() != Features.JUNGLE) { return true; } return false;
			
			case GEMS:
				if (getTerrain() == Terrains.GRASSLAND && getFeature() == Features.JUNGLE) { return true; } return false;
			
			case WHEAT:
				if (getTerrain() == Terrains.PLAINS && getPlotType() != Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
				
			case GOLD:
				if ((getTerrain() == Terrains.PLAINS || getTerrain() == Terrains.DESERT) && getPlotType() == Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case HORSE:
				if ((getTerrain() == Terrains.GRASSLAND || getTerrain() == Terrains.PLAINS|| getTerrain() == Terrains.TUNDRA) && !isRiverside() && getPlotType() != Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case INCENSE:
				if (getTerrain() == Terrains.DESERT && getPlotType() != Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case IVORY:
				if ((getTerrain() == Terrains.PLAINS || (getTerrain() == Terrains.GRASSLAND && getFeature() == Features.JUNGLE)) && getPlotType() != Types.HILLS) { return true; } return false;
			
			case MARBLE:
				if ((getTerrain() == Terrains.TUNDRA || getTerrain() == Terrains.PLAINS || getTerrain() == Terrains.SNOW) && !isRiverside() && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case OIL_LAND:
				if ((getTerrain() == Terrains.TUNDRA || getTerrain() == Terrains.SNOW || getTerrain() == Terrains.DESERT || (getTerrain() == Terrains.GRASSLAND && getFeature() == Features.JUNGLE)) && !isRiverside() && getPlotType() != Types.HILLS) { return true; } return false;
			
			case PIG:
			case RICE:
				if (getTerrain() == Terrains.GRASSLAND && !isRiverside() && getFeature() != Features.FOREST) { return true; } return false;
			
			case SHEEP:
				if ((getTerrain() == Terrains.GRASSLAND || getTerrain() == Terrains.PLAINS) && !isRiverside() && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case SILK:
				if (getFeature() == Features.FOREST && (getTerrain() == Terrains.GRASSLAND || getTerrain() == Terrains.PLAINS) && getPlotType() != Types.HILLS) { return true; } return false;
			
			case SILVER:
				if ((getTerrain() == Terrains.TUNDRA || getTerrain() == Terrains.SNOW) && getPlotType() == Types.HILLS && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case SPICES:
				if ((getTerrain() == Terrains.GRASSLAND || getTerrain() == Terrains.PLAINS) && (getFeature() == Features.FOREST || getFeature() == Features.JUNGLE) && getPlotType() != Types.HILLS) { return true; } return false;
			
			case STONE:
				if ((getTerrain() == Terrains.PLAINS || getTerrain() == Terrains.DESERT) && !isRiverside() && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;
			
			case SUGAR:
				if (getTerrain() == Terrains.GRASSLAND && getFeature() == Features.JUNGLE) { return true; } return false;
			
			case URANIUM:
				if (!isRiverside()) { return true; } return false;
			
			case WINE:
				if (getTerrain() == Terrains.PLAINS  && !(getFeature() == Features.FOREST || getFeature() == Features.JUNGLE)) { return true; } return false;

			default:
				return false;
			}	 
		}
		return false;
	}

this is the resources code from the optimiser, compare the conditions with the xml and I'm sure you will see!

 
@Dancing
Now you know why I write my own from scratch :D
When you don't like something, write it your own style like me lol.
I also don't like that whole chunk of definitions in python so use XML infos

@Jamie
Here comes the wet blanket :D
1) Extra Happiness in Cities is NOT permanent.
They are lost upon city acquired.
Trust me, same with health or bonus added directly to cities.

And the way you do it, this cannot be fixed either, since you cannot tell if the added effects was Happiness or Specialist.
So you cannot simply write extra codes in City Acquired to add in the extra happiness since the bonus might have been specialist.

2) You keep nagging at me to use xrange and you are still using range for the big loops yourself :D
 
Now what's happening?
 
not my fault :p I didn't check, clearly not wirtten by me :p (I can prove this by the fact I have told the person that did it that it was a bad idea in the first place in the comment :lol:)

and whoops. tommorrow morning I will get some code onCityAquired to handle the happiness, and don't worry, happiness over specialist is VEEEEEEEEEERY easy to determine :evil:
 
fixing is happening :p expect code in the morning
 
Code:
	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]
		if (city.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(city, False)	
		CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
# Natural Wonders - Start
		for x in xrange(city.getX() - 1, city.getX() + 2): # To who ever removed my index loop: you do realise this is first ring tiles only?!
			for y in xrange(city.getY() - 1, city.getY() + 2): # Oh well I wanted that to happen now anyway :p
				pPlot = CyMap().plot(x, y)
				if pPlot.getFeatureType() > -1:
					if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
                                                if Game.getSorenRandNum(100, "Chance for happy") < iChanceForHappy:
                                                        city.changeExtraHappiness(iNumPermanentHappy)
                                                        city.setScriptData("Happy City")
                                                else:
                                                        eSpecialist = Game.getSorenRandNum(5, "Specialist") + 1
                                                        city.changeFreeSpecialistCount(eSpecialist, 1) #is this too risky? randomly picks between priest, artist, merchant, engineer and scientist
                                                        city.setScriptData("Specialist City:%s" % eSpecialist)
# Natural Wonders - End
		
	def onCityAcquired(self, argsList):
		'City Acquired'
		iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
# Natural Wonders - Start
		for x in xrange(pCity.getX() - 1, pCity.getX() + 2):
                        for y in xrange(pCity.getY() - 1, pCity.getY() + 2):
                                pPlot = CyMap().plot(x, y)
                                if pPlot.getFeatureType() > -1:
                                        if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
                                                if pCity.getScriptData() == "Happy City":
                                                        pCity.changeExtraHappiness(iNumPermanentHappy)
                                                elif pCity.getScriptData.split(":")[0] == "Specialist City":
                                                        pCity.changeFreeSpecialistCount(int(pCity.getScriptData.split(":")[1]), 1)                                                        
# Natural Wonders - End
		CvUtil.pyPrint('City Acquired Event: %s' %(pCity.getName()))

	def onGameStart(self, argsList):
		'Called at the start of the game'

# Natural Wonders - Start
		doNaturalWondersConstantsInit()
                # This is the code that spawns each natural wonder into the map to add new wonder see below!
		dNaturalWonders = {\
                #These are parameters for new wonders, you pick a type ie: "TERRAIN_DESERT" and then things about it
                # in order of appearance: is it a hill?, (if coast) is it next to a land tile? is it a river? is it a mountain?
                # (if water) is it a lake?, is the tile adjectent to lake or oasis?, is it next to the sea (possibly lake?)?, is it a water tile?
                # True for yes
                # False for no
                # None for doesn't matter (same for terrain, however in this case bWater will handle plot type (bWater CANNOT be None))
                #Wonder XML name:[TerrainType, bHills, bAdjecentLand, bRiver, bPeak, bLake, bFreshWater, bCostalLand, bWater (CANNOT BE NONE!)]
		"FEATURE_DEVILS_TABLE":["TERRAIN_PLAINS", True, None, None, None, None, None, None, False],\
		"FEATURE_LANDSCAPE_ARCH":["TERRAIN_DESERT", False, None, None, False, None, False, None, False],\
		"FEATURE_PAMUKKALE":["TERRAIN_GRASS", False, None, None, False, None, False, None, False],\
		"FEATURE_VICTORIA_FALLS":["TERRAIN_GRASS", False, None, False, False, None, False, None, False],\
		"FEATURE_SOPKA":["TERRAIN_TUNDRA", False, None, False, False, None, False, None, False],\
		"FEATURE_ULURU":["TERRAIN_DESERT", False, None, False, False, None, None, None, False],\
		"FEATURE_SUGARLOAF":["TERRAIN_COAST", None, True, None, None, None, None, None, True]\
		}
		iNumCivs = Game.countCivTeamsEverAlive()

                #check if all plots are revealed by default
		x = 0
		bAllRevealed = False
		for team in xrange(iNumCivs):
			if CyMap().plot(0, 0).isRevealed(team, False):
				x += 1
		if x == iNumCivs:
			bAllRevealed = True
                
		for wonder in dNaturalWonders.iterkeys():
			WonderType = gc.getInfoTypeForString(wonder)
			TerrainType = gc.getInfoTypeForString(dNaturalWonders[wonder][0])
			bHills = dNaturalWonders[wonder][1]
			bAdjacentLand = dNaturalWonders[wonder][2]
			bRiver = dNaturalWonders[wonder][3]
			bPeak = dNaturalWonders[wonder][4]
			bLake = dNaturalWonders[wonder][5]
			bFreshWater = dNaturalWonders[wonder][6]
			bCoastalLand = dNaturalWonders[wonder][7]
			bWater = dNaturalWonders[wonder][8]
                        #start checking plots
			lPlots = []
			for i in xrange(CyMap().numPlots()):
				pPlot = CyMap().plotByIndex(i)
				bPlotPerfect = False
				if (not pPlot.isWater() and not pPlot.isAdjacentToLand()) or pPlot.isGoody(): continue #This plot must be a one tile island or have a goody hut
				if not pPlot.getFeatureType() == -1:
					if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder(): continue #has a wonder already
				if pPlot.getBonusType(-1) != -1: continue
				for team in xrange(gc.getMAX_CIV_TEAMS()):
					if (pPlot.isRevealed(team, False) and not bAllRevealed):
						bPlotPerfect = True
						break
				if bPlotPerfect: continue
				if TerrainType != None:
					if pPlot.getTerrainType() != TerrainType: continue
				elif pPlot.isWater() != bWater: continue
				if bHills != None and pPlot.isHills() != bHills: continue
				if bAdjacentLand != None and pPlot.isAdjacentToLand() != bAdjacentLand: continue
				if bRiver != None and pPlot.isRiver() != bRiver: continue
				if bPeak != None and pPlot.isPeak() != bPeak: continue
				if bLake != None and pPlot.isLake() != bLake: continue
				if bFreshWater != None and pPlot.isFreshWater() != bFreshWater: continue
				if bCoastalLand != None and pPlot.isCoastalLand() != bCoastalLand: continue
				lPlots.append(pPlot)

			if len(lPlots) > 0:
				pPlot = lPlots[Game.getSorenRandNum(len(lPlots), "Random Plot")]
				pPlot.setFeatureType(WonderType, 0)
# Natural Wonders - End

	def onPlotRevealed(self, argsList):
		'Plot Revealed'
		pPlot = argsList[0]
		iTeam = argsList[1]
		
# Natural Wonders - Start
		iFeature = pPlot.getFeatureType()
		if iFeature != -1:
			iFeatureInfo = gc.getFeatureInfo(iFeature)
			if iFeatureInfo.isNaturalWonder():
				pTeam = gc.getTeam(iTeam)
				if not pTeam.isBarbarian():
					for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
						pPlayerX = gc.getPlayer(iPlayerX)
						if pPlayerX.getTeam() == iTeam:
							message = "TXT_KEY_WONDERDISCOVERED_YOU"
							tValues = (iFeatureInfo.getDescription(),)
							(loopCity, iter) = pPlayerX.firstCity(False)
							while(loopCity):
								loopCity.changeHappinessTimer(iHappyTurns)
								(loopCity, iter) = pPlayerX.nextCity(iter, false)
							if pPlayerX.isHuman():
								popupInfo = CyPopupInfo()
								popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
								popupInfo.setData1(iFeature)
								popupInfo.setData3(3)
								popupInfo.setText(u"showWonderMovie")
								popupInfo.addPopup(iPlayerX)
						else:
							message = "TXT_KEY_WONDERDISCOVERED_ELSE"
							leader = gc.getPlayer(pTeam.getLeaderID()).getName()
							tValues = (leader, iFeatureInfo.getDescription())
                                                                        
						message = localText.getText(message, tValues)
						CyInterface().addMessage(iPlayerX, True, 20, message, "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT,"", -1, -1, -1, False, False)
# Natural Wonders - End

happy now plat :p?

@ dacubz, replace earlier's code with this where appropriate. It's faster and works properly :D
 
Not really :D
Specialist on the other hand, is a permanent effect.
Now you know why I chose that :D
No need for codes on City Acquired for that

As for happiness, why bother to loop through the plots to see if there is a natural wonder?
Just check the script data directly to see if happy city?

P.S.
You might as well just give both happiness and specialist rather than either one.
Since specialist is permanent you can totally ignore it in City Acquired.
As for happiness, since all cities with NW get the benefit, then you can dump the script data idea away as well.
To me, this is just storing of data unnecessary, why bother...
 
whoops I read your original post as saying happiness and specialist are not permanent :lol:

Why bother: I like random chances :p

will edit this post with the attached python file
 
You may want to do some testings:

1) What if the NW is revealed to you during Advanced Start even before you build your capital
2) Your City Acquire codes
3) Add/Remove some specialists and I doubt your specialist codes work. Especially if I remove one of them... That is the problem when you use numbers directly.
4) Any plans to ensure 2 NW don't spawn directly next to each other?
5) Tried it in Full Map Reveal Games like Future Start?
6) There are no extra message codes in Plot Reveal. It means that if the NW is discovered by someone I have not met, I will still get a message that NW is discovered by XXX, telling me who the XXX is

@Voyhkah
You asked me why I didn't add your wonders so I look through the 17 pages for them again :D
1) Shark Bay looks good but there was never a download link
2) Ngorongoro size of 1 MB turned me off when others are 200 KB or so
3) Tepui you mentioned you are still looking for ways to solve the trees?
4) Giant's Causeway looks weird in game, not sure if there are some specific ways to define it in game, else it looks like this for me
 
I cleared the file and made easier and lighter, if it helps :)
Thanks for that:goodjob: Uluru could use some help as well if you are interested
You may want to do some testings:

1) What if the NW is revealed to you during Advanced Start even before you build your capital
2) Your City Acquire codes
3) Add/Remove some specialists and I doubt your specialist codes work. Especially if I remove one of them... That is the problem when you use numbers directly.
4) Any plans to ensure 2 NW don't spawn directly next to each other?
5) Tried it in Full Map Reveal Games like Future Start?
6) There are no extra message codes in Plot Reveal. It means that if the NW is discovered by someone I have not met, I will still get a message that NW is discovered by XXX, telling me who the XXX is

@Voyhkah
You asked me why I didn't add your wonders so I look through the 17 pages for them again :D
1) Shark Bay looks good but there was never a download link
2) Ngorongoro size of 1 MB turned me off when others are 200 KB or so
3) Tepui you mentioned you are still looking for ways to solve the trees?
4) Giant's Causeway looks weird in game, not sure if there are some specific ways to define it in game, else it looks like this for me
Again with all of those errors I think the happiness via sdk is the easiest choice. Having that removes almost all python after the start of a game (depending on wether movie is done in python or sdk). Because with all this python being messed up and taking a bit of time if we dont want to do it through sdk i might just have a tourist site improvement be able to be built on it that gives happiness since we got to get hte mod out so platy stops stealing the idea (:p)

Anyway rereading it it doesnt seem like any should be a huge problem. I can test 1 and 2 now. I dont really understant what you are saying about #3. Number 5 is a problem but the other two are not as important.

But really this is all getting a bit to messy - happiness on the plot i honustly think is the easist. If you (jamie) dont think/want to do it via sdk, although itll be a bit messy, ill just have a tourist sight or something to be buildable on there that gives happiness.
 
All I did was steal the graphics :D
Jamie is the one taking my specialist and adjacent plot solutions:gripe:
Even the way I did the placement of wonders is different. I use XML info directly

#3 You will understand if you are a coder.
What he is doing is using 1, 2, 3 or 4 instead of using gc.getInfoTypeForString("xxx")
This works, assuming that the numbers representing the specialists don't change.
But in most mods, where there ARE added specialists like doctors, celebrities etc, using numbers directly will/may point to the wrong ones
 
I was thinking about the Grand Canyon graphics and I have a question; is there a way to make a second type of water/ocean/sea and make that the Grand Canyon? Not sure if that makes sense.
 
the current code is fine. The full reveal starts shouldn't matter. Why? because as I take it, plots are revealed after the map has been made if I'm wrong then it should be easy to fix. In fact I thought I already fixed that by doing some revealing checks (bAllRevealed)

SDK will not make those problems any easier to solve and they are not errors as such as they work fine, they just might not perform under certain situations. AND those problems still arise (with the exception of one, which is 3) with any SDK happiness plot codes (I think). Solutions:

1) Then nothing happens. Once again different happy codes cannot solve this
2) Because happiness isn't added when in city revolt right? how to handle how to handle...
3) same applies to using gc.getInfoTypeForString() if one of them is removed... Uh oh (and gitfs uses more unessicary code). The numbers will make sure to add the specialist, I did a lot of testing on that. But in the case of added specialists, You are right, I was thinking about that myself but don't like the typical if tree to decide of which enum (wish python had a switch statement)
4) Easy to fix but adds more loops. If dacubz is concerned about this one then fair enough I can do it
5) All ready fixed I believe :p
6) Yup that I should have thought of.

I will have all of these fixed to the point plat can no longer poke holes in it by the time 1 hour has passed :devil:

edit:

1) not sure if it's solveable. unless I can place the wonders AFTER the advanced start mode has ended... but how? It would have to be on turn 1 but then that will mean an if statement every turn. Unsolveable I guess... Unless I replace temporary happiness to 5 turns golden age on discovery!?

2) Hmm, it seems the script data will not do what I want. So, I guess some SDK work IS needed. But I will do it :p I am going to add a needs happiness boolean member variable to CvCity and CyCity so that when the city is captured the happiness is safety added when it's borders expand :p

3) happy now?
Code:
else:
       eSpecialists = [gc.getInfoTypeForString("SPECIALIST_PRIEST"), gc.getInfoTypeForString("SPECIALIST_ARTIST"), gc.getInfoTypeForString("SPECIALIST_SCIENTIST"), gc.getInfoTypeForString("SPECIALIST_MERCHANT"), gc.getInfoTypeForString("SPECIALIST_ENGINEER")]
       eSpecialist = eSpecialists[Game.getSorenRandNum(len(eSpecialists), "Specialist")] #you could set this to a constant specialist if wanted
       city.changeFreeSpecialistCount(eSpecialist, 1)

4) Dacubz do you mind if two natural wonders can spawn adjecent to each other?

5) as I said already fixed :p
Code:
                #check if all plots are revealed by default
		x = 0
		bAllRevealed = False
		for team in xrange(iNumCivs):
			if CyMap().plot(0, 0).isRevealed(team, False):
				x += 1
		if x == iNumCivs:
			bAllRevealed = True
and I tested it, and it works :p however a side effect of this is you can't discover them (makes sense really, if you are in the future era) but they still spawn on the map and I think that was problem you were addressing, do they spawn

6) fixed :p
 
Back
Top Bottom