ID:1456284
 
(See the best response by Magnum2k.)
Problem description:
Hello there,
I have a question:
How do I make a user relocate to a random area, not a specific location but a general area, so that in case another player also relocates to that area, they are not on-top of that other player?


Red Dragon
You can use rand() procedure to generate a random location. You can save these values if you want players to respawn at the same point.
You could take the location that you are trying to take them to so like say a "warpPad" turf, and do something like:

proc
warp(turf/warpPad/warped)
var
warpX
warpY
warpX = warped.x + rand(1,5)
warpY = warepd.y +rand(1,5)
src.loc = locate(warpX,warpY,1)



If you have more z levels you would have to change the third parameter

Whenever you called the proc you would pass in the turf that you are setting as the warp "focus" as the arguement.
I tried to do that, but I am not sure how to add multiple x,y,z values to one rand statement
You could:

src.loc = locate((warped.x+rand(1,5)), (warped.y+rand(1,5)),1)


However, that is much harder to read.
maybe this will help use a random and add some differents locates
                    usr.random=rand(1,10)
if(usr.random==1)
usr.loc=locate(locate1)//example:(346,428,2)
return
if(usr.random==2)
usr.loc=locate(locate2)
return
if(usr.random==3)
usr.loc=locate(locate3)
return
if(usr.random==4)
usr.loc=locate(locate4)
return
if(usr.random==5)
usr.loc=locate(lcoate5)
return
Thanks Akando! Your method works amazingly!
Now I'm getting an error though:
src.loc: undefined var

This is the code I used:
var
warpX
warpY
warpX = floor.x + rand(1,14)
warpY = floor.y +rand(1,8)
src.loc = locate(warpX,warpY,1)
Wow that spacing didn't work at all
In response to Red Dragon Inc
put dm before the code, and /dm after the code inside of <>
I'm sorry?
Oh put parenthses
What are you putting this inside of, such as what is the src?
Well this is putting it under a proc, same as the first method you suggested.
Ok and what is calling the proc, the mob or a location?
Another proc is calling the proc, it is basically an auto-checker, and if the user doesn't pass, they move to that location.
Ok then we need to pass a refrence as the src of the second proc is the proc that called the new proc, if that makes sense.


So now what is this "warp" proc called?
it's called teleport
and no, that didn't make too much sense lol
Ok so in the first proc we need to pass the player into the new proc so in theoriginal proc we need to do:

teleport(src)


Now with the teleport proc we will need to initilize the refrence and then use that.

proc
teleport(/*Your code for refrencing the floor*/,mob/warper)
var
warpX
warpY
warpX = floor.x + rand(1,14)
warpY = floor.y +rand(1,8)
warper.loc = locate(warpX,warpY,1)

Also, do you think we could create a variable that would hold that location instead of having the src immediately teleport there in the proc itself?
Page: 1 2 3