# TBS attack ranges?

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

## 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 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 on other sites
You want the Manhatten distance.

Edit: Sorry, I misread your post and am talking bollocks. The Manhatten distance is only applicable for your movement range (provided your characters can't move diagonally).

[Edited by - SaltyGoodness on October 21, 2008 5:10:03 PM]

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002287
×