I have seen a few questions about how to combine mods. The ideal would be able to easily turn multiple mods on or off... perhaps you want to use someone's improved epic game mod, TheDarkside's real fort and auto missionary mod, and someone else's improvement to one of the game screens.
Civ IV of course doesn't support more than one mod at once, and likely never will. I am working on a utility to make comparing and merging mods easier. However, in the meantime, I would like to offer some advice to modders on how to make their mods easier to combine with other mods.
This applies mainly to mods that modify CvEventManager.py. I personally would hate to have to insert small changes in such a big file, surrounding them with comments about where the changes begin and end. Furthermore, if this file is changed in a patch, then existing mods would need to be updated to include the changes from the patch.
It is possible to avoid most of these problems. You can create a class that derives from CvEventManager (I got this idea from the Greek World Mod). You only have to define overrides for the events you want to handle. You can then change two lines in EntryPoints\CvEventInterface.py to have the game use your derived class. If you have overriden a method, then that method will get called, otherwise the normal method from CvEventManager.py will be called.
Since I have not made any mods yet myself, I have refactored Bhruic's real fort mod to show how this can be done. The class CvCustomEventManager overrides the normal event manager. The real logic for the mod is in a seperate file named RealFort.py. The CvCustomEventManager overrides 3 of the event handlers, and calls appropriate methods in the RealFort module as well as the methods in the base CvEventManager class.
I have verified that the mod will load without any errors, but I did not have time to test whether it still actually adds the fort bonusses as it should. In any case it still serves as a good example for how to seperate your mod-specific code from the base game files.
Enjoy!
EDIT: Somehow I originally miscredited the author of the real fort mod to TheDarkSide instead of Bhruic. Oops!
Civ IV of course doesn't support more than one mod at once, and likely never will. I am working on a utility to make comparing and merging mods easier. However, in the meantime, I would like to offer some advice to modders on how to make their mods easier to combine with other mods.
This applies mainly to mods that modify CvEventManager.py. I personally would hate to have to insert small changes in such a big file, surrounding them with comments about where the changes begin and end. Furthermore, if this file is changed in a patch, then existing mods would need to be updated to include the changes from the patch.
It is possible to avoid most of these problems. You can create a class that derives from CvEventManager (I got this idea from the Greek World Mod). You only have to define overrides for the events you want to handle. You can then change two lines in EntryPoints\CvEventInterface.py to have the game use your derived class. If you have overriden a method, then that method will get called, otherwise the normal method from CvEventManager.py will be called.
Since I have not made any mods yet myself, I have refactored Bhruic's real fort mod to show how this can be done. The class CvCustomEventManager overrides the normal event manager. The real logic for the mod is in a seperate file named RealFort.py. The CvCustomEventManager overrides 3 of the event handlers, and calls appropriate methods in the RealFort module as well as the methods in the base CvEventManager class.
I have verified that the mod will load without any errors, but I did not have time to test whether it still actually adds the fort bonusses as it should. In any case it still serves as a good example for how to seperate your mod-specific code from the base game files.
Enjoy!
EDIT: Somehow I originally miscredited the author of the real fort mod to TheDarkSide instead of Bhruic. Oops!
Comment