ID:1996224
 
Code:
obj
yoyo
verb
Atirar_Yoyo()
usr.Stun=1
var/obj/yoyobeam/K = new /obj/yoyobeam
if(usr.dir == NORTH)
K.loc = locate(usr.x,usr.y+1,usr.z)

if(usr.dir == SOUTH)
K.loc = locate(usr.x,usr.y-1,usr.z)

if(usr.dir == EAST)
K.loc = locate(usr.x+1,usr.y,usr.z)

if(usr.dir == NORTHEAST)
K.loc = locate(usr.x+1,usr.y+1,usr.z)

if(usr.dir == SOUTHEAST)
K.loc = locate(usr.x+1,usr.y-1,usr.z)

if(usr.dir == WEST)
K.loc = locate(usr.x-1,usr.y,usr.z)

if(usr.dir == NORTHWEST)
K.loc = locate(usr.x-1,usr.y+1,usr.z)

if(usr.dir == SOUTHWEST)
K.loc = locate(usr.x-1,usr.y-1,usr.z)
K.dir = usr.dir
K.name=usr.name
walk(K,usr.dir,2)
spawn(16)
del(K)
usr.Stun=0


Problem description:
I think the title said what i need haha, i cant think a way to make this yoyo come back to the usr (without deal dmg).

First of all, you shouldn't be manipulating the start location by using the loc var and the locate proc.
I'm going to demonstrate the most basic way to do something like this, but it definitely has loose ends and won't look too great if the user walks after throwing the yoyo.

var/yoyoBeam/K = new/yoyoBeam()
step(K,usr.dir)
K.name = usr.name

var/duration = 10 //How many steps to take before retracting

for(var/a in 1 to duration)
step(K,K.dir)
walk_to(K,usr)

yoyoBeam
Bump(mob/M)
if(ismob(M))del src
..()
In response to Konlet
Konlet wrote:
First of all, you shouldn't be manipulating the start location by using the loc var and the locate proc.
I'm going to demonstrate the most basic way to do something like this, but it definitely has loose ends and won't look too great if the user walks after throwing the yoyo.

var/yoyoBeam/K = new/yoyoBeam()
> step(K,usr.dir)
> K.name = usr.name
>
> var/duration = 10 //How many steps to take before retracting
>
> for(var/a in 1 to duration)
> step(K,K.dir)
> walk_to(K,usr)
>
> yoyoBeam
> Bump(mob/M)
> if(ismob(M))del src
> ..()


error: inconsistent indentation
i didnt understand what u did : / in this cod the spawn conf isnt setted and that step(K,usr.dir) is repeated