Jump to content
  • 0

Random warp


nunesb

Question


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  11/30/12
  • Last Seen:  

How to make a NPC that teleports randomly predetermined warps ?

warp "prontera", 150, 184;
or
warp "prontera", 158, 182;
or
warp "prontera", 163, 189;
or
warp "prontera", 173, 199;

Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  43
  • Reputation:   15
  • Joined:  06/24/12
  • Last Seen:  

You can set two arrays with the same index for the correspondent coordinates.

Just like this:

setarray @x_axis[0],150,158,163,173;
setarray @y_axis[0],184,182,189,199;
set @map$,"prontera";
set @rand,rand(getarraysize(@x_axis) -1); //-1 prevents the rand() do get an non-existent array index
warp @map$,@x_axis[@rand],@y_axis[@rand];

Think this should work.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

// Define all combinations (x,y).
setarray .@x[0],150,158,163,173;
setarray .@y[0],184,182,189,199;

// Pick a random index value and warp to it.
set .@i, rand(getarraysize(.@x));
warp "prontera",.@x[.@i],.@y[.@i];

@Schrwaizer: rand() starts at index 0, so you don't need -1.

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  11/30/12
  • Last Seen:  

thx

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...