Jump to content
Sign in to follow this  
Voltagez

Soldiers should not refill their ammo

Recommended Posts

So I am creating a mission where a few soldiers (Opfor) protect some ammo/weapon boxes. Blufor has to kill them and safe the weapons.

Everytime when i start this mission these soldiers dont stay at their positions. They run to the ammo crates and refill their ammo instead. How can i stop them from doing this?

The soldiers should just stay where they have spawned and when they see an enemy they should open fire.

How can i do this?

You probably need to know that these soldiers are custom, so they dont have their usual gear. For example:

weapons[] = {"arifle_TRG21_F","hgun_ACPC2_F"}; // Weapons added to the unit.
respawnweapons[] = {"arifle_TRG21_F","hgun_ACPC2_F"}; // Weapons added to the unit. Should be identical to the linkedItems section

and so on...

Would be great if anybody could help me :)

Edited by Voltagez

Share this post


Link to post
Share on other sites

BIS_fnc_addWeapon fills your needs.

It checks if the unit has a weapon, adds the weapon, and if the unit already has a weapon it only adds ammo.

As long as your unit has a rifle and a handgun you're safe to use it.

In your case I'd do:

[this,primaryWeapon this, 6] call BIS_fnc_addweapon;
[this,handgunWeapon this, 4] call BIS_fnc_addweapon;

this will add 6 rifle mags and 4 handgun mags to your unit

Share this post


Link to post
Share on other sites

I'm assuming your using unit's you made into an addon and not units that just have things modified in their init? There are a few things you can try but I wont be able to test them for you since I don't have your mod or mission.

First is a DisableAI command. This disables their movement entirely so it would only make sense for bunkers or positions that don't have to do any moving. They should be able to still turn and shoot from my understanding.

Put this in the unit's init.

this DisableAI "MOVE";

You could also try this but i'm not sure whether or not it would stop the unit's going for the ammo boxes or not but it's worth a shot.

this allowFleeing 0;

Let me know if it works or not.

Share this post


Link to post
Share on other sites

This behavior as far as I know isn't part of the Vanilla engine but must be part of an addon you are using. I might guess ASR-Ai or something.

Share this post


Link to post
Share on other sites

AI units will always try to rearm if they are running low on ammo (had that in a few custom loadouts that I made, looks like it's intended behavior).

Just place a rifleman in the editor and set his ammo a bit above 0, then place a basic ammo box of the same faction in a small distance to the rifleman and watch what's happening.

Hence my suggestion to add more ammo with the commands I posted.

Share this post


Link to post
Share on other sites

Can you empty the ammo box until all the OPFOR are killed? That might stop them going to it?

Share this post


Link to post
Share on other sites

Why you want the poor guys fight until being out of ammo, and then die, in front of a f*****g ammobox??????????????? Let them refill!!

Share this post


Link to post
Share on other sites

First of all, thanks for your help :)

I had many things to do so i couldnt answer.

Why you want the poor guys fight until being out of ammo, and then die, in front of a f*****g ammobox??????????????? Let them refill!!

It would probably be Ok if they refill their ammo and then returning back to thier spawnpoint. But after the soldiers start to refill they just dont stop. They refill their ammo over and over again...

Can you empty the ammo box until all the OPFOR are killed? That might stop them going to it?

The player is Blufor so they open fire/or they run to the ammo crates (it seems to be random :D ). You can't empty them before.

This behavior as far as I know isn't part of the Vanilla engine but must be part of an addon you are using. I might guess ASR-Ai or something.

I am using an addon which more or less Teeha has written. Thank you again for helping me with this :).

Here is a part of the code used in the addon:

enum {
 //  = 2,	// Error parsing: Empty enum name
DESTRUCTENGINE = 2,
DESTRUCTDEFAULT = 6,
DESTRUCTWRECK = 7,
DESTRUCTTREE = 3,
DESTRUCTTENT = 4,
STABILIZEDINAXISX = 1,
STABILIZEDINAXESXYZ = 4,
STABILIZEDINAXISY = 2,
STABILIZEDINAXESBOTH = 3,
DESTRUCTNO = 0,
STABILIZEDINAXESNONE = 0,
DESTRUCTMAN = 5,
DESTRUCTBUILDING = 1,
};
class CfgPatches {
class unit_config {
	units[] = {};
	weapons[] = {};
	requiredVersion = 0.1;
	requiredAddons[] = {"A3_Characters_F_BLUFOR"};
};
};
class CfgFactionClasses
{
class a_units
{
	displayName = "ARMY";
	author = "YOURNAME";
	icon = "Directory to faction Icon"; // Needs to be 16x16 in resolution and it needs to be in the form of a PAA.
	priority = 2;
	side = 1; // Blufor
};
};
class CfgVehicleClasses
{
class army_units
{
	displayName = "Army Battalion";.
};
};
class CfgVehicles {
class B_Soldier_base_F;
   class Army_Squadleader : B_Soldier_base_F {
	_generalMacro = "Army_Squadleader"; 
	scope = 2;
	displayName = "Squad Leader"; // In-game name of unit
	faction = a_units; // Puts unit under new faction
	vehicleClass = "army_units"; // Puts unit in the vehicleclass
	icon = "iconManLeader";
	nakedUniform = "U_BasicBody";  
	uniformClass = "U_B_CombatUniform_mcam";  // Uniform Class
	backpack = "B_AssaultPack_khk"; // Backpack Class
	linkedItems[] = {"V_PlateCarrier3_rgr", "H_HelmetB_light", "NVGoggles", "ItemMap"}; // Item's added to the unit. 
	respawnLinkedItems[] = {"V_PlateCarrier3_rgr", "H_HelmetB_light", "NVGoggles", "ItemMap"}; // Item's added to the unit. Should be identical to the linkedItems section.
	weapons[] = {"arifle_MX_F","Binocular"}; 
	respawnweapons[] = {"arifle_MX_F","Binocular"}; 
	magazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag",};
	Respawnmagazines[] = {"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag",};
	};





I will try the things Teeha and Grumpy are suggesting maybe they help. After this i come back with the results

Share this post


Link to post
Share on other sites

You can try ClearWeaponCargo <ammocratename>; ClearMagazineCargo <ammocratename>;

Then add a trigger than when Blufor enters the perimeter the crate respawns or manually <ammocratename> addweaponcargo ; <ammocratename> addmagazinecargo ;

Share this post


Link to post
Share on other sites

I think grumpy's idea may work better since the AI units still have full maneuverability rather than being stuck in place. If neither my or grumpy's ideas work mcrow does have a good idea about spawning the ammo crate once blufor are in a certain area that is defined by a trigger.

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  

×