help me with new palace idea, please

@God-Emperor

onCityAcquired uses the newly acquired city too, thus the palace would also have been lost.

The only python event that uses the old city, is onCityLost. However, that event does not know the new city, so it cannot put new buildings in new city, or transfer any data from the old city to the new city.
 
Odd. Based on how Final Frontier manages buildings I had assumed otherwise.

Is the capitol deleted automatically, ignoring the iConquestProb? I can see how it might do this because you can only have one at a time.

Why can't you transfer data to the new city? If you add a building with iConquestPRob of 100 to the old city it should be transferd to the new city whenever the copy is done. Or have they already created the new city and done the copy on the buildings before calling the onCityLost callback? (That would be silly of them.)

As long as they havn't done something silly, you should be able to do the swap in onCityLost, pretty much just like the attempt from when it was acquired. If a special capitol is present, remove it and add the special courthouse. Then the old city would have the special courthouse, which would (I hope) always get transfered to the new city as long as it has an iConquestProb of 100.
 
I'm working on it.
atm i try to access the graphic files, which seems to work, but i haven't dealt with the civilization art styles...that could become a problem, but i'm optimistic :).


And for the last dicussion:
That here let's you influence the captured city before doing it.
I know, it's really ugly :blush::

Spoiler :
PHP:
	def onCombatResult(self, argsList):
		'Combat Result'
		pWinner,pLoser = argsList
		playerX = PyPlayer(pWinner.getOwner())
		unitX = PyInfo.UnitInfo(pWinner.getUnitType())
		playerY = PyPlayer(pLoser.getOwner())
		unitY = PyInfo.UnitInfo(pLoser.getUnitType())
###Capture Palace Art Start####		
                iX = pLoser.getX()
                iY = pLoser.getY()                        
                myplot = CyMap().plot(iX,iY)
                if myplot.isCity()==True:
                        pCity = myplot.getPlotCity()
                        if pCity.isCapital():
                                iPlayer = pCity.getOwner()
                                pPlayer = gc.getPlayer(iPlayer)                        
                                WinnerPlayer = gc.getPlayer(pWinner.getOwner())
                                iThisTeam = WinnerPlayer.getTeam()
                                ThisTeam = gc.getTeam(iThisTeam)
                                NumDef = 0
                                for i in range (gc.getMAX_PLAYERS ()):
                                        CurPlayer = gc.getPlayer(i)
                                        iCurTeam = CurPlayer.getTeam()
                                        if iThisTeam ==iCurTeam:continue
                                        if ThisTeam.isAtWar(iCurTeam):                                                
                                                CurDef = myplot.getNumDefenders(i)                                                
                                                NumDef = NumDef+CurDef
                                                if NumDef >=2:
                                                        break                                
                                if NumDef<=1:
                                        ....to be continued
 
Perhaps you could change the iMaxPlayerInstances for the palace to two (up from the existing one), in conjunction with changing iConquest to 100. Of course, you would probably need to add some code to keep the existing situation where building a new one deletes the old.
 
mh...i guess, the AI would not understand that, and try to build everywhere palaces.


I have a problem with my code:
(intendation is right, just looks here false)

Spoiler :
PHP:
	def onCombatResult(self, argsList):
		'Combat Result'
		pWinner,pLoser = argsList
		playerX = PyPlayer(pWinner.getOwner())
		unitX = PyInfo.UnitInfo(pWinner.getUnitType())
		playerY = PyPlayer(pLoser.getOwner())
		unitY = PyInfo.UnitInfo(pLoser.getUnitType())
###Capture Palace Art Start####		
                iX = pLoser.getX()
                iY = pLoser.getY()                        
                myplot = CyMap().plot(iX,iY)
                if myplot.isCity()==True:
                        pCity = myplot.getPlotCity()
                        if pCity.isCapital():
                                iPlayer = pCity.getOwner()
                                pPlayer = gc.getPlayer(iPlayer)                        
                                WinnerPlayer = gc.getPlayer(pWinner.getOwner())
                                iThisTeam = WinnerPlayer.getTeam()
                                ThisTeam = gc.getTeam(iThisTeam)
                                NumDef = 0
                                for i in range (gc.getMAX_PLAYERS ()):
                                        CurPlayer = gc.getPlayer(i)
                                        iCurTeam = CurPlayer.getTeam()
                                        if iThisTeam ==iCurTeam:continue
                                        if ThisTeam.isAtWar(iCurTeam):                                                
                                                CurDef = myplot.getNumDefenders(i)                                                
                                                NumDef = NumDef+CurDef
                                                if NumDef >=2:
                                                        break                                
                                if NumDef<=1:
                                        Me = gc.getPlayer(pWinner.getOwner())
                                        iMyCiv = Me.getCivilizationType ()
                                        #iMyCiv = gc.getInfoTypeForString(strMyCiv)
                                        MyCiv = gc.getCivilizationInfo(iMyCiv)
                                        MyCivArt = MyCiv.getArtDefineTag ()
                                        MyArtStyle = MyCiv.getArtStyleType ()
                                        #ArtStyle = pCity.getArtStyleType ()                                        
                                        #MyCivArtClass = MyCivArt.getCivilizationArtInfo(MyArtStyle)
                                        MyCivArtClass = gc.getCivilizationArtInfo(MyArtStyle)
                                        MyCivNif = MyCivArtClass.getNIF ()
                                        MyCivKFM = MyCivArtClass.getKFM()
                                        BuildingPalace = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_GREAT_WALL"))
                                        PalaceArt = BuildingPalace.getArtInfo ()
                                        TheNif = PalaceArt.getNIF ()
                                        TheKFM = PalaceArt.getKFM ()                                        
                                        NewCourtHouse = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_COURTHOUSE"))
                                        CourtHouseArt = NewCourtHouse.getArtInfo()
                                        CourtHouseArt.setNIF(TheNif)
                                        CourtHouseArt.setKFM(TheKFM)
                                        #MyCivArtClass.setNIF(TheNif)
                                        #MyCivArtClass.setKFM(TheKFM)
                                        CourtHouseArt.setScale(6.1)##for testing
                                        CourtHouseArt.setPath("ART_DEF_PALACE")
                                        pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_COURTHOUSE"),1)
                                
                                
###Capture Palace Art End####

You can see, that i change the courthouse art to the great wall (tried several things), and give it a scale of 6.1. The interesting thing is: A get a incredible huge courthouse.
setScale works, but setNIF and setKFM do not work :confused:.

I thought, that maybe after capturing the city the art is rebuild, so i've added

Spoiler :
PHP:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
                BuildingPalace = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_PALACE"))
                PalaceArt = BuildingPalace.getArtInfo ()
                TheNif = PalaceArt.getNIF ()
                TheKFM = PalaceArt.getKFM ()                                        
                NewCourtHouse = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_COURTHOUSE"))
                CourtHouseArt = NewCourtHouse.getArtInfo()
                CourtHouseArt.setNIF(TheNif)
                CourtHouseArt.setKFM(TheKFM)
                CourtHouseArt.setScale(6.1)##for testing
                CourtHouseArt.setPath("ART_DEF_PALACE")
                pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_COURTHOUSE"),0)
                pCity.setNumRealBuilding(gc.getInfoTypeForString("BUILDING_COURTHOUSE"),1)
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))

but still no change.

(The code is just for testing [hardest first])
 
setNIF and setKFM are methods inherited from CvArtInfoAsset, while setScale is method inherited from CvScalableInfo, that's the only thing I know which could result in one working but the other doesn't.

Also, the_J, if uses this method, all courthouses will use the new art, right?
 
A, good point, didn't see that.
That explains it.

Yes...all courthouses would have the same art.
I guess, that could be circumnavigated by changing the art, placing the building, and changing the art back.
The problem is, that it seems, that the cultural city stiles are not really accessible by python -> this changes atm only the default building, and not the cultural ones...mmhh...i have no real idea at the moment :sad:.
 
Hi,
I keep on mind use (for example) Building_whitehouse (as use Tholish) and after first capitol capture could america use for next classic palace only. By this way is special_palace out from game.
Is possible use this by some way? May it solve problem?

sorry, I´m not programer... :blush: idea only
 
I guess, that can't be done, but i'm not sure.
That would need an unbuildable palace, and a national wonder, which acts like a palace...not sure, there could be conflicts.


But you have maybe missed that: I do not have that problem ;).
I'm beyond that, and i try, to make your function work automatically, so that you do not have to add every civ with every special courthouse.
 
The automatical change seems a bit more difficult than i thought, so i've done now the working version from the code from the first page -> you have to add for every civ the special courthouse (not nice :yuck:).
I have only added one example with america and a normal courthouse.

If you try it out: It only works, if you capture a city in a combat. Means, if you walk with your warrior (or whatever) into an empty city, it will not work. But how often will you find a capital without a defender? Nearly never.
 

Attachments

  • hrochland-CapturePalaceGraphics-CvEventManager.zip
    9.2 KB · Views: 36
Hi, many thanks. I will test it. courthouse in this case I can replace to AMERICA_CAPTURED_PALACE, make xml and to civilizations XML paste

AMERICA_CAPTURED_PALACE
NONE

python will paste model. Is it right? And for every one civ copy the same code with next civ specification in python and xml?
It is not problem. I have unique palace (as CIV_UNIQUE_pALACE) for no all civilizations :)
 
Hi, many thanks. I will test it. courthouse in this case I can replace to AMERICA_CAPTURED_PALACE, make xml and to civilizations XML paste

AMERICA_CAPTURED_PALACE
NONE

Sorry, i don't understand you here.
 
I have st. in mind civilization info XML. Here are allowed building. If will new courthouse for every civilization unique, I must for others set here New curthouse other civs can´t use it
 
This thread is not dead so long. I hope people are still watching.

What is the difference between onCityAcquired and onCityAcquiredAndKept? It seems with onCityLost and onCityAcquired, there is no reason for the AndKept variant; but it exists, so there must be a reason.

I want to have one religion, which automatically appears in any city owned by a civ, and never any other city. So onCityBuilt will put the religion into the city. I think onCityAcquired can test if the new player is the right civ, and either add or remove the religion. Is that enough? Or should I do something with AcquiredAndKept instead?
 
I guess, onCityAcquired is fired before you get the menue to choose between razing and keeping.
But yes, no idea, why this event is there :dunno:.

That makes sense. I suppose if you are doing something to this city in your python, you do not care if it is going to be razed. But if you are making some decision which affects other cities / units / civs only if the new city is kept, then it may matter.
 
You are correct. CityAcquired is fired first whether or not the city is kept/razed/liberated. CityAcquiredAndKept is fired if the city is kept or gifted.

To anyone writing onCityAcquiredAndKept handlers: how are you treating the ePlayer parameter? The SDK seems to always pas the active player. I fixed one place to make it the new owner, but I just found another place (gifting) that passes the active player. I think I'll fix this second call in BULL and pass it along to the UP.
 
Top Bottom