trying to use a minimalist mod to do big things

I'm actually giving this some thought...since there's no "stability" like in RFC, might it make sense to simply make the spawns happen without giving a choice to the human player (basically saying, "here's a historical event your civ had to deal with...can you do better?"), or would that be an egregious breach of modding etiquette? The old civ would get to keep their units from the area and would be free to attempt recapture of the rebel territory...
 
I'd say keep it simple at this stage. Once the rest of your mod is done and you're already testing it you'll be able to answer your own question...
 
agreed.

so I've got the spawn working the way I want (I'll have to play with starting units for balance issues). Now I have to set war between the new civ and certain old civs and to make an announcement about the new civ's birth...
 
You're only working on Rome now, for starters?

Post your code once you're satisfied with your implementation. Because you should probably generalize as much of it as possible before moving on to the other Civs. This way the code is basically done and you can move on to designing the rest of the mod.
 
Well, this is what I've got for now. I commented out the announcement line because the game doesn't like it. I'm looking to read up on why. I was just going to cut and paste the code into the other civs, changing the odd name or coord as needed.

The part I've been working with is the classicalSpawn, about 3/4 the way down.

Spoiler :
Code:
#done by Antaine with great indebtedness to Baldyr, God-Emperor, and EmperorFool

from CvPythonExtensions import *
from Popup import PyPopup
from CvEventManager import *
from PyHelpers import *

gc = CyGlobalContext()
cyGame = CyGame()
cyMap = CyMap()
pyGame = PyGame()

#spawn zones
tRome = ((60, 43), (63, 48))
tPersia = ((80, 39), (86, 43))
tJapan = ((111, 41), (116, 51))
tKorea = ((107, 45), (111, 50))
tArabia = ((73, 31), (82, 38))
tEngland = ((53, 53), (56, 56))
tFrance = ((56, 47), (59, 52))
tSpain = ((52, 43), (57, 47))
tGermany = ((60, 50), (64, 64))
tRussia = ((65, 49), (80, 63))
tEastUS = ((24, 42), (34, 50))
tWestUS = ((11, 44), (23, 43))
tHawaii = ((112, 34), (6, 39))

#units for later civ spawns
eSettler = 4
eWorker = 5
eArcher = 57
eLongbowman = 60
eMusketman = 42
eRifleman = 46

#for barbarian spawns
eGalley = 90
eViking = 36
eZulu = 38
eMongol = 68
eNative = 33
eAztec = 27
eInca = 25
eMaya = 39

#civs in the game (civ IDs, not WBS IDs)
eCeltia = 6
eEgypt = 8
eBabylon = 3
eGreece = 13
eIndia = 16
eChina = 7
eRome = 28
ePersia = 26
eJapan = 17
eKorea = 19
eArabia = 1
eEngland = 9
eFrance = 11
eSpain = 30
eGermany = 12
eRussia = 29
eAmerica = 0


cityNameDict = {
(55, 54): "London",
(55, 53): "London",
(56, 53): "London",
(56, 54): "London",
(63, 52): "Berlin",
(62, 52): "Berlin",
(62, 53): "Berlin",
(63, 53): "Berlin",
(51, 55): "Dublin",
(51, 56): "Dublin",
(55, 58): "Edinburgh",
(54, 57): "Edinburgh",
(54, 58): "Edinburgh",
(58, 51): "Paris",
(59, 51): "Paris",
(58, 52): "Paris",
(57, 51): "Paris",
(58, 50): "Paris",
(57, 50): "Paris",
(55, 45): "Madrid",
(55, 46): "Madrid",
(54, 46): "Madrid",
(54, 45): "Madrid",
(53, 45): "Lisbon",
(53, 44): "Lisbon",
(53, 46): "Lisbon",
(61, 46): "Rome",
(62, 45): "Rome",
(62, 46): "Rome",
(61, 47): "Rome",
(60, 47): "Rome",
(67, 43): "Athens",
(66, 42): "Athens",
(67, 44): "Athens",
(66, 44): "Athens",
(68, 46): "Byzantium",
(67, 46): "Byzantium",
(69, 45): "Byzantium",
(73, 40): "Jerusalem",
(73, 41): "Jerusalem",
(72, 39): "Jerusalem",
(72, 40): "Jerusalem",
(73, 42): "Antioch",
(73, 43): "Antioch",
(68, 39): "Alexandria",
(69, 39): "Alexandria",
(67, 39): "Alexandria",
(30, 47): "New York",
(31, 47): "New York",
(29, 47): "New York",
(29, 46): "New York",
(31, 48): "Boston",
(31, 49): "Boston",
(32, 49): "Boston",
(24, 43): "New Orleans",
(23, 43): "New Orleans",
(25, 43): "New Orleans",
(24, 48): "Chicago",
(24, 47): "Chicago",
(24, 49): "Chicago",
(25, 47): "Chicago",
(12, 48): "San Francisco",
(12, 47): "San Francisco",
(12, 49): "San Francisco",
(12, 50): "Seattle",
(12, 46): "Los Angeles",
(75, 35): "Mecca",
(74, 36): "Mecca",
(75, 34): "Mecca",
(74, 37): "Mecca",
(73, 37): "Mecca",
(76, 34): "Mecca",
(68, 57): "St. Petersburg",
(67, 56): "St. Petersburg",
(66, 56): "St. Petersburg",
(68, 56): "St. Petersburg",
(68, 58): "St. Petersburg",
(67, 58): "St. Petersburg",
(71, 54): "Moscow",
(71, 53): "Moscow",
(70, 53): "Moscow",
(72, 53): "Moscow",
(72, 54): "Moscow",
(70, 54): "Moscow",
(70, 56): "Moscow",
(71, 55): "Moscow",
(72, 55): "Moscow",
(69, 52): "Kiev",
(69, 51): "Kiev",
(70, 51): "Kiev",
(70, 50): "Odessa",
(71, 50): "Odessa",
(89, 35): "Bombay",
(89, 34): "Bombay",
(88, 35): "Bombay",
(88, 36): "Bombay",
(92, 34): "Pondicherry",
(91, 34): "Pondicherry",
(91, 33): "Pondicherry",
(102, 47): "Peking",
(101, 48): "Peking",
(102, 48): "Peking",
(103, 48): "Peking",
(101, 47): "Peking",
(103, 47): "Peking",
(101, 46): "Peking",
(102, 46): "Peking",
(103, 46): "Peking",
(115, 46): "Tokyo",
(115, 45): "Tokyo",
(114, 44): "Tokyo",
(106, 43): "Shanghai",
(106, 44): "Shanghai",
(106, 45): "Shanghai",
(107, 43): "Shanghai",
(107, 42): "Shanghai",
(105, 39): "Canton",
(105, 40): "Canton",
(106, 40): "Canton",
(106, 41): "Canton",
(103, 38): "Hong Kong",
(103, 39): "Hong Kong",
(104, 39): "Hong Kong",
(102, 38): "Hong Kong",
(102, 32): "Saigon",
(103, 33): "Saigon",
(102, 33): "Saigon",
(1, 38): "Honolulu",
(3, 37): "Honolulu",
(4, 35): "Hilo",
(5, 36): "Hilo",
(103, 14): "Perth",
(104, 14): "Perth",
(104, 13): "Perth",
(104, 12): "Perth",
(103, 12): "Perth",
(107, 19): "Darwin",
(107, 20): "Darwin",
(108, 20): "Darwin",
(108, 21): "Darwin",
(118, 13): "Sydney",
(117, 12): "Sydney",
(118, 15): "Sydney",
(118, 16): "Sydney",
(118, 17): "Sydney",
(114, 10): "Adelaide",
(114, 11): "Adelaide",
(113, 11): "Adelaide",
(115, 10): "Adelaide",
(77, 41): "Babylon",
(77, 40): "Babylon",
(76, 41): "Babylon",
(77, 42): "Babylon",
(76, 42): "Babylon",
(58, 47): "Marseilles",
(58, 48): "Marseilles",
(59, 48): "Marseilles",
(56, 48): "Bordeaux",
(56, 49): "Bordeaux",
(55, 51): "Brest",
(56, 51): "Brest",
(56, 44): "Gibraltar",
(54, 44): "Gibraltar",
(53, 54): "Cardiff",
(54, 54): "Cardiff",
(53, 55): "Cardiff",
(53, 53): "Cardiff",
(55, 56): "York",
(54, 56): "York",
(49, 54): "Cork",
(49, 56): "Galway",
(50, 56): "Galway",
(51, 54): "Waterford",
(50, 54): "Cashel",
(51, 57): "Belfast",
(50, 57): "Derry",
(50, 55): "Limerick",
(60, 55): "Copenhagen",
(60, 54): "Copenhagen",
(60, 53): "Copenhagen",
(62, 52): "Trondheim",
(63, 63): "Trondheim",
(64, 64): "Trondheim",
(60, 58): "Oslo",
(59, 57): "Oslo",
(58, 58): "Oslo",
(62, 58): "Uppsala",
(62, 59): "Uppsala",
(62, 60): "Uppsala",
(63, 58): "Stockholm",
(63, 57): "Stockholm",
(63, 56): "Stockholm",
(62, 56): "Stockholm",
(66, 59): "Helsinki",
(65, 59): "Helsinki",
(65, 58): "Helsinki",
(65, 58): "Vilnius",
(65, 55): "Vilnius",
(66, 54): "Vilnius",
(66, 55): "Vilnius",
(64, 53): "Vilnius",
(65, 53): "Vilnius",
(66, 53): "Vilnius",
(63, 50): "Vienna",
(64, 50): "Vienna",
(65, 50): "Vienna",
(65, 49): "Vienna",
(64, 49): "Vienna",
(63, 49): "Vienna",
(64, 52): "Warsaw",
(63, 51): "Warsaw",
(62, 48): "Venice",
(61, 48): "Venice",
(63, 48): "Venice",
(61, 43): "Palermo",
(62, 43): "Palermo",
(76, 32): "Sanaa",
(77, 32): "Sanaa",
(77, 33): "Sanaa",
(78, 33): "Sanaa",
(64, 12): "Cape Town",
(64, 13): "Cape Town",
(65, 13): "Cape Town",
(65, 12): "Cape Town",
(42, 18): "Rio De Janeiro",
(43, 19): "Rio De Janeiro",
(41, 18): "Rio De Janeiro",
(39, 15): "Montevideo",
(38, 14): "Montevideo",
(38, 13): "Montevideo",
(36, 13): "Buenos Aires",
(37, 13): "Buenos Aires",
(36, 12): "Buenos Aires",
(18, 39): "Mexico City",
(18, 38): "Mexico City",
(19, 39): "Mexico City",
(19, 40): "Mexico City",
(18, 49): "Mexico City",
(24, 45): "St. Louis",
(25, 45): "St. Louis",
(25, 46): "St. Louis",
(24, 46): "St. Louis",
(27, 38): "Havanna",
(28, 38): "Havanna",
(31, 37): "Port-au-Prince",
(31, 39): "Port-au-Prince",
(56, 50): "Nantes",
(59, 53): "Amsterdam",
(59, 52): "Amsterdam",
(28, 46): "Philadelphia",
(28, 45): "Philadelphia",
(27, 45): "Washington",
(27, 44): "Washington",
(58, 42): "Carthage",
(59, 42): "Carthage",
(59, 41): "Carthage",
(59, 40): "Carthage",
(60, 40): "Tripoli",
(61, 40): "Tripoli",
(62, 40): "Tripoli",
(47, 61): "Reykjavik",
(47, 62): "Reykjavik",
(48, 62): "Reykjavik",
(46, 63): "Reykjavik",
(69, 41): "Knossos",
(96, 39): "Calcutta"
}

#holy city norming


#reads the date regardless of game speed
def isDate(iDate):
	return cyGame.getTurnYear(cyGame.getGameTurn() +1) > iDate and cyGame.getGameTurnYear() <= iDate

#searches in the dictionary to get a name for a key tile
def nameNorm(pCity):
   coord = (pCity.getX(), pCity.getY())
   if coord in cityNameDict:
      name = cityNameDict[coord]
      pCity.setName(name, True)
      return True
   else:
      return False

#compiles a list of plots
def getPlotList(tBL, tTR):
        lPlotList = []
        for x in range(tBL[0], tTR[0]+1):
                for y in range(tBL[1], tTR[1]+1):
                        lPlotList.append((x, y))
        return lPlotList

#gets all tiles within the given distance of the tile given
def getSquareList(tCoords, iDistance):
        return getPlotList((tCoords[0]-iDistance, tCoords[1]-iDistance), (tCoords[0]+iDistance, tCoords[1]+iDistance))

#gets all tiles adjacent to the tile given
def getAdjacentList(tCoords):
        return getSquareList(tCoords, 1)


#spawns the classical civs 800BC on the map (different date used for testing change before release)
def classicalSpawn():
	pRome = cyMap.plot(61, 46)
	pPersia = cyMap.plot(81, 41)
	pJapan = cyMap.plot(115, 46)
	pKorea = cyMap.plot(109, 46)
	if isDate(-3985):
#		CyInterface().addImmediateMessage("Latin tribes have united and declare their independence. A new civilization is born!")
		for tCoords in getAdjacentList((61, 46)):
				x, y = tCoords
				pCurrentPlot = cyMap.plot(x, y)
				if pCurrentPlot.isCity():
						pCity = pCurrentPlot.getPlotCity()
						pCity.kill()
		PyPlayer(7).initCity(61, 46)
		pRome.getPlotCity().setPopulation(3)
		pRome.getPlotCity().setCulture(7, 500, True)
		for tCoords in getPlotList((60, 43), (63, 48)):
			x, y = tCoords
			pCurrentPlot = cyMap.plot(x,y)
			if pCurrentPlot.isCity():
				pCurrentPlot.setOwner(7)
		pPersia.getPlotCity().kill()
		PyPlayer(8).initCity(81, 41)
		pJapan.getPlotCity().kill()
		PyPlayer(9).initCity(115, 46)
		pKorea.getPlotCity().kill()
		PyPlayer(10).initCity(109, 46)
#Romans
		PyPlayer(7).initUnit(4, 61, 46, 2)
		PyPlayer(7).initUnit(5, 61, 46, 2)
		PyPlayer(7).initUnit(57, 61, 46, 15)
#Persians		
		PyPlayer(8).initUnit(4, 81, 41, 2)
		PyPlayer(8).initUnit(5, 81, 41, 2)
		PyPlayer(8).initUnit(57, 81, 41, 15)
#Japanese
		PyPlayer(9).initUnit(4, 115, 46, 2)
		PyPlayer(9).initUnit(5, 115, 46, 2)
		PyPlayer(9).initUnit(57, 115, 46, 15)
#Koreans
		PyPlayer(10).initUnit(4, 109, 46, 2)
		PyPlayer(10).initUnit(5, 109, 46, 2)
		PyPlayer(10).initUnit(57, 109, 46, 15)

#Roman colony spawn 1AD
def romeSpawn():
	if isDate(1):
#Lisbon
		PyPlayer(7).initUnit(4, 53, 45, 1)
		PyPlayer(7).initUnit(5, 53, 45, 2)
		PyPlayer(7).initUnit(57, 53, 45, 5)
#Carthage
		PyPlayer(7).initUnit(4, 58, 42, 1)
		PyPlayer(7).initUnit(5, 58, 42, 2)
		PyPlayer(7).initUnit(57, 58, 42, 5)
#Tripoli
		PyPlayer(7).initUnit(4, 60, 40, 1)
		PyPlayer(7).initUnit(5, 60, 40, 2)
		PyPlayer(7).initUnit(57, 60, 40, 5)

#spawns Arab civ 400AD
#def arabSpawn():
#	if isDate(400):

#spawns medieval civs 800AD
#def medievalSpawn():
#	if isDate(800):
#English
#French
#Spanish
#Germans
#Russians

#American spawn and flip of eastern US 1770AD
#def ameriSpawn():
#	if isDate(1770):

#colony spawn for Greeks and Celts 1600BC
def ancientSpawn():
	if isDate(-1600):
#Celts
		PyPlayer(0).initUnit(4, 51, 55, 1)
		PyPlayer(0).initUnit(5, 51, 55, 2)
		PyPlayer(0).initUnit(57, 51, 55, 3)
		PyPlayer(0).initUnit(4, 55, 54, 1)
		PyPlayer(0).initUnit(5, 55, 54, 2)
		PyPlayer(0).initUnit(57, 55, 54, 3)
		PyPlayer(0).initUnit(4, 55, 58, 1)
		PyPlayer(0).initUnit(5, 55, 58, 2)
		PyPlayer(0).initUnit(57, 55, 58, 3)
#Greeks
		PyPlayer(5).initUnit(4, 68, 46, 1)
		PyPlayer(5).initUnit(5, 68, 46, 2)
		PyPlayer(5).initUnit(57, 68, 46, 3)
		PyPlayer(5).initUnit(4, 69, 41, 1)
		PyPlayer(5).initUnit(5, 69, 41, 2)
		PyPlayer(5).initUnit(57, 69, 41, 3)
		PyPlayer(5).initUnit(4, 64, 47, 1)
		PyPlayer(5).initUnit(5, 64, 47, 2)
		PyPlayer(5).initUnit(57, 64, 47, 3)

#spawns German colonies in Scandinavia and Iceland 1200AD
#def scandiSpawn():
#	if isDate(1200):


#American spawns and flip of western US and Hawaii 1900AD
#def ameriFlip():
#	if isDate(1900):

#colony spawns tied to discovery of Astronomy
#colonySpawn
#Arabs
#English
#French
#Spanish
#Russia

#spawns medieval barbarians 1000AD
#def barbSpawn():
#	if isDate(1000):
#Vikings
#Mongols

#spawns native Americans 1400AD
#def nativeSpawn():
#	if isDate(1400):
#North America
#Aztec
#Inca
 
You mention stability... Once you're done and feel like adding a new feature to the mod, perhaps it would be possible to implement some sort of a rudimentary stability system? It could be based on the number of happy faces contra unhappy ones in all player cities. That way it could be easy enough to adjust the balance by making happiness more or less easy to get hold of. No instability from tile ownership or such, in other words.

Just a thought...
 
possibly, but I don't intend at this point to mimic that particular feature from RFC.

My immediate focus right now is to get the announcement and the war declaration working properly, then the spawn code is "done" (unless I decide to complicate it later). Then it's just a matter of modifying it for the other civs and I can get working on the holy-city-mover (I think I found a way to simplify my original intention, but I'll broach that when we get that far).
 
would this work for the holy city business? This should check to see if the religion's founding year is less than the current year, and if it is, make Jerusalem the holy city of that religion.

First, I'd like to know if I've written it properly (I wasn't sure what to do with the NewValue and bAnnounce in the last line). I'm not sure what will happen if Jerusalem doesn't exist when this runs

Second, I'd like to improve it...I want to search the 3x3 using AdjacentSquare and assign the religion to any city named "Jerusalem" in that box. (since I bumped the city distance down to 1, a 3x3 box could conceivably hold up to four cities, but only one will be named "Jerusalem"). right now, I'm not sure if finding two cities would cause an exception or simply move the holycity twice, leaving it on the last one in the plotlist which may or may not be Jerusalem.

Code:
def holyCityNorm():
		if getReligionGameTurnFounded(0) < isDate():
		for tCoords in getAdjacentList((73, 40)):
				x, y = tCoords
				pCurrentPlot = cyMap.plot(x, y)
				if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.setHolyCity(0)
 
I don't get to tell you what to do :rolleyes:, but here is my suggestion: Define a generic spawnCiv() function that takes a PlayerTypes value as an argument (ePlayer). The spawn message, the spawn tile coordinates and the rest of the spawn area would be fetched from data structures (of some sort), so those would have to be defined for use with this. Because then there would be no need to copy-paste any code at all.

The gain would be that once you realize you wanna change something you only have to implement the change in one single place - not 10 or 20 or 30. Also, applying this approach to your entire mod is the difference between having maybe 50 lines of code (not counting the 50-100 lines of data structures that would have to be defined) or maybe 1000 lines of code.

But since this is your first venture into programming you could of course keep it "simple" (well, not really, but...) and save the more refined approach for your next programming project. So make your mind up before starting to copy-paste any code. (Help is available if you need it.)

With that said, before I start to generalize your code for you :rolleyes: I thought I'd point a few thing out with the current setup:
Code:
	pRome = cyMap.plot(61, 46)
...
		PyPlayer(7).initCity(61, 46)
		pRome.getPlotCity().setPopulation(3)
		pRome.getPlotCity().setCulture(7, 500, True)
PyHelpers isn't actually helping you this time... :p If you use the CyPlayer.initCity() method directly it will yield the newly created CyCity instance as the return value. So you can just go:
Code:
		pPlayer = gc.getPlayer(7)
		pCity = pPlayer.initCity(61, 46)
Then you don't need to go the extra mile to fetch the CyCity instance:
Code:
		pCity.setPopulation(3)
		pCity.setCulture(7, 500, True)
And you don't need the pRome variable for anything anymore.

This is also a good candidate for a helper function, as you probably wanna spawn cities in several different setups:
Code:
def spawnCity(ePlayer, iX, iY, iSize=3, iCulture=500):
	pPlayer = gc.getPlayer(ePlayer)
	pCity = pPlayer.initCity(iX, iY)
	pCity.setPopulation(iSize)
	pCity.setCulture(ePlayer, iCulture, True)
This allows you to get rid of a lot of repetition by simply calling on the helper function for all your city spawning needs:
Code:
spawnCity(7, 61, 46, 3, 500)
But since the last two arguments are optional (they have default values) you could also get away with just this:
Code:
spawnCity(7, 61, 46)
The result would be exactly the same, and if you wanna spawn a city with another size - or with more/less preset culture - you can simply add arguments to those function calls.

Use it if you like and if you feel that it adds to your module instead of just adding to your confusion. :crazyeye:

This method invocation really only changes plot ownership:
Code:
				pCurrentPlot.setOwner(7)
But you're actually using to change city ownership? :eek2: I've always used CyPlayer.acquireCity() myself... But if it works, then it works (but I can't promise its as reliable). In that case you don't really need this condition either:
Code:
			if pCurrentPlot.isCity():
As you'd probably wanna change all the plots to Roman, right?

Could the two areas defined as "getAdjacentList((61, 46))" and "getPlotList((60, 43), (63, 48))" respectively be concatenated into one single area? In that case you'd only have to loop the tile coordinates once - instead of first looping tiles to kill cities, and then looping tiles to change plot ownership (and flipping cities as a consequence).

The indentation for this code isn't showing up correctly in my browser:
Code:
		for tCoords in getAdjacentList((61, 46)):
				x, y = tCoords
				pCurrentPlot = cyMap.plot(x, y)
				if pCurrentPlot.isCity():
						pCity = pCurrentPlot.getPlotCity()
						pCity.kill()
It could just be the forum acting up, but are you using one or two tabs for each level of indentation? I'm getting this as if you were alternating between one and two tabs, which isn't kosher and might cause exceptions (if not for you, then perhaps for others).
 
Your code has several problems, as you might expect from an early draft. The indentation is all over the place, for starters. (Checking the code for colons at the end of lines is a good way to get blocks of code organized. Also, don't mix types of white space for indentation. Keep to the same type of white space and the same amount for each new level.)

The isDate() function I made will only check if a specified date has passed - and make sure it only returns True once. So it must be supplied with a integer value for the date. In short, this wont work at all:
Code:
		if getReligionGameTurnFounded(0) < isDate():
Also, you forgot about the CyGame instance for the method. ;)

If you instead look at the isDate() function definition you see that I'm using the CyGame.getGameTurnYear() for fetching the current game date. So you probably want something like this:
Code:
iFoundDate = cyGame.getReligionGameTurnFounded(0)
iCurrentDate = cyGame.getGameTurnYear()
if iFoundDate < iCurrentDate:
You can of course get rid of the "scaffolding" (the variable assignment) and put everything onto one single line - if you want. Why you need the check these dates escapes me however, but you're in change of the logic on this one...

Code:
		for tCoords in getAdjacentList((73, 40)):
If you use getPlotList() to get a four tile area you're sure to only get once city, right? Then there is no need to check the city name.

With the code you have now, nothing will of course happen if there is no city present. Because you were pro-active enough to use this check:
Code:
				if pCurrentPlot.isCity():
In short: Good job! :goodjob:
 
yeah, I'm using two tabs (forum is funny, and sometimes I copy from TextEdit and sometimes from DashCode when I'm posting messages)

Well, there's is a method to my madness in what looks like a double spawn. The other AIs like to put cities on tiles adjacent to the ones for optimal placement. Rhye solved this problem by assigning desirability values to each tile, but that involved playing with the dll. This way, the game plants Rome where Rome should be, and the kill is to kill any city that would be directly adjacent to it. Other than that, I want it to simply flip Italy as it exists over to the Romans (for variation between games).

If I just did a zone-wide flip from the start, the Roman capital would always be in Sicily (since it is the first city they'd acquire in the loop) and Rome would probably be in an odd place (wherever the Greek or Celtic AI saw fit to put it). So AdjacentSquare is to kill off misplaced Romes while the larger area is for the flip. (unless, that is, I've totally misunderstood your objection here)

What did you think of the holy-city-moving code?
 
"why you need to use these dates"

Well, I don't really...I just need to know if the religion has been founded. Now that I'm not using the method I'd originally wrote (because it won't work), I don't really need to know the date per se.

I suppose I could just use
if isReligionFounded(0)
no?

I've not done anything with searching for cities of a particular name (just any cities existing on sets of tiles), so I'm a little lost on the whole "if "Jerusalem" is in AdjacentSquares (coord)" part of the whole process...

The thing is, I don't want it to assign Jerusalem as a holy city before the religion is founded in the game, and I don't want it to crash if no such city as Jerusalem exists.
 
maybe something like this:

Code:
def holyCityNorm():
		if isReligionFounded(0):
				for tCoords in getAdjacentList((73, 40)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
										pCity = pCurrentPlot.getPlotCity()
										if pCity.getName() = "Jerusalem"
										pCity.setHolyCity(0)

(each of my indents is two tabs...trust me...)
 
Well, there's is a method to my madness in what looks like a double spawn. The other AIs like to put cities on tiles adjacent to the ones for optimal placement. Rhye solved this problem by assigning desirability values to each tile, but that involved playing with the dll. This way, the game plants Rome where Rome should be, and the kill is to kill any city that would be directly adjacent to it. Other than that, I want it to simply flip Italy as it exists over to the Romans (for variation between games).
You can of course use two different areas for each spawning player - RFC defines 3 different areas per player as a reference point. I'm thinking about simplification here, thats all.

If I just did a zone-wide flip from the start, the Roman capital would always be in Sicily (since it is the first city they'd acquire in the loop) and Rome would probably be in an odd place (wherever the Greek or Celtic AI saw fit to put it). So AdjacentSquare is to kill off misplaced Romes while the larger area is for the flip. (unless, that is, I've totally misunderstood your objection here)
Ah, all you really need is a move-capital-statement (adding the Palace in the spawned city) and a helper function for making room for spawning new cities:
Code:
def killZone(iX, iY):
    tFocusPoint = (iX, iY)
    for x, y in getAdjacentList(tFocusPoint):
        pCurrentPlot = cyMap.getPlot(x, y)
        if pCurrentPlot.isCity():
            pCity = pCurrentPlot.getPlotCity()
            pCity.kill()
A call to this new helper function would actually have a place in the spawnCity() function:
Code:
def spawnCity(ePlayer, iX, iY, iSize=3, iCulture=500[B], bKill=False[/B]):
[B]        if bKill:
            killZone(iX, iY)[/B]
	pPlayer = gc.getPlayer(ePlayer)
	pCity = pPlayer.initCity(iX, iY)
	pCity.setPopulation(iSize)
	pCity.setCulture(ePlayer, iCulture, True)
This way you'd have to enable the kill zone functionality by setting the bKill argument to a True value. Or you could have it enabled by default - depending on what makes most sense. Or you could just skip the additional argument and always force the kill zone.
 
I think I need to add an "else" to there.

Basically, I want to to check each turn to see if the religion is founded, if it is, move the holy city to jerusalem (I should probably start with a check to see if it is already). If jerusalem is razed and later refounded, i want it to be made the holy city again...
 
maybe something like this:
You need a class instance for the isReligionFounded() method.

The last if statement is missing the colon at the end - and the subsequent line isn't intended.

And I still get double the indentation for your code, but I guess its not an issue then. :p

Did you understand what I meant by only checking a 2x2 area instead of a 3x3 area? Because checking for city names is unreliable at best - as it firstly requires your city naming code to be 100% functional - and secondly it can be circumvented by the human player renaming the city.

I'm happy to note that you're catching on with this Python thing. :king: All you'll need is more practice and getting used to thinking in terms of functions. You'll make a programmer yet! :goodjob:
 
I think I need to add an "else" to there.

Basically, I want to to check each turn to see if the religion is founded, if it is, move the holy city to jerusalem (I should probably start with a check to see if it is already). If jerusalem is razed and later refounded, i want it to be made the holy city again...
No, you should use the ReligionFounded callup from the SDK. If its not already in the Event Manager you should add it. From there you call on your function once Judaism is founded.

Give it a try!
 
yeah, but won't that call on it when Judaism is founded, rather than doing so every turn thereafter as well?
 
What if I defined a list of tiles to check in reverse order or preference? This way, it'll check what needs to be checked while ending with the most favored tile (theoretically leaving the holycity on the last one it finds with a city on it). I could define pJerusalem, pRoma, pMecca, etc.

I've skimmed back two pages...what was the 2x2 suggestion?

also...I can't seem to find the command that sets two civs at war. I've looked in the api and in eventmanager. I need to set war between the spawning civ and some neighbors...
 
Back
Top Bottom