• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

trying to use a minimalist mod to do big things

soooooooooo

I got it to print the message and to declare war! Now it's a matter of implementing the initial, barbarian, and colony spawns for each civ.

The last thing I've got on my mind for it is the holy city mover. So, when I get all this done (yes, I think I am going to do it the long way because I find it easier to keep it all straight as I work), I'll post it, but in the meantime, if we could continue down the line of hammering out the bugs in the holycity thing I'd appreciate it muchly.
 
yeah, but won't that call on it when Judaism is founded, rather than doing so every turn thereafter as well?
Yeah, using the ReligionFounded callback will only run the code once. Why do you need to check this every turn?

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 don't fully understand this either, but you could try it? You can define such a data structure as a constant:
Code:
tPreference = ( (23, 34), (34, 35), (45, 56) )
Then its just a matter of traversing the tuple in that order:
Code:
for tCoords in tPreference:

I've skimmed back two pages...what was the 2x2 suggestion?
I don't have the exact coordinates you need, but this would look for a city at the bottom left corner of the map:
Code:
for tCoords in getPlotList((0, 0), (1, 1)):
Since the loop only contains four tiles there can only be one city inside that area. So I don't need to worry about choosing the right one.

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...
Yeah, thats a CyTeam thing - not CyPlayer. Because diplomacy as well as technology are handled on the Team level. But that doesn't mean that you can't have your own code for declaring war player to player:
Code:
def DOW(ePlayer, eRival):
    pPlayer = cg.getPlayer(ePlayer)
    ePlayerTeam = pPlayer.getTeam()
    pPlayerTeam = cg.getTeam(eTeam)
    pRival = cg.getPlayer(eRival)
    eRivalTeam = pRival.getTeam()
    pPlayerTeam.declareWar(eRivalTeam, True, -1)
Just as an example. But you should probably figure out all the assignment action above, because ePlayerTeam and pPlayerTeam are quite different values. Shall I explain? Also, lookup the actual method in the API - you might wanna try different parameters (like various WarPlanTypes settings).
 
well, I've pretty much got the whole thing working at this point. As I look there are only two things left to do (before playtesting for balance issues and writing up a description):

1) the colony spawns that happen onTechAcquired: Astronomy
2) the holycity moving code

yes, I know the unnecessary length of this will make you cringe, but it helps me keep it all straight:

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 *
import CvUtil

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

#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

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",
(79, 24): "Zanzibar",
(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",
(95, 43): "Lhasa",
(95, 42): "Lhasa",
(95, 44): "Lhasa",
(94, 43): "Lhasa",
(94, 42): "Lhasa",
(94, 44): "Lhasa",
(96, 43): "Lhasa",
(96, 42): "Lhasa",
(96, 44): "Lhasa",
(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
def classicalSpawn():
		pRome = cyMap.plot(61, 46)
		pPersia = cyMap.plot(81, 41)
		pJapan = cyMap.plot(115, 46)
		pKorea = cyMap.plot(109, 46)
#Romans
		if isDate(-770):
				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)
				PyPlayer(7).initUnit(4, 61, 46, 2)
				PyPlayer(7).initUnit(5, 61, 46, 2)
				PyPlayer(7).initUnit(57, 61, 46, 25)
				romeMessage = "Latin tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(romeMessage,"")
				CvUtil.pyPrint(romeMessage)
				if PyPlayer(0).isAlive():
						gc.getTeam(7).declareWar(0, True, -1)
				if PyPlayer(5).isAlive():
						gc.getTeam(7).declareWar(5, True, -1)
#Persians
		if isDate(-625):
				for tCoords in getAdjacentList((81, 41)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(8).initCity(81, 41)
				pPersia.getPlotCity().setPopulation(3)
				pPersia.getPlotCity().setCulture(8, 500, True)
				for tCoords in getPlotList((80, 39), (86, 43)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(8)
				persiaMessage = "Parsa tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(persiaMessage,"")
				CvUtil.pyPrint(persiaMessage)
				PyPlayer(8).initUnit(4, 81, 41, 2)
				PyPlayer(8).initUnit(5, 81, 41, 2)
				PyPlayer(8).initUnit(57, 81, 41, 15)
#Japanese
		if isDate(-500):
				for tCoords in getAdjacentList((115, 46)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(9).initCity(115, 46)
				pJapan.getPlotCity().setPopulation(3)
				pJapan.getPlotCity().setCulture(9, 500, True)
				for tCoords in getPlotList((111, 41), (116, 51)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(9)
				japanMessage = "Japanese tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(japanMessage,"")
				CvUtil.pyPrint(japanMessage)
				PyPlayer(9).initUnit(4, 115, 46, 2)
				PyPlayer(9).initUnit(5, 115, 46, 2)
				PyPlayer(9).initUnit(57, 115, 46, 15)
#Koreans
		if isDate(-500):
				for tCoords in getAdjacentList((109, 46)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(10).initCity(109, 46)
				pKorea.getPlotCity().setPopulation(3)
				pKorea.getPlotCity().setCulture(10, 500, True)
				for tCoords in getPlotList((107, 45), (111, 50)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(10)
				koreaMessage = "Choson tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(koreaMessage,"")
				CvUtil.pyPrint(koreaMessage)
				PyPlayer(10).initUnit(4, 109, 46, 2)
				PyPlayer(10).initUnit(5, 109, 46, 2)
				PyPlayer(10).initUnit(57, 109, 46, 20)
				if PyPlayer(4).isAlive():
						gc.getTeam(10).declareWar(4, True, -1)

#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
def arabSpawn():
		pArabia = cyMap.plot(75, 35)
		if isDate(700):
				for tCoords in getAdjacentList((75, 35)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(11).initCity(75, 35)
				pArabia.getPlotCity().setPopulation(3)
				pArabia.getPlotCity().setCulture(11, 500, True)
				for tCoords in getPlotList((73, 31), (82, 38)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(11)
				arabMessage = "Arabian tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(arabMessage,"")
				CvUtil.pyPrint(arabMessage)
				PyPlayer(10).initUnit(4, 75, 35, 2)
				PyPlayer(10).initUnit(5, 75, 35, 2)
				PyPlayer(10).initUnit(57, 75, 35, 40)
				if PyPlayer(1).isAlive():
						gc.getTeam(11).declareWar(1, True, -1)
				if PyPlayer(2).isAlive():
						gc.getTeam(11).declareWar(2, True, -1)
				if PyPlayer(6).isAlive():
						gc.getTeam(11).declareWar(6, True, -1)

#spawns medieval civs
def medievalSpawn():
		pEngland = cyMap.plot(55, 54)
		pFrance = cyMap.plot(58, 51)
		pSpain = cyMap.plot(55, 45)
		pGermany = cyMap.plot(63, 52)
		pRussia = cyMap.plot(71, 54)
#English
		if isDate(400):
				for tCoords in getAdjacentList((55, 54)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(12).initCity(55, 54)
				pEngland.getPlotCity().setPopulation(3)
				pEngland.getPlotCity().setCulture(12, 500, True)
				for tCoords in getPlotList((53, 53), (56, 56)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(12)
				englandMessage = "Saxon tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(englandMessage,"")
				CvUtil.pyPrint(englandMessage)
				PyPlayer(12).initUnit(4, 55, 54, 2)
				PyPlayer(12).initUnit(5, 55, 54, 2)
				PyPlayer(12).initUnit(60, 55, 54, 20)
				if PyPlayer(0).isAlive():
						gc.getTeam(12).declareWar(0, True, -1)
#French
		if isDate(450):
				for tCoords in getAdjacentList((58, 51)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(13).initCity(58, 51)
				pFrance.getPlotCity().setPopulation(3)
				pFrance.getPlotCity().setCulture(13, 500, True)
				for tCoords in getPlotList((56, 47), (59, 52)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(13)
				franceMessage = "Frankish tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(franceMessage,"")
				CvUtil.pyPrint(franceMessage)
				PyPlayer(13).initUnit(4, 58, 51, 2)
				PyPlayer(13).initUnit(5, 58, 51, 2)
				PyPlayer(13).initUnit(60, 58, 51, 15)
#Spanish
		if isDate(475):
				for tCoords in getAdjacentList((55, 45)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(14).initCity(55, 45)
				pSpain.getPlotCity().setPopulation(3)
				pSpain.getPlotCity().setCulture(14, 500, True)
				for tCoords in getPlotList((52, 43), (57, 47)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(14)
				spainMessage = "Iberian tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(spainMessage,"")
				CvUtil.pyPrint(spainMessage)
				PyPlayer(14).initUnit(4, 55, 45, 2)
				PyPlayer(14).initUnit(5, 55, 45, 2)
				PyPlayer(14).initUnit(60, 55, 45, 15)
#Germans
		if isDate(843):
				for tCoords in getAdjacentList((63, 52)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(15).initCity(63, 52)
				pGermany.getPlotCity().setPopulation(3)
				pGermany.getPlotCity().setCulture(15, 500, True)
				for tCoords in getPlotList((60, 50), (64, 64)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(15)
				germanMessage = "Germanic tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(germanMessage,"")
				CvUtil.pyPrint(germanMessage)
				PyPlayer(15).initUnit(4, 63, 52, 2)
				PyPlayer(15).initUnit(5, 63, 52, 2)
				PyPlayer(15).initUnit(60, 63, 52, 15)
#Russians
		if isDate(1000):
				for tCoords in getAdjacentList((71, 54)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(16).initCity(71, 54)
				pRussia.getPlotCity().setPopulation(3)
				pRussia.getPlotCity().setCulture(16, 500, True)
				for tCoords in getPlotList((65, 49), (80, 63)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(16)
				russiaMessage = "Slavic tribes have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(russiaMessage,"")
				CvUtil.pyPrint(russiaMessage)
				PyPlayer(16).initUnit(4, 71, 54, 2)
				PyPlayer(16).initUnit(5, 71, 54, 2)
				PyPlayer(16).initUnit(60, 71, 54, 15)

#American spawn and flip of eastern US 1775AD
def ameriSpawn():
		pAmerica = cyMap.plot(27, 45)
		if isDate(1775):
				pAmerica.getPlotCity().kill()
				PyPlayer(17).initCity(27, 45)
				pAmerica.getPlotCity().setPopulation(3)
				pAmerica.getPlotCity().setCulture(17, 500, True)
				for tCoords in getPlotList((24, 42), (34, 50)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(17)
				americaMessage = "American colonists have united and declare their independence. A new civilization is born!"
				CyInterface().addImmediateMessage(americaMessage,"")
				CvUtil.pyPrint(americaMessage)
				PyPlayer(17).initUnit(4, 27, 45, 2)
				PyPlayer(17).initUnit(5, 27, 45, 2)
				PyPlayer(17).initUnit(42, 27, 45, 25)
				if PyPlayer(12).isAlive():
						gc.getTeam(17).declareWar(12, True, -1)

#colony spawn for Greeks and Celts 1600BC
def ancientSpawn():
		if isDate(-1600):
#Celts
				pDublin1 = cyMap.plot(51, 55)
				pDublin1.getPlotCity().kill()
				pDublin2 = cyMap.plot(51, 56)
				pDublin2.getPlotCity().kill()
				PyPlayer(0).initCity(51, 55)
				pDublin1.getPlotCity().setName("Dublin", 1)
				pDublin1.getPlotCity().setNumRealBuilding(0, 1)
				irishMessage = "Prophesies of coming strife prompt Heber Fionn to carry Celtic culture to a distant island.  The Celtic capital has been moved."
				CyInterface().addImmediateMessage(irishMessage,"")
				CvUtil.pyPrint(irishMessage)
				PyPlayer(0).initUnit(5, 51, 55, 1)
				PyPlayer(0).initUnit(57, 51, 55, 3)
				PyPlayer(0).initUnit(4, 55, 54, 1)
				PyPlayer(0).initUnit(5, 55, 54, 1)
				PyPlayer(0).initUnit(57, 55, 54, 3)
				PyPlayer(0).initUnit(4, 55, 58, 1)
				PyPlayer(0).initUnit(5, 55, 58, 1)
				PyPlayer(0).initUnit(57, 55, 58, 3)
#Greeks
				PyPlayer(5).initUnit(4, 68, 46, 1)
				PyPlayer(5).initUnit(5, 68, 46, 1)
				PyPlayer(5).initUnit(57, 68, 46, 3)
				PyPlayer(5).initUnit(4, 69, 41, 1)
				PyPlayer(5).initUnit(5, 69, 41, 1)
				PyPlayer(5).initUnit(57, 69, 41, 3)
				PyPlayer(5).initUnit(4, 64, 47, 1)
				PyPlayer(5).initUnit(5, 64, 47, 1)
				PyPlayer(5).initUnit(57, 64, 47, 3)
#Tibet
				pLhasa = cyMap.plot(95, 43)
				for tCoords in getAdjacentList((95, 43)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x, y)
						if pCurrentPlot.isCity():
								pCity = pCurrentPlot.getPlotCity()
								pCity.kill()
				PyPlayer(18).initCity(95, 43)
				pLhasa.getPlotCity().setPopulation(3)
				pLhasa.getPlotCity().setCulture(18, 200, True)
				pLhasa.getPlotCity().setName("Lhasa", 1)

#spawns German colonies in Scandinavia and Iceland 1200AD
def scandiSpawn():
		if isDate(1200):
#Scandinavia
				for tCoords in getPlotList((58, 55), (65, 64)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(7)
				PyPlayer(15).initUnit(4, 63, 58, 1)
				PyPlayer(15).initUnit(5, 63, 58, 2)
				PyPlayer(15).initUnit(60, 63, 58, 4)
				PyPlayer(15).initUnit(4, 62, 52, 1)
				PyPlayer(15).initUnit(5, 62, 52, 2)
				PyPlayer(15).initUnit(60, 62, 52, 4)
#Iceland
				for tCoords in getPlotList((46, 61), (49, 63)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(7)
				PyPlayer(15).initUnit(4, 47, 61, 1)
				PyPlayer(15).initUnit(5, 47, 61, 2)
				PyPlayer(15).initUnit(60, 47, 61, 4)
				scandiMessage = "Tribes in Scandinavia unite with their Germanic brethren."
				CyInterface().addImmediateMessage(scandiMessage,"")
				CvUtil.pyPrint(scandiMessage)



#colony spawns tied to discovery of Astronomy
#def colonySpawn():
#Arabs
#English
#French
#Spanish
#Russia

#American spawns and flip of western US and Hawaii 1900AD
def ameriFlip():
		if isDate(1900):
				if PyPlayer(17).isAlive():
				for tCoords in getPlotList((11, 44), (23, 43)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(17)
				for tCoords in getPlotList((112, 34), (6, 39)):
						x, y = tCoords
						pCurrentPlot = cyMap.plot(x,y)
						if pCurrentPlot.isCity():
								pCurrentPlot.setOwner(17)
						pHonolulu = cyMap.plot(1, 38)
						pHonolulu.getPlotCity().kill()
						PyPlayer(17).initCity(1, 38)
						pHonolulu.getPlotCity().setName("Honolulu", 1)
						manifestMessage = "The United States achieves Manifest Destiny."
						CyInterface().addImmediateMessage(manifestMessage,"")
						CvUtil.pyPrint(manifestMessage)
						PyPlayer(17).initUnit(5, 4, 35, 1)
						PyPlayer(17).initUnit(46, 1, 38, 3)
						PyPlayer(17).initUnit(4, 12, 48, 1)
						PyPlayer(17).initUnit(5, 12, 48, 1)
						PyPlayer(17).initUnit(46, 12, 48, 3)
						PyPlayer(17).initUnit(4, 12, 48, 1)
						PyPlayer(17).initUnit(5, 12, 48, 1)
						PyPlayer(17).initUnit(46, 12, 48, 3)
						PyPlayer(17).initUnit(4, 12, 48, 1)
						PyPlayer(17).initUnit(5, 12, 48, 1)
						PyPlayer(17).initUnit(46, 12, 48, 3)

#spawns vikings and mongols
def barbSpawn():
		if isDate(900):
#vikings
				PyPlayer(18).initUnit(90, 59, 62, 2)
				PyPlayer(18).initUnit(36, 59, 62, 4)
				vikingMessage = "Northern Europe reports an escalation of Viking raids!!!"
				CyInterface().addImmediateMessage(vikingMessage,"")
				CvUtil.pyPrint(vikingMessage)
		if isDate(910):
#mongols
				PyPlayer(18).initUnit(68, 99, 52, 6)
				mongolMessage = "Asian cities report Mongol hordes pouring out of the steppe to wreak havoc!!!"
				CyInterface().addImmediateMessage(mongolMessage,"")
				CvUtil.pyPrint(mongolMessage)
		if isDate(925):
#vikings
				PyPlayer(18).initUnit(90, 59, 56, 2)
				PyPlayer(18).initUnit(36, 59, 56, 4)
				vikingMessage = "Northern Europe reports an escalation of Viking raids!!!"
				CyInterface().addImmediateMessage(vikingMessage,"")
				CvUtil.pyPrint(vikingMessage)
		if isDate(930):
#mongols
				PyPlayer(18).initUnit(68, 99, 52, 6)
				mongolMessage = "Asian cities report Mongol hordes pouring out of the steppe to wreak havoc!!!"
				CyInterface().addImmediateMessage(mongolMessage,"")
				CvUtil.pyPrint(mongolMessage)
		if isDate(950):
#vikings
				PyPlayer(18).initUnit(90, 49, 58, 2)
				PyPlayer(18).initUnit(36, 49, 58, 4)
				vikingMessage = "Northern Europe reports an escalation of Viking raids!!!"
				CyInterface().addImmediateMessage(vikingMessage,"")
				CvUtil.pyPrint(vikingMessage)
		if isDate(960):
#mongols
				PyPlayer(18).initUnit(68, 99, 52, 6)
				mongolMessage = "Asian cities report Mongol hordes pouring out of the steppe to wreak havoc!!!"
				CyInterface().addImmediateMessage(mongolMessage,"")
				CvUtil.pyPrint(mongolMessage)
		if isDate(975):
#vikings
				PyPlayer(18).initUnit(90, 58, 53, 2)
				PyPlayer(18).initUnit(36, 58, 53, 4)
				vikingMessage = "Northern Europe reports an escalation of Viking raids!!!"
				CyInterface().addImmediateMessage(vikingMessage,"")
				CvUtil.pyPrint(vikingMessage)
		if isDate(985):
#mongols
				PyPlayer(18).initUnit(68, 99, 52, 6)
				mongolMessage = "Asian cities report Mongol hordes pouring out of the steppe to wreak havoc!!!"
				CyInterface().addImmediateMessage(mongolMessage,"")
				CvUtil.pyPrint(mongolMessage)
		if isDate(1000):
#vikings
				PyPlayer(18).initUnit(90, 58, 55, 2)
				PyPlayer(18).initUnit(36, 58, 55, 4)
				vikingMessage = "Northern Europe reports an escalation of Viking raids!!!"
				CyInterface().addImmediateMessage(vikingMessage,"")
				CvUtil.pyPrint(vikingMessage)
		if isDate(1020):
#mongols
				PyPlayer(18).initUnit(68, 99, 52, 6)
				mongolMessage = "Asian cities report Mongol hordes pouring out of the steppe to wreak havoc!!!"
				CyInterface().addImmediateMessage(mongolMessage,"")
				CvUtil.pyPrint(mongolMessage)
		if isDate(1025):
#vikings
				PyPlayer(18).initUnit(90, 63, 54, 2)
				PyPlayer(18).initUnit(36, 63, 54, 4)
				vikingMessage = "Northern Europe reports an escalation of Viking raids!!!"
				CyInterface().addImmediateMessage(vikingMessage,"")
				CvUtil.pyPrint(vikingMessage)
		if isDate(1030):
#mongols
				PyPlayer(18).initUnit(68, 99, 52, 6) 
				mongolMessage = "Asian cities report Mongol hordes pouring out of the steppe to wreak havoc!!!"
				CyInterface().addImmediateMessage(mongolMessage,"")
				CvUtil.pyPrint(mongolMessage) 

#spawns native Americans
def nativeSpawn():
		if isDate(1400):
#Plains Indians
				PyPlayer(18).initUnit(33, 24, 44, 7)
#Aztec
				PyPlayer(18).initUnit(27, 22, 35, 7)
#Inca       
				PyPlayer(18).initUnit(25, 27, 24, 7)
#Maya
				PyPlayer(18).initUnit(39, 22, 35, 7)
 
I'll have a look after work, then. Any special issues you need help with?
 
well, as far as I have been able to test, it all works. It's ugly, but it works.

I'm pretty sure I can figure out the onTechAcquired colony stuff, but any advice on the holy city stuff would be appreciated.

Basically, I want to keep the holy cities in their historical areas so religions spread fairly historically. So I guess I'll be calling on a list of coords every so often after the religion is founded (I suppose it doesn't need to be every turn, maybe when the religion is founded and every 25 thereafter?). I do want the holy city to reemerge if it is razed and a city later refounded on that same spot (or that same adjacentsquare :crazyeye: )
 
Then you need the the onCityBuilt() callup? Because that would allow you to firstly check every new city against a specified map area. If its within the religious birth area, then you know that the old city mush have been razed - since a 2x2 area can't fit more than one city. So you add the religious center to the new city.

Why not just forbid razing the holy sites to begin with? (I haven't looked into it but I'm guessing its doable.)

I'll get back to you regarding your "ugly" script later. ;)

edit: I don't really have anything to add that wouldn't result in me repeating something I've already said. Other than that I think that its very cool to see you program for real. :king: If you intend to do any more project in the future you should really look into data structures more, since you've already proven that you can create a simple setup like this. This would be the next logical step and give you so much more power as a programmer - and mod designer.
 
Ah, that's sort of back to my original idea with a twist!

So I'd check holyCityNorm() onCityBuilt() and in holyCityNorm() I'd have it check to see if the religion is already founded, and then if the city being built is in the 2x2 and if so, make it the holy city.

This does not solve the problem of the Chinese discovering Judaism while Jerusalem is on the map and, if it's never razed, the holy city never gets moved.

Also, I can forsee a problem with forbidding holy city razing. Envision this: Jerusalem is razed and the Greeks discover Christianity. They have a city on the Rome tile and that gets named the holy city. When the Roman spawn comes around, it can't "nuke" the holy city, but plants another city on top of the one on the map (I saw with buggy code, it'll do that).

Honestly, I'd rather just have it check the 2x2 on religion discovery and every 25 turns thereafter.
 
This does not solve the problem of the Chinese discovering Judaism while Jerusalem is on the map and, if it's never razed, the holy city never gets moved.
You can have two different methods called on two different game events.

Checking on turn intervals as you suggest would probably be the worst implementation you could end up with, so lets figure this out. I'm still getting lost on what exactly you wanna do. So explain the whole "mod" design for me one more time, please. :p

Because its simply a matter of solving the puzzle, but firstly I need to see all the pieces.
 
the mod runs from 4000BC to the present day, with certain checks to bring on historical accuracy.

so...I'd like religions to spread historically; keeping their holy cities in their geographical positions would go a long way toward doing that (along with FavoriteReligion in the leaderheads). I also don't want a holycity razing to be final. I'd like that status to respawn in it's old position if another city is established there.

To take Jerusalem again, histocially speaking...twice the city was razed (first by the Babylonians and next by the Romans) and each time when it was reestablished it was again made the holy city of Judaism.
 
hmmmmm...just noticed a problem....no production, commerce, or food from sea tiles...have to fix that....
 
So, you basically need to hack into both onReligionFounded() and onCityBuilt() in the Event Manager. But lets start at the beginning. You really should do this one with data structures and generic lookups, but I guess you could prototype this with Judaism first. :p

(One hour later...)

I've tried to write a run-through of everything that needs to be done several times but I can't explain it without actually doing the whole thing for you. If you just wanna get this over with I could do that - all I basically need is the coordinates for the 2x2 Jerusalem site. It would be somewhat much code I'm afraid and I'm not sure if you would be able to follow all of it.

But if you wanna do it yourself you'd probably learn more, but it should involve making several new functions and it would probably take a few tries to get it right.

The way I would do it myself is to have a global variable that is either True or False depending on whether or not Judaism has been founded - or not. That would enable a simple conditional statement:
Code:
if bJudaism:
The value of bJudaism would of course be False by default, but would change to True once the religion has emerged. Then and only then would all onCityFounded() call-ups be scanned for the Jerusalem tiles.

Wanna give it a try first? :p
 
yeah, I'll give it a try. This no production/food/commerce from sea tiles thing is bothersome. The only related xml I changed was the global warming percent and the min city distance...I can't figure out why I can't get anything from the sea, and I've been so focused on this python spawning stuff I don't know at what point it became an issue...
 
Are land tiles yielding production/food/commerce? Can you assign those sea tiles as worked?

Does it concern all cities or only the ones you spawned with Python? Or perhaps only the cities you've "flipped"? (Because you really haven't - you probably need to use PyPlayer.acquireCity() instead of CyPlot.setOwner() for proper flipping.)
 
land tiles yield what they're supposed to , water yields nothing and is not workable.

here's where I'm at:
 
even if I remove the altered globaldefines.xml file it is the same story. and this is even the case for properly built cities (ie. ones I build from a settler).
 
ditto for removing the mods entire xml file...the problem has to be in the python somewhere...
 
I'm an idiot.

How the heck did I play for so long without realizing that you can't work them until you have fishing!? wowza! Sorry for the confusion...
 
I suppose I've been playing later starts for so long...wow...I really do feel stupid. Alright...back to working on the real stuff...
 
Back
Top Bottom