Platyping's Python

Ok. I´ve tried to change the Bell Rock Lighthouse. For the code in OnCityAcquired, I´m unsure how to deal with pPlayer2. I´ve tried this (added/changed parts in red):

Code:
## Bell Rock LighthouseStart ##
		if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_BELL_ROCK_LIGHTHOUSE")):
			for x in xrange (pCity.getX() - 1, pCity.getX() +2):
				for y in xrange (pCity.getY() - 1, pCity.getY() +2):
					pPlot = CyMap().plot(x,y)
					pPlot.changeVisibilityCount(iTeam, -1, 0)
			[COLOR="Red"]for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
				pPlayerX = gc.getPlayer(iPlayerX)
				if pPlayerX.isAlive() and pPlayerX.getTeam() == iTeam:[/COLOR]
					(loopCity, iter) = pPlayer[COLOR="Red"]X[/COLOR].firstCity(false)
					while(loopCity):
						if loopCity.isCoastal(10):
							for x in xrange (loopCity.getX() - 1, loopCity.getX() +2):
								for y in xrange (loopCity.getY() - 1, loopCity.getY() +2):
									pPlot = CyMap().plot(x,y)
									pPlot.changeVisibilityCount(iTeam, -1, 0)
						(loopCity, iter) = pPlayer[COLOR="Red"]X[/COLOR].nextCity(iter, false)
					[COLOR="Red"]for iPlayerX2 in xrange(gc.getMAX_CIV_PLAYERS()):
						pPlayerX2 = gc.getPlayer(iPlayerX2)
						if pPlayerX2.isAlive() and pPlayerX2.getTeam() == iTeam:[/COLOR]
							(loopCity, iter) = pPlayer[COLOR="Red"]X[/COLOR]2.firstCity(false)
							while(loopCity):
								if loopCity.isCoastal(10):
									for x in xrange (loopCity.getX() - 1, loopCity.getX() +2):
										for y in xrange (loopCity.getY() - 1, loopCity.getY() +2):
											pPlot = CyMap().plot(x,y)
											pPlot.changeVisibilityCount(iTeam2, 1, 0)
								(loopCity, iter) = pPlayer[COLOR="Red"]X[/COLOR]2.nextCity(iter, false)
		else:
			if p[COLOR="Red"]Team[/COLOR].getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_BELL_ROCK_LIGHTHOUSE")) == 1:
				for x in xrange (pCity.getX() - 1, pCity.getX() +2):
					for y in xrange (pCity.getY() - 1, pCity.getY() +2):
						pPlot = CyMap().plot(x,y)
						pPlot.changeVisibilityCount(iTeam, -1, 0)
			if p[COLOR="Red"]Team[/COLOR]2.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_BELL_ROCK_LIGHTHOUSE")) == 1:
				for x in xrange (pCity.getX() - 1, pCity.getX() +2):
					for y in xrange (pCity.getY() - 1, pCity.getY() +2):
						pPlot = CyMap().plot(x,y)
						pPlot.changeVisibilityCount(iTeam2, 1, 0)

Should that be ok?
 
Nope, you do not put the for loop within the first for loop.

Code:
## Bell Rock LighthouseStart ##
		pPlayer = gc.getPlayer(iPreviousOwner)
		pPlayer2 = gc.getPlayer(iNewOwner)
		iTeam = pPlayer.getTeam()
		iTeam2 = pPlayer2.getTeam()
		if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_BELL_ROCK_LIGHTHOUSE")):
			for x in xrange (pCity.getX() - 1, pCity.getX() +2):
				for y in xrange (pCity.getY() - 1, pCity.getY() +2):
					pPlot = CyMap().plot(x,y)
					pPlot.changeVisibilityCount(iTeam, -1, 0)
			for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
				pPlayerX = gc.getPlayer(iPlayerX)
				if pPlayerX.isAlive():
					if pPlayerX.getTeam() == iTeam:
						(loopCity, iter) = pPlayerX.firstCity(false)
						while(loopCity):
							if loopCity.isCoastal(10):
								for x in xrange (loopCity.getX() - 1, loopCity.getX() +2):
									for y in xrange (loopCity.getY() - 1, loopCity.getY() +2):
										pPlot = CyMap().plot(x,y)
										pPlot.changeVisibilityCount(iTeam, -1, 0)
							(loopCity, iter) = pPlayerX.nextCity(iter, false)
					if pPlayerX.getTeam() == iTeam2:
						(loopCity, iter) = pPlayerX.firstCity(false)
						while(loopCity):
							if loopCity.isCoastal(10):
								for x in xrange (loopCity.getX() - 1, loopCity.getX() +2):
									for y in xrange (loopCity.getY() - 1, loopCity.getY() +2):
										pPlot = CyMap().plot(x,y)
										pPlot.changeVisibilityCount(iTeam2, 1, 0)
							(loopCity, iter) = pPlayerX.nextCity(iter, false)
		else:
			pTeam = gc.getTeam(iTeam)
			pTeam2 = gc.getTeam(iTeam2)
			if pTeam.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_BELL_ROCK_LIGHTHOUSE")) == 1:
				for x in xrange (pCity.getX() - 1, pCity.getX() +2):
					for y in xrange (pCity.getY() - 1, pCity.getY() +2):
						pPlot = CyMap().plot(x,y)
						pPlot.changeVisibilityCount(iTeam, -1, 0)
			if pTeam2.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_BELL_ROCK_LIGHTHOUSE")) == 1:
				for x in xrange (pCity.getX() - 1, pCity.getX() +2):
					for y in xrange (pCity.getY() - 1, pCity.getY() +2):
						pPlot = CyMap().plot(x,y)
						pPlot.changeVisibilityCount(iTeam2, 1, 0)
## Bell Rock Lighthouse End ##

Now you see why I didn't bother to apply to whole team for wonders.
Pretty much every section has to be edited, and usually involves a loop through all players :D
 
Things are getting nasty quiet around here :(
 
make things :p

in the mean time check this out (it's code for a mod idea I have called HarshWinter)

Code:
##Classes##

#Meta - This class is used to allow WinterStorm[i] and len(WinterStorm)
#       in reference to all instances of storms! Also allows the following statement to be acceptable:
#       for value in WinterStorm:
#       Essentially it makes WinterStorm act like a list, which contains elements that are instances of itself which actually are real Storms :p
#       Yay for advanced python programming :D!

class Meta(type):
    lpStorms = list()
    
    def __getitem__(self, i):
        return Meta.lpStorms[i]

    def __len__(self):
        return len(Meta.lpStorms)

    def __iter__(self):
        return iter(Meta.lpStorms)

    def __delitem__(self, key):
        del Meta.lpStorms[key]

    def append(self, o):
        Meta.lpStorms.append(o)

#WinterStorm - Authough this class doesn't directly store the WinterStorms it appears to thanks to the Meta class.
#              It is used to spawn and manage the lifetime of a WinterStorm!
        
class WinterStorm:

    #Static Member Variables + Class Methods
    __metaclass__ = Meta
    iCurrentID = 0

    @classmethod
    def getChanceForStorm(cls, pPlot):
        iChance = diBaseProbabilities[pPlot.getTerrainType()]
        iChance += round(f(pPlot.getLatitude()))
        iChance += round(countAdjecentPlotScores(pPlot)/10.0)
        return iChance

    @classmethod
    def countAdjecentPlotScores(cls, pPlot):
        iScore = 0
        for pAdjecentPlot in getAdjecentPlots(pPlot):
            iScore += round(diBaseProbabilities[pPlot.getTerrainType()]/2.0)
        return iScore

    @classmethod
    def createStorm(cls, Map):
        for x in xrange(Map.getGridWidth()):
            for y in xrange(Map.getGridHeight()):
                pPlot = Map.plot(x, y)
                iChance = getChanceForStorm(pPlot)
        pass

    #Pointer Methods
    def __init__(self, tOrigin):
        self.iNumTurns = 0
        self.iRadius = iDefaultRadius + (Game.getSorenRandNum(3)-1)
        self.origin = tOrigin
        self.id = WinterStorm.iCurrentID
        WinterStorm.iCurrentID += 1
        WinterStorm.append(self)

    def kill(self):
        WinterStorm.iCurrentID += -1
        del WinterStorm[self.id]

Beautiful :D an ingenious idea, the class acts as a list for it's children.
 
Nope, retired from making wonders and projects.
Lazy to make traits and promotions in the meantime also...

I do know there are at least 2 bugs which... I am lazy to update :D
Apadana Palace:
20% discount for buildings present in capital.
Need a check to stop hammers overflow.

Magellan's Voyage:
+1 move and cargo for naval units.
+1 cargo is gone when units upgraded, just like base strength.
Thus, to achieve that has to use promotion, although I rather remove it and use +2 move instead.
 
Lazy to make traits and promotions in the meantime also...

I do know there are at least 2 bugs which... I am lazy to update :D

ahaha:lol: Now THAT is my kind of people, YEAH :p
 
Hey, I'm back to report another found bug with one of your wonders.

The Catacombs of Kom El Shaqofa's effect is glitched; When you receive a great general, you continually receive them one after another when you have that wonder. Instead of holding over 20% like it is supposed to, it holds over a much larger percentage and gives you hundreds of great generals (337 the first time it happened, I didn't check the exact number the second time).

It happened with both the Gigapack and the Terapack; I've been using the terapack and enjoying it greatly, thanks for making such a great set of mods. At least the bug gave me a good chance to try out all the new promotions you added.
 
Hi, I am guessing you meant Tomb of Khalid rather than the Catacombs, unless you did some alterations yourself.
P.S.
Oh yeah, the effects was given to Catacombs in Terapack :D

Tomb of Khalid effects:
Retain 20% of GG points after GG born.
Tested in Gigapack, no issue.
Tested Terapack as well, no issue.
Screenshot attached
 
That's quite odd. I just tested it out in the Gigapack again and it had the same effect, drowning my cities in 354 GGs. I reloaded, removed the Tomb and then I only received one GG.

Then I made a new game just to test it right away (Although I was testing in Terapack this time), and it worked as advertised. Bizarre. I'll try testing it a few more times and see if I can divine what is messing it up.
 
I intend to add these wonders to my "Modern Earth" mod. Are the python components required if there are already placed and existing in the cities in the mod/scenario. i.e. I only need XML and art files.
 
it you want the effects the python must be there too, if you just want them for aesthetic purposes then no.
 
Depends which wonders you are talking about.
Some wonders have codes onBuildingBuilt.
Those effects will not take place if they are placed directly in cities for your scenario.
Even if you copied down the python codes, it is useless since they were never built, codes will not be triggered.

Others like jamie said, if you want the effects, you need the python.
 
If we assume the Wonders are already built ... what effects if any will continue to exist ... after the Python script has run. Would the python script be called again after onBuildbuilt. If not the only thing that would affect is the XML setting ... true?
 
I believe the only types that will not work are those with onBuildingBuilt codes.
All others will work.
For instance, Big Ben adds gold every turn, all it checks if this player has Big Ben.
It does not care whether BB is built or placed directly, and it does not care who build BB either.

Brandenburg adds extra XP to units in cities with Great Generals.
Again, all it checks if player has Brandenburg, whether it is built or not does not matter.

On the other hand, wonders like Lotus Temple has both on Built effect and everlasting effects.
When it is built, it adds happiness and unhappiness to all civs with same/different religion.
And the effects change when civs change religion thereafter.
As such, if it is placed directly via world builder, it is not built and the first step is not activated.
Effects thereafter will also go haywire.

If you insist on using those with on Built effects, the solution I can think of is:
Type extra codes to activate on Built effects on first turn.
 
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]

## Machu Picchu Start ##
		if eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU"):
			iPlayer = pCity.getOwner()
			for i in range(21):
				pPlot = pCity.getCityIndexPlot(i)
				if pPlot.getOwner() == iPlayer and pPlot.isHills():
					return False
			return True
## Machu Picchu End ##
		return False
 
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]

## Machu Picchu Start ##
		if eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU"):
			iPlayer = pCity.getOwner()
			for i in range(21):
				pPlot = pCity.getCityIndexPlot(i)
				if pPlot.getOwner() == iPlayer and pPlot.isHills():
					return False
			return True
## Machu Picchu End ##
		return False

Thanks! :) I searched for some of your wonders but missed Machu Picchu.
 
Don't forget to activate python callback for this.
River part is purely XML
 
Back
Top Bottom