I decided to go for the long shot and have completely rewritten the procedure the AI uses to equip heroes, so that it won't just pick the most expensive item but actually considers what the item is.
The new algorithm is the following:
Go through all heroes in an order of preference based on the hero's type, generally better heroes have higher priority and heroes likely to stay for fortress guard duty in the mid or late game have higher than equally powerful heroes that do not stay.
For each of the heroes, generate all possible set of 3 valid items that can be equipped to them from the remaining items. Calculate a priority value for the set and equip the set with the highest priority, then continue with the next hero.
The new thing is, it considers sets of 3 items instead of just each item individually, and ofc that it considers individual stats on items and the hero itself instead of just item costs.
The priority calculation currently uses the following number for each ability or stat, and opinions on these are welcome :
Vampiric : +40 (medicore ability)
Guardian Wind : +50 (Decent ability)
Lightning : +80 (good ability)
Destruction : +50 (kills entire units and cannot regenerate...overrated maybe?)
Cloak of Fear : +40 (medicore ability)
Wraith Form : +400 (hero is protected from web and crack's call, the two most likely ways the human player will use to kill them, also can move though water, and ignores walls and combat terrain. 400 Might be overkill? Might pick a WF item with crappy stats over an actual good item that has no WF)
Regeneration : +80 (isn't that good for AI because they can't guarantee they'll be the winning side unlike the human player)
Pathfinding : +10 (unimportant)
Waterwalking : +20 (nice but secondary)
Resist Elements : +30 (probably the weakest defensive enchantment)
Elemental Armor : +80 (very strong protection against magic damage)
Doom : +120 (extremely effective offensive ability especially against the human player)
Stoning : +15 (weakest instant KO ability, generally unimportant for a hero)
Teleporting : +140 (Hero is impossible to chase down, or run away from, and gets extra defense, amazing ability)
Haste : +150, and doubles the value of ATK, MOV, HIT (Hero deals double damage and moves twice as fast. might be overrated? )
Invisibility : +120 (Surprise factor can win the AI critically important battles. Defensive effects are huge even if this doesn't happen)
Death : +20 (Better than stoning but instant KO isn't what heroes are for usually. Might be underrated? )
Flight : +60 (Hero can attack flying enemies, is protected from being attacked by ground units, and can move over ocean. Forces the human player to waste a turn on Web before they can try to Crack's Call the hero as well.)
Resist Magic : None, instead it counts as +5 Resistance stat points.
Magic Immunity : +1000 (Most OP item power in the game)
Flaming : None, instead it adds +3 attack to the stat points directly.
Exorcism : +50 (Contains Bless and a medicore instant KO attack)
True Sight : +70 (One of the easiest way to dispose of an AI hero is using phantom beasts. This blocks that and a few other nasty spells.)
Phantasmal : +180 (Strongest weapon ability in the game)
Divine Protection : +100 and also adds +1 to the To Hit stat total
Bless : +40 (Slightly better than Resist Elements)
Lionheart : +100 (adds 8 health which is often enough to survive a Crack's Call or two Doom Bolts etc) Also adds 3 to the attack and resistance stat points so this is only the value for the health boost.
Inner Fire : +50 (Cold and Fire immunity can protect the hero against some threats, Immolation is decent when fighting many medicore units that can barely damage the hero but would win by their numbers)
Planar Travel : 0 (AI cannot use this item power, only unit enchantment is recognized due to space problems)
Merging : +80 (Like teleportation minus the defense boost. Maybe underrated?)
Shadow : +100 (Unit can attack flying enemies, and damage output increases roughly by 50% too)
Invulnerability : +120 (2 damage reduction is worth about as much as 6 shields.)
Any ability that is redundant in the item set (appears more than once) is only worth half of the above points to encourage the AI to distribute those on different heroes unless the other stats outweight it.
If hero is over ocean then Water Walking, Flight, Wraith Form : +5000. If hero is Draconian, Water Walking and Flight -50.
Various other modifications for pairs of abilities that strengthen or cancel each other, like Merging+Teleport = bad.
If hero has the ability granted by item by default then reduce priority (Missile Immunity, Illusion, Illusion Immunity, Lucky, Charmed vs Resistance items etc).
Bow or Staff : +250 (prefer these to melee weapons on heroes who can use both)
each point of ATK : +10
each point of DEF : +20 (defense is generally more important for heroes than damage output)
each point of RES : +18, however each point above +7 counts as it it was -2 instead, to avoid stacking more than needed.
each point of HIT : +40+4*ATK on items
each point of SKILL : +2
Spell Save : For each point take the next value from this table instead : 40,100,170,250,500,750,1000,1250,1500,1750,2000,... (to encourage stacking multiple SAVE items on the same hero, preferably the best one)
each point of MOV : +8
Spell Charge : +2*each point of casting cost of the spell * Number of charges
The new algorithm is the following:
Go through all heroes in an order of preference based on the hero's type, generally better heroes have higher priority and heroes likely to stay for fortress guard duty in the mid or late game have higher than equally powerful heroes that do not stay.
For each of the heroes, generate all possible set of 3 valid items that can be equipped to them from the remaining items. Calculate a priority value for the set and equip the set with the highest priority, then continue with the next hero.
The new thing is, it considers sets of 3 items instead of just each item individually, and ofc that it considers individual stats on items and the hero itself instead of just item costs.
The priority calculation currently uses the following number for each ability or stat, and opinions on these are welcome :
Vampiric : +40 (medicore ability)
Guardian Wind : +50 (Decent ability)
Lightning : +80 (good ability)
Destruction : +50 (kills entire units and cannot regenerate...overrated maybe?)
Cloak of Fear : +40 (medicore ability)
Wraith Form : +400 (hero is protected from web and crack's call, the two most likely ways the human player will use to kill them, also can move though water, and ignores walls and combat terrain. 400 Might be overkill? Might pick a WF item with crappy stats over an actual good item that has no WF)
Regeneration : +80 (isn't that good for AI because they can't guarantee they'll be the winning side unlike the human player)
Pathfinding : +10 (unimportant)
Waterwalking : +20 (nice but secondary)
Resist Elements : +30 (probably the weakest defensive enchantment)
Elemental Armor : +80 (very strong protection against magic damage)
Doom : +120 (extremely effective offensive ability especially against the human player)
Stoning : +15 (weakest instant KO ability, generally unimportant for a hero)
Teleporting : +140 (Hero is impossible to chase down, or run away from, and gets extra defense, amazing ability)
Haste : +150, and doubles the value of ATK, MOV, HIT (Hero deals double damage and moves twice as fast. might be overrated? )
Invisibility : +120 (Surprise factor can win the AI critically important battles. Defensive effects are huge even if this doesn't happen)
Death : +20 (Better than stoning but instant KO isn't what heroes are for usually. Might be underrated? )
Flight : +60 (Hero can attack flying enemies, is protected from being attacked by ground units, and can move over ocean. Forces the human player to waste a turn on Web before they can try to Crack's Call the hero as well.)
Resist Magic : None, instead it counts as +5 Resistance stat points.
Magic Immunity : +1000 (Most OP item power in the game)
Flaming : None, instead it adds +3 attack to the stat points directly.
Exorcism : +50 (Contains Bless and a medicore instant KO attack)
True Sight : +70 (One of the easiest way to dispose of an AI hero is using phantom beasts. This blocks that and a few other nasty spells.)
Phantasmal : +180 (Strongest weapon ability in the game)
Divine Protection : +100 and also adds +1 to the To Hit stat total
Bless : +40 (Slightly better than Resist Elements)
Lionheart : +100 (adds 8 health which is often enough to survive a Crack's Call or two Doom Bolts etc) Also adds 3 to the attack and resistance stat points so this is only the value for the health boost.
Inner Fire : +50 (Cold and Fire immunity can protect the hero against some threats, Immolation is decent when fighting many medicore units that can barely damage the hero but would win by their numbers)
Planar Travel : 0 (AI cannot use this item power, only unit enchantment is recognized due to space problems)
Merging : +80 (Like teleportation minus the defense boost. Maybe underrated?)
Shadow : +100 (Unit can attack flying enemies, and damage output increases roughly by 50% too)
Invulnerability : +120 (2 damage reduction is worth about as much as 6 shields.)
Any ability that is redundant in the item set (appears more than once) is only worth half of the above points to encourage the AI to distribute those on different heroes unless the other stats outweight it.
If hero is over ocean then Water Walking, Flight, Wraith Form : +5000. If hero is Draconian, Water Walking and Flight -50.
Various other modifications for pairs of abilities that strengthen or cancel each other, like Merging+Teleport = bad.
If hero has the ability granted by item by default then reduce priority (Missile Immunity, Illusion, Illusion Immunity, Lucky, Charmed vs Resistance items etc).
Bow or Staff : +250 (prefer these to melee weapons on heroes who can use both)
each point of ATK : +10
each point of DEF : +20 (defense is generally more important for heroes than damage output)
each point of RES : +18, however each point above +7 counts as it it was -2 instead, to avoid stacking more than needed.
each point of HIT : +40+4*ATK on items
each point of SKILL : +2
Spell Save : For each point take the next value from this table instead : 40,100,170,250,500,750,1000,1250,1500,1750,2000,... (to encourage stacking multiple SAVE items on the same hero, preferably the best one)
each point of MOV : +8
Spell Charge : +2*each point of casting cost of the spell * Number of charges