Ok, so I am working on getting my TBS updated, but I have run into a quick block. The problem is that when you are attacked from behind it should recalculate damage and hit percentages slightly different, but what if they are behind you and to the side(long range) it should also that into consideration. I just need a simple method to check if the attacker is "behind" them using the angle from which they are to the player. To my understanding of Trig I know 2 sides and 1 angle, I just need to figure out the angle opposite.
What I need to find is a formula that will help me figure this out, can someone help me out with this? I am not the best at trig and so I am getting lost.
Here is what I have so far.
Well any help would be appreciated, otherwise this function will be pretty dumb.
I was hopeing to say that if the angle returned was like a \/ (using a 90* angle) from behind them, it would be considered from_back, while outside of that, again check if from side.. being > < from the character, else from front.
Thanks again
Code:
/|
/ |
/ |
/ |5
/ |
a/_____| < obviously a 90* angle.
2
Here is what I have so far.
Code:
def from_back?(attacker)
back = false
case self.direction
when 2 #down
if (attacker.y < self.y) #if attacker y is less than
angle = Math.tan((attacker.x - self.x)/(attacker.y - self.y))
p angle
end
when 4
when 6
when 8
if (attacker.y > self.y)
back = true
end
end
return back
end
Well any help would be appreciated, otherwise this function will be pretty dumb.
I was hopeing to say that if the angle returned was like a \/ (using a 90* angle) from behind them, it would be considered from_back, while outside of that, again check if from side.. being > < from the character, else from front.
Thanks again