Hi,
I'm adding some "AI" autocasting to my map, thought it was time to improve it from "IF THEY ATTACK SOMETHING THEN CAST THE ABILITY!!"
I've got 2 different units with Frost Nova and Shadow Strike each, I thought it would make some sense to make them cast these as somewhat "execution" abilities.
I completely understand how to pick the enemy with the highest health, lowest health, group of enemies (within reason), etc. But to stop the AI wasting the spell on something with VERY low health I was thinking I would make them use it enemies closest to 25% health for example, that way they will still use it on a healthy unit and also use the spell to finish an enemy off.
However I'm struggling to work out what maths I need to use to work out these differences? My maths example below -
Enemy with 10% health is 15% from 25%, an enemy with 80% health is 55% from 25%, however to get to these two answers you needed to do different sums...
How do I do this maths to detect what number is closer to the 25%?
NOTE - I don't want to have them "save" the spell for a better target, once they have full mana (this matches the cast cost) I want them to use the spell on the best thing that is nearby to them at the time
P.S. I would also like to do something with autocasting "line" based damage like shockwave and carrion wave, if anyone knows how to check if enemies are in a line that would be great too!
I'm adding some "AI" autocasting to my map, thought it was time to improve it from "IF THEY ATTACK SOMETHING THEN CAST THE ABILITY!!"
I've got 2 different units with Frost Nova and Shadow Strike each, I thought it would make some sense to make them cast these as somewhat "execution" abilities.
I completely understand how to pick the enemy with the highest health, lowest health, group of enemies (within reason), etc. But to stop the AI wasting the spell on something with VERY low health I was thinking I would make them use it enemies closest to 25% health for example, that way they will still use it on a healthy unit and also use the spell to finish an enemy off.
However I'm struggling to work out what maths I need to use to work out these differences? My maths example below -
Enemy with 10% health is 15% from 25%, an enemy with 80% health is 55% from 25%, however to get to these two answers you needed to do different sums...
How do I do this maths to detect what number is closer to the 25%?
NOTE - I don't want to have them "save" the spell for a better target, once they have full mana (this matches the cast cost) I want them to use the spell on the best thing that is nearby to them at the time
P.S. I would also like to do something with autocasting "line" based damage like shockwave and carrion wave, if anyone knows how to check if enemies are in a line that would be great too!