Teleporting to a random destination

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Waylander76
Sergeant Major
Posts: 122
Joined: Wed Jun 01, 2005 10:03 am

Teleporting to a random destination

Post 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.
LeBabouin
Lance Corporal
Posts: 22
Joined: Tue Jun 21, 2005 11:10 pm

Re: Teleporting to a random destination

Post 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
Waylander76
Sergeant Major
Posts: 122
Joined: Wed Jun 01, 2005 10:03 am

Post by Waylander76 »

Thanks very much LeBabouin
Post Reply