[MOD] More Naval AI

Version 2.4 Official Release (not compatible with any previous saves)

Download link

Bugfixes
  • Barbarian animals should no longer try to guard cities
  • Units with a 0 value for iXPValueAttack or iXPValueDefense should no longer grant a minimum of 1 experience after combat (they will now grant no experience) (fix for fireballs granting experience)
  • Perfect Sight (bSeeInvisible) updates sight when given and will now see through all invisible types (fix by red-key)
  • Fix for potential crash after playing a game of Somnuim for pride
  • Fx for units with AI_CITY_DEFENSE sometimes getting stuck in a loop
  • Fix for potential assert caused by Enraged units
  • Fix for players not receiving free techs properly when playing a multiplayer PBEM game (fix by Sareln)
  • Fix for Unhealthy hits from Blight to always be a fixed formula. It now starts with a random base of 1-15 as originally intended
  • Illusionary units will no longer drop equipment
  • Illusionary units that split after dying in combat will now create illusionary units
  • Fix for players being unable to create Puppet States when the city they captured had been originally founded by Barbarians, even though the current owner was a legitimate civ (bug find and fix by lfgr)
  • Tolerant players should no longer be able to train barbarian units in captured barbarian cities
  • Fix to (hopefully) stop barbs from spawning disciples and other religious units
  • Fix for potential assert error in AI_barbAttackMove()
  • Fix for potential python error (fix and bug find by MagisterCultuum)
  • Fix for potential python errors when running with debug logging and Revolutions
  • Removed invalid references to Team 7 in Wages of Sin scenario
  • Updated Lord of the Balors scenario - slotted Einion Logos into the empty player spot; made adjustments to starting locations for the non-Infernal players and removed the Starting Settler promotion as well to try and keep them from settling on top of each other

AI
  • AI should be better about attacking cities with nearby stacks
  • AI will no longer use limited national units or high tier units for exploration
  • Adjustments to the default AI for a number of units (assassins, beastmasters and druids should no longer be assigned to AI_EXPLORE; Monks now allowed UNITAI_ATTACK_CITY, Axemen class units now allowed UNITAI_CITY_DEFENSE, other tweaks)
  • Explore units will now use AI_heal() to decide whether or not to heal
  • Added some logic so that units using AI_heal() will sometimes seek out defensive ground first
  • Players who are running the GetBetterUnits strategy are now more likely to create unit training buildings
  • Sprawling civs less interested in city sites with lots of water
  • Terraformers should be a little better about avoiding danger
  • Patrol groups will sometimes consider attacking a nearby enemy city
  • Units converted to Shades should now disconnect from their group
  • Barbs should be more proactive about building new cities if Raging Barbarians or the No Settlers options are selected
  • AI's eagerness to attack weak neighbors will now scale with difficulty level
  • Fallow civs should be less interested in resources and techs that grant food or health bonuses
  • Civs with only 1 city are less interested in adopting a Crush strategy unless they are Aggressive or the One City Challenge option is on
  • AI less likely to use higher-level units to create buildings
  • AI should be more interested in civics that reduce food consumption (ie Infernal Pact)
  • Added python catch for the Illians to make sure they build their best projects
  • AI will give more value to spells that increase a cities population
  • Tweaks to how the AI values units. Now using AI_CombatValue() for the player rather than the game so now things like weapon tier and mana affinities are figured in
  • AI will now take into account traits that grant extra combat strength (ie Sinister) when calculating AI_trueCombatValue()
  • Several tweaks to city production code - AI should be better about building early workers, workboats, settlers and defensive units; should also be better about creating buildings that it needs in order to train better units
  • Updates to AI_techValue() - AI will be more interested in Open Borders techs if they have met more players; AI should be more interested in Agriculture and Sanitation; Tweaks to how the AI chooses to research religious techs; AI should be more willing to puruse techs that are further down the line; tweaks to how the AI values units and buildings when choosing techs; AI should be more interested in techs that unlock Altar buildings when pursuing an Altar victory

User Interface
  • Combat odds will now display proper text for any bonuses due to combat bonuses vs promotions (ie, undead slaying, for example)
  • Advanced Combat Odds will now display the name of the attacking and defending units
  • Sevopedia should now display info for most spells and abilities
  • Restoring Tech Chooser background colors to original color scheme (fix by kekekeke)
  • Fix for unimproved mana being displayed inappropriately in the Sevopedia
  • Added basic concept entries to the Pedia for Revolutions and Puppet States
  • Fix for Dies Diei icon not appearing

Misc
  • XML: BonusInfos now has a <bIsMana> tag to help the AI identify mana
  • XML: Removed the AIweights from the Spell Extension promotions (the DLL understands the concept of promotions that grant mobility to summoned creatures)
  • XML: Increased the AIweight for Infernal Pact
  • Advanced Tactics: Now includes Super Forts (code by red-key)
    • Forts connect resources
    • Forts exert culture on their tile (and surrounding tiles after they upgrade)
    • Forts can be bombarded
  • Advanced Tactics - Unit Gifting now enabled; in addition to regular restrictions, Avatars, Limited Units, units with the <bAbandon> tag and units whose prerequisite civilization is not the same type as the receiving civilization are all disallowed from being Gifted (NOTE: this feature could use some testing. Find ways to break it and once everything is solid I'll consider adding this to the base game)

Code
  • Enabled Hyborems Whisper for multiplayer
  • Added new AI function, AI_seekDefensiveGround(int iRange, bool bIncludeHealing)
  • Added an isIllusionary() function for units (Any unit that has a promotion that is flagged as a racial promotion and also has <iCombatHealPercent> set to 100 will be considered Illusionary)
  • Exposing getPromotionSummonPerk() to python
  • Tried to improve the methods used to calculate plot danger (previous method would discount any units that had already moved, not taking into consideration that they will get to move again next turn)
  • Code / Bugfix - Units will now check at the end of turn for spells to cast; spells that sacrifice the caster no longer trigger delayed death (this required a couple of other code adjustments to account for the change. hopefully got them all)
  • Added the scenario files to the codebase for MNAI
  • Additional logging


As many of you know, I am a new father of twins. As you might imagine, this leaves me little time to myself, and unfortunately, this mod has languished as a result. To combat this, I've tried to become a little more organized, moving all my scribbled notes into a Bug Database and Feature Database. I'm hoping that my increased organization will better enable others to chip in more often (and a BIG shout-out to everyone who has previously provided code and fixes for this mod!)

I'm willing to take any assistance, no matter how large or small or how (in)experienced coder you might be (I had never coded python or C++ before I started this project). Please contact me if you are interested in helping out!
 
Thanks!

I just played a very quick game, just to see how the forts work. It seems fine so far.

I'm just now about to start looking at the code and then merging this update with the latest internal version of my modmod. Unless something goes horribly wrong, I expect that I'll probably release a MNAI v 2.4 - based version of Magister Modmod on Christmas Eve.


Edit: I just just finished merging this version with my modmod. I played a couple of very brief test games which revealed bug I introduced by not indenting code changes properly, but I fixed those easily enough. In my next test everything seemed fine until after I founded The Runes of Kilmorph and tried to use the Found Temple of Kilmorph ability. That spell caused the game to crash.


I just ran a quick test with my unaltered copy of More Naval AI Version 2.4, and found that the Found Temple of Kilmorph ability causes a crash to desktop there too. Found Temple of the Overlords and Found Temple of the Leaves causes the same crash. I haven't tested the other religion's temple founding spells, but I assume they have the same issue.


I hope there is a simple fix for this bug and that it can be released quickly.
 
I just went back and continued the Falamar of the Lanun game where I first noticed the crash. When I deleted my Stonewarden instead of sacrificing him through the spell, then everything was fine. I don't think that a unit merely dying is the problem.

A dozen turns later I got an identical crash when my (automated) work boat sacrificed itself to build a Pirate's Cove.


I would guess that the issue occurs for all spells with the <bSacrificeCaster>1 tag.

Such spells probably used delayed death before in order to prevent this crash.
 
tried to use the Found Temple of Kilmorph ability. That spell caused the game to crash.

[to_xp]Gekko;12091558 said:
I can confirm this crash

A dozen turns later I got an identical crash when my (automated) work boat sacrificed itself to build a Pirate's Cove.


I would guess that the issue occurs for all spells with the <bSacrificeCaster>1 tag.

Such spells probably used delayed death before in order to prevent this crash.

Yeah. It's probably related to that change. Strange that those spells seem to work fine for the AI. I'm looking into it now. May be able to get a fix up tonight but no promises...


EDIT: OK, the fix was easy enough (at least it seems so). Turns out that doDelayedDeath() was being called everytime that a unit performed a command from a human player. It will now first check to see if that unit is in delayedDeath mode.

Download version will be updated in a few moments. Hopefully this fix doesnt break anything else.
 
mouseovering on single promotions in the unit info panel in the bottom left corner doesn't show info for the promotion ( it keeps displaying the unit info )
 
[to_xp]Gekko;12091871 said:
mouseovering on single promotions in the unit info panel in the bottom left corner doesn't show info for the promotion ( it keeps displaying the unit info )


It appears to me that this issue is caused by you commenting out the lines 2052 to 2061 in CvMainInterface.py. The mouseovers work as they did in previous versions if undo that.

However, the game seems to crash when you end your turn when those lines are not commented out. I don't have any idea why.
Edit: That crash only seemed to happen when I made the change and then continued the game I had in progress. When I started a new game things seem to work fine without that code commended out.

It might be worth noting that in the game where not having that code in comments caused a crash, one of my units was Enraged. (It was actually the same priest who caused the first crash, who had gotten mutated since then.) I suspect he was Crazed too, but I'm not sure. I can't easily check now because I've already made a change to the mod that breaks saved games. (I removed an improvement which I had only added in order to test a possible spell mechanic that didn't end up working very well.)


How do we tell when the download has been updated?
Edit: I guess it has been. I downloaded and installed it again, and saw that the DLL is newer so I replaced the one in my modmod's folder with that. The Fount Temple spells are all working fine now. There weren't any changes outside the DLL in the stealth re-release that I need to copy too, were there?


Edit: I just reread the changelog and noticed that Perfect Sight now lets the unit see all invisible types. That is somewhat of a problem for my modmod. I added a new type of invisibility specifically because I really did not want anyone to ever the the Sluagh units that are used to store the data of deceased heroes so hat they can be resurrected with the promotions etc intact. I just did a quick test and found that a unit with Perfect Sight can not only see the Sluaghs, but attack and kill them; that makes those heroes' resurrections impossible, even worse than if they had been slain by the Netherblade of Clava Vindex.

I suppose I can get around the real problem by making the netherworld plot (0,0) require a minimum level of 1000000 to enter. It still seems a bit odd to see the Sluagh's there though.



Edit: For the most part v2.4 seems to be working quite well with my modmod, except fairly late in my current game as Auric Ulvin. Here I've been getting unexplained crashes.

There were no python bugs listed. From MPLog.txt I got the impression that they might be in some way related to my Temple of the Hand terraforming code. I am far from certain that that is right, but when I removed all of those buildings the crashes seemed to stop.

Since the code was working perfectly before this merge, I'm thinking the problem may be related to the Advanced Forts (a feature I quite like). Does their change how pLoopPlot.isWithinCultureRange(iPlayer) works? If so, I may very well have problems with both Temples of the Hand and Chancels of the Guardians.

Edit: Maybe it wasn't the Temples of the Hand. I added one back in a city where it would effect territory held by forts and things still seemed fine. I then went back again and played a few turns without removing any of the temples and I still got no crash where I had before. I had just made a couple of very minor python changes, but I fail to see how any of them would be relevant.


I just gifted a few summons. It doesn't seem like units that will expire so soon should be giftable. I also gifted the summoner; it might be a good idea not to allow the gifting of arcane units as it can let players take advantage of free mana promotions. Frankly I tend to think that it might be better to have a bGiftble tag for units so modders can decide exactly what should and should not be eligible rather than following rules you would have to tweak in the SDK.


Edit: I just found that setting a minimum level to the netherworld tile is not sufficient, due to the ICBM movement ability of Auric Ascended and Rifts. There should really be a way to make such special units invisible even to Perfect Sight.
 
playing as Charadon, I spawned next to keelyn ( rushed ) and I'm now besieging the amurites. while doing this, they built a worker but they now can't use him due to my siege :D
 
It appears to me that this issue is caused by you commenting out the lines 2052 to 2061 in CvMainInterface.py. The mouseovers work as they did in previous versions if undo that.

I commented that section out because it was causing extreme lag when you would select a large group of units. Maybe that's why Kael had moved the unit image in the first place.

There weren't any changes outside the DLL in the stealth re-release that I need to copy too, were there?

Nope. Just the DLL.


Edit: I just reread the changelog and noticed that Perfect Sight now lets the unit see all invisible types. That is somewhat of a problem for my modmod. I added a new type of invisibility specifically because I really did not want anyone to ever the the Sluagh units that are used to store the data of deceased heroes so hat they can be resurrected with the promotions etc intact. I just did a quick test and found that a unit with Perfect Sight can not only see the Sluaghs, but attack and kill them;

Hmmm...OK. Red-key actually is the one who fixed Perfect Sight. Maybe he can help out with this one. If not, I'll try to figure out some sort of solution.


Edit: For the most part v2.4 seems to be working quite well with my modmod, except fairly late in my current game as Auric Ulvin. Here I've been getting unexplained crashes.

If it's a repeatable crash I can generally track it down with a save.


I just gifted a few summons. It doesn't seem like units that will expire so soon should be giftable.

Fair enough. I'll disable temporary units from being gifted.


I also gifted the summoner; it might be a good idea not to allow the gifting of arcane units as it can let players take advantage of free mana promotions. Frankly I tend to think that it might be better to have a bGiftble tag for units so modders can decide exactly what should and should not be eligible rather than following rules you would have to tweak in the SDK.

Aggghhhh! Not more XML tags?!? :eek: The main problem I have with adding new tags is that they then have to be set for every single entry in that XML file, which is a big pain in the butt. Nonetheless, your suggestion has merit and I'll consider it.
 
I just reread the changelog and noticed that Perfect Sight now lets the unit see all invisible types. That is somewhat of a problem for my modmod. I added a new type of invisibility specifically because I really did not want anyone to ever the the Sluagh units that are used to store the data of deceased heroes so hat they can be resurrected with the promotions etc intact. I just did a quick test and found that a unit with Perfect Sight can not only see the Sluaghs, but attack and kill them; that makes those heroes' resurrections impossible, even worse than if they had been slain by the Netherblade of Clava Vindex.

I suppose I can get around the real problem by making the netherworld plot (0,0) require a minimum level of 1000000 to enter. It still seems a bit odd to see the Sluagh's there though.

I don't know exactly what you want to do, but you generally can store values with SdToolkit (Part of the merged RevDCM mod), without having "workaround" units.

Aggghhhh! Not more XML tags?!? :eek: The main problem I have with adding new tags is that they then have to be set for every single entry in that XML file, which is a big pain in the butt. Nonetheless, your suggestion has merit and I'll consider it.
Can't you make new Tags optional? Done with minOccurs="0" in the Schema file (see CvUnitSpellSchema.xml).
 
Edit: I just found that setting a minimum level to the netherworld tile is not sufficient, due to the ICBM movement ability of Auric Ascended and Rifts. There should really be a way to make such special units invisible even to Perfect Sight.

Use the bInvisible tag in UnitInfos. I believe with this they should be invisible to everything including Perfect Sight.

edit: I looked around in the DLL and it looks like there is also a setInvisible function available to python in CyInfoInterface1. This function sets the same variable as the bInvisible tag.
 
Can't you make new Tags optional? Done with minOccurs="0" in the Schema file (see CvUnitSpellSchema.xml).

I can look into that and see if it works. Just looking at the XML, it seems that most (if not all) of the minoccurs references are in the sub-tag <element> rather than the main tags <ElementType>. Not really sure if that makes a difference or not.

Use the bInvisible tag in UnitInfos. I believe with this they should be invisible to everything including Perfect Sight.

edit: I looked around in the DLL and it looks like there is also a setInvisible function available to python in CyInfoInterface1. This function sets the same variable as the bInvisible tag.

Thanks Red key!

Is the SVN version also updated?

It is now.
 
I can look into that and see if it works. Just looking at the XML, it seems that most (if not all) of the minoccurs references are in the sub-tag <element> rather than the main tags <ElementType>. Not really sure if that makes a difference or not.

Yes, it took some time for me to fully understand this, too: <ElementType> just defines an Element Type, but not, where it occurs (and how many of it). <element> defines an occurrence of that element, and the quantity.
I think most of the elements could have minOccurs="0", that could make the xml files much easier to read (but I think that also requires default values in the DLL). I actually don't know why it isn't done that way in vanilla Bts, so maybe there is another obstacle.
Every time I added new XML tags myself, though it worked that way.

It is now.

Thanks :)
 
Yes, it took some time for me to fully understand this, too: <ElementType> just defines an Element Type, but not, where it occurs (and how many of it). <element> defines an occurrence of that element, and the quantity.
I think most of the elements could have minOccurs="0", that could make the xml files much easier to read (but I think that also requires default values in the DLL). I actually don't know why it isn't done that way in vanilla Bts, so maybe there is another obstacle.
Every time I added new XML tags myself, though it worked that way.

I used minOccurs="0" for the tags I added for Super Forts. Most tags seems to already have default values in the DLL from what I have seen. Works fine for the tags I added.
 
If it's a repeatable crash I can generally track it down with a save.

It was repeatable, but it does not seem to be so anymore.

You wouldn't be able to use that saved game anyway unless I sent you all my modmod files in the state they were at the time of that game.

Before I started to suspect a Super Forts + Temple of the Hand conflict, I assumed the problem was probably related to the passive effect I use to prevent summons too close to a city with the Ring of Warding building from attacking. Perhaps that guess was right. The only change I made which seems even remotely relevant (most of the others were simply reorganizing code so that it easier to read, without actually changing any effects) was placing most of the effectRingOfWarding(pCaster) code within the conditional if not pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHARMED')):. The code itself grants the Charmed promotion to any summons near a Ring of Warding as well as dealing them damage. (Originally it just killed them, but some claimed that seemed too strong.) Checking for the Charmed promotion prevents the same unit from getting effected by the code over ad over again pointlessly, and allows me to make the damage dealt rather than the damage cap dependent on how much Force mana the city owner controls.

Use the bInvisible tag in UnitInfos. I believe with this they should be invisible to everything including Perfect Sight.
Thanks! This seems to work perfectly.

You don't have to change anything, Tholal. So long as I can keep those units invisible I prefer Perfect Sight letting you see everything else.

I don't know exactly what you want to do, but you generally can store values with SdToolkit (Part of the merged RevDCM mod), without having "workaround" units.
I have no idea how to use that, but perhaps I should learn. I think the code which reserves the (0,0) plot for the sluagh's is what causes the python errors in certain mapscripts, so eliminating the need for it would be a good thing.


I use these dummy units called Sluaghs (which is the canonical term for a disembodied spirit that has not yet left the place of Erebus to enter Arawn's netherworld or the service of another god) to store the xp, levels, promotions, religions, and unique names of various units when they die. There is a different version for the unitclass of every world unit (except The War Machine, The Black Wind, and the Armageddon heroes) plus one for adventurers and another one for each unitcombat of other units. I'd rather be able to keep track of exactly what type of unit it was that died, but I didn't want to create that many types of dummy units.

The Resurrection spells in my modmod will only work if they can find the proper type of Slaugh on plot (0,0) and if said Sluagh does not have either the Netherbind or Vindexbind promotion. Those promotions are respectively given to units that are killed by the units wielding the Nether Blade or Clava Vindex equipments. In addition to blocking Resurrection, they also stop units from returning as Angel or Manes. (The Clava Vindex only effects those who might otherwise return as Manes.) The Destroy Nether Blade ability removes the Netherbind promotion from all the Sluaghs, thus allowing them to resurrected again by the Life III spells. The Destroy Clava Vindex causes all the Sluaghs with Vindexbind to return and serve the Infernals.

Not every unit creates a Sluagh when it is lost. Those units who die in lands whose owner controls the Soul Forge create no Sluaghs and can never be resurrected. World units (except The War Machine, The Black Wind, and the Armageddon heroes) otherwise generate Sluaghs, as do units with the Adventurer promotion (unless they have the same name as a living adventurer, which would typically indicate that the unit was merely upgraded instead of killed). Other units would only generate Sluaghs if they have an extremely high levels, or if they were given the Netherbind/Vindexbind promotion. Adventurers and world units have their own Resurrection spells (limited by civilization, technology, and in the case of leader avatars also leader type), whereas more mundane units use the version that requires a Graveyard. A Sluagh with random xp is also generated whenever a Graveyard appears on the map. (It just crossed my mind that that may actually be source of the Erebus.py mapscript problem.)
 
Back
Top Bottom