Jump to content
Sign in to follow this  
Sneakson

Creating enemies in random positions

Recommended Posts

Hey, is there an easy way to select a radius and have enemies randomly spawn in this radius?

I thought the modules would work but then I tried spawning Opfor in Agia Marina only 3-4 guys spawn in the very middle even when the radius covers the entire area around Marina.

Creating a clump of enemies with spawn radius also works like shit because all except one guy spawns in the default position anyways.

Gonna keep experimenting.

Share this post


Link to post
Share on other sites

put down a marker in the center of where you want the units to spawn

_spawnCenter = getmarkerpos "markerName";

_radiusX = **put number here**;
_radiusY = **put number here**;

_randomX = random _radiusX;
_randomY = random _radiusY;

_randomPositionSelect = random 9;
if (_randomPositionSelect >= 5) then {_randomX  = _randomX; _randomY = _randomY}else {_randomX = _randomX - (2*_randomX); _randomY = _randomY- (2*_randomY);};

_spawnPos = [_spawnCenter select 0 + _randomX , _spawnCenter select 1 + _randomY, _spawnCenter select 2];

_group = [_spawnPos, EAST, "GROUPTYPE"] call bis_fnc_spawnGroup;

Share this post


Link to post
Share on other sites
put down a marker in the center of where you want the units to spawn

_spawnCenter = getmarkerpos "markerName";

_radiusX = **put number here**;
_radiusY = **put number here**;

_randomX = random _radiusX;
_randomY = random _radiusY;

_randomPositionSelect = random 9;
if (_randomPositionSelect >= 5) then {_randomX  = _randomX; _randomY = _randomY}else {_randomX = _randomX - (2*_randomX); _randomY = _randomY- (2*_randomY);};

_spawnPos = [_spawnCenter select 0 + _randomX , _spawnCenter select 1 + _randomY, _spawnCenter select 2];

_group = [_spawnPos, EAST, "GROUPTYPE"] call bis_fnc_spawnGroup;

And then?

Share this post


Link to post
Share on other sites
And then?

my fault, i should have explained more

1. Put down a n central marker and give it a name

2. Put down a trigger and give it a condition

3. Open notepad (or a text editor -- not Word)

3a. Copy the above code into notepad

3b. Replace the "markerName" with your marker name in ""

3c. Replace the **number here with a number. I recommend 100 (means the max ditance the unit can spawn from the marker is 100 units away)

3c. Replace the "GROUPTYPE" with the config entry for a group type

4. Save the file as **.sqf

5. In the mission editor place this in the trigger on act. field

_nul = [] execVM "yourScriptName.sqf";

6. Play the mission and watch the enemy spawn

Share this post


Link to post
Share on other sites

Also an easy workaround is just to Group a unit with multiple markers -the game will randomly pick which location he spawns at.

Share this post


Link to post
Share on other sites

Check out my eos script. Easy to use and does exactly what you are looking for and more if you want

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  

×