MNAI-U: unofficial build & bugfixes

Thanks!


I think I have it all merged with my modmod now, but it could still use some playtesting and debugging.

So far the most noticeable bug in my merged version is that only the alphabetically first 7 spells and 10 special abilities show up in the civilopedia, and nothing happens when I click on those spells/abilities to try to see more details on what they do.

I'm getting this python exception
Code:
Traceback (most recent call last):
  File "CvScreensInterface", line 471, in pediaMain
  File "SevoPediaMain", line 258, in pediaJump
  File "SevoPediaMain", line 355, in showContents
  File "SevoPediaMain", line 635, in placeSpells
  File "SevoPediaMain", line 1026, in placeItems
RuntimeError: unidentifiable C++ exception
ERR: Python function pediaMain failed, module CvScreensInterface

Traceback (most recent call last):
  File "CvScreensInterface", line 519, in pediaJumpToSpell
  File "SevoPediaMain", line 302, in pediaJump
  File "SevoPediaMain", line 355, in showContents
  File "SevoPediaMain", line 639, in placeAbilities
  File "SevoPediaMain", line 1026, in placeItems
RuntimeError: unidentifiable C++ exception
ERR: Python function pediaJumpToSpell failed, module CvScreensInterface


I think my Sevopedia files are all identical to yours (except one line in SevoPediaPromotion.py checking channeling promotions)

The hardest part of the merge was sorting through the majority of python differences which are just white space. I tried to clean up my files a long time ago to get rid of trailing spaces, tabs, and to consistently use tabs for syntactically important indentation instead of spaces or an odd mix of tabs and spaces. I also like to consistently capitalize True and False so that me editor recognized them as keywords. A lot of your files have white space that is still a mess, so most of my time merging was spent going through to white space differences before dismissing them as inconsequential. I would appreciate it if you cleaned up the white space for future versions, at least in those files that are otherwise identical in my modmod which you could simply copy from my next release.
 
Last edited:
I'm getting this python exception
Ouch, looks like some bug in the spell help code. Can you post the XML of the first spell that doesn't show up in the pedia?
I'm currently away, so I'll get to this in 10 days or so.

The hardest part of the merge was sorting through the majority of python differences which are just white space. I tried to clean up my files a long time ago to get rid of trailing spaces, tabs, and to consistently use tabs for syntactically important indentation instead of spaces or an odd mix of tabs and spaces. I also like to consistently capitalize True and False so that me editor recognized them as keywords. A lot of your files have white space that is still a mess, so most of my time merging was spent going through to white space differences before dismissing them as inconsequential. I would appreciate it if you cleaned up the white space for future versions, at least in those files that are otherwise identical in my modmod which you could simply copy from my next release.
The biggest problem with that is that it messes up history in the repository. But I thought of maybe changing the folder structure; if/when I get to that, I will also normalize whitespace.
Also, your merging program might have an option to ignore whitespace.
 
Ouch, looks like some bug in the spell help code. Can you post the XML of the first spell that doesn't show up in the pedia?
I'm currently away, so I'll get to this in 10 days or so.

It is kind of hard to tell what the first spell that doesn't show up in the pedia is. The entries are sorted alphabetically and I'm not sure which spell would come after Assume True Form (the last Spell), but if I comment out the lines that sort them (so I can go by the order in the xml file) I get a very different list. A lot of my spells use the <bGraphicalOnly>1 tag, which I had to change to 1 to see whether the issue could be with any of them.

I found that when looking through the religion pedia entries that certain spells cause the game to crash when I do a mouseover. These include Astral projection (basically Sever Soul, but as a spell for Coven priests, ie., Mobius Witches), Rescue Refugees (the Brotherhood of Warden's priest spell, which reduces city population and creates a refugee unit that can be settled as population elsewhere), and Summon Guardian Vines.

In the civilizations page I get a crash when mousing over Summon Sand Lion or Rebuild War Machine.

In the spell sphere promotions, I get crashes when mousing over Raise Skeleton Greater, Raise Skeleton, Raise Dracolich, or Craft Automaton.

Code:
ERR: Python function pediaMain failed, module CvScreensInterface
Traceback (most recent call last):
  File "CvScreensInterface", line 519, in pediaJumpToSpell
  File "SevoPediaMain", line 302, in pediaJump
  File "SevoPediaMain", line 355, in showContents
  File "SevoPediaMain", line 639, in placeAbilities
  File "SevoPediaMain", line 1026, in placeItems
RuntimeError: unidentifiable C++ exception
ERR: Python function pediaJumpToSpell failed, module CvScreensInterface


Traceback (most recent call last):
  File "CvScreensInterface", line 471, in pediaMain
  File "SevoPediaMain", line 258, in pediaJump
  File "SevoPediaMain", line 355, in showContents
  File "SevoPediaMain", line 639, in placeAbilities
  File "SevoPediaMain", line 1026, in placeItems
RuntimeError: unidentifiable C++ exception
ERR: Python function pediaMain failed, module CvScreensInterface

Traceback (most recent call last):
  File "CvScreensInterface", line 457, in linkToPedia
  File "SevoPediaMain", line 1127, in link
  File "SevoPediaMain", line 302, in pediaJump
  File "SevoPediaMain", line 355, in showContents
  File "SevoPediaMain", line 635, in placeSpells
  File "SevoPediaMain", line 1026, in placeItems
RuntimeError: unidentifiable C++ exception
ERR: Python function linkToPedia failed, module CvScreensInterface

There seems to be a pattern among what spells' mouseovers cause a crash. They all create permanent summons.

It should be noted that I was using this new option in GlobalDefinesAlt.xml:
Code:
    <!-- If 0, permanent summons can only be summoned if the player has less units of the summoned type than summoners.
        If 1, permanent summons can only be summoned if the caster has no living summon of that type.  -->
    <Define>
        <DefineName>COUNT_SUMMONS_PER_CASTER</DefineName>
        <iDefineIntVal>1</iDefineIntVal>
    </Define>

When I change it back to 0 in my modmod, then the pedia seems just fine.


I just checked on what happens in the latest MNAI if I only change that tag. Its spell and special ability lists also end early. The first spell not listed is Graft Flesh and the first ability not listed is Create Battering Ram; those are the first permanent summons in either list. When I go to the Magic Spheres and select Death 1 so I can mouseover Raise Skeleton, that also causes a crash to desktop.


I tested giving myself a unit with Death 1 so I could mouseover Raise Skeleton in game. I notice no mention of a limit on the number of summons before using the spell the first time, and then once I already have a Skeleton there is a red warning "Can only Maintain one summon of this type" at the bottom of the mouseover.

I bet the pedia is trying to determine whether to include that line, but then running into an issue as there is no caster whose existing summons it can check.

Frankly I think it would be better to display the "Can only Maintain one summon of this type" requirement for those spells all the time. Having it show up in red to indicate why a caster cannot currently cast is nice, but it is frankly more useful to know about such limits before deciding whether to cast a spell while it is still available.



Until you get that issue fixed, I guess I'll just not use the COUNT_SUMMONS_PER_CASTER tag and instead go back to using a python prereq to limit the number of summons and a dummy promotion with a PyPerTurn effect to remove the limited duration from non-permanent summons if I don't want them to count against the civ wide permanent summon limit. I had deleted that code during the merge but it won't be hard to add back using WinMerge from a backup I made before.

The biggest problem with that is that it messes up history in the repository. But I thought of maybe changing the folder structure; if/when I get to that, I will also normalize whitespace.
Also, your merging program might have an option to ignore whitespace.

WinMerge's Whitespace options are Compare, Ignore Change, and Ignore All, but when I use those options it has occasionally missed indentation issues.

I do tend to make it ignore whitespace when I first merge the files, but then if I find any sort of bug I feel the need to go back to the more tedious process of comparing whitespace too.

Occasionally I have found really weird bugs that I could not explain but which could be fixed if I delete an errant space found between tabs in certain files. That includes XML files, even though I didn't think spaces and tabs had a syntactical meaning there like in python.

------

I'm noticing that all of my priests have the Automated Terraforming command, even though the only priests in my modmod with any terraforming spells are Druids (with Vitalize) or Saperes or Mobius Witches that purchase mage promotions.

Clicking the Automated Terraforming command mostly seems to function like Skip Turn (even for Druids who could, although I find that it does send Saperes to sacrifice themselves to construct buildings and that one with Water 1 may try to cast spring sometimes. It seems to make a Mobius Witch wander around but haven't seen one do much yet, perhaps because I have not promoted any with spell spheres that let them cast terraforming spells.

When I removed the <bAllowAutomateTerrain>0</bAllowAutomateTerrain> tag from Vitalize spell then all the priests (except those given affinities that also grant terraforming spells) loose that automate button

I think you forgot to check for religious prereqs on Divine spells like you said you would in this post https://forums.civfanatics.com/threads/mnai-u-unofficial-build-bugfixes.645898/page-21#post-16152117
------

How exactly is Inflation supposed to work?

I was thinking of changing the Stewards of Inequity priest spell to a thematically appropriate new ability called Counterfeit, which give the caster's owner's free gold at the cost of increasing inflation.

(Previously their spell was a trade mission that worked a lot like a great merchant's, even killing the caster, but subtracted the same sum of gold from the target city's owner. The AI never figured to that spell though and I didn't really like the Rentiers being so disposable that they could not level up to Cronies.)

I could not find any python function to change inflation, but there is already an Event that does so. I tried writing a spell to trigger that event. The event seems to trigger just fine, but when I check the financial adviser screen the inflation always seems to stay at 0.


Whenever you do get around to cleaning up white space, can you also make sure to match open and closed quotes in the various text files so that my editor won't mark huge sections of the files in a different color as being within quotes? It seems that German text strings are the biggest offenders for that.
 
Last edited:
Can you make it so world spell casts show in the event log? Would assist strategy when knowing when Sanctuary ends. I noticed the Amurite spell and Stasis turns display to all players, but Sanctuary does only to the one who cast it.
 
Gargoyles can attack into players' territories. End turn at the attached save.
 

Attachments

  • AutoSave_TURN-0270.CivBeyondSwordSave
    415.4 KB · Views: 25
I could not find any python function to change inflation, but there is already an Event that does so. I tried writing a spell to trigger that event. The event seems to trigger just fine, but when I check the financial adviser screen the inflation always seems to stay at 0.
There is a base inflation calculated by the current game turn (modified by gamespeed and handicap, and some other stuff for AI players). On top of that, each player has a modifier that is permanently changed by those events (and nothing else). I'll just expose the modifier. You should probably be careful with reducing inflation like that. Casting a -10% inflation spell 10 times would totally remove inflation.

Whenever you do get around to cleaning up white space, can you also make sure to match open and closed quotes in the various text files so that my editor won't mark huge sections of the files in a different color as being within quotes? It seems that German text strings are the biggest offenders for that.
I found a couple missing or superfluous quotes and removed them, but isn't the rule in English that you repeat a quotation mark at the beginning of a paragraph within a quote? See e.g.
TXT_KEY_WB_WAGES_OF_SIN_HERO_VALIN_CALABIM. So I don't think this will help your text editor problem.
 
I just found, and fixed, another minor bug in the pedia.

in line 136 of Assets\python\Contrib\Sevopedia\SevoPediaProject.py, gc.getTechInfo( iPrereq ) should be gc.getProjectInfo( ePrereqRitual )

Code:
#BUGFfH: Added by Denev 2009/08/16
        iPrereqCiv = gc.getProjectInfo(self.iProject).getPrereqCivilization()
        if (iPrereqCiv >= 0):
            screen.attachImageButton(panelName, "", gc.getCivilizationInfo(iPrereqCiv).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iPrereqCiv, 1, False)
#BUGFfH: End Add
        iPrereq = gc.getProjectInfo(self.iProject).getTechPrereq()
        if (iPrereq >= 0):
            screen.attachImageButton(panelName, "", gc.getTechInfo(iPrereq).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, iPrereq, 1, False)
        # lfgr 04/2021: Show required ritual
        ePrereqRitual = gc.getProjectInfo(self.iProject).getAnyoneProjectPrereq()
        if ePrereqRitual != -1 :
            screen.attachImageButton( panelName, "", gc.getTechInfo( iPrereq ).getButton(),
                GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROJECT, ePrereqRitual, 1, False )

Code:
#BUGFfH: Added by Denev 2009/08/16
        iPrereqCiv = gc.getProjectInfo(self.iProject).getPrereqCivilization()
        if (iPrereqCiv >= 0):
            screen.attachImageButton(panelName, "", gc.getCivilizationInfo(iPrereqCiv).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iPrereqCiv, 1, False)
#BUGFfH: End Add
        iPrereq = gc.getProjectInfo(self.iProject).getTechPrereq()
        if (iPrereq >= 0):
            screen.attachImageButton(panelName, "", gc.getTechInfo(iPrereq).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, iPrereq, 1, False)
        # lfgr 04/2021: Show required ritual
        ePrereqRitual = gc.getProjectInfo(self.iProject).getAnyoneProjectPrereq()
        if ePrereqRitual != -1 :
            screen.attachImageButton( panelName, "", gc.getProjectInfo( ePrereqRitual ).getButton(),
                GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROJECT, ePrereqRitual, 1, False )
 
For those interested, I just posted a thread on my plans for the revolution component, as announced a while ago. Feel free to discuss there.

I don't know about German grammar rules but here is a discussion about English quotation usage if it helps. https://english.stackexchange.com/questions/96608/why-does-the-multi-paragraph-quotation-rule-exist
Thanks, that confirms what I was saying. In German you definitely don't do this.

I just found, and fixed, another minor bug in the pedia.
Thanks!
 
edit: It seems that this odd bug was all caused by accidentally using UNIT_DRAGON_SIEGE where it should have been UNITCLASS_DRAGON_SIEGE, in both CIV4UnitInfos.xml and CIV4UnitClassInfos.xml

Spoiler :
I just noticed an odd graphical bug in which helpUnitHelp(iUnit) sometimes uses the <UnitCreateFromCombat> tag from the wrong unit.


I was testing an adjustment to the prereqs for resurrecting the Imprimatur Council members in my modmod, when by chance I noticed that the helpUnitHelp(iUnit) for Wode claimed that he has a "+0% chance of creating a Clockwork Golem if successful in combat"

Nothing in his own xml defines referred to a Clockwork Golem. He had no UnitCreateFromCombat or iUnitCreateFromCombatChance tag. However, he is isted in CIV4UnitInfos.xml directly after Velgyr, who should have a 5% chance of creating Clockwork Golems in combat. Velgyr's chance of creating Clockwork Golems is now showing up in his help string though.

Wode was bGraphicalOnly so I could not check if the help string was the same in the pedia without changing that tag. When I tested changing that tag to 0 for every unit (before realizing I could have just used mouseovers in the add unit mode of Worldbuilder), I saw Velgyr and Wode were not the only units experiencing that kind of bug.

There were several other units claiming to have a "+0% chance of creating a X if successful in combat" where X is the type of unit that might be generated in combat by the previous unit in CIV4UnitInfos.xml.


Based on the text I found "[ICON_BULLET]%D1% chance of creating a %s2_unit if successful in combat" is from the tag "TXT_KEY_UNIT_CREATE_FROM_COMBAT", which is only called in CvGameTextMgr.cpp in lines 1590 and 12943. I skimmed the code but don't see why it would be calling the wrong unit.


It seems to work correctly for some units, such as the Air Elemental being correctly listed as generating Lightning elementals rather than falsely claiming that Earth elementals make lightning elementals.

I'm not sure yet what the distinction is between those cases, but I think that all of these graphical bugs have to do with World Units that can never be trained (having a cost of -1 and being created only through spells) which should generate units in combat not showing up as generating the unit but whatever unit is listed next being falsely listed as doing so.

For example, Morrigan should have a 1% chance of generating Angels of Death, but her help string sdoes not list any chance of generating any units while Condatis's claims she has a 0% chance of generating Angels of Death. Sarabride should have a 1% chance of generating Seraphs but instead it claims the Ironclad has a 0% chance of generating them. Leucetious should have a 1% chance of generating Adventurers, but that is not listed and it claims Majen has a 0% chance of generating Adventurers instead.

When I tried seeing what would happen if I gave Wode a 10% chance of generating Baby Spiders, it instead claims he has a 10% chance of generating Clockwork Golems while Kylorin (who comes next after Wode in CIV4UnitInfos.xml) then gained a 0% chance of generating Baby Spiders.
 
Last edited:
When I tried seeing what would happen if I gave Wode a 10% chance of generating Baby Spiders, it instead claims he has a 10% chance of generating Clockwork Golems while Kylorin (who comes next after Wode in CIV4UnitInfos.xml) then gained a 0% chance of generating Baby Spiders.
What did Wode generate in combat after that change? Golems or Spiders?
 
What did Wode generate in combat after that change? Golems or Spiders?
I just now checked and found it generated a Clockwork Golem.

I guess this is more than just a graphical bug.


Edit:
I went through and tried adding other UnitCreateFromCombat tags to other units to see which ones would apply to the right unit and which ones to the wrong one.

Everything seems to be working properly until we reach the Siege Dragon entry. When I made the siege dragon generate Chas Marauders, that got pushed on to the Spire Dragon, when I made the Spire Dragon generate Djinni those got pushed onto the Vault Wyrm, etc.

The Siege Dragon entry also inexplicably says that it can use the Craft Ice Golem ability, which should belong only to Barnaxus when running the White Hand religion.

Edit 2: I tried replacing the Siege Dragon entry with a copy of the Pit Dragon just replacing the specific strings in case I was somehow overlooking some error with it. When I tried loading a save I then found an assert claiming that UNITCLASS_DRAGON_SIEGE does not exist. When I looked in CIV4UnitClassInfos.xml I was surprised to see that the unitclass was called UNIT_DRAGON_SIEGE instead of UNITCLASS_DRAGON_SIEGE. I'm guessing UNIT_DRAGON_SIEGE might have the same index as UNITCLASS_BARNAXUS? I'm not sure.

When I fixed that dragon's UNITCLASS it seemed to fix the Craft Ice Golem bug and all of the bugs with generating the wrong unit type!
 
Last edited:
Something that came to mind when checking out Revolution mechanics again: Would it be possible to add a crime rate display to the city screen, that when hovered over tells you what contributes (+/-) to the rate? Or does that exist and I am just blind? So far the only way I know of checking the crime rate is to hover over the city from the world map.
 
Crime rate doesn't actually do anything anymore right? It was relevant when Corporations were a thing but now I think it only slightly effects some events (kidnappers and such only occur if there's crime).


The issue with the AI and Open Borders is actually pretty simple. The AI no longer view it as a fair and equal deal. When they offer they've obviously hit their trigger to offer an advantageous deal to the player, but every single time the player requests it they refuse until you chuck something else in to sweeten the deal. But then the something else isn't linked to that Open Borders agreement (GPT or Resources) so when they cancel the Open Borders they don't have to cancel the other trade, so the AI always thinks its getting a raw deal with Open Borders.
Issue I reported years ago on 2.7beta2 release. I actually figured out the Open Borders issue a while ago, the AI doesn't think it's a fair deal if you have founded a religion. If you want open borders for missionaries the AI expects you to pay for it, even if you're not spreading your religion about. If both you and the AI have founded a religion its a bit more fair, not sure if the AI considers if they want to spread their religion to you but still.
 
It affects events - in vanilla, I think high crime is actually beneficial due to some better chances at good event outcomes. But it is more relevant with the revolutions gameoption, where crime can cause instability.
 
Top Bottom