ID:259207
 
In the code below, the monster's flame breath should be created with the user's current facing. When it's called from within New(), it is, but when New() returns, it's set to 2. Is this a bug or am I doing something wrong?


mob
monster
verb/breathe(myLength as num | null)
var/obj/breath/myBreath = new breathType(usr)
usr << "After creation, dir is [myBreath.dir]"


obj
breath
var/delay = 3


New(mob/myOwner)
dir = myOwner.dir
var/myLoc = get_step(myOwner, myOwner.dir)

if(myLoc) Travel(myLoc)
else del src


proc
Travel(turf/myLoc)
if(Move(myLoc))
spawn(delay) Travel(get_step(src, dir))


fire_breath
icon = 'fire_breath.dmi'
delay = 5



On 8/20/00 6:28 pm Guy T. wrote:
In the code below, the monster's flame breath should be created with the user's current facing. When it's called from within New(), it is, but when New() returns, it's set to 2. Is this a bug or am I doing something wrong?

Hmm. Could it perhaps have to do with the Move() call (done through Travel())? That does reorient the dir, although I would think from your example that it would be correct here. Just to test, you may want to pass the dir to Move(), eg:
Move(loc,dir). If that isn't the case, try commenting out the Move() altogether and see if you can isolate the place where things go wrong.

Sorry for the speculative response; I'm not in a position to test this too well right now (am betwen release compilations).
In response to Tom H.
Just to test, you may want to pass the dir to Move(), eg:
Move(loc,dir).

Hmm, this makes sense... I made a special effort to exhaust the possibilities, but this fairly basic one escaped me! I'll try it out. Thanks!