Jump to content

Recommended Posts

Hi everyone ...

 

I am player a mission on LAN multiplayer server ... I have an sqf file called (invincible_ai.sqf) ... This file is executed when ever I add new AI player to my squad ... The content of this file is as follows:

 

{
  if ((side _x) == West) then
  {
	_x allowDamage false; 
	_x setdamage 0;
	_x setCustomAimCoef 0.00;
	_x setUnitRecoilCoefficient 0;
	_x addEventHandler [ "Fired", { if ((_this select 1) == "launch_NLAW_F") then { (_this select 0) addMagazine "NLAW_F"; } else { (_this select 0) setvehicleammo 1; } } ]; 
	_x addEventHandler [ "GetInMan", { (_this select 2) allowDamage false; (_this select 2) setdamage 0; (_this select 2) setFuel 1; (_this select 2) setCaptive true; } ];
	_x addEventHandler [ "FiredMan", { ( _this select 7) setvehicleammo 1; } ];
}
} forEach allUnits;

in this (invincible_ai.sqf) file, this part of the cod is WORKING NICE:

_x allowDamage false; 
_x setdamage 0;
_x setCustomAimCoef 0.00;
_x setUnitRecoilCoefficient 0;
_x addEventHandler [ "Fired", { if ((_this select 1) == "launch_NLAW_F") then { (_this select 0) addMagazine "NLAW_F"; } else { (_this select 0) setvehicleammo 1; } } ]; 
_x addEventHandler [ "GetInMan", { (_this select 2) allowDamage false; (_this select 2) setdamage 0; (_this select 2) setFuel 1; (_this select 2) setCaptive true; } ];

But this part is NOT WORKING:

_x addEventHandler [ "FiredMan", { ( _this select 7) setvehicleammo 1; } ];

What I am trying to do is: to give the AI unit infinite ammo when using a turret mounted on a vehicle ...

 

I have another sqf file called (god_like_player.sqf) ... The content of this file is as follows:

 

Player addEventHandler [ "Fired", { if ((_this select 1) == "launch_NLAW_F") then { Player addMagazine "NLAW_F"; } else { ( _this select 0) setvehicleammo 1; } } ];
Player addEventHandler [ "GetInMan", { (_this select 2) allowDamage false; (_this select 2) setdamage 0; (_this select 2) setFuel 1; (_this select 2) setCaptive true; } ];
Player addEventHandler [ "FiredMan", { ( _this select 7) setvehicleammo 1; } ];

This part in (god_like_player.sqf) is WORKING NICE:

 

Player addEventHandler [ "FiredMan", { ( _this select 7) setvehicleammo 1; } ];

 

and myself as human player will have unlimited ammo for the turret of the vehicle ...... But this part in (invincible_ai.sqf) is NOT WORKING:

 

_x addEventHandler [ "FiredMan", { ( _this select 7) setvehicleammo 1; } ];

 

and the AI unit is still having limited ammo for the turret of the vehicle ... Why this piece of code is working for me as human player, but not working for AI units ??????

 

Can someone help me with this FiredMan event handler so that it work on all AI united in my LAN multiplayer server ... Or maybe there is another solution ... What I need is to make all AI units in my LAN server to have unlimited ammo for the turret in a vehicle ... By the way: the AI units are created by script, so I don't have access to the init field of the unit in the editor.

Edited by samir17864
correction
  • Like 1

Share this post


Link to post
Share on other sites

I have a very nice script that will give all human or AI units friendly or Foe to always have a roundbof AT/AA unit  or one magazine of any weapon in the inventory. I have been using it since ARMA2 because of the lack of AI rearm ability in the vanilla game. It will not work for vehicles guns but maybe you can tweak it or somebody can help you with it. 

Share this post


Link to post
Share on other sites

This works for me:

// car = Hunter HMG
// Bob = gunner
// debug:
Bob addEventHandler ["FiredMan", {vehicle (_this select 7) setVehicleAmmoDef 1;}];
Bob moveInGunner car;
[] spawn {while {someAmmo car} do {car action ["UseWeapon", car, gunner car, 0]; sleep 0.01;};};

EDIT: Strange behaviour: Once the AI unit has wasted all ammo and you then shoot him or move him out. The gun will shoot a few more bullets then stop. Even though it has no actually has no bullets. Magic?

  • Like 2

Share this post


Link to post
Share on other sites

setVehicleAmmoDef doesn't always work well on non vanilla vehicles. Just keep it in mind when you use this command.

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

×