Home   Help Search Login Register  

Author Topic: Teleport to random location  (Read 1937 times)

0 Members and 1 Guest are viewing this topic.

Jim666

  • Guest
Teleport to random location
« on: 19 Jun 2005, 01:57:26 »
Ive got a trigger that you walk through to teleport you to "battle arena" so to speak, but i was wondering if its possible to place you randomly in this area?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Teleport to random location
« Reply #1 on: 19 Jun 2005, 09:04:07 »
it is. ;)

first put a gamelogic at the centre of the battle arena. call it 'bat_arena'. decide how wide you want the area to be.

dunno how you want to set up the trigger, but it could be west present, repeating, and in the 'on activation' field put

Code: [Select]
[thislist] exec "tele_arena.sqs"
then make the teleport script, like this

Code: [Select]
;teleport to random position within arena

_units = _this select 0
_totalunits = count _units
_bax = getpos bat_arena select 0
_bay = getpos bat_arena select 1

_i = 0

#loop

_dir = random 360
_width = random ***put the radius (centre to edge) of the arena here***

_units select _i setpos [_bax + (_width*sin(_dir)), _bay + (_width*cos(_dir))]

_i = _i +1
?not (_i>_totalunits) : goto "loop"

hint "All done."
exit

no idea if that will work in multiplayer, but the basics are there.
« Last Edit: 19 Jun 2005, 14:18:59 by bedges »

Jim666

  • Guest
Re:Teleport to random location
« Reply #2 on: 19 Jun 2005, 11:21:03 »
Hmm, doesnt seem to work. Teleports me into the sea each time. (Thats on single player)

Bluelikeu

  • Guest
Re:Teleport to random location
« Reply #3 on: 19 Jun 2005, 11:37:41 »
ok, basically the same thing said before except works for one unit instead of a group, but this might work for you...

place a game logic. Remember that the game logic is the center of your circle, so place it in the center of the arena.

copy this script into a file:

;_gl is the name of the game logic that should be the center point
_gl = _this select 0
;_rng  is the radius of the circle, probably about 200
_rng = _this select 1
;_u is the name of the unit to teleport
_u = _this select 2
_p = getpos _gl
_p set[0, (_p select 0)+(random _rng)-(random _rng)]
_p set[1, (_p select 1)+(random _rng)-(random _rng)]
_u setpos _p



this should work, just place the script into a script file name "teleport.sqs"

then put something like this in a trigger:

[gamelogic1, 200, player] exec "teleport.sqs"


make sure that the trigger can be activated in some way

Hope this works,
Bluelikeu
« Last Edit: 19 Jun 2005, 11:39:22 by Bluelikeu »

Jim666

  • Guest
Re:Teleport to random location
« Reply #4 on: 19 Jun 2005, 11:52:05 »
That works fine, I just need to make it that when someone walks through the teleport it only teleports that person. (Im making a deathmatch) At the moment it teleports everyone.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Teleport to random location
« Reply #5 on: 19 Jun 2005, 14:18:07 »
depending on the order in which units are added to thislist of a trigger, using

Code: [Select]
thislist select 0
should return the first unit who stepped in.

that or make the teleportation area small enough that only one loon can step in at a time...

edit - the reason my script didn't work was a typo - i repeated '_bax'. it should work fine now ;)
« Last Edit: 19 Jun 2005, 14:19:35 by bedges »

Jim666

  • Guest
Re:Teleport to random location
« Reply #6 on: 19 Jun 2005, 15:09:23 »
What i ment was, that when i step through trigger, the whole squad of AI comes with me, im not so sure how to stop this?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Teleport to random location
« Reply #7 on: 19 Jun 2005, 15:50:38 »
right, well the way the script is set up, the trigger returns a list of whatever units are within the trigger. so if there are two, then yes, two would be transported. i shall test this just now to see if it works the way i think it does.

see attached missionette ;)
« Last Edit: 19 Jun 2005, 16:23:09 by bedges »

Jim666

  • Guest
Re:Teleport to random location
« Reply #8 on: 20 Jun 2005, 17:03:48 »
Ah, perfect just what i was looking for.

Thanks, i'll be sure to add your name in the credits somewhere :)