Jump to content
Sign in to follow this  
kuh111578

Here's a hacky AI ROF reduction script

Recommended Posts

As we know the AI prefers to be out of ammo within 2 minutes of enemy contact.

Some sources (such as my former Arma unit) suggest sustained section fire is done at one shot or burst (if using a MG/SAW) every 6 seconds or so.

In order to address these two things I've made a script for my personal use. It works! but it's clearly not the best way to do what I want. Any advice?

(The desired effect is ~5 second pauses between shots or bursts.)

fnc_sultorism_timer = {
if (!(isPlayer _this)) then {
		while {true} do {
			_this setvariable ['its_sultory_time',false];
			sleep (3.85 + random 2.5);

			_this setvariable ['its_sultory_time',true];
			sleep 1;
		};
	};
};
fnc_fire_desultorily = {
private ["_originalGroup","_group", "_groupArray"];
while {true} do {
	if (!(isPlayer (leader _this))) then {
		if (leader _this getvariable ['its_sultory_time', true]) then {
			leader _this setCombatMode "YELLOW";
		} else {
			leader _this setCombatMode "BLUE";
		};
	};
	{
		if (!(isPlayer _x)) then {
			_originalGroup = group _x;
			if (_x getvariable ['its_sultory_time', true]) then {
				_group = createGroup side _x;
				[_x] joinSilent _group;
				_x setCombatMode "YELLOW";
				[_x] joinSilent _originalGroup;
				deleteGroup _group;
			} else {
				_group = createGroup side _x;
				[_x] joinSilent _group;
				_x setCombatMode "BLUE";
				[_x] joinSilent _originalGroup;
				deleteGroup _group;
			}
		};
	} foreach ((units _this) - [leader _this]);
};
};
fnc_everyone_fire_desultorily = {
{
	_x spawn fnc_sultorism_timer;
} foreach allunits;
{
	_x spawn fnc_fire_desultorily;
} foreach allgroups;
};

sleep 0.1;

call fnc_everyone_fire_desultorily;

Edited by kuh111578
fix code

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  

×