ID:143857
 
Code:
mob
var
confunded=1
client
North()
if(usr.confunded==1)
South(usr, 1)
else
return
South()
if(usr.confunded==1)
North(usr, 1)
else
return
East()
if(usr.confunded==1)
West(usr, 1)
else
return
West()
if(usr.confunded==1)
East(usr, 1)
else
return


Problem description:now every time i press up down left or right i get this message:


<
runtime error: Maximum recursion level reached (perhaps there is an infinite loop)
To avoid this safety check, set world.loop_checks=0.
proc name: West (/client/West)
usr: VolksBlade (/mob)
src: VolksBlade (/client)
call stack:
VolksBlade (/client): West(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): West(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): West(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): West(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): West(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
...
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East(VolksBlade (/mob), 1)
VolksBlade (/client): East()

Now, i dont think im doing the oposite direction thingy right, but i havent ever worked in the "if you press one way you the the other" coding before, so i need help...

This is my last post for the night, Good Night!


mob
var
confunded=1
client
North()
if(usr.confunded==1)
South(usr, 1)
else
return
South()
if(usr.confunded==1)
North(usr, 1)
else
return

The problem is, that when player is Confunded, and try to step North, it calls South, which calls North and it keep calling it like that non-stop...
In response to Ripiz
Maybe you could try using step instead of called other procs. It's worth a try.

- Miran94
In response to Miran94
well, calling step for the mob is a good idea, another good idea is to learn boolean and return the parent procedure or else you will not be able to move if you are not confused!
client
North(doconfuse=1)
if(doconfuse&&mob.confunded) South(0)
.=..()


That's one way to fix the infinite recursion problem.
Why you're intercepting this at the North() level is beyond me. client/Move() or mob/Move() is a much better way to go.

mob/Move(newloc, newdir)
if(confused && newdir) // regular movement with a direction, not teleporting
newdir = pick(1,2,4,5,6,8,9,10)
newloc = get_step(src, newdir)
. = ..(newloc, newdir)


Lummox JR
In response to Lummox JR
Well, he wanted the direction to be opposite, rather than random, so the pick() should be replaced with turn(dir,180).
In response to Jp
Jp, i used your idea, and it worked like a charm, thank you and everyone else contributed to my Cunfundus Charm. ^_^
In response to Garthor
Garthor wrote:
Well, he wanted the direction to be opposite, rather than random, so the pick() should be replaced with turn(dir,180).

I considered that, but honestly any mook can adapt to backwards directions. If he wants confusion to be effective, random is the only way to go.

Lummox JR