Skip to main content
gamedev.net
🔒 Locked

TBS attack ranges?

Started by MasterDario 1 reply 700+ views
Original Post
MasterDario
MasterDario
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.
n/a
Zipster
Zipster
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.
SaltyGoodness
SaltyGoodness
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.