ID:170380
 
I know this was sound like something from dbz but it isn't. I need to figure out how to shoot a striahgt line of an object out and if it hits a mob its calls a defined proc.
Probably something like:

obj
laserbeam
icon='laser.dmi'
icon_state = "laserbeam" // laserbeam for all 8 directions

New(Loc,Dir)
..()
dir=Dir //set the beam's dir

mob
verb
laser()
var/list/beam=new // a list to hold the parts that make up the entire beam

var/Dir = usr.dir // save this so it doesn't change if the player moves

var/turf/T = get_step(usr, Dir) // get the first location for the beam the turf
// right in front of where the mob is looking

var/count=5 // This is the range of the beam
// Raise the number for longer beams

while(T&&count) // while there is a place to go and range to get there
count-- // reduce the range

// if this turf is dense or opaque, stop
if(T.density || T.opacity)
break

// Create a new beam and pass on the Dir we saved
var/obj/laserbeam/Beam=new(T, Dir)

beam+=Beam // add the part to the beam list

for(var/mob/M in T) // if there is a mob there
M.Hit(src) // Hit them
del_beam(beam) // Delete the beam
return // and return

T = get_step(T, Dir) // get the next turf in line for the beam

del_beam(beam) // after the beam stops, delete it


proc
del_beam(list/beam) // deletes the laserbeam
sleep(3) // wait for it

for(var/obj/O in beam) // for every part in the list
del(O) // delete the part

Hit(var/mob/M)
if(M) // if there is an atacker
src << "[M.name] hit you!"
M << "You hit [name]!"


~X