BTS Heroes (Wonder Units)

As far as i know, its done with CIV4EventTriggerInfos and CIV4EventInfos.

Actually I mean how do you intend to make the AI actively go after building the first colosseum? The way it is now it would be pure luck if the AI builds the first colosseum. It has no knowledge that the first colosseum gives Spartacus. See what I mean?
 
I am still confused cause you said that it should ALREADY be there and its not.

Here's what i have:

Code:
def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()
###water start part 3####
then a BUNCH your codes from alot of YOUR stuff.

That's the place, which i've meant ;).
Put the code, which i had labeled with ### in there.

@Strat:
I like the concept of giving a unit to the first civ that builds a certain building i.e. first civ that builds a colosseum receives Spartacus.
I'm quite sure the AI is totally oblivious of this. How do you intend to get the AIs actively going after building, in this case, the first colosseum?
Otherwise human players can easily exploit this :rolleyes:

It's the same problem with the technologies ;).
The AI will also not go on them.
 
That's the place, which i've meant ;).
Put the code, which i had labeled with ### in there.



It's the same problem with the technologies ;).
The AI will also not go on them.

OK so i leave ("TECH_WHATEVER") and ("CIVILIZATION_WHATEVER") just the way they are?
 
The code for getting a unit through a tech is totally different from the code for getting a unit through a building, and they have nothing to do with each other.
Just use the second piece of code, wich i've mentioned after your question.
 
It's the same problem with the technologies ;).
The AI will also not go on them.

Not entirely. At some point in time in the game each civ will get its hero, always.
Another thing that would be nice is to display a message when a hero has been killed.
I suspect some code attached to 'onUnitKilled' will do the trick. Too bad I can't code Python :(
 
OK heres what i ended up with:

Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "CvEventManager", line 1180
'Building Completed'
^
IndentationError: expected an indented block
load_module CvAppInterface

Code:
def onBuildingBuilt(self, argsList):
        [B]'Building Completed'[/B]
        pCity, iBuildingType = argsList
        game = gc.getGame()
###water start part 3####		
		if (iBuildingType == gc.getInfoTypeForString("BUILDING_AQUEDUCT"))or(iBuildingType == gc.getInfoTypeForString("BUILDING_KHMER_BARAY"))or(iBuildingType == gc.getInfoTypeForString("BUILDING_OTTOMAN_HAMMAM")):
                        thisplot = CyMap().plot(pCity.getX(),pCity.getY())
                        thisplot.setFeatureType(gc.getInfoTypeForString("FEATURE_WATER"),0)
####water end part 3###
###from here###
        thisBuilding = gc.getBuildingInfo(iBuildingType)
        BuildingClass = thisBuilding.getBuildingClassType ()
        if BuildingClass == gc.getInfoTypeForString("BUILDINGCLASS_COLOSSEUM"):
            if game.getBuildingClassCreatedCount(BuildingClass)==1:                
                iX = pCity.getX()
                iY = pCity.getY()
                newUnit = pPlayer.initUnit(gc.getInfoTypeForString( 'UNIT_WHATEVER' ), iX, iY, UnitAITypes.UNITAI_GENERAL, DirectionTypes.NO_DIRECTION)
####to here###    

        
        if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
            # If this is a wonder...
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
            popupInfo.setData1(iBuildingType)
            popupInfo.setData2(pCity.getID())
            popupInfo.setData3(0)
            popupInfo.setText(u"showWonderMovie")
            popupInfo.addPopup(pCity.getOwner())

        CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)

## Djenne Start ##
 
@Strat:

I'm have little knowledge of Python, but try this:
Change
Code:
pCity, iBuildingType = argsList
to
Code:
pCity, iBuildingType, iPlayer = argsList

and add

Code:
pPlayer = gc.getPlayer(iPlayer)
just below
Code:
BuildingClass = thisBuilding.getBuildingClassType ()

And change UNIT_WHATEVER in the correct unit you want, UNIT_SPARTACUS, which you have to add via XML :)

Maybe this will work, otherwise I don't know.
 
I get this now? I believe its the same thing.

Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "CvEventManager", line 1180
'Building Completed'
^
IndentationError: expected an indented block
load_module CvAppInterface
Code:
def onBuildingBuilt(self, argsList):
        'Building Completed'
        pCity, iBuildingType, iPlayer = argsList
        game = gc.getGame()
###water start part 3####		
		if (iBuildingType == gc.getInfoTypeForString("BUILDING_AQUEDUCT"))or(iBuildingType == gc.getInfoTypeForString("BUILDING_KHMER_BARAY"))or(iBuildingType == gc.getInfoTypeForString("BUILDING_OTTOMAN_HAMMAM")):
                        thisplot = CyMap().plot(pCity.getX(),pCity.getY())
                        thisplot.setFeatureType(gc.getInfoTypeForString("FEATURE_WATER"),0)
####water end part 3###
###from here###
        thisBuilding = gc.getBuildingInfo(iBuildingType)
        BuildingClass = thisBuilding.getBuildingClassType ()
	pPlayer = gc.getPlayer(iPlayer)
        if BuildingClass == gc.getInfoTypeForString("BUILDINGCLASS_COLOSSEUM"):
            if game.getBuildingClassCreatedCount(BuildingClass)==1:                
                iX = pCity.getX()
                iY = pCity.getY()
                newUnit = pPlayer.initUnit(gc.getInfoTypeForString( 'UNIT_SPARTACUS' ), iX, iY, UnitAITypes.UNITAI_GENERAL, DirectionTypes.NO_DIRECTION)
####to here###    

        
        if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
            # If this is a wonder...
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
            popupInfo.setData1(iBuildingType)
            popupInfo.setData2(pCity.getID())
            popupInfo.setData3(0)
            popupInfo.setText(u"showWonderMovie")
            popupInfo.addPopup(pCity.getOwner())

        CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)

## Djenne Start ##
 
I get this now? I believe its the same thing.

Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "CvEventManager", line 1180
'Building Completed'
^
IndentationError: expected an indented block
load_module CvAppInterface
Code:
def onBuildingBuilt(self, argsList):
        'Building Completed'
        pCity, iBuildingType, iPlayer = argsList
        game = gc.getGame()
###water start part 3####		
		if (iBuildingType == gc.getInfoTypeForString("BUILDING_AQUEDUCT"))or(iBuildingType == gc.getInfoTypeForString("BUILDING_KHMER_BARAY"))or(iBuildingType == gc.getInfoTypeForString("BUILDING_OTTOMAN_HAMMAM")):
                        thisplot = CyMap().plot(pCity.getX(),pCity.getY())
                        thisplot.setFeatureType(gc.getInfoTypeForString("FEATURE_WATER"),0)
####water end part 3###
###from here###
        thisBuilding = gc.getBuildingInfo(iBuildingType)
        BuildingClass = thisBuilding.getBuildingClassType ()
	pPlayer = gc.getPlayer(iPlayer)
        if BuildingClass == gc.getInfoTypeForString("BUILDINGCLASS_COLOSSEUM"):
            if game.getBuildingClassCreatedCount(BuildingClass)==1:                
                iX = pCity.getX()
                iY = pCity.getY()
                newUnit = pPlayer.initUnit(gc.getInfoTypeForString( 'UNIT_SPARTACUS' ), iX, iY, UnitAITypes.UNITAI_GENERAL, DirectionTypes.NO_DIRECTION)
####to here###    

        
        if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
            # If this is a wonder...
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
            popupInfo.setData1(iBuildingType)
            popupInfo.setData2(pCity.getID())
            popupInfo.setData3(0)
            popupInfo.setText(u"showWonderMovie")
            popupInfo.addPopup(pCity.getOwner())

        CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)

## Djenne Start ##

I see your indentation of the ### water code (tab=8?) is different from the rest (tab=4) or so it seems. Have you tested the code in a Python editor?
 
I see your indentation of the ### water code (tab=8?) is different from the rest (tab=4) or so it seems. Have you tested the code in a Python editor?

Python editor?:confused:
 
Not entirely. At some point in time in the game each civ will get its hero, always.
Another thing that would be nice is to display a message when a hero has been killed.
I suspect some code attached to 'onUnitKilled' will do the trick. Too bad I can't code Python :(

PHP:
	def onUnitKilled(self, argsList):
                print 'onUnitKilled'
		'Unit Killed'
		unit, iAttacker = argsList
		player = PyPlayer(unit.getOwner())
		attacker = PyPlayer(iAttacker)
		###this here...
		unittype = unit.getUnitType ()
		if unittype == gc.getInfoTypeForString("UNIT_BLABLA"):
		    CyInterface().addMessage(unit.getOwner(),False,15,CyTranslator().getText("TXT_KEY_YOUKNOWWHATTOPUTINHERE",()),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(44), unit.getX(), unit.getY(), True,True)

OK heres what i ended up with:

Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "CvEventManager", line 1180
'Building Completed'
^
IndentationError: expected an indented block
load_module CvAppInterface

I see your indentation of the ### water code (tab=8?) is different from the rest (tab=4) or so it seems. Have you tested the code in a Python editor?

That's the problem, i guess. There's one tab to much in the new lines.

Python editor?:confused:

This one.
I really suggest downloading and using it.
 
Top Bottom