ID:158104
 
I have implemented a target system into my game and I was wondering how I would get usr to appear behind thier Target with a verb, kind of like a backslash verb where you have a target, use a verb appear behind them and attack.

Thanks for future referance.
You can use turn() to get the opposite direction (IE: turn(dir, 180) gives you the direction opposite of your current direction). You can use get_step() to get a turf in that direction. You can use Move() to move to that turf.
In response to Garthor
Garthor wrote:
You can use turn() to get the opposite direction (IE: turn(dir, 180) gives you the direction opposite of your current direction). You can use get_step() to get a turf in that direction. You can use Move() to move to that turf.

Right, but it's not recognising the var I have set for Target.
In response to Sean93
The problem is in the assignation on line 14. The var O isn't initialized to the correct value.

Oh, wait! I can't actually read your mind and magically know what you did and how it went wrong, so I guess I'm going to need to actually view the code to help you!
In response to Kaioken
mob
verb
FlashAttack()
set hidden = 0
set name = "Attack"
set category = "Combat"
if(usr.Shunpo)
if(Trgt.dir==NORTH)
usr.loc=locate(Trgt.x,Trgt.y-1,Trgt.z)
usr.dir = SOUTH
usr.Attack()
if(Trgt.dir==SOUTH)
usr.loc=locate(Trgt.x,Trgt.y+1,Trgt.z)
usr.dir=NORTH
usr.Attack()
if(Trgt.dir==WEST)
usr.loc=locate(Trgt.x+1,Trgt.y,Trgt.z)
usr.dir=EAST
usr.Attack()
if(Trgt.dir==EAST)
usr.loc=locate(Trgt.x-1,Trgt.y,Trgt.z)
usr.dir=WEST
usr.Attack()
else
usr.Attack()


Sorry, I completely forgot.
In response to Sean93
Where exactly is Trgt defined, and how is it set? For all I know, you've made it up on that spot, in which case of course it will come up as undefined. The problem is that either that var is not declared, or it's declared in a different scope than the one you're trying to access (Trgt must be either a global var or a var of src, the way you're trying to access it) OR, what's more probable, Trgt isn't defined as of the correct type to make Dream Maker know that it should have a dir var. In order to use properties of an object with the . operator, the var containing it must be defined using an object type that has that property (var or proc). For example, to access the loc of an object, its var must be defined at least as /atom, so Dream Maker knows it should have the loc var. Otherwise, DM's error checking will stop you from compiling in order to prevent a possible runtime error.

Also, that entire chain of direction checks is very wrong.
First, when checking the same thing multiple times (e.g. direction, type), once you've got a match that excludes all the other matches, there's no need to continue checking for them and it's a waste of time (for example, if on the first check you've confirmed that Trgt.dir's value is NORTH, then it obviously isn't SOUTH or anything else - no need to check for it. That is done by using 'else if's (and 'else', when applicable) in the next checks so they're skipped if an earlier if() matched:
if(var1 == 1)
world << "one"
else if(var1 == 2)
world << "two"
else if(var1 == 3)
world << "three"
else
world << "not 1,2 or 3"

However, note that when comparing the same expression to multiple constant values, the course of action you should take is switch(), which is more convenient and easier to use, and is considerably more efficient as well.
switch(var1)
if(1)
world << "one"
if(2) world << "two"
else world << "something different"

Look it up in the DM Reference for more info.

The biggest mistake here is that you don't need to do any direction checks at all - what you need to do is use get_step() together with turn(), as you've been directed to. Your verb only needs the first if() check.