def makePeace(eTeam):
pTeam = gc.getTeam(eTeam)
for eRival in range(18): # creates a list with integers from 0 to 17
pRivalPlayer = gc.getPlayer(ePlayer)
if pRivalPlayer.isAlive():
eRivalTeam = pRivalTeam.getTeam()
pTeam.makePeace(eRivalTeam)
makePeace(eTeam)
Its actually about the worst example of repeating code I've yet to see
Use the onTechAcquired call in the Event Manager and fire the code once anyone discovers the required Tech. But then you need a way to stop the code from being run ever again, and you can use a global variable for this. Firstly you set the default value at module level (= outside of any function):So riddle me this...what is the best way to see if a particular tech has been discovered by anybody? I think that's what I'm going to use to determine whether or not a religion has been founded. I'm going to have the code run onCityBuilt and use an if statement regarding the tech. If both are satisfied, I'll use the loop to assign the holycity status.
bNotTriggered = True
if bNotTriggered:
bNotTriggered = False
I actually have no idea... Why do you need the Wworkboat thing, again? Can't the Civs just be dead until they spawn?Just out of curiosity...is there a way to enable autoplay when in single player mode, but nix it in multiplayer? It's fine if I can't, it just means you've got to hold down the <return> key for awhile...a long while...
#moves holycity status to a city with the proper geographical location: run on city found
def holyCityNorm():
if getGame().isReligionSlotTaken(0):
for tCoords in getAdjacentList((73, 40)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
pCity.setHolyCity(0, true, true)
This is actually where it gets interesting. If I'm reading you correctly you're definitely on to something.I'm thinking of splitting up that holycity thing into two functions. One that runs on tech acquired and changes the value of bNotTriggered (do I need one of them for each religious tech? I'd think so...) and a second function that runs on city found and moves the city if that religion's bNotTriggered == False
no?
tReligions = (False,) * 7
(False, False, False, False, False, False, False)
MyModule.religionFounded(eReligion)
if not tReligions[eReligion]:
tReligions[eReligion] = True
I don't know what that method checks actually, so you'd just have to test it.BOOL isReligionSlotTaken (ReligionType eIndex)
bool (ReligionID) - is religion in that tech slot founded?
#moves holycity status to a city with the proper geographical location: run on city found
def holyCityNorm():
if gc.getGame().isReligionSlotTaken(0):
for tCoords in getAdjacentList((73, 40)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
gc.getGame().setHolyCity(0, pCity, false)
if gc.getGame().isReligionSlotTaken(1):
for tCoords in getAdjacentList((61, 46)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
gc.getGame().setHolyCity(1, pCity, false)
if gc.getGame().isReligionSlotTaken(2):
for tCoords in getAdjacentList((75, 35)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
gc.getGame().setHolyCity(2, pCity, false)
if gc.getGame().isReligionSlotTaken(3):
for tCoords in getAdjacentList((89, 39)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
gc.getGame().setHolyCity(3, pCity, false)
if gc.getGame().isReligionSlotTaken(4):
for tCoords in getAdjacentList((95, 43)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
gc.getGame().setHolyCity(4, pCity, false)
if gc.getGame().isReligionSlotTaken(5):
for tCoords in getAdjacentList((102, 45)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
gc.getGame().setHolyCity(5, pCity, false)
if gc.getGame().isReligionSlotTaken(6):
for tCoords in getAdjacentList((102, 32)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
gc.getGame().setHolyCity(6, pCity, false)
def hideSpawn(self):
getPlot((0, 0)).getUnit(0).kill(False, self.Context.player)
for tCoords in getSquareList((0, 0), 2):
getPlot(tCoords).setRevealed(getPlayer(self.Context.player).getTeam(), False, True, -1)
plotZero = gc.getMap().plot( 0, 0 )
if (plotZero.getNumUnits()):
catapult = plotZero.getUnit(0)
catapult.kill(False, iCiv)
gc.getMap().plot(0, 0).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(0, 1).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(1, 1).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(1, 0).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(123, 0).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(123, 1).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(2, 0).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(2, 1).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(2, 2).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(1, 2).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(0, 2).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(122, 0).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(122, 1).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(122, 2).setRevealed(iCiv, False, True, -1);
gc.getMap().plot(123, 2).setRevealed(iCiv, False, True, -1);
pPlot = cyMap.plot(x, y)
iNumUnits = pPlot.getNumUnits()
for i in range(iNumUnits):
pCurrentUnit = pPlot.getUnit(i)
eOwner = pCurrentUnit.getOwner()
pCurrentUnit.kill(False, eOwner)
#colony spawns tied to discovery of Astronomy, run onTechAcquired
def colonySpawn():
pNewYork = cyMap.plot(30, 47)
pPhiladelphia = cyMap.plot(28, 46)
pBoston = cyMap.plot(31, 48)
#Arabs
if gc.getTeam(11).isHasTech(42):
if bArabiaTriggered:
bArabiaTriggered = False
PyPlayer(11).initUnit(4, 99, 27, 1)
PyPlayer(11).initUnit(5, 99, 27, 2)
PyPlayer(11).initUnit(42, 99, 27, 5)
PyPlayer(11).initUnit(4, 104, 27, 1)
PyPlayer(11).initUnit(5, 104, 27, 2)
PyPlayer(11).initUnit(42, 104, 27, 5)
PyPlayer(11).initUnit(4, 71, 25, 1)
PyPlayer(11).initUnit(5, 71, 25, 2)
PyPlayer(11).initUnit(42, 71, 25, 5)
#English or Celts
if gc.getTeam(12).isHasTech(42):
if bEnglandTriggered:
bEnglandTriggered = False
for tCoords in getAdjacentList((30, 47)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
pCity.kill()
for tCoords in getAdjacentList((28, 46)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
pCity.kill()
for tCoords in getAdjacentList((31, 48)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x, y)
if pCurrentPlot.isCity():
pCity = pCurrentPlot.getPlotCity()
pCity.kill()
PyPlayer(12).initCity(30, 47)
pNewYork.getPlotCity().setName("New York", 1)
PyPlayer(12).initUnit(5, 30, 47, 2)
PyPlayer(12).initUnit(47, 30, 47, 5)
PyPlayer(12).initCity(28, 46)
pPhiladelphia.getPlotCity().setName("Philadelphia", 1)
PyPlayer(12).initUnit(5, 28, 46, 2)
PyPlayer(12).initUnit(47, 28, 46, 5)
PyPlayer(12).initCity(31, 48)
pBoston.getPlotCity().setName("Boston", 1)
PyPlayer(12).initUnit(5, 31, 48, 2)
PyPlayer(12).initUnit(47, 31, 48, 5)
PyPlayer(12).initUnit(4, 28, 51, 1)
PyPlayer(12).initUnit(5, 28, 51, 2)
PyPlayer(12).initUnit(47, 28, 51, 5)
PyPlayer(12).initUnit(4, 64, 12, 1)
PyPlayer(12).initUnit(5, 64, 12, 2)
PyPlayer(12).initUnit(47, 64, 12, 5)
PyPlayer(12).initUnit(4, 118, 13, 1)
PyPlayer(12).initUnit(5, 118, 13, 2)
PyPlayer(12).initUnit(47, 118, 13, 5)
if PyPlayer(12).getStateReligion() == 0:
PyPlayer(12).initUnit(17, 30, 47, 1)
PyPlayer(12).initUnit(17, 28, 46, 1)
PyPlayer(12).initUnit(17, 31, 48, 1)
PyPlayer(12).initUnit(17, 28, 51, 1)
PyPlayer(12).initUnit(17, 64, 12, 1)
PyPlayer(12).initUnit(17, 118, 13, 1)
if PyPlayer(12).getStateReligion() == 1:
PyPlayer(12).initUnit(18, 30, 47, 1)
PyPlayer(12).initUnit(18, 28, 46, 1)
PyPlayer(12).initUnit(18, 31, 48, 1)
PyPlayer(12).initUnit(18, 28, 51, 1)
PyPlayer(12).initUnit(18, 64, 12, 1)
PyPlayer(12).initUnit(18, 118, 13, 1)
if PyPlayer(12).getStateReligion() == 2:
PyPlayer(12).initUnit(19, 30, 47, 1)
PyPlayer(12).initUnit(19, 28, 46, 1)
PyPlayer(12).initUnit(19, 31, 48, 1)
PyPlayer(12).initUnit(19, 28, 51, 1)
PyPlayer(12).initUnit(19, 64, 12, 1)
PyPlayer(12).initUnit(19, 118, 13, 1)
if PyPlayer(12).getStateReligion() == 3:
PyPlayer(12).initUnit(20, 30, 47, 1)
PyPlayer(12).initUnit(20, 28, 46, 1)
PyPlayer(12).initUnit(20, 31, 48, 1)
PyPlayer(12).initUnit(20, 28, 51, 1)
PyPlayer(12).initUnit(20, 64, 12, 1)
PyPlayer(12).initUnit(20, 118, 13, 1)
if PyPlayer(12).getStateReligion() == 4:
PyPlayer(12).initUnit(21, 30, 47, 1)
PyPlayer(12).initUnit(21, 28, 46, 1)
PyPlayer(12).initUnit(21, 31, 48, 1)
PyPlayer(12).initUnit(21, 28, 51, 1)
PyPlayer(12).initUnit(21, 64, 12, 1)
PyPlayer(12).initUnit(21, 118, 13, 1)
if PyPlayer(12).getStateReligion() == 5:
PyPlayer(12).initUnit(22, 30, 47, 1)
PyPlayer(12).initUnit(22, 28, 46, 1)
PyPlayer(12).initUnit(22, 31, 48, 1)
PyPlayer(12).initUnit(22, 28, 51, 1)
PyPlayer(12).initUnit(22, 64, 12, 1)
PyPlayer(12).initUnit(22, 118, 13, 1)
if PyPlayer(12).getStateReligion() == 6:
PyPlayer(12).initUnit(23, 30, 47, 1)
PyPlayer(12).initUnit(23, 28, 46, 1)
PyPlayer(12).initUnit(23, 31, 48, 1)
PyPlayer(12).initUnit(23, 28, 51, 1)
PyPlayer(12).initUnit(23, 64, 12, 1)
PyPlayer(12).initUnit(23, 118, 13, 1)
#French
if gc.getTeam(13).isHasTech(42):
if bFranceTriggered:
bFranceTriggered = False
PyPlayer(13).initUnit(4, 31, 37, 1)
PyPlayer(13).initUnit(5, 31, 37, 2)
PyPlayer(13).initUnit(43, 31, 37, 5)
PyPlayer(13).initUnit(4, 31, 53, 1)
PyPlayer(13).initUnit(5, 31, 53, 2)
PyPlayer(13).initUnit(43, 31, 53, 5)
PyPlayer(13).initUnit(4, 33, 32, 1)
PyPlayer(13).initUnit(5, 33, 32, 2)
PyPlayer(13).initUnit(43, 33, 32, 5)
PyPlayer(13).initUnit(4, 57, 30, 1)
PyPlayer(13).initUnit(5, 57, 30, 2)
PyPlayer(13).initUnit(43, 57, 30, 5)
#Spanish
if gc.getTeam(14).isHasTech(42):
if bSpainTriggered:
bSpainTriggered = False
PyPlayer(14).initUnit(4, 27, 38, 1)
PyPlayer(14).initUnit(5, 27, 38, 2)
PyPlayer(14).initUnit(42, 27, 38, 5)
PyPlayer(14).initUnit(4, 18, 39, 1)
PyPlayer(14).initUnit(5, 18, 39, 2)
PyPlayer(14).initUnit(42, 18, 39, 5)
PyPlayer(14).initUnit(4, 42, 18, 1)
PyPlayer(14).initUnit(5, 42, 18, 2)
PyPlayer(14).initUnit(42, 42, 18, 5)
PyPlayer(14).initUnit(4, 36, 13, 1)
PyPlayer(14).initUnit(5, 36, 13, 2)
PyPlayer(14).initUnit(42, 36, 13, 5)
#Russia
if gc.getTeam(16).isHasTech(42):
if bRussiaTriggered:
bRussiaTriggered = False
for tCoords in getPlotList((66, 48), (1, 64)):
x, y = tCoords
pCurrentPlot = cyMap.plot(x,y)
pPotentialCity = pCurrentPlot.getPlotCity()
iUnhappy = pPotentialCity.unhappyLevel(0)
if pPotentialCity != None:
iPopulation = pPotentialCity.getPopulation()
if iUnhappy * 3 >= iPopulation:
pCurrentPlot.setOwner(16)
PyPlayer(16).initUnit(4, 110, 52, 1)
PyPlayer(16).initUnit(5, 110, 52, 2)
PyPlayer(16).initUnit(42, 110, 52, 5)
PyPlayer(16).initUnit(4, 80, 53, 1)
PyPlayer(16).initUnit(5, 80, 53, 2)
PyPlayer(16).initUnit(42, 80, 53, 5)
PyPlayer(16).initUnit(4, 96, 58, 1)
PyPlayer(16).initUnit(5, 96, 58, 2)
PyPlayer(16).initUnit(42, 96, 58, 5)