Sign in to follow this  

TBS attack ranges?

This topic is 3339 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, i've been working on a tactical based battle engine like shining force and final fantasy tactics and have been having a little trouble coming up with a concept on how im going to do attack range determination. I'll show you what i mean with a quick diagram: Let C represent the character who is attacking, and let R represent the ranges in which he can attack at. Lets say that just for reference these ranges are all represented through a coordinate type system where (0,0) is the first tile position on the map. ...R ..RRR RRCRR ..RRR ...R if i stored the character's (c's) x and y coordinates into variables based on his map position. How would i do conditional checks for those particular ranges? I thought about making 4 variables: xmin,xmax,ymin,ymax and setting them all to what i want the min/max attack ranges to be and checking if a target is within those ranges but the problem is that it would give me a square area which im not really looking for.

Share this post


Link to post
Share on other sites
You could always use a circle. Instead of checking against min/max coordinates, check to see if (character_x - enemy_x)2 + (character_y - enemy_y)2 <= r2, where 'r' is the attack range. If you're working with tile centers, then you'll have to mess around with 'r' until you get the right range.

Share this post


Link to post
Share on other sites

This topic is 3339 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this