Page 1 of 1

Teleporting to a random destination

Posted: Mon Jan 16, 2006 10:41 am
by Waylander76
Still getting the hang of scripting..albeit very slowly!

I'm using this script by bdbodger to teleport players to a destination defined by a triggger.
As I understand it the script indexes the triggers and finds the next available free one to use as a destination.
In other words it checks trigger 1, then 2 then 3 etc

If I have 10 destination triggers in my map how do I make the choice of destination random useing the script below?

I'm guessing i'll have to rename the triggers to something like $endtrigger1 , $endtrigger2 etc and have some code to pick a random number between 1 and 10?

Code: Select all

//setthread to tele_porter $endtrigger's are trigger_multiples 

tele_porter: 

local.player = parm.other 

for(local.i=1;local.i <= $endtrigger.size;local.i++) 
{ 
   if($endtrigger[local.i].isused != 1) 
   { 
      local.player thread tele_player $endtrigger[local.i] 
      end 
   } 
} 
end 

tele_player local.spot: 

self tele local.spot.origin 

local.spot.isused = 1 

while(self is touching local.spot) 
waitframe 

local.spot.isused = 0 

end 

As always thanks in advance for any help.

Re: Teleporting to a random destination

Posted: Wed Jan 18, 2006 9:49 pm
by LeBabouin
Waylander76 wrote:

Code: Select all


tele_porter: 

local.player = parm.other 

for(local.i=1;local.i <= $endtrigger.size;local.i++) 
{ 
   if($endtrigger[local.i].isused != 1) 
   { 
      local.player thread tele_player $endtrigger[local.i] 
      end 
   } 
} 
end 

tele_player local.spot: 

self tele local.spot.origin 

local.spot.isused = 1 

while(self is touching local.spot) 
waitframe 

local.spot.isused = 0 

end 

tele_porter:

local.i=1 + randomint $endtrigger.size
local.player thread tele_player $endtrigger[local.i]

end

Posted: Thu Jan 19, 2006 7:50 am
by Waylander76
Thanks very much LeBabouin