Advertisement

Author Topic: Spawning in random area of the marker  (Read 299 times)

0 Members and 1 Guest are viewing this topic.

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Spawning in random area of the marker
« on: 30 May 2011, 18:48:24 »
Lets say I have a marker, brush, 1000x1000 metres big. I am spawning AI unit. How can I force spawned unit to respawn in random area in that marker, on any of these 1000x1000 metres? Such a trick is used in eg. in UPSMON.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: Spawning in random area of the marker
« Reply #1 on: 02 Jun 2011, 13:50:20 »
Code: [Select]
_center = getmarkerpos "markername";
_range = getMarkerSize "markername";
_start = [(_center select 0) + random (_range select 0) - random (_range select 0),(_center select 1) + random (_range select 1) - random (_range select 1),0];
while {player distance _start < 500} do {_start = [(_center select 0) + random (_range select 0) - random (_range select 0),(_center select 1) + random (_range select 1) - random (_range select 1),0];};
_group = [_start, EAST, ["TK_INS_Soldier_EP1"],[],[],[0.7,0.9]] call BIS_fnc_spawnGroup;

With that while loop it also checks that the unit dosent spawn near player.
« Last Edit: 02 Jun 2011, 13:53:33 by SaOk »

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Spawning in random area of the marker
« Reply #2 on: 02 Jun 2011, 21:23:17 »
Works even more than just fine! Thanks man!