HOW TO: BTS non-random Events

The function reads as follows:

Code:
def canTriggerZeusSpawn(argsList):
	kTriggeredData = argsList[0]
	turn = kTriggeredData.iTurn
					
	if (turn % 10 == 0):
		return true
	return false

For the mathematically challenged :) , this uses the modulus operator:

18 % 10 = 8
19 % 10 = 9
20 % 10 = 0
21 % 10 = 1
etc.

So, this function will return true every tenth turn and this return value let's the trigger know the event gets fired.

Pretty cool, but what would be the formula if I wanted an event to repeat every four turns??
 
It tried merging this last bit with a subroutine you gave me some time ago. I obviously didn't do it right. After trying a few approaches I ended up with this, but it's not working right (besides allowing the several other non-related events listed after this one to trigger as well).

Code:
def canTriggerLendLease(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	turn = kTriggeredData.iTurn

	if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ENGLAND")):
		game = gc.getGame()
						
		if (game.getGameTurn() >= 25):
					
			if (turn % 4 == 0):
				return true
			return false

	return false

What did I mess up this time?

(EDITED) -- Still a problem after all...
 
I thinking of doing a alien world mod and I was wondering if this code would work with improvements? preferably each improvement separately for example:

Lets say I have 5 cattle ranches which each provide the resource cattle:

now I would like to trigger an event once a cattle ranch is built that it gives a 5% chance each turn to turn into a pasture with the resource cattle and a
10% each turn to destroy the cattle ranch. Would the random event just chose one cattle ranch or could you trigger it for each ranch separately?
 
It tried merging this last bit with a subroutine you gave me some time ago. I obviously didn't do it right. After trying a few approaches I ended up with this, but it's not working right (besides allowing the several other non-related events listed after this one to trigger as well).

.....code.....

What did I mess up this time?

(EDITED) -- Still a problem after all...

Looks ok to me, but it also depends on how you are testing this. Make sure the event gets triggered without a PythonCanDo (maybe XML problem?) or try

if (turn > 25 && turn % 4 == 0):

remove the gc stuff (make it very similar to the Zeus code, which is tested and runs for sure) and test by playing 27 turns. The event then gets triggered at the end of the 26th turn.

I hope this helps, I haven't been modding lately, so I might have overlooked something...
 
I thinking of doing a alien world mod and I was wondering if this code would work with improvements? preferably each improvement separately for example:

Lets say I have 5 cattle ranches which each provide the resource cattle:

now I would like to trigger an event once a cattle ranch is built that it gives a 5% chance each turn to turn into a pasture with the resource cattle and a
10% each turn to destroy the cattle ranch. Would the random event just chose one cattle ranch or could you trigger it for each ranch separately?

Both are possible, you could even have it triggered for all players by making it a global event. The easiest (less Python) would be to let it trigger for 1 cattle improvement by using the <bPickPlot> XML-tag.
 
Looks ok to me, but it also depends on how you are testing this. Make sure the event gets triggered without a PythonCanDo (maybe XML problem?) or try

if (turn > 25 && turn % 4 == 0):

remove the gc stuff (make it very similar to the Zeus code, which is tested and runs for sure) and test by playing 27 turns. The event then gets triggered at the end of the 26th turn.

I hope this helps, I haven't been modding lately, so I might have overlooked something...

OK, I'll play with the above. What "gc stuff" are you referring to?
 
OK, I'll play with the above. What "gc stuff" are you referring to?

Like this I mean:

Code:
def canTriggerLendLease(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	turn = kTriggeredData.iTurn

	if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ENGLAND")):
		if (turn > 25 && (turn % 4 == 0)):
			return true
		return false
	return false

EDIT: be aware that this also gets triggered (first time after 26 turns) if you have loaded a savegame, so this might not be exactly what you need, but it is a good start...

EDIT2: just noticed you had some tabs in your code in the whiteline after game = gc.getGame(). Not sure, but that could have been screwing your original code.
 
I know it's not an xml problem. I ran the event with your earlier Python coding, and the event did what it was expected to do. It's when I tried to merge the two Python functions that things went haywire.

Me are true barbarian... no read Latin or XML too good.
 
Logically, your correction should have worked. But it didn't. What happens is:

  • the event takes place right away on the initial turn of the scenario (Turn = 24), although I had it set to go off on turn 28,
  • it happens every turn,
  • two different civs are getting the event simultaneously,
  • and the next listed event is also triggered.

EDIT: This is what had been happening with my earlier attempts to elaborate on the original coding.


Here is the coding for the two events (these are listed at the end of the Python file.)

Code:
######## USAAF Reinforcements (American event Turn 128) #########

def canTriggerUSAAF(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	turn = kTriggeredData.iTurn

	if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_AMERICA")):
		if (turn > 27 && turn % 4 == 0):
			return true
		return false

	return false

######## Germany Declares War on USA (American event Turn 89) #########

def canTriggerUSAETOWAR(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)

	if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_AMERICA")):
		game = gc.getGame()
						
		if (game.getGameTurn() == 89):
			return true
		return false

	return false

If the first event's python routine is the same as the one listed for the second event, then they occur as they should, on their expected turns. Event #1 is a recurring event -- listed as such in the XML file.

Here's the actual trigger file.

Spoiler :
Code:
		<EventTriggerInfo>
			<Type>EVENTTRIGGER_USAAF</Type>
			<WorldNewsTexts>
				<Text>TXT_KEY_EVENTTRIGGER_USAAF</Text>
			</WorldNewsTexts>
			<TriggerTexts>
				<TriggerText>
					<Text>TXT_KEY_EVENT_TRIGGER_USAAF</Text>
					<Era>NONE</Era>
				</TriggerText>
			</TriggerTexts>
			<bSinglePlayer>0</bSinglePlayer>
			<iPercentGamesActive>100</iPercentGamesActive>
			<iWeight>-1</iWeight>
			<bProbabilityUnitMultiply>0</bProbabilityUnitMultiply>
			<bProbabilityBuildingMultiply>0</bProbabilityBuildingMultiply>
			<Civic>NONE</Civic>
			<iMinTreasury>0</iMinTreasury>
			<iMinPopulation>0</iMinPopulation>
			<iMaxPopulation>0</iMaxPopulation>
			<iMinMapLandmass>0</iMinMapLandmass>
			<iMinOurLandmass>0</iMinOurLandmass>
			<iMaxOurLandmass>-1</iMaxOurLandmass>
			<MinDifficulty>NONE</MinDifficulty>
			<iAngry>0</iAngry>
			<iUnhealthy>0</iUnhealthy>
			<UnitsRequired/>
			<iNumUnits>0</iNumUnits>
			<iNumUnitsGlobal>0</iNumUnitsGlobal>
			<iUnitDamagedWeight>0</iUnitDamagedWeight>
			<iUnitDistanceWeight>0</iUnitDistanceWeight>
			<iUnitExperienceWeight>0</iUnitExperienceWeight>
			<bUnitsOnPlot>0</bUnitsOnPlot>
			<BuildingsRequired/>
			<iNumBuildings>0</iNumBuildings>
			<iNumBuildingsGlobal>0</iNumBuildingsGlobal>
			<iNumPlotsRequired>0</iNumPlotsRequired>
			<bOwnPlot>0</bOwnPlot>
			<iPlotType>-1</iPlotType>
			<FeaturesRequired/>
			<TerrainsRequired/>
			<ImprovementsRequired/>
			<BonusesRequired/>
			<RoutesRequired/>
			<ReligionsRequired/>
			<iNumReligions>0</iNumReligions>
			<CorporationsRequired/>
			<iNumCorporations>0</iNumCorporations>
			<bPickReligion>0</bPickReligion>
			<bStateReligion>0</bStateReligion>
			<bHolyCity>0</bHolyCity>
			<bPickCorporation>0</bPickCorporation>
			<bHeadquarters>0</bHeadquarters>
			<Events>
				<Event>EVENT_USAAF_1</Event>
				<Event>EVENT_USAAF_2</Event>
			</Events>
			<PrereqEvents/>
			<bPrereqEventPlot>0</bPrereqEventPlot>
			<OrPreReqs/>
			<AndPreReqs/>
			<ObsoleteTechs>
				<ObsoleteTech>TECH_IMPROVED_AIRCRAFT</ObsoleteTech>
				<ObsoleteTech>TECH_IMPROVED_GUNNERY</ObsoleteTech>
			</ObsoleteTechs>
			<bRecurring>1</bRecurring>
			<bTeam>0</bTeam>
			<bGlobal>0</bGlobal>
			<bPickPlayer>0</bPickPlayer>
			<bOtherPlayerWar>0</bOtherPlayerWar>
			<bOtherPlayerHasReligion>0</bOtherPlayerHasReligion>
			<bOtherPlayerHasOtherReligion>0</bOtherPlayerHasOtherReligion>
			<bOtherPlayerAI>0</bOtherPlayerAI>
			<iOtherPlayerShareBorders>0</iOtherPlayerShareBorders>
			<OtherPlayerHasTech>NONE</OtherPlayerHasTech>
			<bPickCity>0</bPickCity>
			<bPickOtherPlayerCity>0</bPickOtherPlayerCity>
			<bShowPlot>0</bShowPlot>
			<iCityFoodWeight>0</iCityFoodWeight>
			<PythonCanDo>canTriggerUSAAF</PythonCanDo>
			<PythonCanDoCity/>
			<PythonCanDoUnit/>
			<PythonCallback/>
		</EventTriggerInfo>

And the two event entries

Spoiler :
Code:
		<EventInfo>
			<Type>EVENT_USAAF_1</Type>
			<Description>TXT_KEY_EVENT_USAAF_1</Description>
			<LocalInfoText/>
			<WorldNewsTexts/>
			<OtherPlayerPopup/>
			<QuestFailText/>
			<bQuest>0</bQuest>
			<bGlobal>0</bGlobal>
			<bTeam>0</bTeam>
			<bPickCity>0</bPickCity>
			<bPickOtherPlayerCity>0</bPickOtherPlayerCity>
			<bDeclareWar>0</bDeclareWar>
			<iGold>0</iGold>
			<bGoldToPlayer>0</bGoldToPlayer>
			<iRandomGold>0</iRandomGold>
			<iCulture>0</iCulture>
			<iEspionagePoints>0</iEspionagePoints>
			<bGoldenAge>0</bGoldenAge>
			<iFreeUnitSupport>0</iFreeUnitSupport>
			<iInflationMod>0</iInflationMod>
			<iSpaceProductionMod>0</iSpaceProductionMod>
			<Tech>NONE</Tech>
			<TechFlavors/>
			<iTechPercent>0</iTechPercent>
			<iTechCostPercent>0</iTechCostPercent>
			<iTechMinTurnsLeft>0</iTechMinTurnsLeft>
			<PrereqTech>NONE</PrereqTech>
			<UnitClass>UNITCLASS_P38</UnitClass>
			<iNumFreeUnits>2</iNumFreeUnits>
			<bDisbandUnit>0</bDisbandUnit>
			<iUnitExperience>0</iUnitExperience>
			<iUnitImmobileTurns>0</iUnitImmobileTurns>
			<UnitPromotion/>
			<UnitName/>
			<UnitCombatPromotions/>
			<UnitClassPromotions/>
			<BuildingClass>NONE</BuildingClass>
			<iBuildingChange>0</iBuildingChange>
			<BuildingExtraYields/>
			<BuildingExtraCommerces/>
			<BuildingExtraHappies/>
			<BuildingExtraHealths/>
			<iHappy>0</iHappy>
			<iHealth>0</iHealth>
			<iHurryAnger>0</iHurryAnger>
			<iHappyTurns>0</iHappyTurns>
			<iRevoltTurns>0</iRevoltTurns>
			<iMinPillage>0</iMinPillage>
			<iMaxPillage>0</iMaxPillage>
			<iFood>0</iFood>
			<iFoodPercent>0</iFoodPercent>
			<FreeSpecialistCounts/>
			<FeatureType>NONE</FeatureType>
			<iFeatureChange>0</iFeatureChange>
			<ImprovementType>NONE</ImprovementType>
			<iImprovementChange>0</iImprovementChange>
			<BonusType>NONE</BonusType>
			<iBonusChange>0</iBonusChange>
			<RouteType>NONE</RouteType>
			<iRouteChange>0</iRouteChange>
			<BonusRevealed>NONE</BonusRevealed>
			<BonusGift>NONE</BonusGift>
			<PlotExtraYields/>
			<iConvertOwnCities>0</iConvertOwnCities>
			<iConvertOtherCities>0</iConvertOtherCities>
			<iMaxNumReligions>-1</iMaxNumReligions>
			<iOurAttitudeModifier>0</iOurAttitudeModifier>
			<iAttitudeModifier>0</iAttitudeModifier>
			<iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
			<iPopulationChange>0</iPopulationChange>
			<AdditionalEvents/>
			<EventTimes/>
			<ClearEvents/>
			<PythonCallback/>
			<PythonExpireCheck/>
			<PythonCanDo/>
			<PythonHelp/>
			<Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
			<iAIValue>1000</iAIValue>
		</EventInfo>
		<EventInfo>
			<Type>EVENT_USAAF_2</Type>
			<Description>TXT_KEY_EVENT_USAAF_2</Description>
			<LocalInfoText/>
			<WorldNewsTexts/>
			<OtherPlayerPopup/>
			<QuestFailText/>
			<bQuest>0</bQuest>
			<bGlobal>0</bGlobal>
			<bTeam>0</bTeam>
			<bPickCity>0</bPickCity>
			<bPickOtherPlayerCity>0</bPickOtherPlayerCity>
			<bDeclareWar>0</bDeclareWar>
			<iGold>0</iGold>
			<bGoldToPlayer>0</bGoldToPlayer>
			<iRandomGold>0</iRandomGold>
			<iCulture>0</iCulture>
			<iEspionagePoints>0</iEspionagePoints>
			<bGoldenAge>0</bGoldenAge>
			<iFreeUnitSupport>0</iFreeUnitSupport>
			<iInflationMod>0</iInflationMod>
			<iSpaceProductionMod>0</iSpaceProductionMod>
			<Tech>NONE</Tech>
			<TechFlavors/>
			<iTechPercent>0</iTechPercent>
			<iTechCostPercent>0</iTechCostPercent>
			<iTechMinTurnsLeft>0</iTechMinTurnsLeft>
			<PrereqTech>NONE</PrereqTech>
			<UnitClass>UNITCLASS_B17</UnitClass>
			<iNumFreeUnits>3</iNumFreeUnits>
			<bDisbandUnit>0</bDisbandUnit>
			<iUnitExperience>0</iUnitExperience>
			<iUnitImmobileTurns>0</iUnitImmobileTurns>
			<UnitPromotion/>
			<UnitName/>
			<UnitCombatPromotions/>
			<UnitClassPromotions/>
			<BuildingClass>NONE</BuildingClass>
			<iBuildingChange>0</iBuildingChange>
			<BuildingExtraYields/>
			<BuildingExtraCommerces/>
			<BuildingExtraHappies/>
			<BuildingExtraHealths/>
			<iHappy>0</iHappy>
			<iHealth>0</iHealth>
			<iHurryAnger>0</iHurryAnger>
			<iHappyTurns>0</iHappyTurns>
			<iRevoltTurns>0</iRevoltTurns>
			<iMinPillage>0</iMinPillage>
			<iMaxPillage>0</iMaxPillage>
			<iFood>0</iFood>
			<iFoodPercent>0</iFoodPercent>
			<FreeSpecialistCounts/>
			<FeatureType>NONE</FeatureType>
			<iFeatureChange>0</iFeatureChange>
			<ImprovementType>NONE</ImprovementType>
			<iImprovementChange>0</iImprovementChange>
			<BonusType>NONE</BonusType>
			<iBonusChange>0</iBonusChange>
			<RouteType>NONE</RouteType>
			<iRouteChange>0</iRouteChange>
			<BonusRevealed>NONE</BonusRevealed>
			<BonusGift>NONE</BonusGift>
			<PlotExtraYields/>
			<iConvertOwnCities>0</iConvertOwnCities>
			<iConvertOtherCities>0</iConvertOtherCities>
			<iMaxNumReligions>-1</iMaxNumReligions>
			<iOurAttitudeModifier>0</iOurAttitudeModifier>
			<iAttitudeModifier>0</iAttitudeModifier>
			<iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
			<iPopulationChange>0</iPopulationChange>
			<AdditionalEvents/>
			<EventTimes/>
			<ClearEvents/>
			<PythonCallback/>
			<PythonExpireCheck/>
			<PythonCanDo/>
			<PythonHelp/>
			<Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
			<iAIValue>1000</iAIValue>
		</EventInfo>
 
@FIERABRAS

I found out how to get around the problem with the recurring event. There was a problem with the coding you suggested. For some reason, it didn't work in my mod.

It turns out the definition of the "Turn" was the culprit. Here is the modified coding (in green) that made the recurring event work. I'm not sure this is of use to you, but someone else might actually run into this.

For reference only:

Code:
######## Lend Lease (English Event Turn > 70) #########

def canTriggerLendLease(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	[B][COLOR="DarkGreen"]iGameTurn = CyGame().getGameTurn()
[/COLOR][/B]
	if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ENGLAND")):
		game = gc.getGame()

		if (game.getGameTurn() > 70):					
			if ([B][COLOR="DarkGreen"]iGameTurn[/COLOR][/B] % 6 == 0):
				return true
			return false
		return false
	return false

The original issue I brought up is listed below:

It tried merging this last bit with a subroutine you gave me some time ago. I obviously didn't do it right. After trying a few approaches I ended up with this, but it's not working right (besides allowing the several other non-related events listed after this one to trigger as well).

Code:
def canTriggerLendLease(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	[B][COLOR="Red"]turn = kTriggeredData.iTurn[/COLOR][/B]

	if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ENGLAND")):
		game = gc.getGame()
						
		if (game.getGameTurn() >= 25):
					
			if ([B][COLOR="Red"]turn[/COLOR][/B] % 4 == 0):
				return true
			return false

	return false

What did I mess up this time?

(EDITED) -- Still a problem after all...
 
Hmmm, I thought we already tried that (in our PM thread), but good to see it you got it working. I think this will indeed be informative for other modders, because this shows that the trigger-turn is not (always) equal to the game-turn, especially with scenarios which don't start on turn 0.

I would suggest some slight cleaning of your working code (because now you are getting the gameturn twice, if I am not mistaken):

Code:
######## Lend Lease (English Event Turn > 70) #########

def canTriggerLendLease(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	iGameTurn = CyGame().getGameTurn()

	if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ENGLAND")):
		if (iGameTurn > 70):					
			if (iGameTurn % 6 == 0):
				return true
			return false
		return false
	return false
 
Actually, I like it even better if you were using the CyClobalContext (which is assigned to gc at the top of the entire file):

instead of:

Code:
iGameTurn = CyGame().getGameTurn()

use:

Code:
game = gc.getGame()
iGameTurn = game.getGameTurn()

I'm not sure if this has any other effect than beautification, but it seems more consistent with the other default BTS defs.
 
I would suggest some slight cleaning of your working code (because now you are getting the gameturn twice, if I am not mistaken):

Am I getting the gameturn twice? I'm not sure what you mean by that (I saw what you corrected, but I don't understand what you are describing as a result).
 
iGameTurn = CyGame().getGameTurn()

does the same as:

game = gc.getGame()
game.getGameTurn()

You already have the game turn integer in iGameTurn, so there is no need to retrieve it again...
 
Nice work :hatsoff:

Just wanted to add one thing that will link well to your tutorial: how to make events to only appear a certain ammout of times ( like if you want a migration to appear or a handful of barb invasions at certain times ).

Instead of explaining, I'll simply show the Mesoamerica Mod code on the Spanish appearance on map:
Code:
class CvMesoamericaSpanishInvation:
		def __init__(self):
				'Constructor'
				
				self.wave = 0
				
				# We keep a list of our invading ships so that we can
				# update their AI in CvGameUtils
				self.ships = []
				
				self.landingPlots = [CyMap().plot(11, 29),
									CyMap().plot(13, 25),
									CyMap().plot(15, 22),
									CyMap().plot(18, 18),
									CyMap().plot(21, 16),
									CyMap().plot(25, 15),
									CyMap().plot(29, 17),
									CyMap().plot(34, 16),
									CyMap().plot(36, 20),
									CyMap().plot(36, 24),
									CyMap().plot(39, 27),
									CyMap().plot(42, 28),
									CyMap().plot(45, 28),
									CyMap().plot(48, 28),
									CyMap().plot(49, 24),
									CyMap().plot(48, 19),
									CyMap().plot(45, 10)]
				self.spawnPlots = [CyMap().plot(24, 33),
								CyMap().plot(25,33),
								CyMap().plot(25, 33)]

		def update(self):
				'Called every turn'
				turn = CyGame().getGameTurn()
				if (turn == 50 or turn == 70 or turn == 100 or turn == 130):
				#if (turn == 3 or turn == 12 or turn == 24 or turn == 36):
					self.__spawnSpanish()
				
					
		def getShips(self):
				return self.ships

		# Private methods

		def __spawnSpanish(self):
				'Spawns a wave of spanish units'

				spanishPlayer = PyPlayer(SPANISH_PLAYER)

				if (self.wave == 0):
						print("Spawing wave 0")
							
						spawnPlot = self.spawnPlots[0]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						unitIDs = []
						
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)
				elif (self.wave == 1):
						print("Spawning wave 1")
						
						spawnPlot = self.spawnPlots[0]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						unitIDs = []
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)
				elif (self.wave == 2):
						print("Spawning wave 2")
						
						spawnPlot = self.spawnPlots[0]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						unitIDs = []
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)
						
						unitIDs = []
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						
						spawnPlot = self.spawnPlots[1]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)
						
						unitIDs = []
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						
						spawnPlot = self.spawnPlots[2]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)
						
				elif (self.wave == 3):
						print("Spawning wave 3")

						unitIDs = []
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						
						spawnPlot = self.spawnPlots[1]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)
						
						unitIDs = []
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						
						spawnPlot = self.spawnPlots[1]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)
						
						unitIDs = []
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
						unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
						
						spawnPlot = self.spawnPlots[2]
						landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
						
						self.__spawnWave(unitIDs, spawnPlot, landingPlot)

				self.wave = self.wave + 1
				
		def __spawnWave(self, unitIDs, spawnPlot, landingPlot):
				spanishPlayer = PyPlayer(SPANISH_PLAYER)
						
				print(unitIDs)
						
				# Init the units
				units = []
				for element in unitIDs:
						print(element)
						newUnit = spanishPlayer.initUnit(element[0], spawnPlot.getX(), spawnPlot.getY(), element[1])
						print(newUnit)
						units.append(newUnit)
						
				print(units)
							
				# Assuming a ship is our first unit..
				self.ships.append([units[0], landingPlot])
						
				# Push our mission
				units[0].getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, landingPlot.getX(), landingPlot.getY(), 0, False, True, MissionAITypes.NO_MISSIONAI, landingPlot, units[0])


In fact I'm inclined to beleive that the only reason firaxis made the Mesoamerica Mod was to show to modders that this kind of stuff was possible :p
 
Hi,

You wouldn't have the original XML "text" files for all the events for BTS would you? I was stuffing around chaning text things and now the game isn't working for the events listings and I don't have the ORIGINAL dsik to reinstall.

I know, I should have made back up copies before messing around but hindsight is a wonderful planning tool ;)

If you can help out it would be much appreciated.

Regards.


Richo
 
Back
Top Bottom