I'm trying to make an "ai" that will only shoot at you when you are in it's "attack angle-range".
I've already worked out like 90% of it, but I have a problem!
i'm using x.angle and angle(x1,y1,x2,y2) in the "between values" condition. I increased the x.angle to each side so it's not just the 1 degree. it looks like this:
Value: round(angle(mob.x, mob.y, player.x, player.y))
Lower bound: round(mob.Angle)-5
Upper bound: round(mob.Angle)+5
And it works (almost) perfectly :D! that, with some good-enough "set angle to you", makes a mean shooter.
The only problem is that the "angle between objects" counts from 0 t 180 and from -180 a 0. while the "object angle" is all 360 degrees. So it means that the AI can't shoot up =(!
my first attempt at solving this was to make all the numbers absolute... but there is still the issue that i will never get a match over 180 degrees. I'm also thinking that there must be a mathematical solution to this, but i'm not that good with maths.
and i wonder... why does the "angle between object" counts like that and not in normal 360?? is it a feature or a mistake? :S
i'm gonna try now to "trick" the game into working this by setting the ai mirrored when looking up.. so it will never actually have to be looking up... hope it works. EDIT: it doesn't >_<! (i'm gonna try mixing values now...)
here is the file i'm testing this on =) <img src="smileys/smiley19.gif" border="0" align="middle" /> <img src="smileys/smiley19.gif" border="0" align="middle" /> <img src="smileys/smiley19.gif" border="0" align="middle" />