ID:159171
 
Okay, on my code I'm trying to make it so that if there isn't anything on the spot that your going to teleport to then it won't teleport you. I know how to set it up so that it checks the spot your enemy is but this modifies the spot where your enemy is and teleports you there.

        Teleport()
for(var/mob/M in oview(usr))
if(M in oview(8))
if(usr.Selected==M)
if(usr.WT==0)
if(usr.Ki>=usr.MKi/20)
flick("Teleport",usr)
if(M.dir==NORTH)
usr.loc=locate(M.x,M.y+1,M.z)
usr.dir=SOUTH
if(M.dir==SOUTH)
usr.loc=locate(M.x,M.y-1,M.z)
usr.dir=NORTH
if(M.dir==WEST)
usr.loc=locate(M.x-1,M.y,M.z)
usr.dir=EAST
if(M.dir==EAST)
usr.loc=locate(M.x+1,M.y,M.z)
usr.dir=WEST
usr.Ki-=usr.MKi/20
return
else
usr<<"You don't have enough Ki to teleport."
return
else
usr<<"You cannot teleport while lifting weights!"
return
else
return
else
return


Any help?
mob/verb/Teleport(mob/M in oview(8,src))
Move(get_step(M,M.dir))
dir = turn(M.dir,180)


Untested, but it looks like it'll work from my eyes right now (note: I'm legally half blind).
In response to Spunky_Girl
Thanks but not what I'm trying to accomplish. The teleportation is supposed to work nice with fast paced combat. So I need it to teleport once space in front not on top of them because that won't end their movement and it won't allow you to quickly attack the enemy.
In response to Forerunnerz
If you actually read the code you would see that it uses get_step() on the M's dir to get the turf in front of it, so it does exactly what you wanted.
In response to Spunky_Girl
EDIT: Thanks problem is solved with such a neat code. The only think that bugs me now is that if you can't teleport in front of the enemy then it changed your direction and will waste your ki. Anyway to make it so if you can't teleport in front of them, nothing happens?
In response to Forerunnerz
Forerunnerz wrote:
EDIT: Thanks problem is solved with such a neat code. The only think that bugs me now is that if you can't teleport in front of the enemy then it changed your direction and will waste your ki. Anyway to make it so if you can't teleport in front of them, nothing happens?

Check the return value of Move() before doing things like changing direction of the mob or subtracting ki. Look up the Move() proc in the DM Reference (press F1 in Dream Maker, look in the Topic tab).