Jump to content
LOzan

Setting Fire Mode

Recommended Posts

My googling has turned up nothing, so it's time to ask the forums.

How do you set an AI unit's fire mode (semi, burst, auto, etc.) through scripting commands? I've got units using Toadie's AK Pack, but the default fire mode is automatic and I need them shooting single-fire. These are trained soldiers, after all.

Anybody know the answer?

Share this post


Link to post
Share on other sites

Try finding the currentWeaponMode command on the wiki, then take a look at the related commands (i.e. switchWeapon) and see if that does the trick.

Share this post


Link to post
Share on other sites

Hi. Try this.

unit init line

_nul=this execVM "fireMode.sqf";

fireMode.sqf

while {!(isNull _this)} do {
waitUntil {!((currentWeaponMode _this) isEqualTo "Single")};
_this action ["SWITCHMAGAZINE", _this, _this, 0];
};

Share this post


Link to post
Share on other sites

Alternatively.

{
if (!(isPlayer _x)) then { 
	_x spawn {
		while {!(isNull _this)} do {
			waitUntil {!((currentWeaponMode _this) isEqualTo "Single")};
			_this action ["SWITCHMAGAZINE", _this, _this, 0];
		};  
	};
};
} forEach allUnits;

Or a bit faster

for "_i" from 0 to (count allUnits) - 1 do {
if (!(isPlayer (allUnits select _i))) then { 
	(allUnits select _i) spawn {
		while {!(isNull _this)} do {
			waitUntil {!((currentWeaponMode _this) isEqualTo "Single")};
			_this action ["SWITCHMAGAZINE", _this, _this, 0];
		};  
	};
};
};

Or EH

{
if (!(isPlayer _x)) then {
	_x addEventHandler ["fired", {
		if !(currentWeaponMode (_this select 0) isEqualTo "Single") exitWith {
			(_this select 0) action ["SWITCHMAGAZINE", (_this select 0), (_this select 0), 0];
		};
	}];
};
} forEach allUnits; 

Edited by Iceman77

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/forceWeaponFire

About half way down the page there's an example by Killzone Kid for this... works perfectly.

Something to note - many AI mods will override this anyhow because they have set parameters already for when the AI will automatically switch weapon mode - usually defined by distance from target.

Edited by thefinn

Share this post


Link to post
Share on other sites

Well it's a good thing someone posted it here! Never knew about that command ;) Though I'd be willing to bet the code behind that command is almost identical to what was posted earlier.

Edited by Iceman77

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

×