Jump to content
Sign in to follow this  
rifle22

AI Random Spawn Script

Recommended Posts

First of all I would like to say, sorry if this has been brought up before, I couldn't find it myself after looking.

Alright what I'm trying to do in my mission is make a single enemy AI (Let's call him target1) spawn in 1 of 4 *or more* positions on the map. I would like this script to make the spawn point be different each time I load the mission. If someone could help me with this that would be nice.

Thanks.

Share this post


Link to post
Share on other sites

Well, create your single AI in the editor, name him target1. Put him in some random spot not on an objective, but it really doesn't matter where you put him. Then create markers on each possible position you want him to spawn (1, 4, 7, doesn't matter, but in this example we'll use 4 markers named spawnpos0, 1, 2, and 3). Then either put the below in init.sqf or put it in a script executed at game init.

_rspawn = round(random 3.49);
_rspawnstr = format ["spawnpos%1",_rspawn]; 
_spawn = getMarkerPos _rspawnstr;
target1 setPos _spawn;

Tested and works.

Share this post


Link to post
Share on other sites

Requires functions module, place it into your init.sqf file. You need to have markers on the map named One - Four.

waitUntil {!isNil "bis_fnc_init"}; 
_marker = ["ONE","TWO","THREE","FOUR"] call BIS_fnc_selectRandom;
_spawn = getMarkerPos _marker;
target1 setPos _spawn;

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Back in my day, we didn't have no functions, we randomized numbers by putting guys in a Ural and tellin' 'em all ta jumps out! However many were left was the number we used in them dang equaysons!

Share this post


Link to post
Share on other sites
Back in my day, we didn't have no functions, we randomized numbers by putting guys in a Ural and tellin' 'em all ta jumps out! However many were left was the number we used in them dang equaysons!

ALL while walking to school in snow, uphill both ways!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×