OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: SaS TrooP on 30 May 2011, 18:48:24

Title: Spawning in random area of the marker
Post by: SaS TrooP 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.
Title: Re: Spawning in random area of the marker
Post by: SaOk 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.
Title: Re: Spawning in random area of the marker
Post by: SaS TrooP on 02 Jun 2011, 21:23:17
Works even more than just fine! Thanks man!