Problem with Spy mission

There's no need to change the red line. In onBuildingBuilt, you're just checking which building type is finished. In doCityTurn, you're checking if the building type is in the city.

The problem with doCityTurn is that it does not come automatically after the spy mission. It is just done once per turn. So, if you wait one turn, is the unit not killed? Do you get any error message?

Note: your indentation is not correct but that might be a copy/paste display on the forum.
Code:
bBuilding = False
		bUnit = False
 
Is it a problem with the UnitClass?

And there is no "Seawall" building in the city?

By the way, what is this line "self.parent.onCityDoTurn(self, argsList)" at the top of the function?

At the end of the function, you could add something like:
Code:
if iPlayer == 0:
	szName = pCity.getName()
	CyInterface().addMessage(0, True, 10, CyTranslator().getText("TXT_KEY_MESSAGE_TEST",(szName, bBuilding, bUnit,)), None, 0, None, ColorTypes(7), 0, 0, False, False)

Then insert in a Text file:
Code:
	<TEXT>
		<Tag>TXT_KEY_MESSAGE_TEST</Tag>
		<English>City %s1: bBuilding = %d2, bUnit = %d3</English>
		<French>City %s1: bBuilding = %d2, bUnit = %d3</French>
		<German>City %s1: bBuilding = %d2, bUnit = %d3</German>
		<Italian>City %s1: bBuilding = %d2, bUnit = %d3</Italian>
		<Spanish>City %s1: bBuilding = %d2, bUnit = %d3</Spanish>
	</TEXT>


Just for debugging, assuming you are Player 0. See what it renders.
 
Sorry for the late answer! :sad: But the last days i had much to work. :cry:


Is it a problem with the UnitClass?

Yes that could be! My test was a result of a Bunker3 in the City.
The units "Bunker" are defined as follows:

Code:
</UnitInfo>
		<UnitInfo>
			<Class>UNITCLASS_BUNKER3</Class>
			<Type>UNIT_BUNKER3</Type>

Code:
</UnitInfo>
		<UnitInfo>
			<Class>UNITCLASS_BUNKER2</Class>
			<Type>UNIT_BUNKER2</Type>


Code:
</UnitInfo>
		<UnitInfo>
			<Class>UNITCLASS_BUNKER</Class>
			<Type>UNIT_BUNKER</Type>



What should i do?

And there is no "Seawall" building in the city?

No, only the Perimeter_Defense Building.

By the way, what is this line "self.parent.onCityDoTurn(self, argsList)" at the top of the function?

I thougt it is a stadart function?!?
 
No, it's not part of the standard function. Maybe from BUG, I don't know.

Yes, the problem is of course that you also have a UNITCLASS_BUNKER3! I suppose that you have your reasons for this. Then, just adjust the line as follows:
Code:
if pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER") or if pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER3"):

Works better? :scan:

EDIT: dang, you have BUNKER2 too! :D Just add it too then! :D
 
Yes i have. Im just to stupid to paste and copy.


...error Message in....



Code:
pPlayer = gc.getPlayer(iPlayer) 
		bBuilding = False
		bUnit = False
		
		if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_PERIMETER_DEFENSE")) > 0 or pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_PIRATES_SEAWALL")) > 0 or pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_WELLEN_SEAWALL")) > 0:   
			bBuilding = True  
		
		for iUnit in xrange (pPlot.getNumUnits()):
			pLoopUnit = pPlot.getUnit(iUnit)
			[COLOR="Red"]if pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER") or if pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER2") or if pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER3"):
[/COLOR]				bUnit = True
				if not bBuilding:
					pLoopUnit.kill(False, iPlayer)
					bUnit = False
		
		if bBuilding and not bUnit:
			pPlayer.initUnit(gc.getInfoTypeForString("UNIT_BUNKER"), pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_IMMOBILE, DirectionTypes.DIRECTION_NORTH)


Okay, it should be this....:sad: Now tasting...

Code:
if pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER") or pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER2") or pLoopUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_BUNKER3"):
 
Good :goodjob:

My mistake about the repetition of the "if" in the middle of the code.

Now, since it appeared in the end that you have as many Classes as Types, then you could just check the UnitType and drop the "Class" 6 times in the code...

If you ever plan of adding a unit, it would be time to make it a list like this:
Code:
lUnit = [
	gc.getInfoTypeForString("UNIT_BUNKER"),
	gc.getInfoTypeForString("UNIT_BUNKER2"),
	gc.getInfoTypeForString("UNIT_BUNKER3"),
	gc.getInfoTypeForString("UNIT_BUNKER4")]

Then your if statement can be shortened as:
Code:
if pLoopUnit.getUnitType() in lUnit:
 
Back
Top Bottom