Merging BUG with other Mods

You're referring to this If statement, right?
Code:
# If this is a wonder...
That comes right fron CvEventManager, intact, and it works fine in that context. I have no PythonDbg errors in the file. It's empty. I'm attaching a zip of the relevant logs, but here are the salient points in a text format:
Code:
[B]<-- snippet from PythonDbg.log -->
[/B]
13:39:47 DEBUG: BUG: looking up StatusDumpEventManager.StatusDumpEventManager
load_module StatusDumpEventManager

load_module BugFile

13:39:47 DEBUG: StatusDump-Start-0
13:39:47 DEBUG: Timer - load mod [StatusDump] took 3 ms
13:39:47 DEBUG: BugConfig - loading mod file MovieMod
13:39:47 DEBUG: BugInit - loading mod MovieMod...
13:39:47 INFO : BugCore - creating uninitialized mod MovieMod
13:39:47 DEBUG: BUG: looking up MovieMod.onBuildingBuilt
load_module MovieMod

13:39:47 DEBUG: BugEventManager - adding event 'BuildingBuilt'
13:39:47 DEBUG: Timer - load mod [MovieMod] took 1 ms
13:39:47 DEBUG: BugConfig - loading mod file BULL Actions
13:39:47 DEBUG: BugInit - loading mod BULL Actions...
13:39:47 INFO : BugCore - creating uninitialized mod Actions
13:39:47 DEBUG: BugOptions - getActions will return IniFile Actions

[B]<-- a snippet from xml.log -->
[/B]
[67242.218] Loading XML file xml\Art/CIV4ArtDefines_Movie.xml
[67242.218] Load XML file xml\Art/CIV4ArtDefines_Movie.xml SUCCEEDED
[67242.218] SetGlobalClassInfo (Civ4ArtDefines/MovieArtInfos/MovieArtInfo)
[67242.280] Loading XML file modules\moviemod\xml\art\mm_civ4artdefines_movie.xml
[67242.296] Load XML file modules\moviemod\xml\art\mm_civ4artdefines_movie.xml SUCCEEDED
[67242.296] SetGlobalClassInfo (Civ4ArtDefines/MovieArtInfos/MovieArtInfo)
[67242.296] Loading XML file xml\Art/CIV4ArtDefines_Misc.xml
[67242.296] Load XML file xml\Art/CIV4ArtDefines_Misc.xml SUCCEEDED
[67242.296] SetGlobalClassInfo (Civ4ArtDefines/MiscArtInfos/MiscArtInfo)
[67242.358] Loading XML file xml\Art/CIV4ArtDefines_Unit.xml
[67242.374] Load XML file xml\Art/CIV4ArtDefines_Unit.xml SUCCEEDED
[67242.374] SetGlobalClassInfo (Civ4ArtDefines/UnitArtInfos/UnitArtInfo)

[B]<-- and another snippet from xml.log -->[/B]

[67247.709] info type NONE not found, Current XML file is: xml\Buildings/CIV4BuildingInfos.xml
[67247.709] info type NONE not found, Current XML file is: xml\Buildings/CIV4BuildingInfos.xml
[67247.772] Loading XML file modules\moviemod\xml\buildings\mm_civ4buildinginfos.xml
[67247.865] Load XML file modules\moviemod\xml\buildings\mm_civ4buildinginfos.xml SUCCEEDED
[67247.865] SetGlobalClassInfo (Civ4BuildingInfos/BuildingInfos/BuildingInfo)
[67247.865] info type NONE not found, Current XML file is: modules\moviemod\xml\buildings\mm_civ4buildinginfos.xml
[67247.865] info type NONE not found, Current XML file is: modules\moviemod\xml\buildings\mm_civ4buildinginfos.xml
[67247.865] info type NONE not found, Current XML file is: modules\moviemod\xml\buildings\mm_civ4buildinginfos.xml
Unless I'm mistaken, it seems to be loading and initializing everything properly, but it just never seems to call the "BuildingBuilt" function when a building is actually built. I saw in the BUG modding guide about the "eventfire" functions, and I'm wondering if my mod needs to have the actual "firing" code put into it to call the handler. Right now, it calls the normal CvEventManager.py handler from the game code and plays all of the regular movies, but not my new ones with the BUG handler. :(

I can do it by adding Phungus's code to CvEventManager, and it works great, but I really want to do this properly so it doesn't mess up other modders. Why do something with brute force, if you can be dainty and use finesse?

That's me. "Play by the Rules" Lemon. ;)
 

Attachments

I read your previous code snippet too quickly. You said that if you plunk the phungus code snippet into CvEventManager, it works. What snippet is this? I see a block of code in your previous post that is labeled as phungus's code, but this is not commented-out. I'm confused.

I don't have CvEventManager handy, but my suspicion is that the event starts with a lowercase "b". Try changing that in your XML (type="buildingBuild"). If that is the problem, it means your handler isn't being called at all rather than having an error inside it.

Always check the event type against what's in CvEventManager. When I get some free time, I'll be enhancing BugEventManager so it's more helpful here.
 
I read your previous code snippet too quickly. You said that if you plunk the phungus code snippet into CvEventManager, it works. What snippet is this? I see a block of code in your previous post that is labeled as phungus's code, but this is not commented-out. I'm confused.
Oops. Sorry. The Phungus snippet is the section that is between the comments. This, exactly:
Code:
bCoolBuilding = False
        if ( (gc.getBuildingInfo(iBuildingType).getMovie()) or (isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())) ):
            bCoolBuilding = True
        if ( (not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and bCoolBuilding ):
He altered the function slightly so that the event manager can differentiate between a regular building and a special building, like a wonder, or any other building you define as "Cool" (His word.) in the xml. That section replaces the normal functionality in the CvEventManager.py onBuildingBuilt function, and it works just fine.
This is the code that gets replaced, specifically:
Code:
if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):

I tested it by inserting Phungus's code into CvEventManager.py and fiddling with WB. I placed some Great people and built Scot Yard, etc. Voila! Movies.

It didn't work with the BUG method because I am a great big dope... :lol:
I don't have CvEventManager handy, but my suspicion is that the event starts with a lowercase "b". Try changing that in your XML (type="buildingBuild"). If that is the problem, it means your handler isn't being called at all rather than having an error inside it.
And that was the exact problem. No lower case 'b'. The movies play now. I had to fiddle with it to get rid of a couple of python "name" errors, and it actually plays World Wonder movies twice atm. I can fix that, though. :)

Thank you much for the help. Consider yourself the recipient of a great big smooch. :D
 
The key to event handler nirvana is to recall that all of the handlers in CvEventManager continue to fire. Any code you add should not include stuff from CvEventManager. There are ways in Python to remove those other handlers, and I will probably make a way to do it in XML eventually, but no one has asked for it yet. ;)

Spoiler The fix :
Hidden in case you want to figure it out on your own or give it a try first. ;)

To fix this you need to make your code detect the same scenario that CvEventManager does and not show the movie in that case.

Code:
if ( gc.getBuildingInfo(iBuildingType).getMovie() [B][COLOR="Red"]and not[/COLOR][/B] isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType()) ):
 
@Lemon Merchant

Could you upload your files for this, so I can just plug them into the RevDCM core, and remove CvEventManager.py from the RevDCM SVN? I as well would rather use the BUG method, but wasn't clear how to do it.
 
@Emperor Fool

jdog just stated he has fixed the critical bug in BetterAI, so a RevDCM update is only days away. Next step is incorporating an updated BUG/BULL SVN into it. Could you release a ready to go stable BUG/BULL SVN for RevDCM to use? I know I'm asking for special treatment for an unrelated mod, but the RevDCM core is used as a standardized modding core by many mods, and thus has many users. For instance RoM has 100,000 regular users, LoR & Dune Wars also have a few thousand users, and there are a few other large mods that use the RevDCM core. So I'd like the RevDCM core to have stable and good to go BUG components in it at official release versions, and not end up throwing in some experimental feature that might not work right. Basically I'm asking for special treatment because I think RevDCM is special enough to ask. If that's OK, please let me know when you have an SVN you think would be good to merge in and I'll grab it.
 
With the OOS bug in BULL now (finally) fixed and verified, I'm planning to release both BUG and BULL this weekend. Both have been fairly stable for a while now, and I won't be adding any new features until after the releases.

I would highly recommend grabbing the latest SVNs of each and run through a quick test game before merging. This will ensure you're starting from a known stable environment before you do the merge.
 
If that's the case I'll just merge in the source for the official releases that come out this weekend. Thanks for the reply.

Edit:
I'm attaching LoR's NSIS install script for you guys to take a look at. It wouldn't work for BUG, but since BAT and BUFFY are their own proper mods, it will work for them, and function more logically then the current install scripts they use (since they are built off of a custom assets installer), I think.
 
@Phungus:

I just got home from a 20+ hour shift and I still have to clean up the code a little. Do you just need the Python for the function? Or do you need the movie XML, as well?

I'm off to bed, but I can post it sometime this weekend. And thanks for the installer file. That will really help me with the new version for BAT. :)

Nighty nite.
 
Do you just need the Python for the function? Or do you need the movie XML, as well?
I need whatever files makes the functionality work. This will be going in the RevDCM gamecore. Different mods that are built around the RevDCM gamecore will have different movies, and different buildings entirely, so if you are asking about MovieDefineInfos XML files and such; obviously not.
 
I need whatever files makes the functionality work. This will be going in the RevDCM gamecore. Different mods that are built around the RevDCM gamecore will have different movies, and different buildings entirely, so if you are asking about MovieDefineInfos XML files and such; obviously not.
Ok. I'll try to send the .py and BUG related files tonight.

Edit: Here they are! All cleaned up and tested. Thanks to you and EF.
 

Attachments

Thanks LM, very tiny mod there. You might consider adding it to BUG by default, it's pretty easy to put in, and doesn't hurt anything so far as I can tell.

Edit:

Actually looking it over it would break MP games, and also cause unintended issues (like you'll get a wonder movie when the AI builds wonders). You need to add back in the active player and not MP checks:

Code:
		[B]if ( (not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) ):[/B]
			if ( gc.getBuildingInfo(iBuildingType).getMovie() and not isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType()) ):

				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
				popupInfo.setData1(iBuildingType)
				popupInfo.setData2(pCity.getID())
				popupInfo.setData3(0)
				popupInfo.setText(u"showWonderMovie")
				popupInfo.addPopup(pCity.getOwner())
 
You might consider adding it to BUG by default, it's pretty easy to put in, and doesn't hurt anything so far as I can tell.
I think I'd better check with the boss about that one. :lol:

I would like to add it to a future release of BAT, though. If I ever manage to get time to get the movie files finished.

Actually looking it over it would break MP games, and also cause unintended issues (like you'll get a wonder movie when the AI builds wonders). You need to add back in the active player and not MP checks:
Thank you for the fixed code. I tested it on my coffee break, and it's working fine in SP on my laptop, anyway. I couldn't play long enough for someone else to build anything, I just used WB. I get some days off soon, so I'll double check then.

Sigh... Back to work for me. Nite nite. :)
 
I use the BUG Mod as part of the Custom assets folder (so it's part of the game, not a mod). I recently made a custom civ. When I open the game, the Technology screen is displayed, then my leader screen, and then a starting position... with no buttons, bars, or any interface things. Strangely, it works fine for a normal civilization.
 
I use the BUG Mod as part of the Custom assets folder (so it's part of the game, not a mod). I recently made a custom civ. When I open the game, the Technology screen is displayed, then my leader screen, and then a starting position... with no buttons, bars, or any interface things. Strangely, it works fine for a normal civilization.

This only happens when you play that new civ? That typically means that the technology advisor is failing to draw. When BTS starts, it draws and hides the tech advisor to speed it up later. If a button fails to draw, this happens.

Check out the Troubleshooting page for a list of what do and information to post here so we can help you.
 
For lack of a better place to post this right now, here's a heads-up to anyone merging BUG with their own mods . . .

One of my early goals with BUG was to minimize the number of Python modules (.py files) from BTS that BUG had to touch. There are certain cases where this is unavoidable (CvEventInterface comes to mind) or mostly unavoidable (CvGameInterfaceFile, CvScreenUtilsInterface), but today I was able to remove the need for three such modules:

  • CvAppInterface - Tells BUG to initialize itself in preGameStart().
  • CvDiplomacyInterface - Hooks into DiplomacyUtil to fire events.
  • CvOptionsScreenCallbackInterface - Handles UI events from the BUG Options screen and intercepts changes to the language and resolution.
  • CvRandomEventInterface - EventSigns placement, 3.17 patches, and BUFFY change to an event.
The following is very technical and included for a) anyone that wants their brain to hurt or b) advanced modders that might be able to make use of it. The only part you need to understand is this:

If your mod includes these modules unmodified from BUG, remove them entirely from your mod. If you modified the ones from BUG, you must make those same changes to the original ones from BTS.

Let me start at the beginning. Civ4 has a limited set of Python modules that it makes available to the DLL. These are the modules that appear in the Python/EntryPoints folder. Sadly, it does not expose every module you place in that folder--only the ones that came with BTS. Whenever the DLL needs to call a Python function, it must do so through one of those modules.

The EXE also calls into these modules for its own purposes: to fire events, initialize the game, handle interaction with the diplomacy window, etc.

For example, BULL Needs to call out to the BugOptions module to access user settings, but this isn't directly possible. Originally, I added functions to CvAppInterface that called BugOptions for BULL and returned the result. This works, but it required BUG to have a copy of CvAppInterface with simplistic functions that merely pass the call on to the BugOptions module.

To fix this, I added some functions to BugUtil and corresponding configuration XML handlers to BugConfig that allow you to make a function in module X appear as if it is also in module Y. This is often called exporting a function, and so I called the function that does this export(). How does this work? In Python, a function is just like any other variable in that you can copy it from one place to another, pass it along to another function, etc. The export() function merely copies (a reference to) a function from one module to another.

Now instead of having a bunch of functions in CvAppInterface, BUG exports the BUgOptions functions needed by the DLL to the CvAppInterface module. BUG modifies CvAppInterface on-the-fly which means it doesn't have to include a modified copy of CvAppInterface anymore.

That's great for functions that don't already exist in the target module, but there are some EntryPoints functions that BUG needs to modify--do something in addition to what the original function does.

For example, at the start of CvAppInterface.preGameStart(), I added code to fire a new PreGameStart event that BUG uses as a call to initialize itself. But Civ4 needs the original function code to run or it won't work.

For these cases I added the BugUtil.extend() function. It allows the modder to specify a function X that should be called before, after or instead of another function Y. It receives the same arguments originally passed to Y. In the case of "instead of", function X receives a reference to function Y as the first parameter. This allows you to call Y at some point during your replacement function and even use its return value if you wish.

I seriously doubt any modder will need these functions, so don't worry if this went over your head. The only reason I needed it at all was so I could remove these EntryPoints modules from BUG. Most mods write new code as event handlers and gameutils callbacks, and for those tasks these new functions are not at all useful. [Well, that's not entirely true. :mischief:]
 
Just saw that last post and yes it did go over my head heh. Just to clarify though: I have BUG 4.3 in my mod, I can now just delete those 4 files from Python/EntryPoints?

Anyway the actual reason I came to this thread is I've recently been getting an error related to missionaries being built:

Code:
Error in unitBuilt event handler <bound method BuildUnitName.onUnitBuilt of <UnitNameEventManager.BuildUnitName object at 0x1130a330>>

In my mod all missionaries are renamed (Hindu Guru, Confucian Scholar, Zoroastrian Magi, etc). I had a search through UnitNameEventManager.py for 'missionary' and 'religion' but couldn't find anything.

What could I do to fix this error? It seems harmless as the missionary is built and works fine but would be nice to be sure and lose the warning. The only other changes I've made to missionaries are giving them UNITCOMBAT_MISSIONARY (so that they can get a free Medic1 promotion under one of my traits).
 
I have BUG 4.3 in my mod, I can now just delete those 4 files from Python/EntryPoints?

Yes, if you didn't modify them which is probably the case.

The only other changes I've made to missionaries are giving them UNITCOMBAT_MISSIONARY.

This is the problem. When not using the Advanced option of Unit Naming, you must have one <option> element in "Unit Naming.xml" per Unit Combat Type. Copy one of the existing elements and modify it for your new type:

Code:
			<option id="Combat_SIEGE" key="CombatSIEGE"
					type="string" default="DEFAULT"/>
[B][COLOR="Green"]			<option id="Combat_MISSIONARY" key="CombatMISSIONARY"
					type="string" default="DEFAULT"/>[/COLOR][/B]
			<accessor get="getByCombatType" set="setByCombatType"
					  args="combatType" id="Combat_%s"/>

You don't need to do anything for people using the Advanced option.
 
That fixed it, thanks very much.

I thought I should let you know that when I deleted those 4 files from EntryPoints leaders had no diplomacy text. The response options were unaffected but the greeting text and such was missing. Soon as I put the files back it was fixed. I have modified DiplomacyInfos.xml to add more leaders but I haven't added new categories of responses or anything like that though.
 
Can you please post Logs/PythonDbg.log after removing the file and making it happen again?
 
Back
Top Bottom