Jump to content
Sign in to follow this  
Janez

Manipulating AI subordinates gear in MP

Recommended Posts

Hi,

I have four playable units that can be either players or AI. Squad leader has higher rank then the rest.

While I can open gear menu for my AI subordinates in MP via "F#\6\#Inventory", I cannot add/remove anything.

Is there any way to enable this? If not, how can I have unlimited ammo for AI but not players?

I was thinking something like this

{
if ((side _x == west) and !(isPlayer _x)) then 
{
	_x addEventHandler ['Fired', {(_this select 0) setVehicleAmmo 1}];
};
} forEach (allUnits);

and it works but how can I make it so if player joins mid session, script would be terminated and vice versa.

Share this post


Link to post
Share on other sites

You could put the if statement inside the eventhandler. Isplayer works if the client controlling the unit is not local.

Alternatively, you could add the eventhandlers only on the server, then remove them onplayerconnected.

Something like:

Onplayerconnected "[player,removealleventhandlers,FALSE,false] call bis_fnc_mp;

Share this post


Link to post
Share on other sites
Might this help? description.ext
allowSubordinatesTakeWeapons= 1;

Already tried that. It seems that is intended to allow subordinates to equip gear in briefing menu prior to mission start. So that's something else. Thanks though.

@TKTom

Thanks, I'll have to play around with that a bit. I would like it to be robust and repeatable. I'm not sure though if this behavior is a bug or intentional. Would be nice to have a command to change it.

Share this post


Link to post
Share on other sites
Hi,

I have four playable units that can be either players or AI. Squad leader has higher rank then the rest.

While I can open gear menu for my AI subordinates in MP via "F#\6\#Inventory", I cannot add/remove anything.

Is there any way to enable this? If not, how can I have unlimited ammo for AI but not players?

I was thinking something like this

{
if ((side _x == west) and !(isPlayer _x)) then 
{
	_x addEventHandler ['Fired', {(_this select 0) setVehicleAmmo 1}];
};
} forEach (allUnits);

and it works but how can I make it so if player joins mid session, script would be terminated and vice versa.

Sorry to bring up a month old post, but where did you put this code, Janez?

Share this post


Link to post
Share on other sites

He more than likely put it in the init.sqf (or a call to this script in the init.sqf).

Share this post


Link to post
Share on other sites
He more than likely put it in the init.sqf (or a call to this script in the init.sqf).

That's what I thought, but it is not working for me.

Share this post


Link to post
Share on other sites

Let me first say that I don't understanding bohemia at times and the decisions they make for functionally within the game. At times pure genius and at other times WTF. It was always a somewhat time consuming task to get your AI units to rearm or swap out items during the game but you could do it with OFP > ARMA1 > ARMA2 but you simply can't tell an AI unit to just drop an item for you now. I don't fully understand why they took this out. Yes the backpack function is nice however it is limited if you just need a magazine or other items that are not inside the backpack.

WHY did they never really fix these things.

1. The whole AI unit rearm/refuel/repair is still very limited.

2. AI units to drop items on the ground if told by leader

3. AI medics can not heal outside of it's group. worked in OFP/ARMA1

4. The whole wound system in the game is just bad.

5. The save function is not like it was in ARMA2. I can only save a mission one time. Maybe I am doing something wrong?

6. Why no 3rd editor function that works. We know it can work just fine. ie MCC

I love this game and bohemia because there is no other game company that gives us the product like this but some decisions I don't understanding Why. My rant is over. Now to the OP question.

MR. XxAnimusxX gave me this awesome script for unlimited Ammo for AI units and or human players back for ARMA2. the script just always keeps 2 rounds of ammo in the inventory for the current weapon that is being used. You don't get a continues fire like some other scripts gave. It was a way to compensate for the poor AI rearming function in the game. Please if you use this script in your mission please give XxAnimusxX credit for his work.

Make a SQF put this in and name it unlimitedAmmo.sqf

//Unlimited Ammo Script by XxanimusxX

_unit = _this select 0;

_ammoCount = _this select 1;

_primeWpn = "";

_prevWpn = "";

_magazineType = "";

_foundMags = 0;

while {alive _unit} do {

waitUntil {sleep 0.5; currentWeapon _unit != ""};

_primeWpn = currentWeapon _unit;

if (_primeWpn != _prevWpn) then

{

_prevWpn = _primeWpn;

_magazineType = getArray(configFile >> "cfgWeapons" >> _primeWpn >> "magazines") select 0;

};

_foundMags = 0;

{

if (_x == _magazineType) then

{

_foundMags = _foundMags + 1;

};

} forEach (magazines _unit);

if (_foundMags < _ammoCount) then

{

for "_i" from 1 to (_ammoCount - _foundMags) do

{

_unit addMagazine _magazineType;

};

};

sleep 1;

};

Now in your mission INIT.SQF put this

//add Unlimited Ammo to player unit

grantUnlimitedAmmo = compile preprocessFileLineNumbers "unlimitedAmmo.sqf";

[player, 2] spawn grantUnlimitedAmmo;

OR this Unlimited Ammo to AI units

{

if (!(isPlayer _x)) then

{

[_x, 2] spawn grantUnlimitedAmmo;

};

} foreach allUnits;

You can add both if you like for player and AI units.

Avibird

Edited by AVIBIRD 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  

×