MNAI-U: unofficial build & bugfixes

yeah but when I have champions, assassins, mages, etc running around they should not have 10-20 upgraded warriors. Like I don't remember seeing that at that stage of the game in older builds.

I noticed before that the AI is bad getting modern units. I think they sometimes don't build the required military buildings early enough. You could try to enabling the "AI No Building Requirements" option.
I'd be surprised if this a MNAI-specific problem, though.
 
I found a game crashing possible bug. Take a fireball from the mega-stack of Mages due south of Astrum, sling it at the stack of Sidar Ghosts under the Illian Knight on the hill west-northwest of Astrum. Game immediately crashes.
 

Attachments

  • cdsteig TURN-0355.CivBeyondSwordSave
    2 MB · Views: 36
Immortal units with limited duration really should not be reborn with no duration limitation upon their duration's expiration.

I think I mentioned this before and you may have already addressed it, but I just wanted to make sure it is fixed for the next release.

In a recent game I had some Changelings take on the form of one rival Stoneskin Ogre, and then was surprised when they become an enduring army of immortal units.


Similarly, units that are both bImmortal and bAbandon should not be reborn if the bAbandon religion/civic/alignment criteria are not met.




Bickendan's description of his crash reminded me of several crashes I have experienced a while back. I had a couple saves that would reliably crash, but they were from an unreleased version of my modmod with numerous changes from the last released version. I've made numerous changes that break saved games since then.

My theory on those crashes was that they were caused by units that had the Hidden promotion engaging in combat that caused them to loose their invisibility (because PROMOTION_HIDDEN has <bRemovedByCombat>1</bRemovedByCombat>) while remaining on a tile with hostile units. I think in one of the saves the previously hidden unit remained Hidden Nationality and in another units with whose owner its owner was at war had entered the tile without combat due to the Hidden status. These were on a pretty crowded map, so it may be that the game would normally eject the units once they became visible but could not find a place to put them.
 
That sounds reasonable - Knight 1 killed a unit on that tile, leaving Chalid as the remaining visible unit. Knight 2 kills Chalid, moves onto the tile.
An archmage casts the eyeball, revealing Rathus and the posse of ghosts under Knight 2. The 20 other mages cast fireballs. First fireball forces Rathus a tile south, next kills him. He drops his dagger. Third fireball crashes the game; alternately, the fireballs can successfully deal with the Bannor stack, including a shadow, just north of Astrum.
 
I suspect it's an older mod build then, as I haven't updated in quite some time.
The flag tooltip should tell you the version you're playing with.

Immortal units with limited duration really should not be reborn with no duration limitation upon their duration's expiration.
Okay, I'll make it so that temporary units are not reborn.

Similarly, units that are both bImmortal and bAbandon should not be reborn if the bAbandon religion/civic/alignment criteria are not met.
How do you get that situation? The unit abandons you because of a religion/... change and then is reborn?
 
I don't mind limited duration units being reborn after dying in combat; when that happens they still keep their duration limits, You just meed to add a single lint of code just before expiring duration kills a unit to make the unit mortal first. It goes the same place as the line I had added to unload any cargo in limited duration summons like by Rifts/Warp Bubbles.



Yes, converting to a different State religion will make any bAbandon units that require that state religion to abandon you but them come back, only to abandon you again the next turn an every turn until you convert back. It could also happen based on Civics, if a unit like the Royal Guard were immortal.

I don't think bAbandon checks for Alignment, but I think it would be nice if it did.

In my next version I'm planning on adding the Silkies, Neasa, and Maolisa as immortal units that require the Eternal Cabal (Arawn's cult) as a state religion and abandon you if you convert away, but the way things work currently you could train them and have them forever after changing religions.

(Silkies would be religions champions like paramanders, but likely limited to 7 per player. I'd like to make Maolisa available to evil players and Neasa to good (or at least non-evil) ones. I'd like to let Neutral players have Khalida, but only if I can figure out how to make her stronger every time she died and comes back to life. I thought I could put code in under onUnitLost to do so, but it does not seem like this code is actually running during an immortal's resurrection.)
 
Last edited:
The flag tooltip should tell you the version you're playing with.
Looks like it's MNAI 2.7. I'll attach a screenshot as I want to finish this game before upgrading. The lack of places where the outed Sidar Ghosts can go is likely what's causing the crash: I have a knight occupying the tile Rathus was killed so I can capture his dagger, and the Sidar apparently don't have open borders with the Bannor, so they are pincered.
 

Attachments

  • Game Chrash.png
    Game Chrash.png
    4.4 MB · Views: 47
I think if you want to be helpful here you need to better express "the problem" - at least I dont understand how exactly the AI got worse - if that is what you are saying.

I don't know how I was not clear enough on what you call "the problem". I will simply repeat myself again. The AI is not keeping up to us in our games. We use to run the game on prince, "prince" since we like to use quotes here, and the AI did not have a problem at least than on keeping up with upgrading their units and keeping up with us on score. Now it seem like they have a issue where they are either building too many warriors without the economy to upgrade it

I noticed before that the AI is bad getting modern units. I think they sometimes don't build the required military buildings early enough. You could try to enabling the "AI No Building Requirements" option.
I'd be surprised if this a MNAI-specific problem, though.

I mean we never did that before, but I suppose we could try it next time and see the results. Though it still strange the whole thing.
 
I don't mind limited duration units being reborn after dying in combat; when that happens they still keep their duration limits, You just meed to add a single lint of code just before expiring duration kills a unit to make the unit mortal first. It goes the same place as the line I had added to unload any cargo in limited duration summons like by Rifts/Warp Bubbles.
I see, thanks for the hint. :)

Yes, converting to a different State religion will make any bAbandon units that require that state religion to abandon you but them come back, only to abandon you again the next turn an every turn until you convert back. It could also happen based on Civics, if a unit like the Royal Guard were immortal.
Thanks, should also not be hard to fix.

In my next version I'm planning on adding the Silkies, Neasa, and Maolisa as immortal units that require the Eternal Cabal (Arawn's cult) as a state religion and abandon you if you convert away, but the way things work currently you could train them and have them forever after changing religions.
Okay, maybe I still don't quite get it. I thought you said they abandon you the turn after they are reborn?

Just FYI, I expected to release next weekend (playtesting is done), but I'll have to see how hard Bickendan's bug is to fix.

I don't know how I was not clear enough on what you call "the problem". I will simply repeat myself again. The AI is not keeping up to us in our games. We use to run the game on prince, "prince" since we like to use quotes here, and the AI did not have a problem at least than on keeping up with upgrading their units and keeping up with us on score. Now it seem like they have a issue where they are either building too many warriors without the economy to upgrade it
Some things that might be helpful: How many games did you play where the degenerate AI behavior happened? I understand that it happened in every game you played recently? What mapscripts do you play? What where the AI civilizations? Do you know which old EMM/Magister versions you played where the AI behavior was better? Could you provide a savegame that shows the problem?
In my recent games the AI seemed to do fine mostly. They are not very good at "beelining" specific military technologies, which is what players usually do.
It is unfortunately really hard to test this stuff, because I don't have a good criterion for when the AI should research which techs and train which units (in the sense of "by turn m, you should have n Archers/Axemen/...) , so I cannot even easily identify games where this is a problem.
 
Okay, maybe I still don't quite get it. I thought you said they abandon you the turn after they are reborn?

Just FYI, I expected to release next weekend (playtesting is done), but I'll have to see how hard Bickendan's bug is to fix.
If a unit has the bAbandon tag, and you cease to meet the prerequisite state religion/civic requirements, the game waits until the end of your turn (actually I think it is probably beginning of the next turn) to kill the unit. The game checks these unit's prerequisites every turn, not just when the player changes religions or civics.

(In the case of religious heroes I believe it also de-incremenets the unit so that a player who does meet the requirements may train the hero again, whether that is a different player or the same player after going back to the previous religion.)

If a unit has the bImmortal tag, it becomes immortal again every turn and has to be killed twice in a single turn in order to stay dead. The bAbandon death from not meeting prerequisites seem to count as an ordinary death but only one per turn, so the unit keeps coming back.

A unit with both bImmortal and bAbandon will thus keep dying and keep coming back every turn until you return to its prerequisite religion/civic.



p.s. Would it be possible to add a python callback for a bImmortal or Promotion_immortal unit's resurrection, or to make it so that the unit does use the onUnitLost callback maybe with a special tag to check it it is immortal? I'd really like it if I could get Khalida working the canonical way where she gets stronger with each death and resurrection, but the code in onUnitLost seems to be ignored. I'd also like certain immortals (Heirs of Taranis, Os-Gabella, and Auric Ascended) to be rebron at full strenth instead of being injured, I think I'd also like it if bImmoral units whose owners have no capital cities (such as Barbarian units) get reborn on random tiles instead of dying permanently.
 
If a unit has the bImmortal tag, it becomes immortal again every turn and has to be killed twice in a single turn in order to stay dead. The bAbandon death from not meeting prerequisites seem to count as an ordinary death but only one per turn, so the unit keeps coming back.
Thanks, that's what I missed. I'll fix this and the immortal temporary summons in the upcoming version.

p.s. Would it be possible to add a python callback for a bImmortal or Promotion_immortal unit's resurrection, or to make it so that the unit does use the onUnitLost callback maybe with a special tag to check it it is immortal? I'd really like it if I could get Khalida working the canonical way where she gets stronger with each death and resurrection, but the code in onUnitLost seems to be ignored. I'd also like certain immortals (Heirs of Taranis, Os-Gabella, and Auric Ascended) to be rebron at full strenth instead of being injured, I think I'd also like it if bImmoral units whose owners have no capital cities (such as Barbarian units) get reborn on random tiles instead of dying permanently.
Sure, but calling onUnitLost seems not a good idea, since the unit is not actually lost and future modders might misunderstand the function's behavior. I'd rather make it a new callback. I'll put it on the TODO list and see how it works currently.
 
I was discussing the bug I found with a couple friends, and as we were analyzing the logic of it, my thoughts were along the lines of hidden units shouldn't be beholden to open border rules; ie, they should behave like Loki when he's attacked. That could solve the game crashing nature of the bug (which neccesitates a alt-ctrl-del Windows signout if not a hard system restart on Fullscreen Mode for me as the game won't release and minimize the overlay to address the Dump File window - solved by switching Civ IV to Windowed Mode): Using my screenshot as an example, we know that if a fireball or other unit fails to kill a Hidden Ghost or Shadow, and that Ghost or Shadow Withdraws or is otherwise forced to move by the nature of an enemy unit sharing the tile, they cannot move to a tile occupied by an enemy unit; they cannot move to a Mountain or Coast/Ocean Tile [as it's unlikely they'll have promotions or skills allowing it]: Here, the only other tiles available would be 'closed' 3rd Party rival territory (no Open Borders). But, as Stealthed Units, this shouldn't matter as the 3rd Party rival Civ wouldn't 'know' they're there.

Extreme case (ie, trying to corner and kill Loki situations): The Stealthed Units Withdraw or are otherwise forced to retreat, and all eight tiles are occupied by the Hostile Actor (Player or AI at war with them) or Impassible Terrain. In such situations, to prevent a game crash, override combat results and force a defeat for the defender and a victory for the attacker? A: Is that even possible? B: Does that infringe on Balance Issues? C: Situation not yet coming to mind?

Obviously, this is a fairly esoteric bug to begin with and the more I think of it and how it works the more I'm amused by it (outside of the Fullscreen Mode issue).
 
Routing shenanigans - see screencap.
Using Go To function to move entire stack into city I captured; it's wanting to take a 3 turn route around my city instead of directly into it.
 

Attachments

  • Routing wtf.png
    Routing wtf.png
    5 MB · Views: 50
Moving a stack of troops (especially with mixed units and/or mixed movement points) usually does not give correct information when using the goto command and this is a bug even in base BTS. I've never had it actually take more turns than it is supposed to but it does get annoying when trying to calculate multiple turn moves on mixed not roaded terrain. That said one of the reasons that is giving you a weird path is because you are moving from what appears to be hostile land into a hill tile (the city) in friendly land. Because you are moving them as a group it will prioritize those units that can not use enemy roads in the calculation which means that it will prioritize a different path that looks bad but is actually not that bad for those units. Once you add in the mixed unit thing with the not every unit can use enemy roads thing these things happen and at that point it's best to move troops one at a time if you care about having movement points remaining when they get there. If you don't care about movement points remaining and just want every in the city then it should move them just fine on the same turn but do have at least 1 unit that you can cycle to after trying just in case or move then one at a time.
 
That's all true but there is no way that the pathfinding algorithm is going to think that moving one tile sideways is more than 3 moves. Something is definitively wrong here.
 
I'm not trying to be rude here but I already explained exactly why the game "thinks" it will take 3 turns in my first sentence.
 
I'm not trying to be rude here but I already explained exactly why the game "thinks" it will take 3 turns in my first sentence.
I understood your logic. I just disagree with your conclusion.

We know that moving from one tile to another adjacent tile can newer cost more than 1 movement point for units with 1 movement point. If that could happen the game would end up in states where some units can't ever walk into certain squares. Knowing this and given that these two tiles are directly touching their movement cost for units with 1 movement point can't be more than 1.

Looking at the screenshot it clearly shows A unit with a movement of 1. And that unit is going to dictate pathfinding behavior for the entire stack. Thus it is, or rather should not be possible for the stack not to be able to move directly into the adjacent tile.

Roads, ownership or anything else does not really modify this. Certainly not sufficiently to make the move cost 4. Not unless this mod has some very extreme deviations from vanilla in terms of terrain and movement mechanics. Well that or if the pathfinding is coded extremely ass backwards and does not actually use movement points spent but some odd arbitrary algorithm that ignores the obvious numerical value it could test. But that would be just dumb from a development standpoint.
 
There is a lot of what you said that is correct and a lot that is completely wrong. We are talking about a situation with 2 different issues that is appearing to be one single issue. First, as I said before, the game will not actually take 3 turns to move those troops and will likely move them all in that turn. Looking at the list of promotions I think there are enough movement points to move those 3 tiles but because the list of promotions is maxed out visually and I don't know what every unit has as a base I can not be 100% sure of that. That you are seeing a timeframe of 3 turns is a graphical bug and is not what will actually happen when you move the troops. The second issue is the exact path those troops will take which at first glance seems to be bad but when calculating stack movements of different unit types the game will default to whatever is best for the worst unit. Some of those units would be far better off being moved individually (or creating a 2nd group) but because they are all 1 group they will all follow the same path. I am very aware that having anything above 0 movement will allow you to move into a higher cost tile for less than it should (and I sometimes abuse that mechanic with the body mana movement spell) but again we are calculating the movement for the entire group and because of how it defaults to do what's best it will and does ALWAYS take into account roads, ownership, and anything else that affects movement. If yall wish to track down and figure out the graphical bug I'm sure the entire civ 4 community would appreciate it since that bug is in the base game (or at least BTS) but I do recommend creating a separate topic for it since it's not caused by anything in MNAI unofficial.
 
Top Bottom