Jump to content
spelmo3

Spawning AI in my Randomly selected AO

Recommended Posts

So i'm a novice scripter. I've started to create a simple randomly generated AO system, very basic. Takes an array of invisible pre-placed markers on the map. selects one and creates an AO marker around it. (right now its just moving a marker placed in the editor.)
my next step is spawning a few enemy AI's around the AO area. using a mix of fnc_findsafepos & fnc_spawngroup. 

I'm just looking at some simple ways to populate the AO with a handful of groups by scratch. I've always used someone elses released scripts over on the bis forums to populate the AO. But i'd love to have ago at making my own simple and possibly crude script from scratch.

 

//**AO Selection**

_locations = ["mrk","mrk_1","mrk_2","mrk_3","mrk_4","mrk_5","mrk_6","mrk_7",
				"mrk_8","mrk_9","mrk_10","mrk_11"];
				
_objType = floor(random(24));
rndLoc = _locations call BIS_fnc_selectRandom;

"aoArea" setMarkerPos (getMarkerPos rndloc); /*created in the map already*/

switch (_objType) do
{

  	case 0: {"aoArea" setMarkerPos (getMarkerPos rndloc); }; 
	case 1: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 2: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 3: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 4: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 5: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 6: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 7: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 8: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 9: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 10: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
	case 11: {"aoArea" setMarkerPos (getMarkerPos rndloc); };
};

//**AI Population**
 
spawnPos = ["aoArea", 50, 100, 10, 0, 20, 0] call BIS_fnc_findSafePos;
[spawnPos, east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad_Weapons")] call BIS_fnc_spawnGroup;

Just to add.. my last two lines of code are probably completely written wrong and will probably throw and unexpected variable error.. i've tried a few things round and just left it how it is right now.
Its been awhile playing in arma sqf's so bare with any sloppyness!

  • Like 1

Share this post


Link to post
Share on other sites

Your markers management is weird.

You could write : rndLoc =  selectRandom _locations // or even selectRandomWeighted

For your switch, if you need 12 possibilities among 24... so with half chances to move a marker above a marker (🙄) use default for the other half. You can write floor random 24 straight as well without _objType variable.

 

spawnPos = ["aoArea", 50, 100, 10, 0, 20, 0] call BIS_fnc_findSafePos;

BIS_fnc_findSafePos  has a syntax you need to follow.

center is not a string (even a marker) but an object or a position, use markerPos "aoArea" instead

min distance: 50 is huge compared to your radius: 100  Are you sure you want to exclude such center?

10 ... depending on the map but why not

0 on ground

20  hard slop possible

0 shore mode ok

I suggest you give a look at extra optional params:

blacklist positions (some trigger areas could be handy for spawning elsewhere)

default positions (land/sea)  you could set it to [0,0,0] and treat this case further (delete group for example)

 

[spawnPos, east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad_Weapons")] call BIS_fnc_spawnGroup; // very basic

 

The main problem here is you place your leader on a decent position (using BIS_fnc_findSafePos), but other units can be stuck inside rocks or houses and vehicles can blow on near objects.

The main reason why, scripting for any map, I decided to create my own spawning script for groups and units/vehicles safe placement, without too much resource consuming.
See also : find findEmptyPosition and isFlatEmpty (used in BIS function)

  • Like 1

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

×