Jump to content
flyingsaucerinvasion

Foolproof way of forcing ai man to fire specified mag from underbarrel launcher.

Recommended Posts

1: Is there a foolproof way of forcing an AI man to fire a specified mag (in this case a smoke round) from his underbarrel grenade launcher?  Preferably, he should fire immediately.  By foolproof, I mean that if he has the mag and the weapon, he will definitely fire (the mag and weapon), and without hesitation.

 

2:  Is there a way to make him fire it at a specific position without the use of invisible targets?  (I'm currently just setting the velocity of the projectile to get it to go where I desire.  But that's pretty hacky).

 

3:  Is there a way to automatically determine if an ai man has a weapon which can fire a certain mag.  And to do all of the above using the identified weapon and the appropriate muzzle.

Share this post


Link to post
Share on other sites

Item 1:

You can test this. Give the enemy man a weapon with smoke rounds and no other rounds. 

From a distance start firing at him. Don't hit him.

As he only has smoke, he should fire smoke at you. 

Try this at different distances and check the result.

 

In theory you could create a trigger that removes all the mans ammo except for the smoke. When he shoots back he shoots smoke. Then another trigger that gives him back is usual load of usual ammunition.

 

Item 2:

Not that I know of. There is a work around.

Make a trigger that causes smoke to appear a the required location. It will give the appearance to any spectator, that he is firing smoke at the required location.

 

Item 3:

Above my pay grade sorry!

Share this post


Link to post
Share on other sites

I use the below in combination with doTarget:

_unit selectWeapon ((getArray(configFile>>"cfgWeapons" >> primaryWeapon _unit >> "muzzles")) select 1);
_unit forceWeaponFire [primaryWeapon _unit,"Single"];

The select 1 can be changed to whatever index number is needed, it may be different between mods/vanilla.

 

edit: Sorry, just realised this is only a half answer. You'll also need to force the AI to reload a specific (smoke) grenade: https://community.bistudio.com/wiki/reload

  • Like 1

Share this post


Link to post
Share on other sites

 

20 hours ago, beno_83au said:

I use the below in combination with doTarget:


_unit selectWeapon ((getArray(configFile>>"cfgWeapons" >> primaryWeapon _unit >> "muzzles")) select 1);
_unit forceWeaponFire [primaryWeapon _unit,"Single"];

The select 1 can be changed to whatever index number is needed, it may be different between mods/vanilla.

 

edit: Sorry, just realised this is only a half answer. You'll also need to force the AI to reload a specific (smoke) grenade: https://community.bistudio.com/wiki/reload

Can you do all that instantly?  in other words all commands in sequence with no delay between them?

 

Also, keep in mind I'm shooting at a position, not at an object.  So if dotarget is required, it's no good.

Share this post


Link to post
Share on other sites

So, I don't know of a way of reliably targeting a position. I've been through a lot of this kind of thing when making a support-by-fire function, but I can get AI to reliably fire any of their weapons at a target - https://www.youtube.com/watch?v=W4j0MkmNMQE&list=PLec6T_DTU707E72sxxPGIxuobvmuQcP8I&index=9

 

 

To break down what I have to the bare bones of what you should need:

//Create logic target and reveal.
_target = "Logic" createVehicleLocal _targetPosition;

_unit reveal [_target,4];
_unit doWatch objNull;
_unit doWatch _target;
_unit doTarget _target;

//Sleep to allow everything to catch up (e.g. aiming).
sleep 1;

//Unit fires the weapon.
_unit selectWeapon ((getArray(configFile>>"cfgWeapons" >> primaryWeapon _unit >> "muzzles")) select 1);
_unit forceWeaponFire [primaryWeapon _unit,"Single"];

With _unit being the grenadier obviously, see if that works out for you. This is also assuming that the unit already has a smoke round loaded, but you can do that whenever you want or just put it in at the beginning of the code block with a short sleep after.

  • Like 1

Share this post


Link to post
Share on other sites

doSuppressiveFire allows you to target a position but that doesn't seem to work with a GL muzzle.

doFire works with GL muzzle but you need a 3D object as target (windsock, lamp, even helper or anything else, but forget 2D helipads, markers). The good news: even if hidden, the units will fire at this object!

 

 

  • Like 1

Share this post


Link to post
Share on other sites

I can now answer two of my questions.

 

1)   To force a unit to fire a weapon muzzle using a specific mag:

_unit reload [_muzzle,_mag];
_unit selectWeapon _muzzle;
 _unit fire _muzzle;

It will take time for them to reload the mag (but only if it isn't already loaded.  However, the delay caused by reloading the mag does not appear to stop them from firing the weapon.  I don't really know if the "selectWeapon" function is needed, but it doesn't seem to cause any harm that I can see.


2) This script (see spoiler) gets the muzzle capable of firing a magazine.  But only from the primary weapon.  All it does is check each muzzle in the weapon until it finds one that contains the searched for "_mag" in that muzzle's possible magazines.  "none" is returned if no muzzle can fire the magazine.

Spoiler

 


	func_SMOKE_Unit_get_muzzle = {
		params ["_mag","_unit"];
		private ["_weapon", "_cfg", "_muzzles", "_muzzle", "_mags", "_muzzle_name", "_compatible_muzzle"];
		_weapon = primaryweapon _unit;
		_cfg = configFile/'CfgWeapons'/_weapon;
		_muzzles = getarray(_cfg>>"muzzles");
		_compatible_muzzle = "none";
		{
			if (_x == "this") then { 
				_muzzle = _cfg; 
				_muzzle_name = _weapon;
			} else {
				_muzzle = _cfg>>_x; 
				_muzzle_name = _x;
			};
			_mags = getarray(_muzzle>>"magazines");
			if (_mag in _mags) exitWith { 
				//player sidechat "compatible muzzle found"; 
				_compatible_muzzle = _muzzle_name; 
			};
		} forEach _muzzles;
		_compatible_muzzle;
	};

 

 

 

 

-----------------------

 

I've not seen any way of firing on a position that doesn't involve using an invisible target.  However, what I'm actually doing is just making them fire (in whatever direction they happen to be facing), and then I adjust the velocity of the fired projectile to set it on a parabolic course toward its intended firing position.  Somehow, this seems easier to me than mucking around with invisible targets (in this context anyway).

  • Like 2

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

×