1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Merging BUG with other Mods

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

  1. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,663
    Do I have to manually copy over the folder with all the .ini files? If so, why are there defaults set in the XML?
     
  2. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    Sorry for the delay, I have been uber busy at work and not checking up on the forum. What is the latest status of your questions? What are you still unable to resolve?

    • The INI files will be created using the defaults, but the folder itself must exist.
    • BUG should be calling all the right GameUtils callbacks unless you added some of your own.
    • You place all your mod's XML into a new XML file that you load from init.xml. The instructions for that first part in the tutorial with an example file. Can you reference a link that you don't understand and post the XML you have created so far?
    • There's no built-in way to create an option that is disabled all the time, but you could trick BUG by setting the option to require a very large version of the DLL by adding dll="99999" to the <option> element.
     
  3. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,663
    Hey Emp. Thanks for the response!

    I cannot get this to work. It will run fine if the .ini files are there. But if the folder is empty, I get the 'cannot locate settings folder error'.

    I'm merging BUG into my mod, which is a mod of FFH, which adds lots of python code to CvGameUtils. I ended up removing the CvGameInterfaceFile.py entirely and that seemed to fix the issue.

    I think this is an issue with my mod not being modular? Anyway, this question was also part of the above issue regarding CvGameUtils.

    Works like a charm! Thanks!
     
  4. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    384
    Location:
    Gold Coast
    First off, I really like the bug mod!

    Eventually I want to merge my whole expanded plus mod with bug, but for now I'm trying to get a simple part of the mod merged: abandon raze demolish. It only contains one event python file.
    what i've done so far and what seems to work:
    Spoiler :

    • installed bug as a standalone mod
    • added abandonrazedemolish to the /config/init.xml
    • created abandonrazedemolish.xml
    • created abandonrazedemolish.py in /contrib
    • altered abandonrazedemolish.py with some evenhandler edits mentioned in this thread


    the python showing success?
    Spoiler :

    03:52:50 DEBUG: BugConfig - loading mod file AbandonRazeDemolish
    03:52:50 DEBUG: BugInit - loading mod AbandonRazeDemolish...
    03:52:50 INFO : BugCore - creating uninitialized mod AbandonRazeDemolish
    03:52:50 DEBUG: BugUtil - looking up AbandonRazeDemolish.AbandonRazeDemolish
    load_module AbandonRazeDemolish

    03:52:50 DEBUG: BugEventManager - adding event 'KbdEvent'
    03:52:50 DEBUG: BugEventManager - adding event 'DestroyBuildingBegin'
    03:52:50 DEBUG: BugEventManager - adding event 'DestroyBuildingApply'
    03:52:50 DEBUG: BugEventManager - adding event 'CityRazed'
    03:52:50 DEBUG: Timer - load mod [AbandonRazeDemolish] took 24 ms


    I think the problem is that this mod requires a keyboard event "cntrl z" and im not sure I have everything in the xml files I need.

    abandonrazedemolish.xml snippit
    Code:
    <events module="AbandonRazeDemolish"/>
    abandonrazedemolish.py snippit
    Spoiler :
    Code:
    class AbandonRazeDemolish:
    	def __init__(self, eventManager):
    		self.eventMgr.EventKeyDown=6
    		eventManager.addEventHandler("KbdEvent", self.onKbdEvent)
    		eventManager.addEventHandler("DestroyBuildingBegin", self.eventDestroyBuildingBegin)
    		eventManager.addEventHandler("DestroyBuildingApply", self.eventDestroyBuildingApply)
    		eventManager.addEventHandler("CityRazed", self.onCityRazed)
    		self.eventMgr = eventManager		
    		
    	def onKbdEvent(self, argsList, bCtrl):
    		eventType,key,mx,my,px,py = argsList
    		self.eventMgr.bCtrl = bCtrl
    		if ( eventType == self.eventMgr.EventKeyDown ):
    			CvUtil.pyPrint("test")
    			theKey=int(key)
    			CvCameraControls.g_CameraControls.handleInput( theKey )
    			'Check if city screen is active'
    			if ( CyInterface().isCityScreenUp() ):
    				'Check if CTRL + Z was hit'
    				if(theKey == int(InputTypes.KB_Z) and self.eventMgr.bCtrl):
    					'Make sure the owner is the player!'
    					if (CyInterface().getHeadSelectedCity().getOwner() == gc.getGame().getActivePlayer()):
    						return 1
    		return 0


    you can see i have a debug pyPrint command in there...but pressing cntrl-Z in game does nothing. No errors in the logs.

    Thoughts?

    EDIT: source mod code:http://forums.civfanatics.com/showthread.php?t=252243

    EDIT x2: now im really confused...going through the "modders corner" it seems like there are two different ways to enable events. plus it seems this simple mod blends two different kinds of events. im not sure if i need a CvEventmanager file or not.
     
  5. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    384
    Location:
    Gold Coast
  6. God-Emperor

    God-Emperor Chieftain

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    I expect your problem was the the leading K in the event name should be lower case: "kbdEvent". So your event handler was not registered for the correct event and therefore was not being used for the desired event.

    By the way, your CityRazed appears to have the same problem: "cityRazed", no leading capitalization. There is also a problem for each of the other two but since those are not normal BtS events I can't say what.

    A good hint that the event name is not correct is that the log says "adding event". This is not normal. Each of them is creating a brand new type of event that nothing ever uses, instead of registering a handler for an existing event.
     
  7. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    384
    Location:
    Gold Coast
    good catch :wallbash:

    thanks for the "adding event" tip!

    FYI Emperorfool this typo is in your modders corner:
    class ReminderEvent:
    def __init__(self, eventManager):
    eventManager.addEventHandler("kbdEvent", self.onKbdEvent)
    eventManager.addEventHandler("endTurnReady", self.onEndTurnReady)
    eventManager.addEventHandler("GameStart", self.onGameStart)
    ...
     
  8. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    384
    Location:
    Gold Coast
    update:
    i ditched trying to port over the abandon raze demolish mod since a working copy exists in ROM : AND.

    i did successfully *crosses fingers* port over my basic limited religions mod, see here:
    http://forums.civfanatics.com/showthread.php?t=293743

    thanks for the help!
     
  9. God-Emperor

    God-Emperor Chieftain

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    ???

    I see no typo there.
     
  10. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    384
    Location:
    Gold Coast

    so the differing K capitalization here is correct?

    "kbdEvent", self.onKbdEvent
     
  11. God-Emperor

    God-Emperor Chieftain

    Joined:
    Jul 18, 2009
    Messages:
    3,551
    Location:
    Texas
    The event names are what is used by the DLL when using them and you have to match or it won't work (BUG can also create events entirely in Python and those have to match what they are set up to be too). The second part, self.whatever in the addEventHandler function, can be anything you want it to be - it just has to match what you named the function that you want called when the event happens.

    The event names themselves are a mixed bag. Some start with a capital letter, some don't. For example, all but one of the unit related events start with "unit" with the exception being "UnitRename". The function names (that come with BtS) called to handle the events are more regular in form: they all start with "on", with the lower case "o", and then every word (or shortened version in the case of "kbd") after that which is incorporated into the function name is capitalized (whether or not it was in the event name). So in the standard event manager that comes with BtS the mouseEvent event is handled by the onMouseEvent function, the Init event is handled by onInit, and the OnSave event is handled by onSaveGame (where they snuck in a whole extra word). As you can see, it is pretty haphazard.
     
  12. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    384
    Location:
    Gold Coast
    I just ran full force into this issue with my limited religions mod. I was pulling my hair out.

    This:
    PHP:
    eventMgr.addEventHandler("techAcquired"self.onTechAcquired)
    works

    This
    PHP:
    eventMgr.addEventHandler("TechAcquired"self.onTechAcquired)
    Does not.

    "t" vs '"T" :wallbash:
     
  13. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    One helpful thing to add would be for BUG to warn when an event differs only by case from an existing event. I didn't want to post up a bunch of warnings when creating new events because that's part of BUG, and it does it itself. However, if you have "kbdEvent" and later register "KbdEvent", it's probably a typo.

    Yet one more thing to add to the ever-growing list of feature requests. :)

    I'm glad GE was able to help you along, modifieda4. I just got back from vacation and will be around more now.
     
  14. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    384
    Location:
    Gold Coast
    With help :), i was able to get two of my mods converted (im my sig, basic limited religions and basic inquisition) with a third on the way.

    Some things ive noticed for mod mergers . Some of this stuff may be obvious I guess, but it wasn't for me...a newbie BUG mod merger.
    • mod XML files are merged the old way with a BUG install
    • CVmaininterface changes get merged the old way with a BUG install
    • art files get merged the old way with a BUG install
    • a new mod's CGgameUtil functions overwrite the default function entirely if placed outside a CLASS in a new BUG mod events file
    • a new mod's event with the same name of a default function (case matters!) gets appended to default function in a CLASS in a new BUG mod events file. Otherwise you may see two events fired at a time. only put additions in the new mod.
    • when an event is triggered by the user (ie. a function of a new unit) and can be triggered by AI functions, then it has to be placed in a sepate py file and called into the new BUG mod event file via import.

    does all of this sound more or less right? essentially the BUG mod is very modular for events but not for other aspects of a mod (art,xml, main interface)?

    I hope the vacation was nice!
     
  15. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    You got most of that right, and the others may just be terminology that differs from what I'm used to.

    These are spot on. BUG doesn't alter how art, music, and XML files are handled. As without BUG, game-element-defining XML files (units, buildings, etc) overwrite those from the game while text-translation XML files are semi-additive (they all get loaded and each <TEXT> element overwrites any previously loaded one).

    You can use a class-with-methods and/or module-level functions for your gameutils callbacks with BUG, and they operate identically. Whether they override those from the base game and other merged mods or fire in addition to them depends on each callback. If the callback is defined to return a value, the registered callbacks are called in order until one returns a value other than None. Otherwise all registered callbacks are called.

    All registered event callbacks (both class methods and module functions) are called by BUG. There is no way to override an event programmatically. You must either remove the class code that registers it or the BUG XML <event> that registers it.

    I don't understand what you mean here. BUG should never require any imports itself as it will import modules automatically when you reference them in your BUG XML config files. Also, you're free to cram all your Python into a single module if you like, but that just makes it harder on you to organize your code and other modders to mix in your mods.

    My vacation was action packed but nice. Though I kinda feel like I need another vacation to lay around and do nothing! :D
     
  16. Seraiel

    Seraiel Chieftain

    Joined:
    Sep 6, 2011
    Messages:
    7,948
    Gender:
    Male
    Hi :)

    I have BUFFY installed for playing HoF games, and now wanted to start playing forum games so I installed BUG + BULL in the CustomAssets Folder.

    Now I ask myself, if I can still play HoF games, as when I try to load old save-files (files created before installing BUG / BULL) Civ ctd's. New savefiles do not have the problem. Does the modified gamecore.dll still allow the HoF games to be legit?

    Tia, Seraiel
     
  17. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    Putting the DLL into the CustomAssets folder does nothing--Civ ignores it. It must be placed in the Assets folder where the EXE is or into a new folder inside either Mods folder location. I believe BUFFY will ignore the custom DLL anyway because it has its own DLL.

    That being said, loading saved games (BUFFY or plain BTS) after installing BUG and BULL should be fine because they are saved-game compatible. Since you're using BUFFY, you must have BTS 3.19 up-to-date, but can you please follow the instructions in the Troubleshooting page linked in my sig and post here again?
     
  18. Seraiel

    Seraiel Chieftain

    Joined:
    Sep 6, 2011
    Messages:
    7,948
    Gender:
    Male
    The gamecore.dll was of course in the assets folder where the original gamecore.dll was, as told in the installation instructions. Anyhow, there is no .exe file in that directory.

    Here is the requested information:

    OS Version: Vista
    BTS version: 3.19
    BUG / BAT Version: 4.4 no BAT
    Installation source: .exe
    Installation method: singleplayer (CustomAssets)
    Merged mods: BULL
    Anything non-standard about my setup: BUFFY also installed

    The 2 requested logs are attached.

    Tia, Seraiel
     

    Attached Files:

  19. Seraiel

    Seraiel Chieftain

    Joined:
    Sep 6, 2011
    Messages:
    7,948
    Gender:
    Male
    It has definately something to do with the modified gamecore.dll as when I replace it with the original, I can load those old saves when only BUFFY had been installed.
     
  20. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    Right, I just meant the Assets folder that lives with Civ4BeyondSword.exe as opposed to CustomAssets in your My Documents folder. I don't see any problems in the logs. You are talking about loading non-BUFFY saved games, right? Do saved BUFFY games also crash?

    Are you able to start, save, quit, and load a new game using the BULL DLL? And can you load that same new saved game without the BULL DLL?
     

Share This Page