[MOD] MagisterModmod

I saved it with Notepad++ and it works fine for me. I'm guessing that when you copied and pasted it that you messed up the indentation. Python is very particular about how many tabs each line has, but when copying and pasting things it is easy to end up with extra tabs on the first line.
Huh. I've barely ever used Python, so I wasn't aware of that. I tried again, with a new copy-paste, but it still didn't work, though. The indentation of the first line didn't change visibly when I overwrote the old stuff.
 
Just found one more bug.
Code:
Traceback (most recent call last):

  File "CvSpellInterface", line 115, in miscast

  File "<string>", line 0, in ?

  File "CvSpellInterface", line 35585, in miscastSteal

UnboundLocalError: local variable 'pCity' referenced before assignment
ERR: Python function miscast failed, module CvSpellInterface

in both lines 35548 and 35585 of CvSpellInterface.py it seems I forgot to change pCity to pUnit

While fixing that I noticed that the code would also have a problem if the spell was miscast by a player with no capital city, so I added checks to stop that too in this fixed code.
It should be like this
Spoiler :

Code:
def miscastSteal(pCaster, eSpell=-1):
    iTeam = pCaster.getTeam()
    pPlot = pCaster.plot()
    iPlayer = pCaster.getOwner()
    iX = pCaster.getX()
    iY = pCaster.getY()
    sButton = 'Art/Interface/Buttons/Spells/Steal.dds'
    for i in xrange(pPlot.getNumUnits()):
        pUnit = pPlot.getUnit(i)
        if pUnit.isDelayedDeath():continue
        if pUnit.getTeam() == iTeam:continue
        if pUnit.isInvisible(iTeam, False):continue
        iUnit = pUnit.getUnitType()
        if iUnit == -1: continue
        if gc.getUnitInfo(iUnit).isObject():
            iProm = gc.getUnitInfo(iUnit).getEquipmentPromotion()
            if iProm != -1:
                if not pCaster.isHasPromotion(iProm):
                    sDescription = gc.getPromotionInfo(iProm).getDescription()
                    iPlayer = pCaster.getOwner()
                    pPlayer = gc.getPlayer(iPlayer)
                    iPlayerT = pUnit.getOwner()
                    pPlayerT = gc.getPlayer(iPlayerT)
                  
                    iRnd = CyGame().getSorenRandNum(100, "Steal")
                    if iRnd < 50:
                        CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL_ESCAPE", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                    elif iRnd < 95:
                        pPlayerT.AI_changeAttitudeExtra(pCaster.getOwner(), -2)
                        pCaster.doDamageNoCaster(50, 95, gc.getInfoTypeForString('DAMAGE_PHYSICAL'), False)
                        pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), False)
                        pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN'), False)
                        pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_INVISIBLE'), False)
                        CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                        CyInterface().addMessage(iPlayerT, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_RED'), iX, iY, True, True)
                    else:
                        CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_EPIC_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                        CyInterface().addMessage(iPlayerT, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_EPIC_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_RED'), iX, iY, True, True)
                        if CyGame().getSorenRandNum(100, "Steal") < 50 and not pPlayer.getCapitalCity().isNone():
                            pCaster.setXY(pPlayer.getCapitalCity().getX(), pPlayer.getCapitalCity().getY(), False, True, True)
                        else:
                            pCaster.kill(True, PlayerTypes.NO_PLAYER)
                        cf.startWar(pCaster.getOwner(), pUnit.getOwner(), WarPlanTypes.WARPLAN_TOTAL)
                  

        for iProm in xrange(gc.getNumPromotionInfos()):
            if not pCaster.isHasPromotion(iProm):
                if pUnit.isHasPromotion(iProm):
                    if gc.getPromotionInfo(iProm).isEquipment():
                        if iProm == gc.getInfoTypeForString('PROMOTION_PIECES_OF_BARNAXUS') and iUnit == gc.getInfoTypeForString('UNIT_BARNAXUS'):
                            continue
                        if iProm == gc.getInfoTypeForString('PROMOTION_PIECES_OF_MITHRIL_GOLEM') and iUnit == gc.getInfoTypeForString('UNIT_MITHRIL_GOLEM'):
                            continue
                        if iProm == gc.getInfoTypeForString('PROMOTION_PIECES_OF_WAR_MACHINE') and iUnit == gc.getInfoTypeForString('UNIT_WAR_MACHINE'):
                            continue
                        sDescription = gc.getPromotionInfo(iProm).getDescription()
                        iPlayer = pCaster.getOwner()
                        pPlayer = gc.getPlayer(iPlayer)
                        iPlayerT = pUnit.getOwner()
                        pPlayerT = gc.getPlayer(iPlayerT)
                      
                        iRnd = CyGame().getSorenRandNum(100, "Steal")
                        if iRnd < 50:
                            CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL_ESCAPE", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                        elif iRnd < 95:
                            pPlayerT.AI_changeAttitudeExtra(pCaster.getOwner(), -2)
                            pCaster.doDamageNoCaster(50, 95, gc.getInfoTypeForString('DAMAGE_PHYSICAL'), False)
                            pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), False)
                            pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN'), False)
                            pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_INVISIBLE'), False)
                            CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                            CyInterface().addMessage(iPlayerT, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_RED'), iX, iY, True, True)
                        else:
                            CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_EPIC_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                            CyInterface().addMessage(iPlayerT, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_EPIC_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_RED'), iX, iY, True, True)
                            if CyGame().getSorenRandNum(100, "Steal") < 50 and not pPlayer.getCapitalCity().isNone():
                                pCaster.setXY(pPlayer.getCapitalCity().getX(), pPlayer.getCapitalCity().getY(), False, True, True)
                            else:
                                pCaster.kill(True, PlayerTypes.NO_PLAYER)
                            cf.startWar(pCaster.getOwner(), pUnit.getOwner(), WarPlanTypes.WARPLAN_TOTAL)
    if pPlot.isCity():
        pCity = pPlot.getPlotCity()
        if pCity.getTeam() != iTeam:
            for iBuild in xrange(gc.getNumBuildingInfos()):
                if pCity.getNumRealBuilding(iBuild) > 0:
                    if gc.getBuildingInfo(iBuild).isEquipment():
                        for iUnit in xrange(gc.getNumUnitInfos()):
                            if gc.getUnitInfo(iUnit).getBuildings(iBuild):
                                iProm = gc.getUnitInfo(iUnit).getEquipmentPromotion()
                                if not pCaster.isHasPromotion(iProm):
                                    sDescription = gc.getBuildingInfo(iBuild).getDescription()
                                    iPlayer = pCaster.getOwner()
                                    pPlayer = gc.getPlayer(iPlayer)
                                    iPlayerT = pCity.getOwner()
                                    pPlayerT = gc.getPlayer(iPlayerT)
                                  
                                    iRnd = CyGame().getSorenRandNum(100, "Steal")
                                    if iRnd < 50:
                                        CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL_ESCAPE", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                                    elif iRnd < 95:
                                        pPlayerT.AI_changeAttitudeExtra(pCaster.getOwner(), -2)
                                        pCaster.doDamageNoCaster(50, 95, gc.getInfoTypeForString('DAMAGE_PHYSICAL'), False)
                                        pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY'), False)
                                        pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN'), False)
                                        pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_INVISIBLE'), False)
                                        CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                                        CyInterface().addMessage(iPlayerT, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_RED'), iX, iY, True, True)
                                    else:
                                        CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_EPIC_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_GREEN'), iX, iY, True, True)
                                        CyInterface().addMessage(iPlayerT, True, 25, localText.getText("TXT_KEY_SPELL_STEAL_EPIC_FAIL", (pCaster.getName(), sDescription, )), '', InterfaceMessageTypes.MESSAGE_TYPE_INFO, sButton, gc.getInfoTypeForString('COLOR_RED'), iX, iY, True, True)
                                        if CyGame().getSorenRandNum(100, "Steal") < 50 and not pPlayer.getCapitalCity().isNone():
                                            pCaster.setXY(pPlayer.getCapitalCity().getX(), pPlayer.getCapitalCity().getY(), False, True, True)
                                        else:
                                            pCaster.kill(True, PlayerTypes.NO_PLAYER)
                                        cf.startWar(pCaster.getOwner(), pCity.getOwner(), WarPlanTypes.WARPLAN_TOTAL)

Huh. I've barely ever used Python, so I wasn't aware of that. I tried again, with a new copy-paste, but it still didn't work, though. The indentation of the first line didn't change visibly when I overwrote the old stuff.
Make sure you have the ¶ (Show All Characters) toggle button turned on so that you can see the difference between tabs, spaces etc.

I used tabs in the code but just noticed that when I copied the code from my last post that it changed everything to spaces. Python can use spaces instead of tabs but you have to be really consistent. Generally it will interpret 4 spaces and 1 tab, but sometimes may use 8 spaces per tab. Having 3, 5, 7, or 9 tabs can bad. It is best to just use tabs. Notepad ++ should change the spaces to tabs if you highlight a block of code and press the tab key to indent it all, and then shift+tab at the same time to unindent it.
 
Make sure you have the ¶ (Show All Characters) toggle button turned on so that you can see the difference between tabs, spaces etc.

I used tabs in the code but just noticed that when I copied the code from my last post that it changed everything to spaces. Python can use spaces instead of tabs but you have to be really consistent. Generally it will interpret 4 spaces and 1 tab, but sometimes may use 8 spaces per tab. Having 3, 5, 7, or 9 tabs can bad. It is best to just use tabs. Notepad ++ should change the spaces to tabs if you highlight a block of code and press the tab key to indent it all, and then shift+tab at the same time to unindent it.
That worked. Thanks!
 
What the heck? I don't know if this is vanilla FFH, or the modmod, but I've been attacked by a barbarian Aquilan really early game. Like "just researched bronze working and am building my first axemen" early. Is this meant to happen, and if so, how am I meant to deal with a 15 strength enemy that can move way faster than anything I can field?

Update: I have a second, completely unrelated question. Is there a way to stop the Grigori adventurers from downgrading if you don't want them to? I can't use them to cast spells on my cities long term because they reset to adventurer and lose their free promotions.

Edit: Or...do they? I'm so confused, my adept adventurers seem to have gained several different spell promotions that don't match up at all with the mana I have access to.
 
Last edited:
Aquilians spawning from lairs was removed by Magister some time ago, but it might still be spawnable from Letum Frigus by exploration. I am not sure if they are a timed duration spawn or pemanent - but they ought be timed at least.

The Adventurer promotion will randomly cause them to revert, but only in cities. So unfortunately aside from some early game Muse or Ring of Warding, they tend to lose value pretty quickly as city mages. Though since the Grigori have 2 of each mana to start with, getting a few Adepts with Creation Affinity is easier than for other civs (especially if you also get the Museum of Maponos).

I don't recall precisely how Adepts getting their first random spell works, but i think it is random albeit heavily favoured towards mana you have access to. The two adepts the Amurite start with can have any spell sphere promotion to begin with, although it favours the civ/leader choice as usual.
 
What the heck? I don't know if this is vanilla FFH, or the modmod, but I've been attacked by a barbarian Aquilan really early game. Like "just researched bronze working and am building my first axemen" early. Is this meant to happen, and if so, how am I meant to deal with a 15 strength enemy that can move way faster than anything I can field?

Update: I have a second, completely unrelated question. Is there a way to stop the Grigori adventurers from downgrading if you don't want them to? I can't use them to cast spells on my cities long term because they reset to adventurer and lose their free promotions.

Edit: Or...do they? I'm so confused, my adept adventurers seem to have gained several different spell promotions that don't match up at all with the mana I have access to.

An Aquilan in the early game does seem quite odd. The only ways I can think of an Aquilan showing other than being summoned by a High Priest of the Hand (or the high priest versions of Anagantios, Riuros, or Dumannios), in which case they would have limited duration, is being spawned by the doFlareDimensionalNode random event. That can only happen on a tile with either a Dimensiona Node or a Planar Gate. Are there more advanced players in the game who might have built a Dimensional Node or Planar Gate?
Spoiler :

Code:
def doFlareDimensionalNode(argsList):
    kTriggeredData = argsList[0]
    pPlot = CyMap().plot(kTriggeredData.iPlotX,kTriggeredData.iPlotY)
    point = pPlot.getPoint()
    CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPELL1'),point)
    CyAudioGame().Play3DSound("AS3D_SPELL_DEFILE",point.x,point.y,point.z)

    pPlot = cf.findClearPlot(-1, pPlot)
    if pPlot != -1:
        pPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
        lList = [    'UNIT_AIR_ELEMENTAL',
                    'UNIT_EARTH_ELEMENTAL',
                    'UNIT_FIRE_ELEMENTAL',
                    'UNIT_WATER_ELEMENTAL',
                    'UNIT_ICE_ELEMENTAL',
                    'UNIT_LIGHTNING_ELEMENTAL',
                    'UNIT_BALOR',
                    'UNIT_DJINN',
                    'UNIT_SPIDERKIN',
                    'UNIT_WRAITH',
                    'UNIT_CHAOS_MARAUDER',
                    'UNIT_AUREALIS',
                    'UNIT_FROST_GIANT',
                    'UNIT_SUCCUBUS',
                    'UNIT_REVELERS',
                    'UNIT_MANTICORE',
                    'UNIT_MOBIUS_WITCH',
                    'UNIT_COLUBRA',
                    'UNIT_TAR_DEMON',
                    'UNIT_CHAOS_MARAUDER',
                    'UNIT_AZER',
                    'UNIT_AQUILAN',
                    'UNIT_IMP'
                    ]
        iUnit = gc.getInfoTypeForString(lList[CyGame().getSorenRandNum(len(lList), "Pick Elemental")-1])
        newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.UNITAI_LAIRGUARDIAN, DirectionTypes.DIRECTION_SOUTH)
I'm thinking that the Aquilan might be overkill for a planar gate since I strengthened then when they were revealed to be the 7 strongest true angels of Mulcarn besides his archangel. I think I'll remove them from the list.

Aquilians spawning from lairs was removed by Magister some time ago, but it might still be spawnable from Letum Frigus by exploration. I am not sure if they are a timed duration spawn or pemanent - but they ought be timed at least.

The Adventurer promotion will randomly cause them to revert, but only in cities. So unfortunately aside from some early game Muse or Ring of Warding, they tend to lose value pretty quickly as city mages. Though since the Grigori have 2 of each mana to start with, getting a few Adepts with Creation Affinity is easier than for other civs (especially if you also get the Museum of Maponos).

I don't recall precisely how Adepts getting their first random spell works, but i think it is random albeit heavily favoured towards mana you have access to. The two adepts the Amurite start with can have any spell sphere promotion to begin with, although it favours the civ/leader choice as usual.
Adventurers get bored easily if left in safe cities, but they won't revert types if away from a city, or if the city is mosly a foreign culture, or is still under occupation, or if there are any hostile units (including hidden nationality units of neutral players) nearby.
Spoiler :

Code:
def effectWanderlust(pCaster):
    if pCaster.isAlive() and not pCaster.hasMoved():
        if pCaster.getImmobileTimer() < 1:
            if pCaster.getUnitType() != gc.getInfoTypeForString('UNIT_ADVENTURER'):
                pPlot = pCaster.plot()
                if not pPlot.isOwned():
                    if CyGame().getSorenRandNum(100, "Wanderlust "+ str(pCaster.getName())) < pCaster.getLevel():
                        iRnd = CyGame().getSorenRandNum(100, "Explore Lair "+ str(pCaster.getName()))
                        if iRnd < 14:
                            cf.exploreLairBigBad(pCaster)
                        elif iRnd < 44:
                            cf.exploreLairBad(pCaster)
                        elif iRnd < 70:
                            cf.exploreLairNeutral(pCaster)
                        elif iRnd < 95:
                            cf.exploreLairGood(pCaster)
                        else:
                            cf.exploreLairBigGood(pCaster)
                        pCaster.changeExperience(1, -1, False, False, False)
                elif pPlot.isCity():
                    iX = pCaster.getX()
                    iY = pCaster.getY()
                    bBoard = True
                    iTeam = pCaster.getTeam()
                    if pPlot.getNumDefenders(pCaster.getOwner()) < 2:
                        bBoard = False
                    elif pPlot.findHighestCultureTeam() != iTeam:
                        bBoard = False
                    elif pPlot.getPlotCity().getOccupationTimer() > 0:
                        bBoard = False
                    else:
                        pTeam = gc.getTeam(iTeam)
                        for iiX in xrange(iX-2, iX+ 3, 1):
                            for iiY in xrange(iY-2, iY+ 3, 1):
                                pPlot2 = CyMap().plot(iiX, iiY)
                                if not pPlot2.isNone():
                                    for i in xrange(pPlot2.getNumUnits()):
                                        pUnit = pPlot2.getUnit(i)
                                        if pUnit.getTeam() == iTeam:
                                            continue
                                        elif pUnit.isHiddenNationality():
                                            bBoard = False
                                            break
                                        elif pTeam.isAtWar(pUnit.getTeam()):
                                            bBoard = False
                                            break
                    if bBoard:
                        if CyGame().getSorenRandNum(100, "Something Completely Different for "+ str(pCaster.getName())) < 2*pCaster.getLevel():
                            bImmortal = pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'))
                            cf.makeMortal(pCaster)
                            iPlayer = pCaster.getOwner()
                            CyInterface().addMessage(iPlayer, True, 25, localText.getText("TXT_KEY_SOMETHING", ()), '', 1, 'Art/Interface/Buttons/Units/Adventurer.dds', ColorTypes(7), iX, iY, True, True)
                            pPlayer = gc.getPlayer(iPlayer)
                           
                            bFoxmenHero = False
                            if pCaster.getReligion() == gc.getInfoTypeForString('RELIGION_FOXMEN'):
                                if pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DIVINE')):
                                    #if pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_AFFINITY_AIR')):
                                    bFoxmenHero = True

                            iUnitCombat = pCaster.getUnitCombatType()
                            if iUnitCombat == gc.getInfoTypeForString('UNITCOMBAT_DISCIPLE'):
                                for sProm in [
                                                'PROMOTION_DIVINE',
                                                'PROMOTION_ZEAL',
                                                'PROMOTION_INQUISITOR',
                                                'PROMOTION_EVANGELIST',
                                                'PROMOTION_EREMITE',
                                                'PROMOTION_CROWN_OF_BRILLANCE',
                                                'PROMOTION_EXORCIST',
                                                'PROMOTION_SUNDERED',
                                                'PROMOTION_MAGIC_IMMUNE'

                                                ]:
                                    iProm = gc.getInfoTypeForString(sProm)
                                    if iProm > -1:
                                        if pCaster.isHasPromotion(iProm):
                                            pCaster.setHasPromotion(iProm, False)


                            elif iUnitCombat == gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
                                cf.removeAffinities(pCaster, True)
                                for sProm in [
                                                'PROMOTION_CHANNELING1',
                                                'PROMOTION_CHANNELING2',
                                                'PROMOTION_CHANNELING3',
                                                'PROMOTION_CHANNELING4',

                                                'PROMOTION_MASTERY',
                                                'PROMOTION_ARCANE',
                                                'PROMOTION_SUMMONER',
                                                'PROMOTION_SUNDERED'

                                                ]:
                                    iProm = gc.getInfoTypeForString(sProm)
                                    if iProm > -1:
                                        if pCaster.isHasPromotion(iProm):
                                            pCaster.setHasPromotion(iProm, False)
                                            info = gc.getPromotionInfo(iProm)

                                            iBonus = info.getBonusPrereq()
                                            if iBonus != -1:
                                                if gc.getBonusInfo(iBonus).isMana():

                                                    iSpell2 = info.getPrereqPromotion()#Normal Mage tier spell
                                                    if iSpell2 != -1:
                                                        iMana = gc.getPromotionInfo(iSpell2).getBonusPrereq()
                                                        if iMana != -1:
                                                            pCaster.setHasPromotion(iSpell2, True)
                                                            info = gc.getPromotionInfo(iSpell2)
                                                            iSpell1 = info.getPrereqPromotion()#Normal Mage tier spell
                                                            if iSpell1 != -1:
                                                                iMana = gc.getPromotionInfo(iSpell1).getBonusPrereq()
                                                                if iMana != -1:
                                                                    pCaster.setHasPromotion(iSpell1, True)

                            iUnit = gc.getInfoTypeForString('UNIT_ADVENTURER')


                            newUnit = pPlayer.initUnit(iUnit, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
                            for iProm in xrange(gc.getNumPromotionInfos()):
                                if newUnit.isHasPromotion(iProm) and not pCaster.isHasPromotion(iProm):
                                    newUnit.setHasPromotion(iProm, False)
                            newUnit.setPromotionReady(False)
                            newUnit.convert(pCaster)
                            newUnit.changeExperience(-newUnit.getLevel(), -1, False, False, False)
                            if bImmortal:
                                newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), True)
                            if bFoxmenHero:
                                #newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_AFFINITY_AIR'), True)
                                newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FAIR_WINDS'), True)
                                newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DIVINE'), True)
The random spell spheres for arcane units is determined randomly based on your effective supply of mana, which is the atual supply of mana plus bonuses or penalties based on player religion, alignment, unit religion, resources on the plot, civ type, leader type, etc. Most of that can be seen from the +x or -y that appears next to the actual mana count on the main screen, but unit specific bonuses do not.

The rather complicated code is here:
Spoiler :
CvEventManager.py
Code:
        elif iPromotion == iChanneling1:
            if pUnit.getRace() != gc.getInfoTypeForString('PROMOTION_PUPPET'):
    ##            if iUnitCombat == gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
                listWeightedAffinities = []
                listAffinities = [    gc.getInfoTypeForString('PROMOTION_AIR1'),
                                    gc.getInfoTypeForString('PROMOTION_BODY1'),
                                    gc.getInfoTypeForString('PROMOTION_CHAOS1'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_CREATION'),
                                    # gc.getInfoTypeForString('PROMOTION_DEATH_ARAWN1'),
                                    # gc.getInfoTypeForString('PROMOTION_DEATH1'),
                                    gc.getInfoTypeForString('PROMOTION_DIMENSIONAL1'),
                                    gc.getInfoTypeForString('PROMOTION_EARTH1'),
                                    gc.getInfoTypeForString('PROMOTION_ENCHANTMENT1'),
                                    gc.getInfoTypeForString('PROMOTION_ENTROPY1'),
                                    gc.getInfoTypeForString('PROMOTION_FIRE1'),
                                    gc.getInfoTypeForString('PROMOTION_FORCE1'),
                                    gc.getInfoTypeForString('PROMOTION_ICE1'),
                                    gc.getInfoTypeForString('PROMOTION_LAW1'),
                                    gc.getInfoTypeForString('PROMOTION_LIFE1'),
                                    gc.getInfoTypeForString('PROMOTION_METAMAGIC1'),
                                    gc.getInfoTypeForString('PROMOTION_MIND1'),
                                    gc.getInfoTypeForString('PROMOTION_NATURE1'),
                                    gc.getInfoTypeForString('PROMOTION_SHADOW1'),
                                    gc.getInfoTypeForString('PROMOTION_SPIRIT1'),
                                    gc.getInfoTypeForString('PROMOTION_SUN1'),
                                    gc.getInfoTypeForString('PROMOTION_WATER1')
                                    ]

                if pPlayer.isFullMember(gc.getInfoTypeForString('DIPLOVOTE_OVERCOUNCIL')):
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_DEATH_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_DEATH1') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_DEATH1'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_ENTROPY_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_ENTROPY1') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_ENTROPY1'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_SHADOW_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_SHADOW1') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_SHADOW1'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_DIMENSIONAL_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_DIMENSIONAL1') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_DIMENSIONAL1'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_CHAOS_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_CHAOS1') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_CHAOS1'))
                elif pPlayer.isFullMember(gc.getInfoTypeForString('DIPLOVOTE_UNDERCOUNCIL')):
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_SUN_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_SUN1') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_SUN1'))

                lAlignment = [pPlayer.getAlignment(), cf.getUnitAlignment(pUnit, False)]

                if iCiv == iSidar or pUnit.getReligion() == iCabal or gc.getInfoTypeForString('ALIGNMENT_GOOD') in lAlignment:
                    if gc.getInfoTypeForString('PROMOTION_DEATH1') in listAffinities:
                        listAffinities.remove(gc.getInfoTypeForString('PROMOTION_DEATH1'))
                elif gc.getInfoTypeForString('ALIGNMENT_EVIL') in lAlignment:
                    if gc.getInfoTypeForString('PROMOTION_DEATH_ARAWN1') in listAffinities:
                        listAffinities.remove(gc.getInfoTypeForString('PROMOTION_DEATH_ARAWN1'))

                if iCiv == iSidar or pUnit.getReligion() == iCabal or pUnit.getRace() == gc.getInfoTypeForString('PROMOTION_GREY'):
                    listAffinities.append(gc.getInfoTypeForString('PROMOTION_DEATH_ARAWN1'))

                if isWorldUnitClass(pUnit.getUnitClassType()):
                    for iProm in listAffinities:
                        if not pUnit.isHasPromotion(iProm):
                            if gc.getUnitInfo(pUnit.getUnitType()).getFreePromotions(iProm):
                                pUnit.setHasPromotion(iAffinity, True)
                                self.onUnitPromoted([pUnit, iAffinity])
                    listAffinities = []

                iNumSpheres = 1
                if CyGame().getSorenRandNum(6, "Petrarch "+str(pUnit.getID())) < 1:
                    iNumSpheres = 2
                for iAffinity in listAffinities:
                    if pUnit.isPromotionImmune(iAffinity):
                        continue
                    elif pUnit.isHasPromotion(iAffinity):
                        iNumSpheres -= 1
                        if iNumSpheres < 1:
                            break
                    else:
                        infoAffinity = gc.getPromotionInfo(iAffinity)
                        iMana = infoAffinity.getBonusPrereq()
                        for i in range(cf.getNumBonusEffective(iPlayer, iMana, pUnit)):
                            listWeightedAffinities.append(iAffinity)
                for i in range(iNumSpheres):
                    if len(listWeightedAffinities) > 0:
                        iAffinity = listWeightedAffinities.pop(CyGame().getSorenRandNum(len(listWeightedAffinities), "Affinity-Channeling1 " + str(pUnit.getID())))
                        pUnit.setHasPromotion(iAffinity, True)
                        self.onUnitPromoted([pUnit, iAffinity])

        elif iPromotion == iChanneling2:
            if pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
                listWeightedAffinities = []
                listAffinities = [    gc.getInfoTypeForString('PROMOTION_AFFINITY_AIR'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_BODY'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_CHAOS'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_CREATION'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH_ARAWN'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_DIMENSIONAL'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_EARTH'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_ENCHANTMENT'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_ENTROPY'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_FIRE'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_FORCE'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_ICE'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_LAW'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_LIFE'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_METAMAGIC'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_MIND'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_NATURE'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_SHADOW'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_SPIRIT'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_SUN'),
                                    gc.getInfoTypeForString('PROMOTION_AFFINITY_WATER')
                                    ]

                if pPlayer.isFullMember(gc.getInfoTypeForString('DIPLOVOTE_OVERCOUNCIL')):
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_DEATH_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_ENTROPY_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_AFFINITY_ENTROPY') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_ENTROPY'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_SHADOW_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_AFFINITY_SHADOW') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_SHADOW'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_DIMENSIONAL_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_AFFINITY_DIMENSIONAL') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_DIMENSIONAL'))
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_CHAOS_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_AFFINITY_CHAOS') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_CHAOS'))
                elif pPlayer.isFullMember(gc.getInfoTypeForString('DIPLOVOTE_UNDERCOUNCIL')):
                    if CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_SUN_MANA')):
                        if gc.getInfoTypeForString('PROMOTION_AFFINITY_SUN') in listAffinities:
                            listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_SUN'))
                lAlignment = [pPlayer.getAlignment(), cf.getUnitAlignment(pUnit, False)]
                if iCiv == iSidar or pUnit.getReligion() == iCabal or gc.getInfoTypeForString('ALIGNMENT_GOOD') in lAlignment:
                    if gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH') in listAffinities:
                        listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH'))
                elif gc.getInfoTypeForString('ALIGNMENT_EVIL') in lAlignment:
                    if gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH_ARAWN') in listAffinities:
                        listAffinities.remove(gc.getInfoTypeForString('PROMOTION_AFFINITY_DEATH_ARAWN'))

                if isWorldUnitClass(pUnit.getUnitClassType()):
                    for iProm in listAffinities:
                        if not pUnit.isHasPromotion(iProm):
                            if gc.getUnitInfo(pUnit.getUnitType()).getFreePromotions(iProm):
                                pUnit.setHasPromotion(iAffinity, True)
                                self.onUnitPromoted([pUnit, iAffinity])
                    listAffinities = []

                iNumSpheres = 1
                if CyGame().getSorenRandNum(6, "Petrarch "+str(pUnit.getID())) < 1:
                    iNumSpheres = 2
                for iAffinity in listAffinities:
                    if pUnit.isPromotionImmune(iAffinity):
                        continue
                    elif pUnit.isHasPromotion(iAffinity):
                        iNumSpheres -= 1
                        if iNumSpheres < 1:
                            break
                    else:
                        infoAffinity = gc.getPromotionInfo(iAffinity)
                        iMana = infoAffinity.getBonusPrereq()
                        for i in range(cf.getNumBonusEffective(iPlayer, iMana, pUnit)):
                            listWeightedAffinities.append(iAffinity)

                for i in range(iNumSpheres):
                    if len(listWeightedAffinities) > 0:
                        iAffinity = listWeightedAffinities.pop(CyGame().getSorenRandNum(len(listWeightedAffinities), "Affinity-Channeling2 "+ str(pUnit.getID())))
                        pUnit.setHasPromotion(iAffinity, True)
                        self.onUnitPromoted([pUnit, iAffinity])
CustomFunctions.py
Code:
    def getNumBonusEffective(self, iPlayer, iBonus, unit=-1):
        return gc.getPlayer(iPlayer).getNumAvailableBonuses(iBonus) + self.getNumSupplimentalMana(iPlayer, iBonus, unit)

    def getNumSupplimentalMana(self, iPlayer, iBonus, unit=-1):
        iNum = 0
        if gc.getBonusInfo(iBonus).isMana():
            if PyHelpers.PyGame().doesBuildingExist(gc.getInfoTypeForString('BUILDING_CRUCIBLE')):

                if gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    if not PyHelpers.PyGame().doesBuildingExist(gc.getInfoTypeForString('BUILDING_FANE_OF_FATE')):
                        return 0
                elif gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    if not PyHelpers.PyGame().doesBuildingExist(gc.getInfoTypeForString('UNIT_FOUNDRY_OF_VENGEANCE')):
                        return 0
                elif gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    if not PyHelpers.PyGame().doesBuildingExist(gc.getInfoTypeForString('UNIT_DOCKS_OF_DREAMS')):
                        return 0
                elif gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    if not PyHelpers.PyGame().doesBuildingExist(gc.getInfoTypeForString('UNIT_CATHEDRAL_OF_VENGEANCE')):
                        return 0
                else:
                    return 0
            iNum += self.getNumSupplimentalManaPlayer(iPlayer, iBonus)
            if unit != -1:
                iNum += self.getNumSupplimentalManaUnit(iBonus, unit)
        return iNum


    def getNumSupplimentalManaUnit(self, iBonus, unit):
        iNum = 0

        iPrereq = gc.getUnitInfo(unit.getUnitType()).getPrereqAndBonus()
        if iPrereq == iBonus:
            iNum += 3
        elif iPrereq != -1 and unit.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
            iNum = -21
            return iNum

        pPlot = unit.plot()
        pArea = unit.area()
        iTeam = unit.getTeam()
        if iBonus == pPlot.getBonusType(iTeam):
            iNum += 7

        for iProm in xrange(gc.getNumPromotionInfos()):
            if unit.isHasPromotion(iProm):
                if gc.getPromotionInfo(iProm).getBonusPrereq() == iBonus:
                    iNum += abs(gc.getPromotionInfo(iProm).getAIWeight()//50)

        if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ADVENTURER')):
            if iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                iNum += 1


        iRace = unit.getRace()
        if iRace != -1:
            if iRace == gc.getInfoTypeForString('PROMOTION_ELF'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_NATURE'):
                    iNum += 1
            elif iRace == gc.getInfoTypeForString('PROMOTION_DWARF'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_EARTH'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                    iNum -= 1
            elif iRace == gc.getInfoTypeForString('PROMOTION_UNDEAD'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum -= 3
            elif iRace == gc.getInfoTypeForString('PROMOTION_DEMON'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    iNum -= 1
            elif iRace == gc.getInfoTypeForString('PROMOTION_ANGEL'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ICE'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    iNum -= 1



        iRel = unit.getReligion()
        if iRel != -1:
            if iRel == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    iNum += 3
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FORCE'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    # iNum += 1

                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    iNum -= 7
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_NATURE'):
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    iNum += 3

                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    # iNum += 1


                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW'):
                    iNum -= 7

                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ICE'):
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_EARTH'):
                    iNum += 3
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    # iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                    iNum -= 7
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    iNum -= 3

            elif iRel == gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_NATURE'):
                    iNum += 3
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    # iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ICE'):
                    iNum -= 7
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum -= 3

            elif iRel == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    iNum += 2
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum -= 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW'):
                    iNum += 3
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    # iNum += 1
                # elif iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    # iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    iNum -= 7
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum += 1

                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    iNum -= 7
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    iNum -= 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_CULT_OF_THE_DRAGON'):
                pPlayer = gc.getPlayer(unit.getOwner())
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_BLOOD')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_CORAL')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_DAWN')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FORCE'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_ELDER')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_FEATHERED')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_ACHERON')):
                        iNum += 6
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_GRAVE')):
                        iNum += 3
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRACOLICH')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_GOLD')):
                        iNum += 3
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_EURABATRES')):
                        iNum += 7
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_OBSIDIAN')):
                        iNum += 3
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_ABASHI')):
                        iNum += 6
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_PIT')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_RUNE')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_SCALED')):
                        iNum += 3
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_THALATTH')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_NATURE'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_SEED')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_SHADOW')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_SHIELD')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_SHIMMERING')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_SIEGE')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_SPIRE')):
                        iNum += 3
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_VAULT_WYRM')):
                        iNum += 3
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_THALATTH')):
                        iNum += 2
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ICE'):
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRAGON_WINTER')):
                        iNum += 3
                    if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DRIFA')):
                        iNum += 4


            elif iRel == gc.getInfoTypeForString('RELIGION_WHITE_HAND'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_ICE'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_EARTH'):
                    # iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_NATURE'):
                    iNum -= 2
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_MATRONAE'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum += 3
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    iNum += 3
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    iNum += 3
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum += 1

            elif iRel == gc.getInfoTypeForString('RELIGION_CHILDREN_OF_THE_ONE'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_FORCE'):
                    iNum += 3
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum += 2
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    iNum += 1
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    iNum += 1
            elif iRel == gc.getInfoTypeForString('RELIGION_UNBLEMISHED'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    # iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    # iNum += 1
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_NATURE'):
                    iNum += 1


            elif iRel == gc.getInfoTypeForString('RELIGION_LAERAN_CORD'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    # iNum += 1

            elif iRel == gc.getInfoTypeForString('RELIGION_BROTHERHOOD_OF_WARDENS'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_FORCE'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    # iNum += 1
            elif iRel == gc.getInfoTypeForString('RELIGION_FOXMEN'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                    iNum += 3
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_EARTH'):
                    iNum -= 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    # iNum += 1
            elif iRel == gc.getInfoTypeForString('RELIGION_COVEN'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    # iNum -= 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    # iNum -= 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    # iNum += 1
            elif iRel == gc.getInfoTypeForString('RELIGION_STEWARDS_OF_INEQUITY'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'):
                    # iNum -= 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_FORCE'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    # iNum += 1
            elif iRel == gc.getInfoTypeForString('RELIGION_ANOINTED'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    # iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    # iNum += 1



            elif iRel == gc.getInfoTypeForString('RELIGION_SONS_OF_DISCORD'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    # iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_BODY'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                    # iNum += 1
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    iNum -= 3
            elif iRel == gc.getInfoTypeForString('RELIGION_EMBER_LEGION'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    # iNum += 2
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_LAW'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    # iNum += 1
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    iNum -= 3
            elif iRel == gc.getInfoTypeForString('RELIGION_ETERNAL_CABAL'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_WATER'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ICE'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    # iNum += 1
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum += 1
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum -= 3
            elif iRel == gc.getInfoTypeForString('RELIGION_RINGGIVER'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_EARTH'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    # iNum -= 3
            elif iRel == gc.getInfoTypeForString('RELIGION_HOUSE_OF_PLENTY'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    iNum += 3
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    # iNum += 1
                # if iBonus == gc.getInfoTypeForString('BONUS_MANA_SPIRIT'):
                    # iNum += 1
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY'):
                    iNum -= 3

        else:
            iAlignment = self.getUnitAlignment(unit)
            if iAlignment == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'),
                                gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE')]:
                    iNum += 1
                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                gc.getInfoTypeForString('BONUS_MANA_FORCE')]:
                    iNum -= 1

            elif iAlignment == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL')]:
                    iNum += 1
                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                    gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'),
                                    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                    gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                    gc.getInfoTypeForString('BONUS_MANA_FORCE')]:
                    iNum -= 1



        return iNum

    def getNumSupplimentalManaPlayer(self, iPlayer, iBonus):
        iNum = 0
        pPlayer = gc.getPlayer(iPlayer)
        if gc.getBonusInfo(iBonus).isMana():
            iRel = pPlayer.getStateReligion()
            if iRel == gc.getInfoTypeForString('RELIGION_MATRONAE'):
                if iBonus in [gc.getInfoTypeForString('BONUS_MANA_DEATH'),gc.getInfoTypeForString('BONUS_MANA_FIRE'),gc.getInfoTypeForString('BONUS_MANA_WATER')]:
                    return 21

            if PyHelpers.PyGame().doesBuildingExist(gc.getInfoTypeForString('BUILDING_CRUCIBLE')):
                return 0

            if pPlayer.isBarbarian():
                return CyMap().getNumBonuses(iBonus)

            iOvercouncil = gc.getInfoTypeForString('DIPLOVOTE_OVERCOUNCIL')
            iUndercouncil = gc.getInfoTypeForString('DIPLOVOTE_UNDERCOUNCIL')
            if pPlayer.isFullMember(iOvercouncil):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_DEATH') and CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_DEATH_MANA')):
                    return -pPlayer.getNumAvailableBonuses(iBonus)
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL') and CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_DIMENSIONAL_MANA')):
                    return -pPlayer.getNumAvailableBonuses(iBonus)
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_ENTROPY') and CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_ENTROPY_MANA')):
                    return -pPlayer.getNumAvailableBonuses(iBonus)
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS') and CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_CHAOS_MANA')):
                    return -pPlayer.getNumAvailableBonuses(iBonus)
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW') and CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_SHADOW_MANA')):
                    return -pPlayer.getNumAvailableBonuses(iBonus)
                else:
                    for jPlayer in xrange(gc.getMAX_PLAYERS()):
                        if iPlayer != jPlayer:
                            pPlayer2 = gc.getPlayer(jPlayer)
                            if pPlayer2.isFullMember(iOvercouncil):
                                if pPlayer2.isAlive():
                                    iPatron = self.getPatronSphere(pPlayer2)
                                    if iBonus == iPatron:
                                        iNum += 1

            elif pPlayer.isFullMember(iUndercouncil):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN') and CyGame().isVotePassed(gc.getInfoTypeForString('VOTE_NO_SUN_MANA')):
                    return -pPlayer.getNumAvailableBonuses(iBonus)
                else:
                    for jPlayer in xrange(gc.getMAX_PLAYERS()):
                        if iPlayer != jPlayer:
                            pPlayer2 = gc.getPlayer(jPlayer)
                            if pPlayer2.isFullMember(iUndercouncil):
                                if pPlayer2.isAlive():
                                    iPatron = self.getPatronSphere(pPlayer2)
                                    if iBonus == iPatron:
                                        iNum += 1

            iPatron = self.getPatronSphere(pPlayer)
            if iBonus == iPatron:
                iNum += 1
            if iBonus == self.getOppositeSphere(iPatron):
                iNum -= 2

            iLeader = pPlayer.getLeaderType()
            if iLeader == gc.getInfoTypeForString('LEADER_ALEXIS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH')]:
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    iNum -= 1
            elif iLeader == gc.getInfoTypeForString('LEADER_AMELANCHIER'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_NATURE'),
                                gc.getInfoTypeForString('BONUS_MANA_AIR'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_ANAGANTIOS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_LAW')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_ARENDEL'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_NATURE'),
                                gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_ARTURUS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_EARTH'),
                                gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_AURIC'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_AVERAX'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_BASIUM'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_LIFE'):
                    iNum += 2
            elif iLeader == gc.getInfoTypeForString('LEADER_BEERI'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'),
                                gc.getInfoTypeForString('BONUS_MANA_EARTH')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_BRAEDEN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_WATER')]:
                    iNum += 2
            elif iLeader == gc.getInfoTypeForString('LEADER_CAPRIA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_CARDITH'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                gc.getInfoTypeForString('BONUS_MANA_NATURE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_CASSIEL'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                gc.getInfoTypeForString('BONUS_MANA_FORCE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_CHARADON'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_DAIN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_SUN')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_DECIUS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_DUIN'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_CHAOS'):
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_DUMANNIOS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_EINION'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                gc.getInfoTypeForString('BONUS_MANA_METAMAGIC')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_ETHNE'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE')]:
                    iNum += 1

            elif iLeader == gc.getInfoTypeForString('LEADER_FAERYL'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_NATURE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_FALAMAR'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_AIR'),
                                gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                gc.getInfoTypeForString('BONUS_MANA_WATER')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_FLAUROS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_FURIA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_GARRIM'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'):
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_GOSEA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_SPIRIT')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_HANNAH'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_WATER'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_HAFGAN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_HYBOREM'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_JONAS'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_JUDECCA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                gc.getInfoTypeForString('BONUS_MANA_EARTH')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_KANE'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_KANDROS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_EARTH')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_KEELYN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_KOUN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_LETHE'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_ENTROPY')]:
                    iNum += 1
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS')]:
                    iNum -= 1
            elif iLeader == gc.getInfoTypeForString('LEADER_MALCHAVIC'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_FORCE'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_MAHALA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_MAHON'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_MELISANDRE'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_MERESIN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_ENTROPY')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_OS-GABELLA'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'):
                    iNum += 3
            elif iLeader == gc.getInfoTypeForString('LEADER_OSTANES'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_AIR'):
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_OUZZA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_ENTROPY')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_PERPENTACH'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_RHOANNA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_LAW')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_RIUROS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_AIR')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_RIVANNA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_SABATHIEL'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_FORCE'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_SALLOS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_SANDALPHON'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_SHEELBA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_LAW')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_SHEKINAH'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_STATIUS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_ENTROPY')]:
                    iNum += 1
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY')]:
                    iNum -= 1
            elif iLeader == gc.getInfoTypeForString('LEADER_TASUNKE'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_TEBRYN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_TETHIRA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_SPIRIT')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_THESSA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                gc.getInfoTypeForString('BONUS_MANA_NATURE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_THESSALONICA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_FORCE'),
                                gc.getInfoTypeForString('BONUS_MANA_SPIRIT')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_TYA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_ENTROPY')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_ULDANOR'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_VALLEDIA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW')]:
                    iNum += 1
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    iNum -= 1
            elif iLeader == gc.getInfoTypeForString('LEADER_VARN'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_SUN'):
                    iNum += 2
                elif iBonus == gc.getInfoTypeForString('BONUS_MANA_SHADOW'):
                    iNum -= 2
            elif iLeader == gc.getInfoTypeForString('LEADER_VOLANNA'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE')]:
                    iNum += 1
            elif iLeader == gc.getInfoTypeForString('LEADER_WEEVIL'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_MIND'):
                    iNum += 1


            if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_FALLOW')):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_CREATION'):
                    return -pPlayer.getNumAvailableBonuses(iBonus)


            if iRel == -1:
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_FORCE'):
                    iNum += 1
            elif iRel == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_FORCE'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                    gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                    gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                    gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                    gc.getInfoTypeForString('BONUS_MANA_NATURE'),
                                    gc.getInfoTypeForString('BONUS_MANA_SPIRIT')]:
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                gc.getInfoTypeForString('BONUS_MANA_CREATION')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                    gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                    gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                    gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                    gc.getInfoTypeForString('BONUS_MANA_ICE')]:
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_EARTH'),
                                gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                    gc.getInfoTypeForString('BONUS_MANA_AIR'),
                                    gc.getInfoTypeForString('BONUS_MANA_MIND')]:
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_NATURE'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                gc.getInfoTypeForString('BONUS_MANA_AIR'),
                                gc.getInfoTypeForString('BONUS_MANA_CREATION')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                    gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                    gc.getInfoTypeForString('BONUS_MANA_LAW')]:
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_WATER'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                    gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                    gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT')]:
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                    gc.getInfoTypeForString('BONUS_MANA_FIRE')]:
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                    gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                    gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT')]:
                    iNum -= 1

            elif iRel == gc.getInfoTypeForString('RELIGION_WHITE_HAND'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_WATER'),
                                gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_METAMAGIC')]:
                    iNum += 1

                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                    gc.getInfoTypeForString('BONUS_MANA_NATURE'),
                                    gc.getInfoTypeForString('BONUS_MANA_LIFE')]:
                    iNum -= 1


            iAlignment = pPlayer.getAlignment()
            if iAlignment == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'),
                                gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                gc.getInfoTypeForString('BONUS_MANA_CREATION'),
                                gc.getInfoTypeForString('BONUS_MANA_LIFE')]:
                    iNum += 1
                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                gc.getInfoTypeForString('BONUS_MANA_FORCE')]:
                    iNum -= 1

            elif iAlignment == gc.getInfoTypeForString('ALIGNMENT_NEUTRAL'):
                if iBonus == gc.getInfoTypeForString('BONUS_MANA_FIRE'):
                    iNum -= 1
                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_FORCE'),
                                    gc.getInfoTypeForString('BONUS_MANA_NATURE'),
                                    gc.getInfoTypeForString('BONUS_MANA_AIR'),
                                    gc.getInfoTypeForString('BONUS_MANA_EARTH'),
                                    gc.getInfoTypeForString('BONUS_MANA_WATER'),
                                    gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                    gc.getInfoTypeForString('BONUS_MANA_METAMAGIC')]:
                    iNum += 1
            elif iAlignment == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
                if iBonus in [    gc.getInfoTypeForString('BONUS_MANA_ENTROPY'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_BODY'),
                                gc.getInfoTypeForString('BONUS_MANA_CHAOS'),
                                gc.getInfoTypeForString('BONUS_MANA_DEATH'),
                                gc.getInfoTypeForString('BONUS_MANA_MIND'),
                                gc.getInfoTypeForString('BONUS_MANA_ICE'),
                                gc.getInfoTypeForString('BONUS_MANA_SHADOW'),
                                gc.getInfoTypeForString('BONUS_MANA_FIRE'),
                                gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL')]:
                    iNum += 1
                elif iBonus in [    gc.getInfoTypeForString('BONUS_MANA_SUN'),
                                    gc.getInfoTypeForString('BONUS_MANA_SPIRIT'),
                                    gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'),
                                    gc.getInfoTypeForString('BONUS_MANA_LAW'),
                                    gc.getInfoTypeForString('BONUS_MANA_LIFE'),
                                    gc.getInfoTypeForString('BONUS_MANA_FORCE')]:
                    iNum -= 1

        return iNum


The Grigori don't get 2 sources of each type of mana from their palaces anymore in the newest version. I got rid of that when I added the Monothiest Meetinghouse temple building for the Children of the One.
I think it's a bug - two generals can be attached to 15+ units at the same time.


That is a bug I had not noticed before.


My first few attempts to fix it (adding delayed death checks, checking the req within the spell, etc) did not work.

Ultimately the only thing that did help was restoring a few lines that I had commended out, giving the commander the golem promotion and killing.

At one point I recall I used to apply the commanders promotions, name, religion, etc manually but then found using pCaster.convert(pUnit)worked better. I was thinking killing the unit after pCaster.convert(pUnit) would cause an error as the unit would already be dead by then, but it seems not to have any issues in my test so far.
Spoiler :

Code:
def reqCommanderJoin(pCaster, eSpell=-1, sCommander = 'UNIT_GREAT_GENERAL'):
    iPlayer = pCaster.getOwner()
    pPlot = pCaster.plot()
    if pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_GREAT_GENERAL')):
        return False
    if pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HERO')):
        return False
    if pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ADVENTURER')):
        return False
    if pCaster.getUnitCombatType() in [-1, gc.getInfoTypeForString('UNITCOMBAT_CIVILIAN')]:
        return False

    if -1 < pCaster.getScenarioCounter() < gc.getNumUnitInfos():#Joining Decius to a hero could make that hero impossible to resurrect
        return False

    if isWorldUnitClass(pCaster.getUnitClassType()):
        return False


    iIllusion = gc.getInfoTypeForString('PROMOTION_ILLUSION')
    iReflection = gc.getInfoTypeForString('PROMOTION_DARK_REFLECTION')

    iCommander = gc.getInfoTypeForString(sCommander)
    pCommander = -1
    for i in xrange(pPlot.getNumUnits()):
        pUnit = pPlot.getUnit(i)
        if iPlayer == pUnit.getOwner():
            if pUnit.getRace() in [iIllusion,iReflection]:
                continue
            if pUnit.getUnitType() == iCommander:
                pCommander = pUnit
                break
    if pCommander == -1:
        return False
    if pCommander.isDelayedDeath():
        return False
    if pCommander.isHasCasted():
        return False
    if not pCaster.isHuman():
        if pCaster.baseCombatStr() < 5:
            return False
    return True

def spellCommanderJoin(pCaster, eSpell=-1):
    # if reqCommanderJoin(pCaster):
    iPlayer = pCaster.getOwner()
    pPlayer = gc.getPlayer(iPlayer)
    pPlot = pCaster.plot()
    iCommander = gc.getInfoTypeForString('UNITCLASS_GREAT_GENERAL')

    iIllusion = gc.getInfoTypeForString('PROMOTION_ILLUSION')
    iReflection = gc.getInfoTypeForString('PROMOTION_DARK_REFLECTION')
    pCommander = -1
    for i in xrange(pPlot.getNumUnits()):
        pUnit = pPlot.getUnit(i)
        if iPlayer == pUnit.getOwner():
            if pUnit.getUnitClassType() == iCommander:
                if pUnit.getRace() in [iIllusion,iReflection]:
                    continue
                if pUnit.isDelayedDeath():
                    continue
                pCaster.convert(pUnit)
                pCommander = pUnit
                pCommander.setHasPromotion(gc.getInfoTypeForString('PROMOTION_GOLEM'), True)
                pCommander.kill(False, PlayerTypes.NO_PLAYER)
                break


def helpCommanderJoin(lpUnits, eSpell):
    szBuffer = ''
    if len(lpUnits) ==1:
        pCaster = lpUnits[0]
        pPlot = pCaster.plot()
        iPlayer = pCaster.getOwner()
        iCommander = gc.getInfoTypeForString('UNITCLASS_GREAT_GENERAL')

        iIllusion = gc.getInfoTypeForString('PROMOTION_ILLUSION')
        iReflection = gc.getInfoTypeForString('PROMOTION_DARK_REFLECTION')
        for i in xrange(pPlot.getNumUnits()):
            pUnit = pPlot.getUnit(i)
            if iPlayer == pUnit.getOwner():
                if pUnit.getRace() in [iIllusion,iReflection]:
                    continue
                if pUnit.getUnitClassType() == iCommander:
                    if pUnit.isDelayedDeath():continue
                    szBuffer += '\n' + localText.getText("TXT_KEY_RENAME_UNIT", ()) + pUnit.getNameNoDesc()
                    lPerks = []
                    for iProm in xrange(gc.getNumPromotionInfos()):
                        if pUnit.isHasPromotion(iProm):
                            if not pCaster.isHasPromotion(iProm):
                                lPerks.append(iProm)

                    lPerks = list(set(lPerks))
                    iCount = len(lPerks)
                    sAdd = localText.getText("TXT_KEY_HELP_SPELL_ADDS", ())
                    if iCount > 0:
                        if iCount == 1:
                            szBuffer += sAdd + CyGameTextMgr().getPromotionHelp(lPerks.pop(0), False)
                        else:
                            sList = ''
                            while len(lPerks) > 0:
                                szBuffer += sAdd + CyGameTextMgr().getPromotionHelp(lPerks.pop(0), False)
                                if len(lPerks) > 0:
                                    if len(lPerks) == 1:
                                        szBuffer += " and "
                                    else:
                                        szBuffer += ", "
                    break
    szBuffer += helpTogglePromotionsBuffCaster(lpUnits, eSpell, ['PROMOTION_GREAT_GENERAL'], [], False)
    return szBuffer
 
An Aquilan in the early game does seem quite odd. The only ways I can think of an Aquilan showing other than being summoned by a High Priest of the Hand (or the high priest versions of Anagantios, Riuros, or Dumannios), in which case they would have limited duration, is being spawned by the doFlareDimensionalNode random event. That can only happen on a tile with either a Dimensiona Node or a Planar Gate. Are there more advanced players in the game who might have built a Dimensional Node or Planar Gate?

The only dimensional mana I can see in worldbuilder are the soul gates and tapestry house, so I don't think it can be that. The Sheaim got defeated quite a long time ago in my game. Worldbuilder records show that they did manage to research Knowledge of the Ether, and its prerequisites. They didn't manage to research anything else so this must have been pretty near their demise, but perhaps they managed to finish the planar gate, got stupidly unlucky and immediately had the Aquilan show up and wipe them out?

Edit: Wait, no, the Sheaim are apparently still around. I guess they came back thanks to a revolution. And they're across the water in the direction the Aquilan came from.
 
Last edited:
Is there any way to see which religions are hostile to others for the purpose of temples? Such as which state religions would turn any Fenestrian Temple hostile.
You could look at the code
Spoiler :
Code:
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_EMPYREAN')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_EMPYREAN_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN') or pPlayer.isFullMember(gc.getInfoTypeForString('DIPLOVOTE_OVERCOUNCIL')) or iAlignment == iGood

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_BROTHERHOOD')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_BROTHERHOOD_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_BROTHERHOOD_OF_WARDENS') or pPlayer.isCivic(gc.getInfoTypeForString('CIVIC_PACIFISM')) or iAlignment == iGood

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_ARTIFICERY')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_ARTIFICERY_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_RINGGIVER') or iAlignment == iGood or pPlayer.isCivic(gc.getInfoTypeForString('CIVIC_ARETE'))

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_ORDER')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_ORDER_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ORDER') or iAlignment == iGood

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_UNBLEMISHED')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_UNBLEMISHED_HOSTILE')
        bFriendly = pPlayer.getStateReligion() in [gc.getInfoTypeForString('RELIGION_UNBLEMISHED'),gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES')] or iAlignment == iGood

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_KILMORPH')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_KILMORPH_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH') or (iAlignment != iEvil and pPlayer.getStateReligion() != gc.getInfoTypeForString('RELIGION_FOXMEN'))

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_OVERLORDS')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_OVERLORDS_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS') or iAlignment != iGood

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_STEWARDS_OF_INEQUITY') or iAlignment != iGood

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)

        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_ANOINTED')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_ANOINTED_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_ANOINTED') or iAlignment == iEvil

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_VEIL')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_VEIL_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL') or iAlignment == iEvil

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TOPHET')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TOPHET_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_EMBER_LEGION') or iAlignment == iEvil

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_INTERSTICE')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_INTERSTICE_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_COVEN') or  (iAlignment == iEvil and pCity.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_CALABIM'))

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)
                    
        iTempleFriendly = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_HAND')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_HAND_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_WHITE_HAND')
        if gc.getGame().getProjectCreatedCount(gc.getInfoTypeForString('PROJECT_THE_DRAW')) > 0:
            iAuricPlayer = cf.getLeader(gc.getInfoTypeForString('LEADER_AURIC'))
            if iAuricPlayer != -1:
                pAuricPlayer = gc.getPlayer(iAuricPlayer)
                if pAuricPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_AURIC')) > 0:
                    iTeam = pPlayer.getTeam()
                    eTeam = gc.getTeam(iTeam)
                    iAuricTeam = pAuricPlayer.getTeam()
                    if iAuricTeam == iTeam:
                        bFriendly = True
                    elif eTeam.isVassal(iTeam):
                        bFriendly = True
                    elif eTeam.isAtWar(iAuricTeam):
                        bFriendly = False

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)

        iTempleFriendly = gc.getInfoTypeForString('BUILDING_APHOTIC_THRONE')
        iTempleHostile = gc.getInfoTypeForString('BUILDING_APHOTIC_THRONE_HOSTILE')
        bFriendly = pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS') or pPlayer.isFullMember(gc.getInfoTypeForString('DIPLOVOTE_UNDERCOUNCIL')) or iAlignment == iEvil

        if pCity.getNumBuilding(iTempleFriendly) > 0 or pCity.getNumBuilding(iTempleHostile) > 0:
            pCity.setNumRealBuilding(iTempleHostile, not bFriendly)
            pCity.setNumRealBuilding(iTempleFriendly, bFriendly)
        else:
            iProduction = pCity.getBuildingProduction(iTempleFriendly) + pCity.getBuildingProduction(iTempleHostile)
            if iProduction > 0:
                if bFriendly:
                    pCity.setBuildingProduction(iTempleFriendly, iProduction)
                    pCity.setBuildingProduction(iTempleHostile, 0)
                else:
                    pCity.setBuildingProduction(iTempleHostile, iProduction)
                    pCity.setBuildingProduction(iTempleFriendly, 0)

        if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_PLANAR_GATE')) > 0:
            if not pCity.hasBonus(gc.getInfoTypeForString('BONUS_MANA_DIMENSIONAL')):
                pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_PLANAR_GATE'), False)
                pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_PLANAR_GATE_CLOSED'), True)

Or wait until the next release when I intend to pedia and mouseovers for the temples and religions to make it clear in game. (I had intended to do that before the last release but it somehow slipped by mind.)


In case you cannot read the code and don't want to wait, I'll summarize it here.

The Empyrean's Fenestran Temple will be hostile unless you have the Empyrean State religion, or a Good alignment, or join the Overcouncil.

The Brotherhood of Warden's Safehouse will be hostile unless you have the Brotherhood of wardens State religion, or Good alignment, or the Pacifism civic.

(Note that this does not apply to the Calabim, for whom both versions of the Safehouse are replaced by the Almshouse unique building, since the heterodox Blinded Brotherhood are welcomed there but the Orthodox Wardens who try to fight injustice instead of teaching absolute submission are not. I am thinking of changing this so that other player's Rescuers can found hostile Safehouses in Calabim cities unless the Calabim build an Almshouse there. Note that the Rescue Refugees spell should always be able to be used in cities with a hostile Safehouse, whereas without a safehouse it depends on factors like the current level of hurry anger.)

The Ringgivers's Artificery will be hostile unless you have the Ringgivers State religion, or Good alignment, or the Arete civic (which requires either Runes of Kilmorph or Ringgivers state religion).

The Order's Basilica will be hostile unless you have the Order State religion or Good alignment.

The Unblemished's Healing Garden will be hostile unless you have the Unblemished or Fellowship of the Leaves State religion or Good alignment.

The Rune of Kilmorph's Kilmorphian Grotto will be hostile unless you have the Rune of Kilmorph State religion or a non-Evil alignment and not the Foxmen state religion.

The Undertow's Asylum will be hostile unless you have the Undertow state religion or a non-Good alignment.

The Steward of Inequity's Gambling House will be hostile unless you have the The Steward of Inequity state religion or a non-Good alignement.

The Annointed's Abattoir will be hostile unless you have The Annointed as state religion or the Evil alignment.

The Ember Legion's Tophet will be hostile unless you have The Ember Legion as state religion of the evil alignment.

The Between Coven's Interstice will be hostile unless you have the Coven as you state religion or have the evil alignment and are not Calabim (since they are canonically very much at odds with Ceridwen's other cult called the Chainbreakers, which is merged with The Between and Emrys in my modmod.)

The White Hand's Temple of the Hand will be hostile unless you have the White hand state religion or are a teammate of vassal of Auric Ulvin after the completion of The Draw ritual.

The Council of Esus's Aphotic Throne will be hostile unless you have the Council of Esus state religion, or the evil alignment, or are a member of the Undercouncil.


The other temples do not currently have hostile versions.

I may decide to tweak these prereqs in the next version.
 
hey! great mod, but im running into an issue - as Lanun, my pirate coves are not upgrading at all. The upgrade timer runs down, and on the turn they're supposed to upgrade, it gives the "needs to be worked" note and then on the next turn the upgrade timer starts over. I have checked - the city is working those tiles, I have warriors and boats stationed on those tiles, and I can't even place upgraded harbors/ports in the worldbuilder - it just places a cove instead.
 
Last edited:
Do you have any plan to update the "KE huge ICE Empires" map (the one with the civs already spread across Erebus, the Mercurians and Infernals summoned, etc) at some point? I'd be interested in your choice of location for the new resources and Unique Features you've introduced so that I may update the unsettled version of the map in turn. Alternatively, just the general location you'd choose for them would be interesting.

Semi-related: I've noticed that in pre-made scenarios, Dragon Bones seem to reload a random choice of mana every time a new game is started. Is there a way to stop this from happening?
 
I think i found 2 bugs with Auric Ulvin, and i dont know if they are related. First of, Auric spawns with only "channeling" 2 and 3. Every time he levels up, i have the option to take "channeling 1", with does nothing (you just waste the level). Second, Auric starts with no affinity, and gets an affinity (TEMPORARILY) based on the mana he stands on (see attached screen shot). I do not have entropic mana, but still, he gets entropic affinity. If i move to any tile without entropic mana, he loses it, same as every other mana tile he stands on.
 

Attachments

  • Civ4ScreenShot0000.jpg
    Civ4ScreenShot0000.jpg
    763.4 KB · Views: 44
Last edited:
There's also a bug with commanders. If you build a unit and this unit has free promotions, "attaching" a commander without picking the promotions will make them vanish, making your unit vanilla (i know this can be edited with ctrl+w, but it is not, try it in game).
 

Attachments

  • Civ4ScreenShot0001.png
    Civ4ScreenShot0001.png
    4.6 MB · Views: 907
There's a typo, as the Temple for the One should be called Monotheist Meeting House rather than Monothiest. Nevertheless, truly great work, I really enjoy this modmod which has kept FfH alive for so many, many years!
 
hey! great mod, but im running into an issue - as Lanun, my pirate coves are not upgrading at all. The upgrade timer runs down, and on the turn they're supposed to upgrade, it gives the "needs to be worked" note and then on the next turn the upgrade timer starts over. I have checked - the city is working those tiles, I have warriors and boats stationed on those tiles, and I can't even place upgraded harbors/ports in the worldbuilder - it just places a port instead.

This seems to have resolved itself. I think maybe it's tied to techs? But if there is a tech requirement it's not listed anywhere I've seen.

Also, is The Draw a particularly reosurce/script heavy ritual? This has been awhile and on the previous version but when it finished the game hangs but doesn't freeze (spinning globe forever). What's odd is that I see everyone else declare war on me and a few cpu actions complete before it hangs.
 
Last edited:
The second Auric thing isn't a bug, the tile that he is standing on gives entropy mana, the side bar does not matter for him. And yes, the draw causes everyone who is not teamed or vassaled with auric to dec war on you, this is a big AI tax as the AI starts casting spells everywhere. You could stop a bunch of the casting lag if you could somehow make the interturn go full fog so the game doesn't load the spell effects and sound off screen from tiles you have vision on but are not focused.
 
There's an Old Bug: enemy Shades attacking tiles with civilian units destroy them.
The Shades have 0 attack and invisibility, and my workers disappeared without messages.
MagisterCultuum, when to expect a new version of mod? I hope not in a year.
==========
SPELL_BREATH_LIGHT spell does not give effects to own team, it should be?
 
Last edited:
Back
Top Bottom