Experienced Elementalist
- Joined
- Mar 6, 2012
- Messages
- 241
- Reaction score
- 153
Hello folks,
I was taking a look on some Mu GS sources and I noticed that all of them (At least, the ones who I've looked into), use a Square Math to determine a skill area attack, but WHY?
Take a look on this code sample:
It check the area of skill as a Square, like on this picture:
But IMO this is wrong, as far we got a skill radios (The attack distance of a skill), we need to use a Circle area. On above picture it shows the difference between Square and Circle area Maths.
Why this is wrong IMO? Because when you use Square Math the skill attacks has a large distance in any diagonal. And the code to use a Circle area is very easy, so i really dont know why to use Square Math. Some one knows why?
Here is the same code, but using a Circle Area:
I was taking a look on some Mu GS sources and I noticed that all of them (At least, the ones who I've looked into), use a Square Math to determine a skill area attack, but WHY?
Take a look on this code sample:
Code:
[...]
if (EnableAttack && gObj[tObjNum].X >= x - aDistance && gObj[tObjNum].X <= aDistance + x && gObj[tObjNum].Y >= y - aDistance && gObj[tObjNum].Y <= aDistance + y)
[...]
It check the area of skill as a Square, like on this picture:
But IMO this is wrong, as far we got a skill radios (The attack distance of a skill), we need to use a Circle area. On above picture it shows the difference between Square and Circle area Maths.
Why this is wrong IMO? Because when you use Square Math the skill attacks has a large distance in any diagonal. And the code to use a Circle area is very easy, so i really dont know why to use Square Math. Some one knows why?
Here is the same code, but using a Circle Area:
Code:
// (center.X - x)^2 + (center.Y - y)^2 < radius^2
if (EnableAttack && ( ((gObj[tObjNum].X - x)^2) + ((gObj[tObjNum].Y - y)^2) <= (aDistance^2) )
Attachments
You must be registered for see attachments list