I made something similar for my current project. Not sure how you currently have your scripts set up but I created a function that checks tiles depending on the direction the character was facing. Below is an example:
function getfronttile() begin
for $objectsingroup in group["SELECTEDRAIL"] do
if $objectsingroup.direction == NORTH then
$newxcoord = 0;
$newycoord = -1;
elseif $objectsingroup.direction == EAST then
$newxcoord = 1;
$newycoord = 0;
elseif $objectsingroup.direction == SOUTH then
$newxcoord = 0;
$newycoord = 1;
elseif $objectsingroup.direction == WEST then
$newxcoord = -1;
$newycoord = 0;
end;
$newxvalue = $objectsingroup.coord.x + $newxcoord;
$newyvalue = $objectsingroup.coord.y + $newycoord;
$tilecoord = coord[$newxvalue, $newyvalue, 0];
return $tilecoord;
end;
end;
This should give you a good starting point. You can change the $newxcoord or $newycoord to skip a tile, or you could make some adjustments to the function to make it return multiple $tilecoords and then have your spell effect each of the tiles. Note that this function only returns the tile, not any objects or characters on the tile.