1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Merging BUG with other Mods

Discussion in 'Civ4 - BTS Unaltered Gameplay (BUG, BAT and BULL)' started by EmperorFool, Oct 17, 2008.

  1. Seraiel

    Seraiel Deity

    Joined:
    Sep 6, 2011
    Messages:
    7,954
    Gender:
    Male
    Old Games that were played with BUFFY crash when loading while using BULL DLL.

    Other Users seem to have the same problem, they all exchange the DLL's to whether they're playing a Forum game (BUG/BULL) or a HoF / GOTM (BUFFY) .

    Take a look here: http://forums.civfanatics.com/showthread.php?t=450849
     
  2. EmperorFool

    EmperorFool Deity

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    Thanks for the link. Since BUFFY uses its own DLL it seems strange that it would even see the one in the main Assets folder. I know HoF has an assets checker to validate that you're running the correct files. It might be crashing on purpose if the other DLL has been modified.
     
  3. TheMarshmallowBear

    TheMarshmallowBear Benelovent Chieftain of the BearKingdom

    Joined:
    Dec 27, 2006
    Messages:
    7,361
    Location:
    Inside an Ikanda.
    Yo!.... right..

    I wanna know how exactly I add two mods.. since I have absolutely no modding experience. (except changing unit cost/research cost)

    Currently i only have TWO mods I wanna add
    Advanced Diplomacy
    AND
    Plot Capacity ( http://forums.civfanatics.com/showthread.php?t=372716 )

    I have no idea how to add anything, there's no "good" tutorial (the ones prvoided in the first post appears to be HOW to make NEW mods not merging them)

    I'd use RoM but that mod really annoys me with the annoying unremovable clutter it contains. (However, I'm gonna see if I'm hopefully wrong)
     
  4. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Could someone explain to me how the game works when you have multiple python files with the same functions. For example, in my mod, I now have several python files with an onCityAcquired function. However, it seems that only the version in CvEventManger.py is being called. What do I need to do to have it call the other functions as well and how does the game decide what order to run through these functions?
     
  5. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    385
    Location:
    Gold Coast
    merging two bug mods is easy
    • xml isnt modular in BUG, so merge typical game XML files as normal
    • add your bug mod to the load section of the init.xml file
    • add custom python files to the "contrib" directory in bug
    • special python files like "cvmaininterface" which comes with a bug install will have to be merged manually

    check my sig link for a list of BUG 4.4 mods. each of which comes with a readme.txt explaining how to merge to an installed standalone bug install. i've been able to merge all of them into one installed "mod".
     
  6. EmperorFool

    EmperorFool Deity

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    @Tholal - Each Python file is its own little world. All of those functions with the same name in different modules are unrelated. Only BUG makes them related by hooking them up to the event manager using <event> in your config XML.

    Start with the BUG Tutorial and use the BUG Reference. Then come back with questions where you don't understand something.
     
  7. blitzkrieg1980

    blitzkrieg1980 Octobrist

    Joined:
    Aug 29, 2006
    Messages:
    4,899
    Location:
    New Jersey, USA
    I made my own little MOD that simply changes some xml files (added a few units/civs/leaders/traits) but did nothing to change the python or any other code. Just xml. The MOD is loading fine and I'm able to see all my new leaders in the custom game screen. However, when it loads the map, I get a message:

    BUG Init: cannot find XML file for mod init
    and none of the interface is on the screen.

    I tried looking at the wiki entry. I added the MyMod.xml file to the Config folder in my custom assets which contains the code:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!--MyMod - Provides whatever MyMod provides -->
    <mod id="MyMod"/>
    
    and added the line to the init.xml
    Code:
    <load mod="MyMod"/>
    
    but I'm still getting the error message. Do I have to do a lot of work with python to get this mod to work correctly even though I haven't changed anything in the python code? Thanks in advance for your help.

    EDIT / UPDATE
    I have solved this problem for myself. If anyone is making an "XML Only" mod for themselves and can't get BUG to work with it like I couldn't (above), there is a simple solution. Just go into CustomAssets and copy all the files (leaving out the ones you already changed for your mod) to your MOD assets folder (in their proper folder locations). That's it. I feel kinda silly. The CustomAssets folder contains basically all the BUG interface. By copying it into your MOD assets folder, you are essentially including BUG inside your mod. Sorry to take up a post on your thread, EmperorFool, but hopefully this will help other beginners.
     
  8. Cruel

    Cruel King

    Joined:
    Jun 22, 2005
    Messages:
    823
    Location:
    São Paulo, Brazil
    RI merged the BUG mod with K-mod, but would like to further integrate the two mods. I would like add to this list the data overflow that are in K-mod.




    In which file is this data? I searched the CvMainInterface.py, but it seems they are imported from elsewhere.

    Please tell me that it is in another file in python :lol:

    Edit: Found in RawYields.py, but still needs the fuction for overflow...

    Edit2:
    Code:
    	bool bIsProcess = city.isProductionProcess();
    	int iPastOverflow = (bIsProcess ? 0 : city.getOverflowProduction());
    
    How transform this code in python code?

    Full code in the file so far (need the correct code for red):
    Code:
    [COLOR="Red"]# iPastOverflow
    	def addOverflow(self, pCity):
    	for eYield in range(YieldTypes.NUM_YIELD_TYPES):
    		iValue = 0
    		for eFlow in range(gc.isProductionProcess()):
    			if not eFlow = 0
    				range(gc.getOverflowProduction()):
    		self.addOverflow(eYield, eFlow)[/COLOR]
     
    [COLOR="Red"]
    		iPastOverflow = self.getYield(eYield, OVERFLOW)
    [COLOR="Black"]		if iPastOverflow != 0:
    			# Subtotal
    			self.appendTableTotal(screen, table, eYield, iTotal)
    			#self.appendTable(screen, table, True, BugUtil.getPlainText("base"), eYield, iTotal)
    			iValue = iPastOverflow
    			iSubtotal = iTotal + iValue
    			iTotal += iValue
    			self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_OVERFLOW", (iPastOverflow,)), eYield, iValue)
    		else:
    			iSubtotal = iTotal
    [/COLOR]

    Edit 3: Final Code - Working! :)
    Code:
    		#Overflow, #iPastOverflow
    		pHeadSelectedCity = CyInterface().getHeadSelectedCity()
    		iOverflow = int(pHeadSelectedCity.getOverflowProduction())
    		if iOverflow != 0:
    			# Subtotal
    			self.appendTableTotal(screen, table, eYield, iTotal)
    			#self.appendTable(screen, table, True, BugUtil.getPlainText("base"), eYield, iTotal)
    			iValue = iOverflow
    			iSubtotal = iTotal + iValue
    			iTotal += iValue
    			self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_OVERFLOW", (iOverflow,)), eYield, iValue)
    		else:
    			iSubtotal = iTotal
    
    It was necessary to make a small change to the code doesn't affect the other yields.
    Edit 4:
    Code:
    		if eYield == YieldTypes.YIELD_PRODUCTION and iOverflow != 0:
    
    [/COLOR]Result:
     

    Attached Files:

  9. Alrik2002

    Alrik2002 Warlord

    Joined:
    May 24, 2012
    Messages:
    214
    Location:
    Berlin, Germany
    Hi,

    I try to change some gameutils and it works fine for all players in SinglePlayer and MP besides Pitboss games.

    F.e. I would like to add a wonder with the following code:
    Code:
    	def getBuildingCostMod(self, argsList):
    		iPlayer, iCityID, iBuilding = argsList
    		pPlayer = gc.getPlayer(iPlayer)
    		pCity = pPlayer.getCity(iCityID)
    		pTeam = gc.getTeam(pPlayer.getTeam())
    		iCostMod = -1 # Any value > 0 will be used
    
    ## Apadana Palace Start ##
    		if pTeam.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_APADANA_PALACE")) == 1:
    			obsoleteTech = gc.getBuildingInfo(gc.getInfoTypeForString("BUILDING_APADANA_PALACE")).getObsoleteTech()
    			if gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1:
    				capital = pPlayer.getCapitalCity()
    				if capital.getNumActiveBuilding(iBuilding) and not pCity.isCapital():
    					return 80
    ## Platyping Wonders End ##
    Like said in your tutorial, I´ve made a different file named AlriksMultiModUtils (former CvGameUtils) where I have the new code to the existing callback and all the other callbacks. I´ve tried to register it in two ways in the init.xml:

    Code:
    <gameutils module="AlriksMultiModGameUtils" class="AlriksMultiModGameUtils" override="True"/>
    and

    Code:
    <gameutils module="AlriksMultiModGameUtils" class="AlriksMultiModGameUtils" handler="getBuildingCostMod"/>
    The problem is, that I get an OOS. The logs show, that all the computers of the players which are logged in calculating the BuildingCosts correctly with the discount. Only the pitboss ignores it, so on all the computers of the players some buildings are already finished while the pitboss believes there is still some production missing.

    The crazy thing is, that the code works in pitboss games with standard BtS and only this modification.

    Any idea why this problem occurs and how I can solve it? Thank you very much for your help!

    EDIT:

    Here the entries that refering to the getBuildingCostMod of the PythonDbg logfile:

    Code:
    load_module pickle
    [COLOR="Red"]load_module AlriksMultiModGameUtils[/COLOR]
    load_module BugOptionsScreen
    .
    .
    .
    [COLOR="Red"]22:50:17 DEBUG: BugUtil - binding CvGameUtils.CvGameUtils.getBuildingCostMod to <CvGameUtils.CvGameUtils instance at 0x1D5D2738>
    22:50:17 DEBUG: BugGameUtils - creating callback getBuildingCostMod
    .
    .
    .
    22:50:17 DEBUG: BugGameUtils - getBuildingCostMod - setting default to -1[/COLOR]
    .
    .
    .
    22:50:18 DEBUG: BugConfig - loading mod file AlriksMultiModSettings
    22:50:18 DEBUG: BugInit - loading mod AlriksMultiModSettings...
    22:50:18 INFO : BugCore - creating uninitialized mod AlriksMultiModSettings
    22:50:18 DEBUG: BugUtil - looking up AlriksMultiModGameUtils.AlriksMultiModGameUtils
    22:50:18 DEBUG: BugGameUtils - registering AlriksMultiModGameUtils.AlriksMultiModGameUtils
    22:50:18 DEBUG: BugGameUtils - doPillageGold - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - getUpgradePriceOverride - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - getExperienceNeeded - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - canConstruct - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - doCityCaptureGold - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - getConscriptUnitType - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - citiesDestroyFeatures - adding AlriksMultiModGameUtils handler
    [COLOR="Red"]22:50:18 DEBUG: BugGameUtils - getBuildingCostMod - adding AlriksMultiModGameUtils handler[/COLOR]
    22:50:18 DEBUG: BugGameUtils - getUnitCostMod - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - AI_unitUpdate - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - getExtraCost - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - cannotConstruct - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - AI_chooseProduction - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - getWidgetHelp - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: BugGameUtils - doMeltdown - adding AlriksMultiModGameUtils handler
    22:50:18 DEBUG: Timer - load mod [AlriksMultiModSettings] took 1 ms
    
     
  10. Jaxx

    Jaxx Chieftain

    Joined:
    Jul 25, 2014
    Messages:
    68
    Location:
    Earth
    Where is the tutorial? the link is a download exe file and it opens and installs the BUG mod itself with not tutorial


    Edited as I didn't think I was clear
     
  11. oldnooob

    oldnooob Prince

    Joined:
    Mar 29, 2013
    Messages:
    475
    Location:
    Aberdeen Washington
    Yes, same here. WHERE IS THE TUTORIAL, please.
     
  12. Monaldinio

    Monaldinio Prince

    Joined:
    Jan 6, 2010
    Messages:
    415
    Location:
    Rostock
    Hi!

    ...after 5 days, this tread is my last hope!

    Im using some parts of the BUG Mod for my mod.

    Now, i like to add a python Mod componente -> http://forums.civfanatics.com/downloads.php?do=file&id=21217


    I copy and paste the copy code into my mod py files, but it dont work.
    Then i copy and paste the code to the next war mod in the same way as i did it to my files, it works in the Next war mod!

    The creator says it could be a problem with the BUG Mod, "Widget help text disabled by BUG if you use it."

    So, where can can i enable the help text?
     
  13. Monaldinio

    Monaldinio Prince

    Joined:
    Jan 6, 2010
    Messages:
    415
    Location:
    Rostock
    THANK You Bilfrost for your Help!!! :thumbsup:
     
  14. GrimaceJD

    GrimaceJD Chieftain

    Joined:
    Oct 27, 2014
    Messages:
    8
    Location:
    San Diego, CA
    Yeah, I was looking for the tutorial as well, but the link is not valid any longer. It looks like all of the old "sections" of the sourceforge page aren't there any more, so none of the links on EmperorFool's signature work correctly except of the general BUG link. :(
     
  15. topsecret

    topsecret Believer

    Joined:
    Feb 11, 2010
    Messages:
    4,306
    Gender:
    Male
    Location:
    At the Foot of the Cross
    If anyone still knows about merging the BUG mod with other mods, I could use your help here.
     
  16. Klausi

    Klausi Chieftain

    Joined:
    Dec 10, 2015
    Messages:
    2
    Hi! I am still in love with Civ4, but it seems I am way passed high modding season for this game. Anyone alive yet?

    I am trying to implement slavery captures. I am using LOR 1.10, which uses BUG which seems to make everything different (no offence!). I tried to modify CvEventManager, but without luck. Then I found this post. I searched for onCombatResult in the files and found the "autologEventManager.py". My hope was to simply modify things here. However, I just get a at least for me useless error message in the game. This was my puny code:

    Code:
    def onCombatResult(self, argsList):
         
         
            ####################################
            # My naive try to change something #
            ####################################
            'Combat Result'
            pWinner,pLoser = argsList
            playerX = PyPlayer(pWinner.getOwner())
            unitX = PyInfo.UnitInfo(pWinner.getUnitType())
            playerY = PyPlayer(pLoser.getOwner())
            unitY = PyInfo.UnitInfo(pLoser.getUnitType())     
            if playerX and playerX and unitX and playerY:
                CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s'
                    %(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(),
                    playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
         
            xType = unitX.getUnitCombatType()
            yType = unitY.getUnitCombatType()
            player = gc.getActivePlayer()
            unitSlave = gc.getInfoTypeForString("UNIT_SLAVE")
            if (yType != gc.getInfoTypeForString("UNITCOMBAT_SIEGE") and yType != gc.getInfoTypeForString("UNITCOMBAT_ARMOR") and yType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and yType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") and yType != gc.getInfoTypeForString("NONE")):
                if (xType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and xType != gc.getInfoTypeForString("NONE")):
                    iRand = random.randint(1, 100)
                    if (iRand >=1):
                        if (player.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY"))):
                            newUnit = playerX.player.initUnit(unitSlave, pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)
                            newUnit.finishMoves()
         
         
         
            #################
            # End of my try #
            #################
         
         
         
         
            if (AutologOpt.isLogCombat()):
                self.UnitKilled = 1
                pWinner,pLoser = argsList
                if (pWinner.getOwner() == CyGame().getActivePlayer()
                or pLoser.getOwner() == CyGame().getActivePlayer()):
                    playerX = PyPlayer(pWinner.getOwner())
                    playerY = PyPlayer(pLoser.getOwner())
                    winnerHealth = float(pWinner.baseCombatStr()) * float(pWinner.currHitPoints()) / float(pWinner.maxHitPoints())
                    zsBattleLocn = self.getUnitLocation(pWinner)
                    playerXDesc = PyPlayer(pWinner.getVisualOwner()).getCivilizationAdjective()
                    playerYDesc = PyPlayer(pLoser.getVisualOwner()).getCivilizationAdjective()
                    if (pWinner.getOwner() == CyGame().getActivePlayer()):
                        if (self.bHumanPlaying):
                            message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_ATTACKING_DEFEATS", (zsBattleLocn, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), playerYDesc, pLoser.getNameKey(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
                            self.iBattleWonAttacking = self.iBattleWonAttacking + 1
                        else:
                            self.fOdds = 100 - self.fOdds
                            message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_DEFENDING_DEFEATS", (zsBattleLocn, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), playerYDesc, pLoser.getNameKey(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
                            self.iBattleWonDefending = self.iBattleWonDefending + 1
                        Logger.writeLog(message, vColor="DarkRed")
                    else:
                        if (self.bHumanPlaying):
                            message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_ATTACKING_LOSES", (zsBattleLocn, pLoser.getNameKey(), playerXDesc, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
                            self.iBattleLostAttacking = self.iBattleLostAttacking + 1
                        else:
                            self.fOdds = 100 - self.fOdds
                            message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_DEFENDING_LOSES", (zsBattleLocn, pLoser.getNameKey(), playerXDesc, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
                            self.iBattleLostDefending = self.iBattleLostDefending + 1
                        Logger.writeLog(message, vColor="Red")
    
     

Share This Page