HELP ME WITH THE LOGIC FOR THIS TARGETING SYSTEM

Posts

Pages: 1
I'm designing a tactical RPG like Final Fantasy Tactics with grid movement etc.

I currently need help thinking an issue. I don't need exactly scripting/eventing help, just figuring out the logic for what I want.

When the player is going to move, movement tiles are placed to signal his movement reach. To do so, I used a event spawner plugin, and made events spawn copies of themselves on adjacent tiles until they reach the movement limit. They don't spawn over occupied tiles, so if there's an obstacle, it reduces the movement range, and it looks like the first chart of this image:



So far so good. What I need to do now is to place tiles for long range attacks. I cannot use the same logic because, according to the first chart, you'd be able to target an enemy behind the obstacle. Another option would be just to place the target tiles in all non-occupied tiles within range, but it would also allow you to target enemies behind obstacles, like chart 2.

So how do I design it so that an obstacle will block other tiles "behind" it? Ideas?
I'm on mobile so I can't write a whole lot but the general form of this problem is called raycasting -- you essentially want to check the passability of all tiles along the ray from source to target. Bresenham's line algorithm is one way to do this on a grid: http://www.roguebasin.com/index.php?title=Bresenham%27s_Line_Algorithm
Pages: 1