- deleted content -

hmmm, I think I made a mistake there, Can you change this line:

Code:
for pCivPlayer in CivPlayer.CivPlayer.getCivs():

to

Code:
for pCivPlayer in CivPlayer.CivPlayer.getPlayers():

that should fix a problem you will have down the line (the difference is that the original needs a name provided), of course it could be that I am wron g and it should be the original, in that case just change it back. When it is shown in use in documentation it is shown without parameters, which is confusing me...
 
Spoiler :

ahhh... sounds great! I guess a little like Rome Total War in respect (with the whole civil war thingy!). what sort of stuff did you take from JRM? I'm guessing the rebellions? edit: Make sure you add the legendary culture into the Victory_Special (but I'm sure you have something else which is why I left it as a variable for you! When do you think release is likely to be then?


Np problem, the mod sounds cool (see above if you dare...)
 
to be honest this whole idea of imperial victory makes me think I could make Historical Victory conditions for my mod (a bit like this and RFC) but in C++ for performance (having 8 or 9 conditions in python would be much slower). I think the rebellion stuff could be an interesting feature for your mod, fail to keep care of your cities and the outer reaches of your empire rebel (as opposed to the solid core) the chance affected by distance to capital. I could always attempt to build something for you if you wanted, I need the challenge. :p
 
well lucky for you I have already been working on it :p

It's not finished yet (gotta add some storage systems to make sure that a player doesn't get more than 1 in a city at a time and that they don't have 3 at one time...) Rebellions are terminated when all units/the city is regained by a civ (currently barbarians are the rebels but it is easy to make a new civ to fit in). It also detects the technology of the owner of the city, if it has tech 1 spawn unit 1 else spawn unit 2. Either you can leave this blank or add in another unit and a tech to spawn it with. (current both unit 1 and 2 are archer for garrison and 1 and 2 for attacking are swordsman).

The percentages are actually quite a nice idea here, a rebellion cannot occur within 10 tiles of the capital using a min distance variable(and because distance is a variable the capital canot ever experience a rebellion) and the chance of rebellion increases the further you are away.

the formula is:
iModified Chance = (iChance/100) * (iDistance**1.22222)

where iChance is defaulted at 70 this means a tile is calculated as (where iDistance == 20 tiles away):

20 power 11 = 204800000000000
204800000000000 root 9 = 38.91
38.91 * 0.7 = 27.24% chance of rebellion in city 20 tiles away per turn if it is unhappy enough
at 58 tiles away or more the chance becomes over 100% so it is crucial you keep your cities in far away countries happy and keep your capital central, but 58 tiles is a long way...

in theory if you controlled iberia and a city in italy, you would want your capital to be in eastern iberia as your empire would be central.
 
Can I upload the versions of Kongo and Madagascar that I converted to AND?
 
that's fine! Thats why I left you variables to play with :p the code itself doesn't care whether you conquor or found cities so that doesn't matter. However are you sure you don't want to include building a palace so that civs can still move capital (the crucial victory building itself wouldn't be able to move meaning the capital could be a different city but that shouldn't matter)

That way it means the player has more freedom, for example it could put people off capturing cities in the middle east because their imperial maintenance would be distributed unevenly. Constantinople would be a nicer capital in that respect, and after it is changed the building that is needed for victory would still be in the original capital's place.

Just a thought :p Btw the code is ready I just need to find the time to test it for when it goes horribly wrong :p but anyway the code looks like this:

Spoiler :

Code:
from CvPythonExtensions import *
from CivPlayer import *

##Helpers##
def getIndex(category, entry):
    """
    Returns the enumerated index value (integer) of the specified entry belonging to the
    specified category, as specified by the XML.
    """
    key = category.replace(" ", "") + "_" + entry.replace(" ", "_")
    return gc.getInfoTypeForString(key.upper())

def initActiveRebellions():
    setGlobalData("Active Rebellions", ([], 0))

def getActiveRebellions():
    return getGlobalData("Active Rebellions")

def setActiveRebellions(pRebellion):
    n = getActiveRebellions()[1] + 1
    lRebellions = getActiveRebellions()[0]
    lRebellions.append(pRebellion)
    setGlobalData("Active Rebellions", (lRebellions, n))

def removeRebellion(pRebellion):
    n = getActiveRebellions()[1] - 1
    lRebellions = getActiveRebellions()[0]
    lRebellions.remove(pRebellion)
    setGlobalData("Active Rebellions", (lRebellions, n))
    
def createRebellion(pCity, pCivPlayer):
    pRebellion = Rebellion(pCity, pCivPlayer)
    setActiveRebellions(pRebellion)
    if Game.getSorenRandNum(100, "Rebellion Chance") >= iFlipChance:
        pRebellion.spawnRebels()
    else:
        pRebellion.flipCity()
        pRebellion.spawnGarrison()

def isRebellionActive(pRebellion):
    sUnitData = "RebelUnit City:%s" % pRebellion.pCity.getName()
    for pUnit in (eRebelCiv.get(CyPlayer).getUnit(iNum) for iNum in xrange(eRebelCiv.get(CyPlayer).getNumUnits())):
        if pUnit.getScriptData() == sUnitData:
            return True
    for pCity in (eRebelCiv.get(CyPlayer).getCity(iNum) for iNum in xrange(eRebelCiv.get(CyPlayer).getNumCities())):
        if pCity.getName() == pRebellion.pCity.getName():
            return True
    return False
    
##Constants##
bActive = True #set to False to turn rebels off
gc = CyGlobalContext()
Game = CyGame()
#eRebelCiv = pointer("Rome", playerID) #edit if you want a rebel player, use short desc of civ
eRebelCiv = instance(gc.getBARBARIAN_PLAYER())
tGarrisonUnits = (getIndex("Unit", "Archer"), getIndex("Unit", "Archer"))
tRebelUnits = (getIndex("Unit", "Swordsman"), getIndex("Unit", "Swordsman"))
eTransitionTech1 = getIndex("Tech", "Archery")
eTransitionTech2 = getIndex("Tech", "Iron Working")
iChance = 100
iMinUnhappy = 4
iMinUnhealthy = 6
iMinDistance = 15
iFlipChance = 25
maxRebellionsPerPlayer = 3

##Class code##
class Rebellion:
    def __init__(self, pCity, pOwner):
        self.pCity = pCity
        self.pOwner = pOwner

    @classmethod
    def refreshRebels(cls):
        for pRebellion in getActiveRebllions()[0]:
            if not isRebellionActive(pRebellion): removeRebellion(pRebellion)

    @classmethod
    def runCheck(cls):
        if not bActive: return
        for pCivPlayer in CivPlayer.getPlayers():
            pPlayer = CivPlayer.get(CyPlayer)
            n = 0
            for pRebellion in getActiveRebellions()[0]:
                if pRebellion.pOwner == pCivPlayer: n+=1
            if n > 3: continue
            for i in range(pPlayer.getNumCities()):
                pCity = pPlayer.getCity(i)
                bInRebellion = False
                for pRebellion in getActiveRebellions()[0]:
                    if pRebellion.pCity == pCity: bInRebellion = True
                if bInRebellion: continue
                if cls.calculateChance(pCity, pPlayer):
                    createRebellion(pCity, pCivPlayer)

    @classmethod
    def calculateChance(cls, pCity, pOwner):
        pCapital = pOwner.get(CyPlayer).getCapitalCity()
        iDistance = max((pCity.getX() - pCapital.getX()),(pCity.getY() - pCapital.getY()))
        if iDistance >= iMinDistance and (pCity.angryPopulation(0) - (pCity.getWarWearinessPercentAnger()/100)) >= iMinUnhappy:
            #y is directly proportional to ((x power 11) power 0.11111) * iChance/100 math FTW :p
            iModifiedChance = (float(iChance)/100) * (float(iDistance) ** (11.0 / 9.0))
            return (Game.getSorenRandNum(100, "Rebellion Chance") <= iModifiedChance)
        else: return False

    def spawnRebels(self):
        if self.pOwner.get(CyTeam).isHasTech(eTransitionTech2):
            eUnit = tRebelUnits[1]
            lPlots = [self.pCity.getCityIndexPlot(iIndex) for iIndex in xrange(19) if not ( self.pCity.getCityIndexPlot(iIndex).isPeak() or
                                                                                            self.pCity.getCityIndexPlot(iIndex).isWater() or
                                                                                            self.pCity.getCityIndexPlot(iIndex).isCity() )]
            pRandPlot = lPlots[Game.getSorenRandNum(len(lPlots), "Rand Plot")]
            CivPlayer(eRebelCiv).get(PyPlayer).initUnit(pUnit.getUnitTpe(), pPlot.getX(), pPlot.getY(), 8)
            
        else:
            eUnit = tRebelUnits[0]
            lPlots = [self.pCity.getCityIndexPlot(iIndex) for iIndex in xrange(19) if not ( self.pCity.getCityIndexPlot(iIndex).isPeak() or
                                                                                            self.pCity.getCityIndexPlot(iIndex).isWater() or
                                                                                            self.pCity.getCityIndexPlot(iIndex).isCity() )]
            pRandPlot = lPlots[Game.getSorenRandNum(len(lPlots), "Rand Plot")]
            CivPlayer(eRebelCiv).get(PyPlayer).initUnit(pUnit.getUnitTpe(), pPlot.getX(), pPlot.getY(), 8)

        for pUnit in (pRandPlot.getUnit(iUnit) for iUnit in range(pRandPlot.getNumUnits())):
            if pUnit.getOwner == eRebelCiv:
                sUnitData = "RebelUnit City:%s" % self.pCity.getName()
                pUnit.setScriptData(sUnitData)
            
    def flipCity(self):
        pPlot = self.pCity.plot()
        lUnits = [pUnit for pUnit in (pPlot.getUnit(iUnit) for iUnit in range(pPlot.getNumUnits())) if pUnit.getOwner() == self.pCity.getOwner()]
        lUnitsData = lUnits
        for pUnit in lUnits:
            pUnit.kill(False, self.pCity.getOwner())
        CivPlayer(eRebelCiv).get(CyPlayer).acquireCity(self.pCity, True, False)
        for pUnit in lUnitsData:
            CivPlayer(eRebelCiv).get(PyPlayer).initUnit(pUnit.getUnitTpe(), self.pCity.getX(), self.pCity.getY(), 1)
            
    def spawnGarrison(self):
        if self.pOwner.get(CyTeam).isHasTech(eTransitionTech1):
            eUnit = tGarrisonUnits[1]
            CivPlayer(eRebelCiv).get(PyPlayer).initUnit(eUnit, self.pCity.getX(), self.pCity.getY(), 6)
        else:
            eUnit = tGarrisonUnits[0]
            CivPlayer(eRebelCiv).get(PyPlayer).initUnit(eUnit, self.pCity.getX(), self.pCity.getY(), 6)


edit: if running HR military still will provide the happy :p

I might have a solution to the religion problem aswell I will see what I can do...
 
ok on the religion thing, I think I can work something out, but you need to disable the foundin gof christanity from tech and I will attempt to trigger manually with python, let me have a look
 
ok finished!

Code:
                ## Found Christianity ##
                iTurn = 350
                tHolyCoords = (0,0) #coords of Rome or Jerusalem
                eChrist = gc.getInfoTypeForString("RELIGION_CHRISTIANITY")
                Map = CyMap()
                if iGameTurn == iTurn - 1:
                        iX, iY = tHolyCoords
                        pHolyCity = Map.plot(iX, iY).getPlotCity() 
                        pHolyCity.setHasReligion(eChrist, True, True, True)
                        Game.setHolyCity(eChrist, pHolyCity, True)
                ## Found Christianity ##

put this in onBeginGameTurn under the victory condition stuff

founds christianity on iTurn in city on tHolyCoords. The player gets a do you wish to convert to christanity popup and there is a message: christanity has been founded in X

If your mod has multiple speeds then I will need to work out something that will trigger on 0AD instead of on turns but I'm sure you can work out 0AD's turn ingame (and add it as the variable!)

Make sure you remove the founding tech of cristanity so it can't be founded by research and you should be fine.
 
hmmm, maybee I should add the provincial capital to the rebellion code (though it may already count the forbidden palace by default)

I think you will need to make sure christianity is not founded by an accessable tech otherwise it can be founded before 1 ad (I have no removal code for existing holy city)
 
ok on the rebels front, I have weeded out the errors so far and now I am debugging to see if the code succesfully deletes and checks for rebellions. But I have got rebellions to spawn in cities so that is fine :p iChance is set to 1000% for testing :lol:
 
I might factor in unhappiness into the equation for chance. at the moment a minimum value is needed to trigger a rebellion but should it also increase the rebellion chances the more unhappy the city actually is?

btw war weariness doesn't affect rebellion conditions so WW unhappy will not trigger rebellions
 
Hey veBear, I was wondering if I could have the Parthian module in .rar or .zip format? I don't think there's a .7z unzipping thing for Macs. Thanks!
-Sam
 
I'm interested in your brazil civ mod and I gotta say it's a well done project. However, I think you should rework on the brazilian UU. Here are my suggestions:

*9% chance to enslave a defeated unit as a worker is way low. Also, 1% chance to generate a settler is downright useless. I suggest you remove the chance to generate a settler and increase the odds of a worker coming out of a battle. Something like 15% or 20% to produce a worker would be enough.

*10% chance to withdraw from combat is not useful for a slow unit (unlike the cavalry or zulu UU, you can't turn around after a failed combat). My suggestion is to replace it with Heal while Moving (more acceptable) or ignore terrain movement cost/mobility + 1 movement point (not the best idea since it conflicts with the french UU). Both emphasize the mobility and self-sufficiency of the Bandeiras, from which the Bandeirantes took their name.
 
Too OP IMO.

How so? Musketman is far from being a blitz unit and the most reliable source of weak attacks, barbarians, is almost non-existent on gunpowder era. It's just a history perk with little actual use IMO. Musketmen aren't exactly walls like Machine Guns, which can hold off most units till Tanks and Marines come into the game.


It will help if you have a large stack of units, which basically allows you to keep the unit in a battle it else could have lost, so maybe you can spare some units that way. Heal while mowing would be a good enough bonus by itself IMO (OP together with the previous bonus) and extra movement is out of the question due to the Musketeer (I never use the same bonus as, or edit, a vanilla UU, with the exception being Carthage in my Berber mod, but even then the Numidian Cavalry stats is unchanged).

Considering Musketmen and its upgrades have defensive nature, there's no way it could be any better than the American UU. Also, it's a promotion which they would get later as Mech Infantry.

But let's not quarrel over that for now. I'll instead tell you why I wanted that bonus. I chose that bonus because they took a lot of natives as slaves so the Brazilians could gain a good workforce. That way I feel like I'm also representating the slave-culture on the plantations (Fazendas) in Brazil. So basically it's to make them a sort of slave-taker unit.

I understand and I think it's a good idea, but you should also consider covering the legendary self-sufficiency which allowed them to walk thousands of kilometers in previously uncharted lands to raid native villages and find gold deposits.
 
Personally, I will say 1% chance is close to never happening anyway.
Also, I rather have the worker than the settler by the time muskets can be built, since all the land plots should be covered anyway. Settler will only be useful if you wish to raze and rebuild.
Thus, might as well combine both codes to just spawn workers, 1 less IF statement, better efficiency also
 
Back
Top Bottom