How to handle lair explorations in python?

Onionsoilder

Reaver
Joined
Mar 19, 2007
Messages
3,173
I've been working on a modmod which, among other things, adds 5 new magical items. I have all the XML work done with the item promotion, picking up the item, etc., but I'm having trouble with adding them into the possible outcomes of lair exploration. I've been messing around with CustomFunctions.py, and added the code in bold below:

Code:
    def exploreLairBigGood(self, caster):
        iPlayer = caster.getOwner()
        pPlot = caster.plot()
        pPlayer = gc.getPlayer(caster.getOwner())

        lList = ['TREASURE_VAULT', 'GOLDEN_AGE']
        if pPlayer.canReceiveGoody(pPlot, gc.getInfoTypeForString('GOODY_GRAVE_TECH'), caster):
            lList = lList + ['TECH']
        if not pPlot.isWater():
            lList = lList + ['ITEM_JADE_TORC', [B]'ITEM_ALSOPHOCUS_TOME', 'ITEM_MARTYR_CROWN', 'ITEM_LIFESAPPER', 'ITEM_PRESERVER', 'ITEM_SEVEN_LEAGUE'[/B], 'ITEM_ROD_OF_WINDS', 'ITEM_TIMOR_MASK', 'PRISONER_ADVENTURER', 'PRISONER_ARTIST', 'PRISONER_COMMANDER', 'PRISONER_ENGINEER', 'PRISONER_MERCHANT', 'PRISONER_PROPHET', 'PRISONER_SCIENTIST']
            if pPlot.getBonusType(-1) == -1:
                lList = lList + ['BONUS_MANA']
                if pPlayer.isHasTech(gc.getInfoTypeForString('TECH_MINING')):
                    lList = lList + ['BONUS_COPPER', 'BONUS_GEMS', 'BONUS_GOLD']
                if pPlayer.isHasTech(gc.getInfoTypeForString('TECH_SMELTING')):
                    lList = lList + ['BONUS_IRON']
        if pPlot.isWater():
            lList = lList + ['PRISONER_SEA_SERPENT']
            if pPlot.getBonusType(-1) == -1:
                lList = lList + ['BONUS_CLAM', 'BONUS_CRAB', 'BONUS_FISH']
        if self.grace() == False:
            lList = lList + ['PRISONER_ANGEL', 'PRISONER_MONK', 'PRISONER_ASSASSIN', 'PRISONER_CHAMPION', 'PRISONER_MAGE']
        sGoody = lList[CyGame().getSorenRandNum(len(lList), "Pick Goody")-1]

        if sGoody == 'TREASURE_VAULT':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_TREASURE_VAULT'), caster)
            return 100    
        if sGoody == 'BONUS_CLAM':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_CLAM'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_CLAM",()),'',1,'Art/Interface/Buttons/WorldBuilder/Clam.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'BONUS_COPPER':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_COPPER'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_COPPER",()),'',1,'Art/Interface/Buttons/WorldBuilder/Copper.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'BONUS_CRAB':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_CRAB'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_CRAB",()),'',1,'Art/Interface/Buttons/WorldBuilder/Crab.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'BONUS_FISH':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_FISH'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_FISH",()),'',1,'Art/Interface/Buttons/WorldBuilder/Fish.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'BONUS_GOLD':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_GOLD'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_GOLD",()),'',1,'Art/Interface/Buttons/WorldBuilder/Gold.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'BONUS_GEMS':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_GEMS'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_GEMS",()),'',1,'Art/Interface/Buttons/WorldBuilder/Gems.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'BONUS_IRON':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_IRON'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_IRON",()),'',1,'Art/Interface/Buttons/WorldBuilder/Iron.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'BONUS_MANA':
            pPlot.setBonusType(gc.getInfoTypeForString('BONUS_MANA'))
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_BONUS_MANA",()),'',1,'Art/Interface/Buttons/WorldBuilder/mana_button.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'GOLDEN_AGE':
            pPlayer.changeGoldenAgeTurns(CyGame().goldenAgeLength())
            CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EXPLORE_LAIR_GOLDEN_AGE",()),'',1,'Art/Interface/Buttons/Spells/Explore Lair.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
            return 100
        if sGoody == 'ITEM_JADE_TORC':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_JADE_TORC'), caster)
            return 100
        if sGoody == 'ITEM_ROD_OF_WINDS':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_ROD_OF_WINDS'), caster)
            return 100
        if sGoody == 'ITEM_TIMOR_MASK':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_TIMOR_MASK'), caster)
            return 100
        [B]if sGoody == 'ITEM_ALSOPHOCUS_TOME':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_ALSOPHOCUS_TOME'), caster)
            return 100
        if sGoody == 'ITEM_MARTYR_CROWN':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_MARTYR_CROWN'), caster)
            return 100
        if sGoody == 'ITEM_LIFESAPPER':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_LIFESAPPER'), caster)
            return 100
        if sGoody == 'ITEM_PRESERVER':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_PRESERVER'), caster)
            return 100
        if sGoody == 'ITEM_SEVEN_LEAGUE':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_ITEM_SEVEN_LEAGUE'), caster)
            return 100[/B]
        if sGoody == 'PRISONER_ADVENTURER':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_ADVENTURER'), caster)
            return 100            
        if sGoody == 'PRISONER_ANGEL':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_ANGEL'), caster)
            return 100            
        if sGoody == 'PRISONER_ARTIST':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_ARTIST'), caster)
            return 100
        if sGoody == 'PRISONER_ASSASSIN':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_ASSASSIN'), caster)
            return 100
        if sGoody == 'PRISONER_CHAMPION':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_CHAMPION'), caster)
            return 100
        if sGoody == 'PRISONER_COMMANDER':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_COMMANDER'), caster)
            return 100    
        if sGoody == 'PRISONER_ENGINEER':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_ENGINEER'), caster)
            return 100    
        if sGoody == 'PRISONER_MAGE':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_MAGE'), caster)
            return 100
        if sGoody == 'PRISONER_MERCHANT':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_MERCHANT'), caster)
            return 100    
        if sGoody == 'PRISONER_MONK':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_MONK'), caster)
            return 100            
        if sGoody == 'PRISONER_PROPHET':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_PROPHET'), caster)
            return 100    
        if sGoody == 'PRISONER_SEA_SERPENT':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_SEA_SERPENT'), caster)
            return 100    
        if sGoody == 'PRISONER_SCIENTIST':
            pPlayer.receiveGoody(pPlot,gc.getInfoTypeForString('GOODY_EXPLORE_LAIR_PRISONER_SCIENTIST'), caster)
            return 100
        if sGoody == 'TECH':
            pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_GRAVE_TECH'), caster)
            return 100
        return 100

But it doesn't seem to be working. When I tested it in-game, out of 50 Dungeons I got 4 Timor Masks, 3 Jade Torques, 6 Rod of Winds, an insane amount of Great People and 200 turns worth of Golden Ages, but not a single one of my new items(though I can place the new items via worldbuilder, then pick them up with units, so I know they're in the game).

Anyone knows what I need to do to add these in?
 
you need to modify the XML for the goodies and add GOODY_EXPLORE_LAIR_ITEM_MARTYR_CROWN etc.
 
Top Bottom