ID:266269
 
this will do everything except move the usr:

mob/proc/randomicearea()
if(prob(25))
usr.oldlocx = usr.x
usr.oldlocy = usr.y
usr.oldlocz = usr.z
usr.oldbattlefield = usr.onbattlefield
usr.onbattlefield = null
usr.Move(locate(1,1,1))
usr << "Battle!"
usr << "Begin!"
return 1
return 0
I believe this is because you are using usr, which you should only use in verbs. Replace all the usr's with src and it should work

Alathon
In response to Alathon
still won't work
In response to Air _King
Air _King wrote:
still won't work

usr isn't the problem because everything else works with usr why wont ths work?????
Air _King wrote:
this will do everything except move the usr:

mob/proc/randomicearea()
if(prob(25))
usr.oldlocx = usr.x
usr.oldlocy = usr.y
usr.oldlocz = usr.z
usr.oldbattlefield = usr.onbattlefield
usr.onbattlefield = null
usr.Move(locate(1,1,1))
usr << "Battle!"
usr << "Begin!"
return 1
return 0

A couple ideas:

1. Maybe the turf at 1,1,1 is blocked. In this case, the Move() will not succeed. If you want to force the mob to go there no matter what, set the loc directly. And as Alathon said, src is better than usr in this case. usr may work now but it may get you into trouble later, it can be tricky sometimes.

2. Are you testing it enough times that the prob(25) returns true at least once? I assume so, but just covering all the bases.

3. Put in some debugging statements if you're still having problems. Stuff like
world << "prob() returned true"
world << "usr is [usr]"

under the prob(25) to see that it's doing what you thought it would.
In response to Air Mapster
Air Mapster wrote:
Air _King wrote:
this will do everything except move the usr:

mob/proc/randomicearea()
if(prob(25))
usr.oldlocx = usr.x
usr.oldlocy = usr.y
usr.oldlocz = usr.z
usr.oldbattlefield = usr.onbattlefield
usr.onbattlefield = null
usr.Move(locate(1,1,1))
usr << "Battle!"
usr << "Begin!"
return 1
return 0

A couple ideas:

1. Maybe the turf at 1,1,1 is blocked. In this case, the Move() will not succeed. If you want to force the mob to go there no matter what, set the loc directly. And as Alathon said, src is better than usr in this case. usr may work now but it may get you into trouble later, it can be tricky sometimes.

2. Are you testing it enough times that the prob(25) returns true at least once? I assume so, but just covering all the bases.

3. Put in some debugging statements if you're still having problems. Stuff like
> world << "prob() returned true"
> world << "usr is [usr]"
>

under the prob(25) to see that it's doing what you thought it would.


It will work like this, but not in ther randomicearea proc.

mob/proc/randomicearea()
if(prob(25))
usr.oldlocx = usr.x
usr.oldlocy = usr.y
usr.oldlocz = usr.z
usr.oldbattlefield = usr.onbattlefield
usr.onbattlefield = null
usr << "Fight!"
spawn()randombattle1()
return 1
return 0
mob/proc/randomicebattle()
usr.loc=locate(1,1,1)