Requesting following features

this what you want?

Code:
	<Define>
		<DefineName>USE_CAN_DO_CIVIC_CALLBACK</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
 
Yeah, you've got it. And its this:
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
It goes into CvGameUtils.py, remember?
 
I'm pretty much done for today and the Highlands code is ready for testing - tomorrow. See you then. :)
 
oh ok :lol:

can't wait for testing :D (do I need to make my XML first?)
 
I'm actually gonna test the code itself with a standard BtS game myself first. But once I'm done its merely a matter of changing a few values and adding some lines of code into your copy of CvEventManager.py to get it to work with your mod. And then you can take care of the actual play-testing. :king:

You can do the new XML feature whenever. I'm using a Hamlet as a stand-in - you can just change it later.
 
And this is what I have thus far (yet to be tested):
Spoiler :
PHP:
### Pictic Highlands ability for Jamie's Rome Mod, by Baldyr

from CivPlayer import *

### constants

pPicts = Civ("Picts")

# settings

iBritainTL = Map.plotNum(0, 40)
iBritainBR = Map.plotNum(10, 51)

# eNums

eHills = PlotTypes.PLOT_HILLS
eHighlands = getIndex("Improvement", "Hamlet") #change to Highland or whatever

### functions

def newHighlandsCity(pCity):
        """
        Looks up all tiles surrounding pCity and adds any Hills tiles to a list which is stored
        in the CyCity object as scriptData.
        """
        lHighlands = list()
        for iPlot in getBFC(pCity):
                pHighlands = Highlands.highlandsMap.get(iPlot, None)
                if pHighlands:
                        lHighlands.append(pHighlands)
        if lHighlands:
                pCity.setScriptData(pickle.dumps(lHighlands))
          
def checkHighlandsCity(pCity):
        """
        Checks if pCity has Hills tiles within reach. If it has, then ownership of those tiles is
        checked. Any Pictic Hills tiles gets a free Highlands improvement.
        """
        scriptData = pCity.getScriptData()
        if not scriptData: return
        for pHighlands in pickle.loads(scriptData):
                if pHighlands.getOwner() == pPicts.playerID():
                        pHighlands.addImprovement()
                else:
                        pHighlands.deleteImprovement()

def processHighlandsCities():
        """
        Checks all cities with highlands tiles.
        """
        for pCivPlayer in list(CivPlayer.Civilizations[key] for key in CivPlayer.Civilizations):
                if pCivPlayer.CyPlayer().isAlive() and pCivPlayer.CyTeam().isHasMet(pPicts.teamID()):
                        for pCity in list(city.GetCy() for city in pCivPlayer.PyPlayer().getCityList()):
                                checkHighlandsCity(pCity)

def setupHighlandsMap():
        """
        Builds the global dictionary of Highlands class instances.
        """
        if not Highlands.HighlandsMap:
                for iPlot in getMapArea(iBritainTL, iBritainBR):
                        if Map.plotByIndex(iPlot).getPlotType() == eHills:
                                Highlands.highlandsMap[iPlot] = Highlands(iPlot)

def getBFC(pCity):
        """
        Used for iteration - yields plot IDs for all plots within city radius.
        """
        iX, iY = pCity.getX(), pCity.getY()
        for iPlot in getMapArea(Map.plotNum(iX - 2, iY -2), Map.plotNum(iX + 2, iY + 2)):
                pPlot = Map.plotByIndex(iPlot)
                if pPlot.isCityRadius() or not pPlot.isCity(): 
                        yield iPlot

def getMapArea(iTL, iBR):
        """
        Used for iteration - yields all plot IDs for the map area defined by arguments.
        """
        for iX in range(Map.plotX(iTL), Map.plotX(iBR) + 1):
                for iY in range(Map.plotY(iTL), Map.plotX(iBR) + 1):
                        yield Map.plotNum(iX, iY)

class Highlands:

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

        highlandsMap = 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 isOwned(self):
                return self.checkOwner() != None

        def isActivated(self):
                return self.bActivated

        def setActivated(self):
                self.bActivated = True

        def addImprovement(self):
                if not self.isActivated():
                        self.getCy().setImprovementType(eHighlands)
                        self.setActivated()

        def deleteImprovement(self):
                if not self.isActivated() and self.isHighlands():
                        self.getCy().setImprovementType(-1)

        def isHighlands(self):
                return self.getCy().getImprovementType() == eHighlands
 
Wow! cool!

Well let's hope it works!

The greek one now works (I have to do some work on this because US is only available to the Greeks and who ever builds the pyramids :lol:)

I guess that what you said to asaf was to do with the Briton and the Gallic Powers? :D

Well thanks for all of your help with this! Good night!
 
Well let's hope it works!
Of course it does. :p This is only my fourth of fifth stab at this particular problem. But since nothing is tested in actual play there are bound to be issues still to be worked out. But we'll get there, eventually.

I'll send you the work tomorrow and have another look at the remaining stuff. Do you think that you can edit the CvEventManager.py file yourself or should I help you with this also?

I guess that what you said to asaf was to do with the Briton and the Gallic Powers? :D
Yeah, a modder can dream, right? :D Without some SDK work I don't think those abilities are gonna get made... So you might wanna have a plan B.
 
Oh No! Not a plan B!!!!!

What do I need to do to the CvEventManager exactly?

I wonder how The J is doing with the Civil War...
 
I created a DLL which you can use.
You can download it here (I also included the source changes I made).

Nothing clever. Just a little code to expose existing internal functions.

I haven't tested it myself, but it does compile ;)

Let me know if something's not working so I can fix it.

This is what I added:

CyPlayer.setCityExtraDefense()

I added CyPlayer.changeCityDefenseModifier(int iChange) (was already used internally, just exposed it to Python).

CyPlayer.changeWarWearinessPercent()

I added CyPlayer.changeWarWearinessModifier(int iChange) (was already used internally, just exposed it to Python).

CyPlayer.setMaintenanceDiscount()

Exposed CyPlayer.changeDistanceMaintenanceModifier(int iChange) and CyPlayer.changeNumCitiesMaintenanceModifier(int iChange).
These already exist internally, so I preferred not adding a new untested functionality.
You can call them both with the same value to simulate your function.


This is what I didn't add:

CyCity.setExtraUnhappiness()

I believe you can use the existing CyCity.changeExtraHappiness() with a negative value.

CyCity.setRevoltChance()

It's not that simple. The revolt chances calculation is much more complicated than just a number (there are in fact 2 'random throws' for this).
If you want me to do something other than that, please specify.

I must say that a constant "30% chance of revolt" doesn't sound like such a good idea to me, since this city will probably revolt within a few turns anyway, so what's the point of conquering english cities?

I suggest something like 'player culture counts for an extra 50% in his ex-cities when calculating revolt chances' or something to that effect, in which case I can add this to the calculation and expose this to Python (this will, however, break saves as this modifier should be kept in the savegame file).

CyCity.setDomainExtraYield()

Not sure what it's supposed to do...
 
I guess the Extra yield does something to tiles and their :hammers:, :food: and :commerce:

I guess this is for baldyr? :D

I don't mind what you do for england as long as it is within my guidelines and doesn't break...

(this will, however, break saves as this modifier should be kept in the savegame file).

does this mean it will not work for existing saves... In that case that's fine
 
I created a DLL which you can use.
Oh, great! :king:

I suggest something like 'player culture counts for an extra 50% in his ex-cities when calculating revolt chances' or something to that effect, in which case I can add this to the calculation and expose this to Python (this will, however, break saves as this modifier should be kept in the savegame file).
Check with the author of the mod regarding the design aspect of this. I'm just a code monkey! :lol:

Not sure what it's supposed to do...
Ah, the Viking/Pictic power was originally described as:
Viking - Power of the Highlands - Hills +1 food
What I've done is to create a script that adds unbuildable improvements to Hills tiles inside cultural border and within reach of cities. If the CyGame.setPlotExtraYield() method could be used with negative values to set the extra food yield to zero again, then that would be better than adding improvements. But unfortunately it can't. :( Can you "fix" it?

But an even better solution would be to add a CyCity.setExtraTerrainYield() method that makes the city yield more food "internally" from Hills tiles. Or perhaps a CyPlayer.setExtraTerrainYield() that affects all tiles within cultural borders.

I'm not sure what is most convenient for you to edit, but anything would do, basically.
 
Since I'm using the civilization adjective names as identifiers with my own CivPlayer module/class, it would be good to have them. Either post the XML file where you define them, or simply post the names. (The exact spelling of the Pictic adjective is most urgent, obviously.)
 
Check with the author of the mod regarding the design aspect of this. I'm just a code monkey! :lol:

I don't mind what you do for england as long as it is within my guidelines and doesn't break...
j_mie6 - It's your mod. Decide what you want. If you like the idea I suggested, I can implement it.

But an even better solution would be to add a CyGame.setExtraTerrainYield() method that makes the city yield more food "internally" from Hills tiles. Or perhaps a CyPlayer.setExtraTerrainYield() that affects all tiles within cultural borders.

I'm not sure what is most convenient for you to edit, but anything would do, basically.

I'll take a look at it this evening, and hopefully have something for you then.
 
I'll take a look at it this evening, and hopefully have something for you then.
Great! :goodjob:

@j_mie6:
I'm basically done testing the current code but since Asaf may be able to get you something even better I'll wait with sending you the code. I'll have a look at the other stuff in the meanwhile.
 
:D brain overload :lol:

Right... The zip attached contains the CivilizationInfos.xml

@Asaf: I would like you to implement the 50% Culture thing as long as it works fine and doesn't do anything weird!

@Baldyr: I would not mind getting your current code now if it works just until there is an alternative

@Me: It's all coming together!!! [party]:thanx::cheers::high5:

And to both of you: :pat:
 

Attachments

  • For Baldyr.zip
    6.2 KB · Views: 50
I would actually prefer to wait for whatever new tools Asaf will bring to the table. Because getting the Picts working requires for you to hack into the Event Manager to get all the function calls and import statements in place. I don't think I can stomach guiding you through it twice. :p And you probably won't need to do the new highlands improvement either, if Asaf comes through. :king:

Remember that I still have a lot to do on the other powers as well. So I think I need to get it all structured - and also include the Carthagian, the Greek and whatever it is I'm forgetting at the moment into one coherent mod component (a set of modules). For your convenience. :D

The reason I don't feel comfortable with messing around with your Event Manager is that you have other Python code in your mod also, right? So you already should have a edited CvEventManager in your mod's Python folder. But perhaps you don't feel comfortable with editing it yourself either?

I believe that it is The_J who has been supplying you with Python, right? Because it would be helpful to know whether or not he has used any scriptData in his work. For reference I'm gonna use scriptData for CyCity and possibly CyPlayer instances. (I edited out the need for using CyGame - the most likely culprit for a conflict with different mod components using the same objects.) If this means nothing to you I could just as The_J myself.

edit: I'm also doing work on the G&G mod at the same time and also working on my own little pet projects (CivPlayer and DataStorage modules respectively). So expect this to be finished in a weeks time or so.
 
I looked at your attachment and realized that I need the TXT definitions for the XML fields. Like where this is defined as a string: "TXT_KEY_CIV_PICTS_TWO_ADJECTIVE"
 
I would prefer if you asked him an way the TXT_KEYs are defined in my text file do you need that too?

Spoiler :

Code:
	<TEXT>
		<Tag>TXT_KEY_CIV_GAUL_DESC</Tag>
		<English>Gallic Empire</English>
		<French>Empire des Gaules</French>
		<German>Gallische Reich</German>
		<Italian>Gallico Impero</Italian>
		<Spanish>Imperio Galo</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_GAUL_SHORT_DESC</Tag>
		<English>Gaul</English>
		<French>Gaule</French>
		<German>Gallien</German>
		<Italian>Gallia</Italian>
		<Spanish>Galia</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_GAUL_ADJECTIVE</Tag>
		<English>Gallic</English>
		<French>Gaulois</French>
		<German>Gallisch</German>
		<Italian>Gallico</Italian>
		<Spanish>Galo</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_BRITON_DESC</Tag>
		<English>Brython Empire</English>
		<French>Empire des Breton</French>
		<German>Brython Reich</German>
		<Italian>Impero Brython</Italian>
		<Spanish>Imperio Britano</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_BRITON_SHORT_DESC</Tag>
		<English>Brittania</English>
		<French>Brittania</French>
		<German>Brittania</German>
		<Italian>Brittania</Italian>
		<Spanish>Brittania</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_BRITON_ADJECTIVE</Tag>
		<English>Brython</English>
		<French>Breton</French>
		<German>Brython</German>
		<Italian>Brython</Italian>
		<Spanish>Britano</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_GERMANIA_DESC</Tag>
		<English>Germanic Empire</English>
		<French>Empire Germanique</French>
		<German>Reich Deutscher Nation</German>
		<Italian>Impero Germanico</Italian>
		<Spanish>Germánico</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_GERMANIA_SHORT_DESC</Tag>
		<English>Germania</English>
		<French>Germania</French>
		<German>Germania</German>
		<Italian>Germania</Italian>
		<Spanish>Germania</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_GERMANIA_ADJECTIVE</Tag>
		<English>Germanic</English>
		<French>Germanique</French>
		<German>Germanisch</German>
		<Italian>Germanico</Italian>
		<Spanish>Germánico</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_PICTS_TWO_DESC</Tag>
		<English>Pictish Empire</English>
		<French>Picte Empire</French>
		<German>Pictish Reich</German>
		<Italian>Pitti Impero</Italian>
		<Spanish>Picto Imperio</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_PICTS_TWO_SHORT_DESC</Tag>
		<English>Pictia</English>
		<French>Pictes</French>
		<German>Pickten</German>
		<Italian>Pitti</Italian>
		<Spanish>Pictos</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_CIV_PICTS_TWO_ADJECTIVE</Tag>
		<English>Pictish</English>
		<French>Picte</French>
		<German>Pictish</German>
		<Italian>Pitti</Italian>
		<Spanish>Picto</Spanish>
	</TEXT>


In side here you will find everything you will need text wise: Gaul, Briton, Picts, Germania (an extra)
 
Top Bottom