ID:2263203
 
(See the best response by Maximus_Alex2003.)
I wish to construct a code that allows for Character 1 to attack character 2 from 2 tiles away. The current "attack" action used can only attack someone if they are right in front of the person but is it possible to change the target area to be the first and the second tile (Or Rather only Target the Second Tile if there is no valid thing to hit in the first tile)
Best response
You're looking for something along the lines of get_dist() and get_dir().
get_step() is probably what you're using to check the tile ahead of the attacker. You can use get_step() on that tile in the same direction to get the second tile away. Combine their contents with the | operator and loop through that.
var
turf/ahead = get_step(src, dir)
turf/far = get_step(ahead, dir)
list/targets = ahead.contents | far.contents
for(var/mob/target in targets)
// src attacks target

Don't forget to check the DM reference (F1 in Dream Maker) if you have questions on any bit of code.