Jump to content
Sign in to follow this  
evilnate

Patrol scripting

Recommended Posts

Greetings,

I would like to make a function or script that has the following ability;

Blufor enters trigger an area surrounding a town or area of interest on the map.

There is a marker at the center of the area of interest.

The trigger detects blufor, and then calls the following function;

//[numberOfGroups(intiger),"markername", minGroupSize(1-12), chanceOfRemainSpawn(0-1), patrolWaypointDistances(number), call opfor_patrolFnc;
[3,"zone1", east, 2, 0.2, 100] call opfor_patrolFnc;

The #included function is here;

opfor_patrolFnc = {

_i = _this select 0;
_marker = _this select 1;
_side = _this select 2;
_mingroupSize = _this select 3;
_chance = _this select 4;
_dist = _this select 5;
_units = ["O_Soldier_SL_F","O_Soldier_TL_F","O_Soldier_F","O_Soldier_AR_F","O_Soldier_GL_F","O_soldier_M_F","O_Soldier__F","O_Soldier_AR_F","O_Soldier_GL_F","O_Soldier_LAT_F","O_medic_F","O_soldier_exp_F"];

if (_i > 0) then
	{
	_i - 1;
	_grp = [getMarkerPos _marker, _side, _units,[],[],[],[],[_mingroupSize,_chance],0] call BIS_fnc_spawnGroup;
	[_grp, getMarkerPos _marker,_dist] call bis_fnc_taskPatrol; 
	some way to get it to check if _i is greater than zero and make more random groups until it is zero;
	};

};

It all worked until I wanted to define the number of groups to for the function to spawn, and then found myself at the limit of my knowledge. I am hoping that I can define the number of randomly sized groups spawned and patrolling at the defined area.

Any help would be appreciated.

Share this post


Link to post
Share on other sites

try:

opfor_patrolFnc = {

_n = _this select 0;
_marker = _this select 1;
_side = _this select 2;
_mingroupSize = _this select 3;
_chance = _this select 4;
_dist = _this select 5;
_units = ["O_Soldier_SL_F","O_Soldier_TL_F","O_Soldier_F","O_Soldier_AR_F","O_Soldier_GL_F","O_soldier_M_F","O_Soldier__F","O_Soldier_AR_F","O_Soldier_GL_F","O_Soldier_LAT_F","O_medic_F","O_soldier_exp_F"];

for "_i" from 0 to _n do
	{
	_grp = [getMarkerPos _marker, _side, _units,[],[],[],[],[_mingroupSize,_chance],0] call BIS_fnc_spawnGroup;
	[_grp, getMarkerPos _marker,_dist] call bis_fnc_taskPatrol; 
	};

};

Not tested but hopefully that helps. see also http://community.bistudio.com/wiki/Control_Structures#for-from-to-Loop :)

Share this post


Link to post
Share on other sites

That worked perfectly, thanks! I will remember this way of looping, very useful!

Share this post


Link to post
Share on other sites

or alternatively

opfor_patrolFnc = { 
   _n = _this select 0;
   _marker = _this select 1;
   _side = _this select 2;
   _mingroupSize = _this select 3;
   _chance = _this select 4;
   _dist = _this select 5;
   _units = ["O_Soldier_SL_F","O_Soldier_TL_F","O_Soldier_F","O_Soldier_AR_F","O_Soldier_GL_F","O_soldier_M_F","O_Soldier__F","O_Soldier_AR_F","O_Soldier_GL_F","O_Soldier_LAT_F","O_medic_F","O_soldier_exp_F"];


   while {_i > 0} do {
       _grp = [getMarkerPos _marker, _side, _units,[],[],[],[],[_mingroupSize,_chance],0] call BIS_fnc_spawnGroup;
       [_grp, getMarkerPos _marker,_dist] call bis_fnc_taskPatrol; 
       _i = _i - 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
Sign in to follow this  

×