Arma 3
MGI ADVANCED MODULES
PierreMGI  [developer] 18 Mar, 2019 @ 12:53pm
AIs could grab some weapons
Discussion about AIs and loot weapons.
Last edited by PierreMGI; 18 Mar, 2019 @ 12:55pm
< >
Showing 1-7 of 7 comments
Völe 19 Mar, 2019 @ 2:26pm 
How about scripting?
This is my old function to assist gunner take machine gun when gunner is dead.
Via some effort you can make FSM or something of your choice to suit your needs.

fnc_Replace_MG =
{
/*
needs to be spawned becaous use of while and sleep (scheluded environment)

waitUntil {!alive Machinegunner};
if !(alive MachinegunnerAssistant) exitWith {};
nul = [Machinegunner, MachinegunnerAssistant] spawn fnc_Replace_MG;
*/
private ["_oldGunner", "_newGunner", "_weaponHolders", "_WeaponHolder", "_weapons", "_magazines"];
_oldGunner = _This select 0;
_newGunner = _This select 1;
_weaponHolders = nearestObjects [_oldGunner,["WeaponHolderSimulated"],5];
_WeaponHolder = _weaponHolders select 0;
_weapons = weaponCargo _WeaponHolder;
_magazines = Magazines _oldGunner;

//hint format ["Fallen gunner: %1\nNew Gunner: %2\nWeapon: %3\nMagazines: %4", _oldGunner, _newGunner, _weapons, _magazines];

while {_newGunner distance _oldGunner > 3} do
{
_newGunner doMove getPos _oldGunner;
sleep 10;
};

//I dont remember which one works best
_newGunner action ["TakeWeapon", _WeaponHolder, (_weapons select 0)];
{_newGunner action ["TakeWeapon", _oldGunner, _x];} forEach weapons _oldGunner;
{_newGunner action ["TakeMagazine", __oldGunner, _x];} forEach magazines _oldGunner;

//may need some editing but you probly know the rest
};

:)
Völe 19 Mar, 2019 @ 2:38pm 
Originally posted by PierreMGI:
OK. I have also some hours on Arma and I didn't play with AIs without weapon, but civilians. I saw many times units out of ammo, but not without weapons. Probably, a mod or a mission I don't know. Reloading weapons seems to me simple. Searching for grabbing another weapon is far more difficult. For example, BI didn't implement a smart action menu for that. You just have a list of possible, known weapons that you can order the subordinate for reloading. No matter if it's far away. For AIs, by their own, the problem is more difficult: why, when, where, who decide, who command the AI... go/no go cases.

As for AI to decide ideas
Why?
A) AI has now weapon -> go for function to search any weapon.
B) Squad has no spesific weapon [ units _Group findIf {(weapon _x) isEqualTo 'WantedWeapon'} == -1); ] -> go for function to search spesific weapon in range,

When?
A) no combat and choises around
B) Urgent need (No AT and engaging tanks

Who command the AI?
Squad leader virtualy via scripts and if player is squad leader maybe use limited functions.

Go/No Go.
Measure distances, think current loadout. Does unit have enough full magazines (or simplifiied just could count AI magazines)
PierreMGI  [developer] 19 Mar, 2019 @ 5:30pm 
Thanks for contribution and ideas. I spent monthes on heal module. So be patient! I'm not able to do that in a week.
ShankZ 20 Mar, 2019 @ 10:38am 
Kiitos Völe!
Play3r 20 Aug, 2021 @ 3:59am 
Any chance you can make it so the unit that runs for Ammo can report " GoTo Reload" or something like it from the game ?
PierreMGI  [developer] 20 Aug, 2021 @ 9:56am 
That means using an existing sentence (to comply with all factions). Not impossible but demands some time for me.
PierreMGI  [developer] 2 Mar, 2022 @ 7:36am 
Ai running "out of ammo" can now reload at ground/vehicle/crate/corpse... (see documentation). remaining problem: even if the Ai grabs a new weapon and reload, then fires, its icon (when in group) stays at low ammo status. No clue about that.
< >
Showing 1-7 of 7 comments
Per page: 1530 50