ID:140156
 
Code:
path
parent_type=/turf
var
Skid // A variable not really related to this problem

Entered(mob/M)
if(!ismob(M)) return
if(!M.client) return
if(M.isriding&&M.auto) // If the MOB is in a vehicle, and auto acceleration is on do the next bit...

if(!Skid) // check if the turf does not have SKID set...

if(M.reverse) // If the mob's reverse is set do this...
walk(M,0) // stop any current movement
sleep(M.speed) // wait as long as speed is set (which is always 1,2 or 3)
M.Move(get_step(M, src.dir), M.reverse) // move them in the direction of the turf, but point them in the direction of M.reverse.

else walk(M,dir,M.speed) // otherwise just push them in the direction of the path.


client/South() // when i press SOUTH...
if(!usr.MoveLkd) // if they have not had their movement locked...

if(usr.isriding) // and if they are in a vehicle

if(istype(usr.loc, /path)&&usr.auto) // if they are auto accelerating and on the special path turf...
if(usr.dir==EAST||usr.dir==WEST) // if they are facing EAST or WEST only..
usr.Move(get_step(usr, SOUTH), usr.dir) // move them SOUTH but keep them pointing the way they were.


Problem description:

M.reverse is set by a verb, which makes it the opposite of the users current direction.

When they are on the track above (path/) if reverse is set it makes them drive forwards while facing backwards.

The reverse appears to work ok *except* when it meets my lane change (see the client/South() example).

When the mob is on special turf and auto accelerating, and i press SOUTH, it will nudge me down 1 tile. Giving the effect of changing lanes. What happens while im 'reversing' is it still works, but my speed increases. It increases again on top of that the more i do it. I end up flying off to the end of the map if i do it too much.

Obviously i dont want it to do this. I want it to keep M.speed which is either set in walk, or with sleep(). I'm not sure why its acting like this. I have tried tinkering to fix it but nothing worked so far.

Would appreciate some help if anyone glances and can see something up. Ta.

Still can't get this to behave. The only way ive found to fix it is to use usr.y++ / usr.y-- instead of usr.Move() with get_step(). That's not ideal though as doing y++ etc means they can move through dense objects and Entered() isnt called (though i can call it manually i guess but still cant stop them moving through dense objects).

I can't figure out why pressing North/South which calls..

usr.Move(get_step(usr, NORTH), usr.dir) // I pushed UP on my keyboard, while in the path/ turf.


and then Entered() in the turf does...

// This is run when my M.reverse is set.
walk(M,0)
sleep(M.speed)
M.Move(get_step(M, src.dir), M.reverse) // Where M.reverse is the opposite direction of src.dir

// If M.reverse is not set (its nulled on certain parts of the track) then it does this instead..
walk(M,0)
walk(M,src.dir,M.speed) // Moves them in the direction the turf is pointing constantly.


Makes me move at double the speed! walk(M,0) should stop all movement right? So its not like its 'doubling' the Move(). Confused.

I tried adding walk(usr,0) to first code sample. Just incase. No affect.

EDIT:

I was worried it might be doing Entered() twice. So i set a variable so that Entered() would return if it was set. I set it to 1 on Entered() and then 0 on Exited(). Anyway it still doubled my speed... :/ I tried replacing "usr.Move(get_step(usr, NORTH), usr.dir)" with step() and still resulted in the double speed thing.

This ONLY happens when it calls M.Move(). If it uses the walk() part of the code above then the lane switching works as expected.

Really scratching my head on this.
In response to EternalDuelistSoul
Probably because you are doing something in mob/Move().
In response to Garthor
Nothing that would affect this.

However just to check i commented the mob/Move() stuff out... still does it.

I took the Entered() out and made it into a proc.

mob/proc/DReverse()

while(reverse)
if(!istype(loc, /path)) // If they are not on the path kill the loop.
reverse = null
if(auto) walk(src,dir,speed)
break

walk(src,0)
sleep(speed)
if(istype(loc, /path)&&reverse) Move(get_step(src, loc.dir), reverse) // a double check that after the sleep its still on the path.

return


Moving between lanes while thats running (instead of it doing the same on Entered() works perfectly.

As soon as i put this into the Entered() moving between lanes with the;

usr.Move(get_step(usr, NORTH), usr.loc.dir)


Code, makes my speed increase. If i move again it increases again.....

It seems like it could be related to the sleep() ? What i dont understand is why walk(usr,0) isnt killing all movement anyway.

I did experience something a bit like this once before, and it turned out it was because i was calling Entered() manually by accident after entering the turf. Simply removed the offending line, no such luck here though. But it is acting in a similar way. Like its entering the turf twice.

Still puzzled over this :/ driving me slowly insane.