Anyone knows what exactly Kryub intended to do with AI Dispel Magic use?
What I see is that he completely rewritten that part of the code but...I can't seem to understand some details.
First, if byte_40DFF = 0 it won't use dispel magic at all and skips the rest of the calculations. This seems to be the byte somehow related to Holy Weapon but not sure how. It cannot be the weapon status of the unit because it's a global byte not one on the unit.
Next it checks if the unit has any enchantments in word 22h, these are the negative enchantments like confusion, if yes it adds 1 to the counter. This is indentical to the original.
Next, it checks if 3A or 2C is positive, if yes adds 5. Otherwise it checks 3C or 2E the same way.
This is completely different from the original, which did this :
-if 3C is a positive value, add 1 otherwise continue
-if 3C is zero, check 3A. if it has any enchantments, add 1 otherwise
-if 3C is nonzero,meaning it's negative -only possible if invulnerability is on-, or both were zero then continue with the following checks :
-if haste, creature binding, or possession is on, add 1 otherwise continue
-if bytes 1A or 18 aren't zero on the overland unit, add 1. (these are the overland enchantments)
The original seems to be doing what it's supposed to, adds 1 if the unit has any dispellable enchantment.
Kyrub's version on the other hand
-adds 5 times more if there is an enchantment
-checks 2C and 2E which are the ITEM enchantments that cannot be dispelled.
-then if it added 5 in any of the above, it adds another 1
-otherwise it checks for creature binding and possession, if yes, adds 1
-and finally if bytes 1A or 18 aren't zero on the overland unit, add 1. (same as original)
after all that, it adds 50 to the priority if the counter is nonzero, subtracts 100 if it is.
The process is modified the same way for both Dispel Magic spells, but the normal one adds only 30 priority.
What I don't understand is that he seems to have
-made the counter gain 6 times more when it is ignored anyway, priority is a flat amount so this change did nothing
-made it check for item enchantments that cannot be removed anyway, why?
-and removed the check for haste, I guess because it uses the same bit as the item?
Anyone knows why he did these and if they are actually meant to help somehow or it just made things worse?
I just faced an AI spamming dispel magic all battle long, removing...flight from one unit and nothing else, lol.
Am I overlooking something or this is buggy as hell and I should restore it to the original or make my own? And anyone knows that the check in the beginning is supposed to do?
Edit : I rewrote it to count the number of enchantments on the unit that has the most and use that*5 as priority.
I still would like to know what byte_40DFF is for, I didn't remove that check yet. It must be quite important if it was explicitly added.
What I see is that he completely rewritten that part of the code but...I can't seem to understand some details.
First, if byte_40DFF = 0 it won't use dispel magic at all and skips the rest of the calculations. This seems to be the byte somehow related to Holy Weapon but not sure how. It cannot be the weapon status of the unit because it's a global byte not one on the unit.
Next it checks if the unit has any enchantments in word 22h, these are the negative enchantments like confusion, if yes it adds 1 to the counter. This is indentical to the original.
Next, it checks if 3A or 2C is positive, if yes adds 5. Otherwise it checks 3C or 2E the same way.
This is completely different from the original, which did this :
-if 3C is a positive value, add 1 otherwise continue
-if 3C is zero, check 3A. if it has any enchantments, add 1 otherwise
-if 3C is nonzero,meaning it's negative -only possible if invulnerability is on-, or both were zero then continue with the following checks :
-if haste, creature binding, or possession is on, add 1 otherwise continue
-if bytes 1A or 18 aren't zero on the overland unit, add 1. (these are the overland enchantments)
The original seems to be doing what it's supposed to, adds 1 if the unit has any dispellable enchantment.
Kyrub's version on the other hand
-adds 5 times more if there is an enchantment
-checks 2C and 2E which are the ITEM enchantments that cannot be dispelled.
-then if it added 5 in any of the above, it adds another 1
-otherwise it checks for creature binding and possession, if yes, adds 1
-and finally if bytes 1A or 18 aren't zero on the overland unit, add 1. (same as original)
after all that, it adds 50 to the priority if the counter is nonzero, subtracts 100 if it is.
The process is modified the same way for both Dispel Magic spells, but the normal one adds only 30 priority.
What I don't understand is that he seems to have
-made the counter gain 6 times more when it is ignored anyway, priority is a flat amount so this change did nothing
-made it check for item enchantments that cannot be removed anyway, why?
-and removed the check for haste, I guess because it uses the same bit as the item?
Anyone knows why he did these and if they are actually meant to help somehow or it just made things worse?
I just faced an AI spamming dispel magic all battle long, removing...flight from one unit and nothing else, lol.
Am I overlooking something or this is buggy as hell and I should restore it to the original or make my own? And anyone knows that the check in the beginning is supposed to do?
Edit : I rewrote it to count the number of enchantments on the unit that has the most and use that*5 as priority.
I still would like to know what byte_40DFF is for, I didn't remove that check yet. It must be quite important if it was explicitly added.