Merging BUG with other Mods

Yeah, added new unit combat types, a few actually, considering the main focus of the Wolfshanze mod, one of the core mods I'm using (merged with RevDCM) has steamship navies.

Do you really want to see the python exception?

You can rip out Unit Naming by removing the <load "Unit Naming"/> line from init.xml.
Cool I'll try that.

I also need to go in and see about the added trait not displaying I asked about before, it confuses me that it's not listed, this is what I've added to Trait Util btw, you said you wanted to see it:
Code:
def init():
	"Performs one-time initialization after the game starts up."
	game = gc.getGame()
	global GENERIC_ICON
	GENERIC_ICON = u"%c" % game.getSymbolID(FontSymbols.MAP_CHAR)
	
	addTrait("AGGRESSIVE", game.getSymbolID(FontSymbols.STRENGTH_CHAR), "Art/Interface/Buttons/Promotions/Combat1.dds")
	addTrait("CHARISMATIC", game.getSymbolID(FontSymbols.HAPPY_CHAR), "Art/Interface/Buttons/TechTree/MassMedia.dds")
	addTrait("CREATIVE", gc.getCommerceInfo(CommerceTypes.COMMERCE_CULTURE).getChar(), "Art/Interface/Buttons/TechTree/Music.dds")
	[B]addTrait("ENLIGHTENED", gc.getCommerceInfo(CommerceTypes.COMMERCE_RESEARCH).getChar(), "Art/Interface/Buttons/TechTree/Liberalisms.dds")[/B]
	addTrait("EXPANSIVE", game.getSymbolID(FontSymbols.HEALTHY_CHAR), "Art/Interface/Buttons/Actions/Heal.dds")
	addTrait("FINANCIAL", gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getChar(), "Art/Interface/Buttons/TechTree/Banking.dds")
	addTrait("IMPERIALIST", game.getSymbolID(FontSymbols.OCCUPATION_CHAR), "Art/Interface/Buttons/Actions/FoundCity.dds")
	addTrait("INDUSTRIOUS", gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar(), "Art/Interface/Buttons/TechTree/Industrialism.dds")
	addTrait("ORGANIZED", game.getSymbolID(FontSymbols.TRADE_CHAR), "Art/Interface/Buttons/Buildings/Courthouse.dds")
	addTrait("PHILOSOPHICAL", game.getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR), "Art/Interface/Buttons/TechTree/Philosophy.dds")
	addTrait("PROTECTIVE", game.getSymbolID(FontSymbols.DEFENSE_CHAR), "Art/Interface/Buttons/Promotions/CityGarrison1.dds")
	addTrait("SPIRITUAL", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")

The other thing I need to do is add in a new list, "Legends" Units that can only be built once, defined in UnitClassInfos.xml, using the maxGlobalInstance tag. I'd like them to be listed in a different list, like how wonders are in their own category in the sevopedia, I'd like the same to occur with legends. Any idea on where to start with this?
 
Yeah, added new unit combat types, a few actually.

You just need to create an <option> tag in "Unit Naming.xml" for each new combat type, but it's your call.

I also need to go in and see about the added trait not displaying I asked about before, it confuses me that it's not listed.

Yes, I checked and indeed you do need to create an entry for the new trait in CIV4NewConceptInfos.xml. Search for FINANCIAL to find it and copy an existing one. You shouldn't need to write up a strategy Civilopedia entry for it if you don't want.

The other thing I need to do is add in a new list, "Legends".

This is doable. Take a look at how the NewConceptInfos are broken up into multiple groups: new concepts, traits, shortcuts, strategy articles. You'll need to do the same for Units. You can also look at buildings to see how they are segmented.
 
Alright cool, think I should start working on it now, for some reason I've been procrastinating on this one. I've gotten to the point where I've gotten all the nuts and bolts working for the mod, now I just need to get into the aesthetics and packaging, and I don't know why but, for some reason this sort of stuff just doesn't motivate me...
 
That's just how I feel about putting together BUG releases. This explains the speedy release of BULL. :(
 
I think I may have nipped it in the butt...

All I did was add an extra TAB (indent) to the second grouping of code that Kael added. Fired up the game and no Python errors at all reported in the log.

It looks like the indentation was the culprit (I think).

All that code added by Kael actually needs to run whether or not the icons are aligned. These look like additional lines shown above the scoreboard. Also, the two lines after it that resize and show the ScoreBackground panel need to be executed in the else block of the "if bAlignIcons" test above Kael's code, but it depends on the number of lines that Kael's code produces.

Scoreboard.py's draw() function needs to return its final yCoord value (probably named differently, e.g. "y") at the end. The if block above needs to store that value into yCoord.

Then all of Kael's code should run as it is, unindented.

Finally the ScoreBackground panel needs to be resized with iCountSpecial taken into account. Check out Kael's original code (not in this file) that resizes ScoreBackground. This part needs to be out-dented one level.





Sorry for my ignorance, Emperor... but are you telling me there's more to it than indenting (one extra Tab) the second batch of Kael's code? I think I get what you're explaining... you're telling me that Kael's code needs to execute no matter what, and not under "else"?

I noticed that BUG does add an "else" to the code (right above the second batch of Kael's code), where in the vanilla code it does not.

Correct.

BUG adds the "if bAlignIcons:" test which checks whether or not BUG needs to draw the scores with the Scoreboard.py module. If so, it also sizes and shows the semi-transparent background behind the scores. If not, CvMainInterface.py has already drawn the scores, and it will size and draw the background.

Kael's code adds up to 3 new lines above the scoreboard that should display whether BUG aligns the scoreboard columns or not, and the background should be expanded to contain them.

Sorry, Emperor... but I'm still a little confused on your answer. Do you mean...

Correct... as in I fixed the code correctly (all I needed to do was indent).

or...

Correct... as in there is more to it than indenting? What would be the effect if there is more required than indenting?


If there is more to it... do you think you could show me what code I could use to make it right? I'd certainly appreciate any time you could offer. I'm not sure what else I would need to do to to fix it... that's why I ask. :sad:

(original question link)
http://forums.civfanatics.com/showpost.php?p=7935532&postcount=71
 
Correct... as in there is more to it than indenting? What would be the effect if there is more required than indenting?

This is what I meant. I could probably fix it with a day's worth of effort (maybe less, harder without being able to test as well). I don't know how long it would take to explain what you'd need to do. How good are you at Python/programming?

I explained briefly what is involved in my previous post. Did any of that make sense? If so, what parts?

I'm extremely busy, and my BUG queue is backed up quite a bit at the moment. This is more than a trivial fix as it will require altering how BUG draws its own scoreboard. It's not hard work, but I've got so many things on my plate that I just can't add something this big. BUG is suffering as it is with me just keeping up with the forums. :(
 
This is what I meant. I could probably fix it with a day's worth of effort (maybe less, harder without being able to test as well). I don't know how long it would take to explain what you'd need to do. How good are you at Python/programming?

Not very. I know that doesn't help. I can do minimal, basic tasks... but anything beyond that is over my head.

I explained briefly what is involved in my previous post. Did any of that make sense? If so, what parts?

I'll take a look over this again after work/school today.

I'm extremely busy, and my BUG queue is backed up quite a bit at the moment. This is more than a trivial fix as it will require altering how BUG draws its own scoreboard. It's not hard work, but I've got so many things on my plate that I just can't add something this big. BUG is suffering as it is with me just keeping up with the forums. :(

Roger that.

I certainly understand where you're coming from with this statement! :goodjob:

Well, if you find you have some spare time... doesn't even have to be in the near future, just let me know and maybe we can walk through this... and maybe I can learn something in the process.

So... with this code not working, do you think it's just an iterface issue (meaning, the screen won't draw like it's designed to) or will the the mod be "broke" because it can't execute it's python?

I'm not sure how familiar you are with Assimilation, but here is a brief rundown of the different features that use the above mentioned Python:

There are C++ elements to this mod. Basically, what it does is check your game score every so many turns. If you're in the top 3, it'll raise your difficulty by one level. If you're in the lower 3, it'll lower your difficulty level. Wash, rinse, repeat...

There are also other features of Assimilation, such as every so many turns removing the lowest scoring Civ from the game, and an option that automatically raises your difficulty every XX amount of turns until you reach the hardest level.

I think each time a change in difficulty occurs or a civ drops out, a popup window or something else pops up in the scoreboard, or changes the scoreboard somehow (the Python portion of the mod). I'm just not sure at this point if it'll break the mechanincs of the mod, or if it's just an aesthetic feature that, while it would be nice to have, isn't necessary?
 
The code that Kael added places 0 to 3 extra lines above the scoreboard. They look to be display-only so this won't affect gameplay too much. You can indent them all to fix the problem for now, and you will only lose them when the player turns on Align Icons in the Advanced Scoreboard.

When I get a chance, I'll take a peek at Scoreboard.py that draws the aligned scoreboard to see how much work it will be on my end to make a fix possible.
 
The code that Kael added places 0 to 3 extra lines above the scoreboard. They look to be display-only so this won't affect gameplay too much. You can indent them all to fix the problem for now, and you will only lose them when the player turns on Align Icons in the Advanced Scoreboard.

When I get a chance, I'll take a peek at Scoreboard.py that draws the aligned scoreboard to see how much work it will be on my end to make a fix possible.


Dude, you are the MAN... seriously! :king:


But please, I would hate to have my setbacks hinder your commitments with the BUG team. On the same token, I most definately look forward to any insight you could give to me when you get the chance. :)

I'll turn off Align Icons in the Advanced Scoreboard and see how it looks. If I recall correctly, it's enabled by default. Looking at your code (and how Assimiliation is set up), it makes perfect sense what you just stated.


** EDIT **

Yep, when I turn off the Advanced Features in the Scoreboard menu, the current difficulty shows up above the scoreboard.
 
I'm trying to get it so that the Legend Units I've added to Bronze, Steam & Tears don't show up in the Unit Upgrade tree, and so that they get their own section in the Sevopedia list, rather then being grouped with the other units.

I've looked through the Sevopedia python files, specifically at the wonder buildings, but feel a bit lost. Any ideas on where to start?
 
Their should be a function in SevoPediaMain that creates the list of units. As it loops through the units, check if they are the type you want to exclude before adding them to the list.

As for the upgrade graph, I've never looked at that code.
 
Wow, I've gotten pretty much everything working. Except I can't figure out how to get the Legends to stop appearing in the UnitUpgrade graph. I can use the exception list, but I'd rather not hardcode specific units. Is there a good way to use the maxglobal instances to screen them out?

This is what I've tried so far in UnitUpgradeGraph.py:

Code:
import CvUtil
import SevoPediaUnit

# globals
gc = CyGlobalContext()
ArtFileMgr = CyArtFileMgr()

#The exception list allow you to completely hide a unit from the upgrade graph.
#This is useful for mods that use an unreachable unit to keep others from expiring.
#unitExceptionList = [UNIT_UNREACHABLE]
self.pediaUnit	= SevoPediaUnit.SevoPediaUnit(self)
unitExceptionList = [self.pediaUnit.getUnitSortedList(1)]
Get a python exception and the Civelopedia refuses to open. Says it self. has no atribute.
 
It looks like the code you posted is at the module level (outside a class) along with the other global variables (gc). In this case, there is no "self" to reference. Just use this:

Code:
pediaUnit	= SevoPediaUnit.SevoPediaUnit([B][COLOR="Red"]None[/COLOR][/B])
unitExceptionList = pediaUnit.getUnitSortedList(1)

getUnitSortedList() should return a list, so I don't think you want to wrap it inside another list, but maybe you do (I removed the []s around the call to it).

Here's the problem: I suspect that the __init__ function in SevoPediaUnit requires a non-None value for the SevoPediaMain object. If so, you'll probably need to change the code so that SevoPediaMain passes in the unit list to the UpgradeGraph instead of the other way around.
 
I litterally just got this working, sorry to waste your time EF (like 30 seconds ago). Got some help from Snarko on irc, this is the functional code:

Code:
unitExceptionList = []
for i in range(gc.getNumUnitClassInfos()):
	if (gc.getUnitClassInfo(i).getMaxGlobalInstances() == 1):
		unitExceptionList.append(gc.getUnitInfo(gc.getUnitClassInfo(i).getDefaultUnitIndex()).getType())

So yeah, I just abandoned the importing thing, and tried to tackle it from this angle. Luckily snarko was on to help with the calls and some syntax, as this would have taken me much longer to figure out on my own.
 
So now I am trying to update BUG 3.5 to BUG 3.6. And, to my horror, I see that so much has changed in the file structure of the BUG mod! Wasn't it supposed to be easier to update, post-3.5? :D For the record, BUG 3.5 is merged into my mod.

How do I go about this? I'd hate to start from a blank Python folder... :sad:
 
So now I am trying to update BUG 3.5 to BUG 3.6. And, to my horror, I see that so much has changed in the file structure of the BUG mod!

Really? We didn't add that much to 3.6. I'll take a look tomorrow and see about creating a "updating your merged mods" document for each release. 3.5 made it much easier to merge in your mod and add new features, and that should translate to easier updating too. :confused:

Edit: Looking at the changelog, I don't see anything changed about the file structure. Can you be more specific about the scary elements? For any BUG files that you hadn't modified, you should be able to copy over the new BUG files. For any that your mod modified (should be very few: CvMainInterface and init.xml), either apply the BUG changes or reapply your changes to the new BUG versions.

You don't have to use the new features for modders such as <shortcut>, <symbol>, or the module attribute on <mod>. Those are entirely optional, and you can continue using the old method.
 
Ahhh.... sorry. I think I have messed up my BUG installation. I had a BUG Mod 3.6 folder inside Documents\My Games\Beyond the Sword, with full Assets etc., in addition to an installation in CustomAssets. Which made everything seem like it was there twice. I'll give it another shot.
 
Okay, merging completed. I had to fix about a hundred indentation errors, tedious work, that.

I still have this in PythonErr2 (notice the bolded error at the bottom):
Spoiler :

23:09:36 DEBUG: BugEventManager - adding event 'PreGameStart'
23:09:36 DEBUG: BugEventManager - adding event 'BeginActivePlayerTurn'
23:09:36 DEBUG: BugEventManager - adding event 'LanguageChanged'
23:09:36 DEBUG: BugEventManager - adding event 'ResolutionChanged'
23:09:36 DEBUG: BugEventManager - adding event 'PythonReloaded'
Initializing AIAutoPlay Mod
23:09:36 DEBUG: BugEventManager - setting popup handler for event 7050
23:09:36 DEBUG: BugEventManager - setting popup handler for event 7052
Removing some event handlers
Initializing ChangePlayer Mod
23:09:36 DEBUG: BugEventManager - setting popup handler for event 7060
23:09:36 DEBUG: BugEventManager - setting popup handler for event 7061
Initializing Tester
23:09:36 DEBUG: BugInit - initializing...
23:09:36 DEBUG: BugInit - global context not ready
PY:OnInit
load_module CvAppInterface


And a bit further up in the log, this:
Spoiler :

load_module BugInit
load_module BugConfig
load_module xmllib
..\WARLORDS\ASSETS\PYTHON\SYSTEM\xmllib.py:9: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead.
load_module BugPath
load_module CvModName


Functionality seems fine. Autoplay works, for instance. What is causing these errors?
 
23:09:36 DEBUG: BugInit - global context not ready[/B]
PY:OnInit

This is just a DEBUG message from when I got rid of the need for the CvModName setting and instead use the CvReplay for the game. If it were a problem, it would be labeled WARN or ERROR.

..\WARLORDS\ASSETS\PYTHON\SYSTEM\xmllib.py:9: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead.

This is just a warning about the XML library I'm using that is built into Civ4. You can safely ignore this as well.

Real error messages will show up in PythonErr.log (no 2 in the name). This all looks fine. Do you get any strange behavior?

About the indentation, was this stuff due to merging with BUG? I want to know if I can make merging any easier.
 
Well, I've run about 250 turns on Auto, with zero python issues, so for now I'm content. :) I think all the indentation issues would have been avoided, if I had switched on Compare Spaces (don't know the exact setting name in English) in WinMerge Settings to begin with. I started tracking indentation errors via PythonErr2, but eventually found that combing through the merged files again, with this switch on in WinMerge, was more time efficient. So that's a definite tip for other mergers.
 
Top Bottom