Bug description
When you attack an enemy wizard at its fortress, he is not defending himself effectively.
He skips turns before casting spells and in Insecticide, after winning your mana becomes negative, and the wizard is automatically defeated.
Versions
In vanilla 1.31 the enemy is merely ineffective, not casting direct damage spells when he could.
In insecticide 1.40n the enemy tries but fails to deliver damage, causes your mana to become negative, and is automatically permanently defeated.
Confirmation
Aureustgo first reported the bug in a thread starting at this post.
I confirmed the bug in that thread.
Jtm also confirmed in this post.
Save game & Reproduction
Aureustgo uploaded a save game here.
Scenario: "defeated" Tlaloc even though I think he had lots of mana left.
After the battle I have -14147 mana. Negative. In battles I can't cast spells - told I have no mana left. I then convert 400 gold to 400 mana. I then end up with 30000 mana.
Test results
In Insecticide 1.40n, Tlaloc's mana jumped to -32768 exactly, after which he did not do anything anymore.
With the tweaker I set his mana back to 30000, after which he recoved and was not defeated but only banished!
Each time Tlaloc casts a spell (ice bolt, disenchant area), his mana goes up instead of down...
That is, until he goes over 32767.
Then it flips and remains constant at -32768.
In vanilla 1.31, it turns out that Tlaloc does not cast any spells.
At the end he still has 30000 mana, and he is only banished.
It happens when:
1. you fight an enemy wizard at his fortress (50% discount),
2. the enemy wizard has more than 16384 mana,
3. the enemy chooses to cast a chargeable spell,
4. the spell seems to do nothing, enemy's mana increases (until it overflows), and his remaining casting skill also increases.
Code analysis
I found an overflow, causing the computer to make the wrong decision how to pump.
Computer is willing to spend all enemy's mana, instead of only the maximum allowed for the spell.
Location ovr112:0451 (or wizards.exe:835d1) contains "3B D0", where the computer does "cmp dx, ax" while dx (2 times enemy's mana) is greater than 32768.
Furthermore, ovr112:0453 (or wizards.exe:835d3) contains 7Dh, which means "jge", which is a signed comparison, while it probably should be an unsigned comparison.
When you attack an enemy wizard at its fortress, he is not defending himself effectively.
He skips turns before casting spells and in Insecticide, after winning your mana becomes negative, and the wizard is automatically defeated.
Versions
In vanilla 1.31 the enemy is merely ineffective, not casting direct damage spells when he could.
In insecticide 1.40n the enemy tries but fails to deliver damage, causes your mana to become negative, and is automatically permanently defeated.
Confirmation
Aureustgo first reported the bug in a thread starting at this post.
I confirmed the bug in that thread.
Jtm also confirmed in this post.
Save game & Reproduction
Aureustgo uploaded a save game here.
Scenario: "defeated" Tlaloc even though I think he had lots of mana left.
After the battle I have -14147 mana. Negative. In battles I can't cast spells - told I have no mana left. I then convert 400 gold to 400 mana. I then end up with 30000 mana.
Test results
In Insecticide 1.40n, Tlaloc's mana jumped to -32768 exactly, after which he did not do anything anymore.
With the tweaker I set his mana back to 30000, after which he recoved and was not defeated but only banished!
Each time Tlaloc casts a spell (ice bolt, disenchant area), his mana goes up instead of down...
That is, until he goes over 32767.
Then it flips and remains constant at -32768.
In vanilla 1.31, it turns out that Tlaloc does not cast any spells.
At the end he still has 30000 mana, and he is only banished.
It happens when:
1. you fight an enemy wizard at his fortress (50% discount),
2. the enemy wizard has more than 16384 mana,
3. the enemy chooses to cast a chargeable spell,
4. the spell seems to do nothing, enemy's mana increases (until it overflows), and his remaining casting skill also increases.
Code analysis
I found an overflow, causing the computer to make the wrong decision how to pump.
Computer is willing to spend all enemy's mana, instead of only the maximum allowed for the spell.
Location ovr112:0451 (or wizards.exe:835d1) contains "3B D0", where the computer does "cmp dx, ax" while dx (2 times enemy's mana) is greater than 32768.
Furthermore, ovr112:0453 (or wizards.exe:835d3) contains 7Dh, which means "jge", which is a signed comparison, while it probably should be an unsigned comparison.
--I like ILSe