well what i want to happen is for AI squads to pick up more ammo when they run low. I noticed that lots of loons wont use ammo crates unless ordered by the player. Even when their skill level is nice and high
any ways around this?
My first thought would be a slowly looping script that periodically checks your guys' ammo levels and sends them to the nearest ammo crate if they're below a certain threshold. However, upon further investigation, this may be a little more long-winded than I initially thought, unless I'm going about it the wrong way.
Since there doesn't appear to be a simple way to get how
much ammo a unit has (aside from how many rounds in his current magazine), some loops and counters seem to be in order.
A little braindead to be writing up code, so I'll just outline. Basically, since
magazines returns all magazines in a given unit's inventory, I figure you can use that to get an idea of what their ammo status is like. The array returned will list magazines in order (primary, secondary, pistols, hand grenades), so you just have to run a counter to find out how many of each type the unit has.
Of course, this approach has its limitations. You'll likely have to tailor the script to different types of units or weapons, since the threshold would be lower for a machinegunner that starts off with 3 hi cap magazines than a unit with 6 30-round magazines. This tailoring could get unwieldly.
The only
completely reliable return (without doing a lot of checking against known values) would be the primary weapon, since the rest get reshuffled if a unit doesn't have a particular weapon type. So someone with a LAW Launcher and hand grenades would return ["M16","M16","Lawlauncher","Lawlauncher","handgrenade","handgrenade"], for example, while a rifleman would return ["M16","M16","handgrenade","handgrenade"]. It gets even more unwieldly when a unit has more than one primary (say, flares, or 40mm grenades).
Magazines also appears to return the last empty magazine the unit has. So if you fire off all the magazines in your pistol, it will still return one pistol mag, unless you drop the weapon (picking it up again won't add the magazine, either).
Agh. My head hurts. I'll leave my ramblings at that for now. :p