Requesting following features

Why not make a custom Improvement that combines the benefits from both Mines and Farms? Unbuildable, of course - only available around Pictic cities.

So basically a "Pictic Settlement" or "Mountain Dwelling" or something. The graphics could illustrate that the Hills tile is inhabited, so perhaps use the Cottage/Hamlet model?
 
The comment lines do absolutely nothing, so no worries.

May I suggest however:
Code:
	def canDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
## Jamie's Rome Mod Greek ability START##
		if ePlayer == 1:
			return eCivic == gc.getInfoTypeForString("CIVIC_UNIVERSAL_SUFFRAGE")
## Greek ability END##
		return False
 
I guess how would that work code wise? So that it is unbuildable yet the picts automaticaly get it on their hills and then it gets destroyed apon city capture.
 
I've been writing a couple of general purpose Python modules for scenarios all afternoon (good times). This is what I've come up with so far as for handling players/teams:
Spoiler :
Code:
### CivPlayer class by Baldyr

from CvPythonExtensins import *
import PyHelpers
import DataStorage

# constants

gc = CyGlobalContext()
Game = CyGame()
Map = CyMap()
Interface = CyInterface()

playerID, CyPlayer, teamID, CyTeam, PyPlayer = range(5)
lPlayers = range(Game.countCivPlayersEverAlive())

# main class definition

class CivPlayer:

        def __init__(self, ePlayer):
                pPlayer = gc.getPlayer(ePlayer)
                eTeam = pPlayer.getTeam()
                pTeam = gc.getTeam(eTeam)
                player = PyHelpers.PyPlayer(ePlayer)
                self.tIndex = ePlayer, pPlayer, eTeam, pTeam, player

        def get(self, iIndex):
                return self.tIndex[iIndex]

        @classmethod
        def playerID(cls, name):
                return Civilizations[name].get(playerID)
        
        @classmethod
        def CyPlayer(cls, name):
                return Civilizations[name].get(pPlayer)

        @classmethod
        def eTeam(cls, name):
                return Civilizations[name].get(teamID)

        @classmethod
        def CyTeam(cls, name):
                return Civilizations[name].get(CyTeam)

        @classmethod
        def PyPlayer(cls, name):
                return Civilizations[name].get(PyPlayer)

        def getScriptDict(self):
                return DataStorage.sd.lPlayerData[self.get(playerID)]

        def setData(self, key, value):
                DataStorage.setPlayerData(self.playerID(), key, value)

        def getData(self, key):
                return DataStorage.getPlayerData(self.get(playerID), key)

# assorted functions

def setup():
        CivPlayer.Civilizations = dict()
        for ePlayer in lPlayers:
                pCivPlayer = CivPlayer(ePlayer)
                name = pCivPlayer.get(pPlayer).getCivilizationShortDescription()
                CivPlayer.Civilizations[name] = pCivPlayer

def Civ(name):
        return CivPlayer.Civilizations[name]

def pointer(name, iIndex):
        return CivPlayer.Civilizations[name].get(iIndex)[/SPOILER]
 
I guess how would that work code wise? So that it is unbuildable yet the picts automaticaly get it on their hills and then it gets destroyed apon city capture.
Yeah, this is how I did it with the Arabian Desert Caravans (albeit in a non-scenario context):
Spoiler :
Code:
### Arabian unique power for Glory and Greatness mod, by Baldyr

from GGUtils import *

### constants

bGameScriptData = True

# eNums

eLand = PlotTypes.PLOT_LAND
eDesert = getIndex("Terrain", "Desert")
eCaravan = getIndex("Improvement", "Camp") #change to Caravan or whatever

### functions

def arabia(pCity=None, bRaze=False):
        """
        Directs the function call to the function corresponding to the game event prompting it.
        """
        if pCity:
                if bRaze:
                        checkDesertCity(pCity)
                else:
                        newDesertCity(pCity)
                        checkDesertCity(pCity)
        else:
                processDesertCities()

def newDesertCity(pCity):
        """
        Looks up all tiles surrounding pCity and adds any Desert tiles to a list which is stored
        in the CyCity object as scriptData.
        """
        lDesertPlots = list()
        for iPlot in getBFC(pCity.getX(), pCity.getY()):
                pCityDesert = CityDesert.desertMap.get(iPlot, None)
                if pCityDesert:
                        lDesertPlots.append(pCityDesert)
        if lDesertPlots:
                pCity.setScriptData(pickle.dumps(lDesertPlots))
          
def checkDesertCity(pCity):
        """
        Checks if pCity has Desert tiles within reach. If it has, then ownership of those tiles is
        checked. Any Arabian desert tiles gets a free Caravan improvement.
        """
        scriptData = pCity.getScriptData()
        if not scriptData: return
        for pCityDesert in pickle.loads(scriptData):
                if pCityDesert.isArabian():
                        pCityDesert.addCaravan()
                else:
                        pCityDesert.deleteCaravan()

def processDesertCities():
        """
        Checks all cities with desert tiles.
        """
        for player in tPlayer:
                if player.CyPlayer.isAlive() and isHasMet("Arabia", player.CyTeam):
                        for pCity in list(city.GetCy() for city in player.PyPlayer.getCityList()):
                                checkDesertCity(pCity)

def setupDesertMap(iPlot=0):
        """
        Builds the global dictionary of CityDesert class instances.
        """
        scriptData = Game.getScriptData()
        if not bGameScriptData or not scriptData:
                while iPlot < Map.numPlots():
                        pPlot = Map.plotByIndex(iPlot)
                        if pPlot.getTerrainType() == eDesert and pPlot.getPlotType() == eLand:
                                CityDesert.desertMap[iPlot] = CityDesert(iPlot)
                        iPlot += 1
                if bGameScriptData:
                        Game.setScriptData(pickle.dumps(CityDesert.desertMap))
        else:
                CityDesert.desertMap = pickle.loads(scriptData)

class CityDesert:

        """
        Each instance of the class corresponds to a desert tile on the map.
        """

        desertMap = dict()
        iEnum = 0

        def __init__(self, iPlot):
                self.ID = iPlot
                self.iIndex = self.iEnum
                self.iEnum += 1
                self.iX = Map.plotX(iPlot)
                self.iY = Map.plotY(iPlot)
                self.bActivated = False

        def getID(self):
                return self.ID

        def getIndex(self):
                return self.iIndex

        def getCy(self):
                return Map.plotByIndex(self.ID)

        def getCoords(self):
                return (self.iX, self.iY)

        def getOwner(self):
                return self.getCy().getOwner()

        def isArabian(self):
                return isCivPlayer("Arabia", self.getOwner())

        def isOwned(self):
                return self.checkOwner() != None

        def isActivated(self):
                return self.bActivated

        def setActivated(self):
                self.bActivated = True

        def addCaravan(self):
                if not self.isActivated():
                        self.getCy().setImprovementType(eCaravan)
                        self.setActivated()

        def deleteCaravan(self):
                if not self.isActivated() and self.isCaravan():
                        self.getCy().setImprovementType(-1)

        def isCaravan(self):
                return self.getCy().getImprovementType() == eCaravan
So now I need to rewrite this module to fit your needs, using the CivPlayer module I posted in the other post. :king:
 
so what does the module you posted do?

also does this mean I have to make the improvement in XML? If so I will probs use POWER_OF_THE_HIGHLANDS and then make a different description... So you can use that for your rewritten code...
 
so... what does that do? :lol:
When modding with Python you constantly have to get hold of CyPlayer and CyTeam instances, most of the time fetched with ePlayer values. Sometimes you also need the eTeam values.

So what I basically did is I built my very own API (Application Programming Interface) for handling players/teams. So instead of writing numerous lines of code up and down every single module and in every single function definition, I can just do this:
Code:
Civ("Picts").get(CyPlayer)
or:
Code:
pointer("Picts", CyPlayer)
or:
Code:
CivPlayer.CyPlayer("Picts")
I don't even have to know what the ePlayer (enumerated player from the WBS) is. Because I can use the Civ's name instead. :king:
 
cool I just tried the greek code and it has done nothing... Time to check for exceptions!
 
so what does the module you posted do?
It does a lot, actually. Because what you don't wanna do is to have a script that manually check and update every single map tile on every single turn. So I built data structures and used scriptData to keep track of what tiles (and cities) need to be checked/updated. *phew*

Basically, tiles are checked once every turn and updated for desert caravans. Without the lag, might I add.

also does this mean I have to make the improvement in XML? If so I will probs use POWER_OF_THE_HIGHLANDS and then make a different description... So you can use that for your rewritten code...
I can use any improvement already in the game (my game) for development. Then its just a matter of changing one word to changing it to whatever improvement it is you end up doing for this.

I didn't catch what you meant with the statement in italics above. :crazyeye: So I can't really answer the last question. :p
 
with the caravan code does the guy have to make the caravan an improvement in the xml? If so I will be using POWER_OF_THE_HIGHLANDS for my name

basically: will I ahve to make a new improvement for this?
 
cool I just tried the greek code and it has done nothing... Time to check for exceptions!
Yeah, not working for me either. :rolleyes: I can't even get confirmation on that the canDoCivic() call is happening, so I guess I'm missing something here. :p

Lets just wait and see what the experienced modders have to say about this. Because I'm new to modding in general, to Python in particular - and especially working with the CvGameUtils module.
 
with the caravan code does the guy have to make the caravan an improvement in the xml? If so I will be using POWER_OF_THE_HIGHLANDS for my name
Aha. Yeah, he will have to make IMPROVEMENT_CARAVAN himself. I'm just using IMPROVEMENT_CAMP as a place holder.

You should probably keep to the naming conventions in the XML, but names are basically arbitrary... In your case you'd need to define the constant with:
Code:
eHighland = gc.getInfoTypeForString("POWER_OF_THE_HIGHLANDS")

basically: will I ahve to make a new improvement for this?
It is completely up to you what improvement you wanna use. But improvements can't be defined with Python, so you'll have to define anything not already present in the XML. (I can't help with that, unfortunately.)
 
ok! what we need now is to catch an experienced modder...:yumyum:
 
I'm not worried - God-Emperor is probably around these parts, somewhere... (You could send him a PM with the code.)

Are we go on the highlands, then? Meaning that I will convert the desert caravan code while you come up with an improvement.

On a side-note - the current code doesn't allow for a pillaged free improvement come back - ever. Because otherwise it would just be automatically refreshed again the next turn. So its a once-per-tile proposition. (I probably should test this more... :p)
 
I tried the carthagian one too and that is not working... maybee we should use the name and not number...
 
I tried the carthagian one too and that is not working... maybee we should use the name and not number...
You realize that you need to research Sailing first, right? (I'll test this right away...)

And there is no "name", the integer index value is the only available identifier. (Sure, we could use it to get a CyPlayer instance and then invoke a method on it to get the string name. But there is no reason since it will all still be derived from the number.)
 
Ok, it seems I overlooked something while copy-pasting the code. :rolleyes:

Use this instead:
Code:
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList

		if iPlayer == 4 and iTechType == gc.getInfoTypeForString('TECH_FISHING'):
			iSea = gc.getInfoTypeForString('DOMAIN_SEA')
			[B]pPlayer = gc.getPlayer(iPlayer)[/B]
			pTeam = gc.getTeam(pPlayer.getTeam())
			pTeam.changeExtraMoves(iSea, 1)
This assignment of pPlayer and pTeam and whetelse is precisely what I've been being busy getting rid of all day! I'd actually like to write all the Python stuff for your mod from scratch using my new CivPlayer class. So while its good to verify the code we have, I might just hand you a different set of code in the end. :p
 
oh yer forgot you need fishing... ok I will edit the code and try again!
 
Top Bottom