Arma 3
LAMBS_RPG
Longtime Nov 2, 2023 @ 6:45am
RPGs and infantry
I am trying to make AI engage enemy infantry with an RPG. I was reading the comments and user 4ur0r4 made a comment which also perfectly describes my coding experience... the AI glitch and equip/de-equip their RPG and rarely fire it at enemy infantry.

Has anyone else solved this problem?

So far I have followed a very similar approach as 4ur0r4. I have a scripted function which removes the primary weapon and grenades and then command the unit to load HE RPG ammo (if required) since units won't fire AT at infantry. Then I call selectWeapon on the secondary weapon launcher. The unit will immediately de-equip the launcher despite having no other weapons.

I found a few forum comments and this is what seems to be happening:

* This is a bug in the Arma engine introduced between A2:OA and A3
* doFire and doSuppressiveFire does not work, unit never fires
* forceFireWeapon works maybe 10% of the time but unit will usually ignore
* Creating a target vehicle doesn't seem to work although I saw some interesting ideas for using a small item that is classified as a vehicle (a land cutter tool)

"Land_ClutterCutter_small_F" createVehicle (getPosASL _target); // doesnt work :(

I am getting into weird solutions like spawning a parachute with invisible textures or something but hoping to find a simpler solution.
< >
Showing 1-2 of 2 comments
Longtime Nov 3, 2023 @ 8:43am 
I found a hacky solution by spawning an invisible target man and making them driver of an invisible quadbike.

pseudocode:

// make sure this doesn't run twice // ie-- add a publicVariable with current task handles to avoid running the task twice on one unit if (can shoot an RPG with correct ammo and unit isn't already running the shoot task) then { spawn a function { // remove primary and handgun weapon and restore them later // create invisible target man and invisible quadbike private _v = "B_Quadbike_01_F" createVehicle [0,0,0]; _v enableSimulation false; _v hideObjectGlobal true; _v setPosATL (getPosATL _target); private _tmptarget = "B_TargetSoldier" createVehicle (getPosATL _target); _tmptarget enableSimulation false; _tmptarget hideObjectGlobal true; _tmptarget moveInDriver _v; _u doWatch _target; _u doTarget _target; _u selectWeapon _secondary_weapon; _u doSuppressiveFire _v; // sleep, delete stuff when finished etc } };

Is this horrible? Yes. Yes, it is.
Last edited by Longtime; Nov 3, 2023 @ 2:38pm
Longtime Nov 30, 2023 @ 5:21pm 
Just to follow up, this technique of using an invisible temp target vehicle with an invisible temp driver actually works. AI actually shoots RPGs at infantry.

The implementation is here if anyone wants to look:

https://github.com/Xeno69/Domination/blob/master/co30_Domination.Altis/scripts/fn_force_fire_rpg.sqf
< >
Showing 1-2 of 2 comments
Per page: 1530 50