Jump to content
  • 0

Random warp


Question

Posted

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;

3 answers to this question

Recommended Posts

Posted

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
Posted

// 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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...