Platyping's Python

As tempted as I am to ask you if you could do a couple of traits for me, I don't want to be of bother too much so do you recommend any ideal references on tutorials/constructing your own Pythons?
 
@Cethegus
Only if there is an artwork

@hemoglobin
There are some tutorials on Python in the tutorial section, although it may be difficult to understand if you have absolutely no idea what programming is about.
For instance, you should at least know what is a for loop, define variables, indentations.

Of course, if you do have some programming background and wish to learn on your own, you can download some of mine or tsentom1's works and start by doing some simple editing, like change of variables and slowly make some progress.
 
Okay, can I ask where I could find the code that controls the golden age timer (e.g. Mausoleum of Mausolos) and the corporation maintenance (e.g. Free Market/Environmentalism) at least?
 
Not everything is exposed to python.
There is a function which can change the golden age timer of a player like adds 5 turns etc.
If you want it to be like MoM, which increases GA length by 50% or 100% with a trait, it is not possible without using dummy building.

Tsentom1 made a trait like that though, but it will not work accurately in certain situations which I pointed out in his thread.
If you are fine with using dummy buildings, then you can just follow Philosophical Trait, just change the dummy building XML effects.

As for corporation maintenance, not possible.
 
Don't really understand what you mean.
If you wanna know what each XML function does, you can check the modiki
 
hey! I sorry but I need your professional opinion on this:

Code:
def dacia(pRazedCity, iPlayer):
    """
    Power of the Sword - cities within x tiles of a razed city may flip to Dacia.
    """
    if iPlayer == eDacia:
        tCoordsRazed = getCoords(pRazedCity)
        pCivDacia = instance(eDacia)
        iPreviousOwner = pRazedCity.getPreviousOwner()
        if not checkCityProximity(tCoordsRazed, iDaciaDistance): #this implies that it is not allowed to put a city here (ie there is at least one city within the distance)
            tCoords1 = (max(tCoordsRazed[0] - iDaciaDistance, 0), max(tCoordsRazed[1] - iDaciaDistance, 0))
            tCoords2 = (min(tCoordsRazed[0] + iDaciaDistance, Map.getGridWidth()), min(tCoordsRazed[1] + iDaciaDistance, Map.getGridHeight()))
            x = 0
            for pCity in findAreaCities(tCoords1, tCoords2, iPreviousOwner):
                if isChance(max(iDaciaChance - max((pCity.getPopulation()-4)*2, 0), 0)) and x < iDaciaMaxCities:
                    if pCity.isCapital(): continue
                    flipCity(pCivDacia, pCity, bDaciaFlipUnits)
                    if cityKnownByHuman(pCity) and not pCivDacia.get(CyPlayer).isHuman():
                            addMessage(sDaciaFlipMessageThem, (getCivName(gc.getPlayer(iPreviousOwner), "adjective"), pCity.getName()), eWhite, getCoords(pCity))
                    elif pCivDacia.get(CyPlayer).isHuman():
                            addMessage(sDaciaFlipMessageUs, (getCivName(gc.getPlayer(iPreviousOwner), "adjective"), pCity.getName()), eGreen, getCoords(pCity))
                    elif gc.getPlayer(iPreviousOwner).isHuman():
                            addMessage(sDaciaFlipMessageLost, (pCity.getName()), eRed, getCoords(pCity))
                    if not bDaciaFlipUnits: spawnCityGarrison(pCivDacia, pCity, 3)
                    x += 1

one: have a look through that :p

the bit that doesn't work is: flipCity(pCivDacia, pCity, bDaciaFlipUnits, False, False)

now you need these three functions to understand it:

Code:
def flipCity(pCivPlayer, pCity, bFlipUnits = False, bConquored = False, bTrade = False, bKillUnits = True):
        if bFlipUnits:
                lUnitTypes = (pUnit.getUnitType() for pUnit in getCityUnits(pCity))
        if bKillUnits:
                killCityUnits(pCity)
        pCivPlayer.get(CyPlayer).acquireCity(pCity, bConquored, bTrade)
        if bFlipUnits:
                for iUnitType in lUnitTypes:
                        pCivPlayer.get(PyPlayer).initUnit(iUnitType, pCity.getX(), pCity.getY(), 1)

def killCityUnits(pCity):
        """
        Kills all units in pCity belonging to the owner
        """
        lUnits = getCityUnits(pCity)
        for pUnit in lUnits:
                if pUnit.getOwner() == pCity.getOwner(): pUnit.kill(False, pCity.getOwner())


def getCityUnits(pCity):
        """
        Returns a list array of all units in pCity (CyCity object) belonging to the city's
        owner.
        """
        eOwner = pCity.getOwner()
        pPlot = pCity.plot()
        for pUnit in (pPlot.getUnit(iUnit) for iUnit in xrange(pPlot.getNumUnits())):
                if pUnit.getOwner() != eOwner: continue
                yield pUnit

the problem is: It won't actually replace the units!!! surely if the UnitTypes were stored before hand it doesn't matter that you kill the units?
 
Hmm, you know I like to keep things simple for my codes, so lazy to use self-defined functions, yet there are too many of them here :D

So you are saying, the cities change ownership as expected, and the previous units are killed as well, but the problem is just the last part initUnit code where there is no unit spawned?

This one you better ask The_J or Emperorer :D
 
we reuse so much code in my mod that it becomes practical to put functions elsewhere! like that code uses at least 2 getCityUnits... the helper module is like 300 lines long of functions :D


all the variables you don't see are at the top of the module... bDaciaFlipUnits is true

the problem is that the units are not recreated. before I had the killing of the units in the convert units if statement untill I released you might want to remove them for other reasons... and it was still working so I don't know... I will put more debug statements in places and see what happens
 
Try and see if the loop is working at all as The_J suggested.

Anyway you can try to use the convert function.
Simply loop through each unit, if not owned by the player, create a new one and convert the old one to it.
I believe it will kill the old one directly, so you don't have to loop twice.
Also, this will keep promotions and experience etc
 
I thought about that just if the civs are at war (as they must be...) the convert would put one of our units on the same tile as an enemy (for a while)

I was thinking that you could move all the units to the capital of the enemy. (I believe there is a way to teleport units) and if you do this then it would be non dangerous to convert the units into our units in the captured city... horrible code :P
 
Platyping, I've been playing with your "Motherland Calls" wonder. When I fought a rival who had 3 vassals and he declared war on me, I got 4 free units per city. This was a huge boost to my military. This is pretty overpowered, is it possible to restrict it to non-vassals or is this how it's supposed to be?
 
Hmm, thanks for the feedback.
I thought of vassals before, but didn't feel that someone would have that many vassals :D

Simple fix for now:
Code:
## The Motherland Calls Start ##
		if bIsWar:
			pTeam2 = gc.getTeam(iRivalTeam)
			if pTeam2.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_THE_MOTHERLAND_CALLS")) == 1:
				[COLOR="DarkRed"]pTeam = gc.getTeam(iTeam)
				if not pTeam.isAVassal():[/COLOR]
					for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
						pPlayerX = gc.getPlayer(iPlayerX)
						if pPlayerX.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_THE_MOTHERLAND_CALLS")) == 1:
							(loopCity, iter) = pPlayerX.firstCity(false)
							while(loopCity):
								loopCity.changeHappinessTimer(10)
								pNewUnit = pPlayerX.initUnit(loopCity.getConscriptUnit(), loopCity.getX(), loopCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
								loopCity.addProductionExperience(pNewUnit, true)
								(loopCity, iter) = pPlayerX.nextCity(iter, false)
							[COLOR="DarkRed"]break[/COLOR]
## The Motherland Calls End ##

Currently it is just working for the Wonder Player. Since it got a nerf, can extend its power to the whole team if you like :D

Will update Gigapack soon, after I finish all my recent tests.
Currently:
1) Reduce Agricultural Trait to 5 Food during Golden Age
2) Modify Conqueror Trait to something unique rather than copy and paste from Women's Suffrage
3) Adds Conqueror, Agricultural and Dynamic into Trait Pack.

4) Lotus Fix
5) Motherland Nerf
6) UN Resolution Fix
7) Religious Temple/Monastry code change

Still doing some tests on 7, but uploaded Motherland standalone changes.
 
Conquerer Trait Remake
Conquerer.jpg
=>
InvasiveTrait.jpg


As mentioned, old Conqueror Trait is using a benefit from an existing work.
Thus, remake it to be more unique rather than just a copy and paste work.
The old benefit of stealing espionage benefit the whole team rather than just the player, thus i choose something new as well, as traits are meant to benefit just the player.

The Happiness Boost is temporarily, turns based on captured city's population * 3
I gave it a new name as all traits are "aggressive, expansive, financial" etc, conquerer sounds wrong.

Agricultural Trait
Nerfed from 8 Food during Golden Age to 5 Food

Added Agricultural, Dynamic and Invasive Traits into Trait Pack
 
Thanks :D
Satisfied with it, not a copy and paste work, so no reason to change it
 
Faithful Trait
FaithfulTrait.jpg


17 is an odd number, so brought back an old trait and remake it.
Old Faithful Trait was granting Golden Age when Religion Founded, together with Production Boost which was given to Spiritual Trait already.

On hindsight, on Religion Founded is a bad idea, when players play games on later Eras, as after few turns, all religions are founded randomly all over the world.
If you are lucky, you get a super long Golden Age for nothing.
Thus, I change the idea to when Great Prophet Born, at least you work for it by building religious wonders or priests.
Also, it will be useful throughout the game unlike the original idea which will be obsolete when the last religion, Islam is founded which is still quite early.

To make it competitive with the other traits, a secondary benefit is granted as well.
+XP or promotion in cities with State Religion sounds repetitive and boring, so I gave it a great boost in Holy Cities only.
If you do not own any HC, too bad, but if you do, 50% is a great boost and it applies to all HCs, not just the HC of state religion.

Latest Traits Pack
Spoiler :
TraitsPack.jpg


Spiritual Trait
Fix Grammer Error:
Cities with State Religion Build 10% Faster

Financial Trait
Text changed to look similar to others.
+1:traderoute:/City
(Lazy to take new screenshot for these)
 
Back
Top Bottom