Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Arsenal Overhaul #441

Draft
wants to merge 19 commits into
base: unstable
Choose a base branch
from

Conversation

jwoodruff40
Copy link

@jwoodruff40 jwoodruff40 commented Jan 17, 2025

What type of PR is this?

  1. Bug
  2. Change
  3. Enhancement
  4. Miscellaneous

Ports:

official-antistasi-community#3392

What have you changed and why?

This PR -

  • Changes AI loadout arsenal to an override system (see below)
  • Limits primary and secondary weapons in AI arsenal based on class type (e.g. only grenadiers can have GL)
  • Limits primary, secondary, and handguns available to only those with unlocked compatible magazines
  • Limits all equipment (weapons, uniforms, NVGs, mags, literally everything) available in the AI arsenal to what's unlocked
  • Ensures rebels are only equipped with unlocked magazines (no magazine farming)

Due to the nature of how the AI arsenal works, it's an all or nothing approach: if you want to change / statically set one thing for an AI class, the AI loadout has to set everything else as well. So e.g. if you want to ensure your AA Specialists use Stingers instead of Strelas, now every other part of their loadout (barring uniform / headgear) will always be exactly the one thing that was set in the loadout you chose the Stinger in.

This PR fixes that annoyance with an override system. Basically, the AI arsenal functions as normal, except that an option is added to all lists (except cargo) called "Petros Knows Best." If this option is chosen, AI will still use the normal functions within fn_equipRebel to equip item(s) from that category.

Example use case: Say I don't want my rebel riflemen to wear police vests, and I want them to always use M4s. So when editing the rifleman class, I choose a vest I like and select the M4. For all other categories, I select "Petros Knows Best." Now when I recruit AI rifleman, they'll have the vest and M4 I chose, and everything else will still be "randomized" using the functions in equipRebel.

PR also limits primary and secondary weapons available for the loadout based on the AI class (e.g. only grenadiers can have a grenade launcher, only AA can have an AA launcher, etc), and ensures rebels only get magazines that are in arsenal (and unlocked if playing with unlocks, or qty >= ITEM_MIN if no unlocks). No more farming rebel recruits for magazines.

Please specify which Issue this PR Resolves (If Applicable).

None AFAIK Fixes - @UAC-MaxxLite desire for limiting weapons available by class, and my annoyance with all or nothing loadout approach.

Please verify the following.

  1. Have you loaded the mission in LAN host?
  2. Have you loaded the mission on a dedicated server?

Is further testing or are further changes required?

  1. No
  2. Yes (Please provide further detail below.)

This is still very much a WIP. It works enough that you can give it a test and see if it makes sense and y'all think it works for this game.

Issues that need worked out:

Major issues:

  • "Petros Knows Best" is not a selection for cargo lists; however, if user selects "Petros Knows Best" for a cargo container (uniform, vest, backpack) user will not be able to add any cargo at all
  • "Petros Knows Best" is a possible selection, but is not implemented, for weapon magazines and attachments - misleading to user

Minor issues:

  • "Petros Knows Best" is not implemented for assigned items (map, gps/uav terminal, radio, compass, watch, nvg) or binoculars. I don't think this really matters.
  • When user selects "Petros Knows Best", leaves that tab, and then comes back to it, "Empty" is selected instead of "Petros Knows Best," which can be confusing. (For clarity, "Empty" selection still functions as normal).
  • Probably some other stuff I'm not thinking of.

How can the changes be tested?

Steps:


Notes:

official-antistasi-community#3392 is partially ported into this (fn_randomRifle, fn_addPrimaryAndMags, fn_equipRebel) to minimize divergence from upstream.

#433 is merged into this for compat.

@jwoodruff40 jwoodruff40 changed the title AI Arsenal Overrides - Add Option for "Petros Knows Best" AI Arsenal Overhaul Jan 18, 2025
@jwoodruff40
Copy link
Author

I need some input on how to deal with cargo items. As of right now, all loadouts get medical supplies and misc essentials from fn_itemset_medicalSupplies and fn_itemset_miscEssentials. They get magazines from the addPrimary / addSecondary functions. They get grenades (depending on class) from addClassEquip. Explosives experts get charges. Do we need to allow setting any additional cargo items?

If you're playing with other real players, you can make an argument for people carrying equipment for other people, e.g. static weapon bags, extra machine gun ammo, etc. But since AI won't use equipment from other AI anyway, I'm thinking we deal with that major issue by just not allowing setting cargo for AI loadouts...

Thoughts?

Otherwise, I think this just needs UI improvements (removing "Petros Knows Best" from item lists where it doesn't make sense or isn't implemented, and a way to make this feature / overhaul of the loadout system more discoverable.

@jwoodruff40 jwoodruff40 marked this pull request as ready for review January 18, 2025 21:47
@SilenceIsFatto SilenceIsFatto added the misc A miscellaneous change label Jan 27, 2025
@stutpip123
Copy link
Collaborator

"Limits all equipment (weapons, uniforms, NVGs, mags, literally everything) available in the AI arsenal to what's unlocked"

What happens when no unlocks is used? As AI need to still pick from limited gear or else become entirely useless

@jwoodruff40
Copy link
Author

What happens when no unlocks is used? As AI need to still pick from limited gear or else become entirely useless

Short answer is as of right now you're right, this only works well with unlocks enabled.


I'm still working through how to make it work for unlocks disabled case. Afaict, unlockedXXX is not used when unlocks are disabled. I'm thinking if arsenal has > ITEM_MIN of an item, we can add that item to the appropriate server var unlockedXXX and the code will otherwise work the same. Just need to then ensure that if those items are pulled out of the arsenal and qty dips below ITEM_MIN, we remove it from unlockedXXX. But it may work better to just deal with jna_datalist directly as is done in fn_generateRebelGear to generate A3A_rebelGear.


This PR is still WIP, I just changed it from draft to review so y'all could get eyes on / lmk if it's not worth spending any more time on.

Imo, it makes it a lot easier to deal with the AI arsenal in general with less UI spam from equipment you can't use, and limiting equipment available by class stops what I consider to be an exploit (taking a super cheap AI class and giving them GLs and missile launchers).

Could even table the 'petros know best' piece for another time / PR.

Just need to sort out the unlocks disabled case as you mentioned, and the current UI issues.

@stutpip123
Copy link
Collaborator

Class limiting equipment may not function correctly with mods that dont have properly setup weapons, many mods have all weapons inherit from the base assault rifle or similar

@jwoodruff40
Copy link
Author

Class limiting equipment may not function correctly with mods that dont have properly setup weapons, many mods have all weapons inherit from the base assault rifle or similar

Those cases would (or should) be handled by addons\core\functions\ammunition\fn_categoryOverrides no?

@stutpip123
Copy link
Collaborator

if they had ever been checked or setup for that yes. but pretty much nothing has

@jwoodruff40
Copy link
Author

jwoodruff40 commented Jan 28, 2025

@stutpip123 I just had a thought, dunno how I didn't think of this earlier: given that the generation of A3A_rebelGear already takes into account unlocks enabled vs disabled, and only adds items to that hashmap if they're either unlocked or > ITEM_MIN, we could just replace the instances of missionNamespace getVariable "unlockedXXX" with A3A_rebelGear get "XXX" and it would work in either case right?

I don't know off hand because I don't play with unlocks disabled, but if you're playing with unlocks disabled, does a rebel AI being equipped with an item remove it from the arsenal? If so, this could cause issues given that rebel gear hashmap is only generated every 10 min.

E.g. set a rebel rifleman to always use M16. You have 15 M16s in arsenal. If you recruit more than 5 rifleman in less than 10 min, qty in arsenal would go below 10 / ITEM_MIN: unintended behavior. If you recruit more than 15 rifleman in less than 10 min, would cause script errors, no?

Won't be able to test this idea until tonight or possibly tomorrow though.

Update:

edd158a and 999063f implements this and seems to work pretty well with both unlocks enabled and disabled.

BUT

When creating an AI loadout with unlocks disabled and selecting an item with qty more than 25 (from jna_minItemsMember) but not unlimited, then spawning AI with that loadout, the items are NOT removed from the arsenal. Seems like this sets up the potential for item duping cheating - get 25+ of an item, add it to rebel loadout, spawn rebels, kill them, and loot to arsenal. This is replicatable in this PR and in main build.

This could be solved, but it would require removing items from arsenal in equipRebel / associated functions and regenerating A3A_rebelGear after every call of equipRebel to ensure that when item qty drops below minItemsMember, rebels stop spawning with it.

Also going back to the categories thing, if a mod isn't properly setup and the overrides aren't setup, then that would also affect the generation of A3A_rebelGear. So if anything, this PR just makes the ai loadout arsenal consistent with the rebel gear hashmap.

@jwoodruff40 jwoodruff40 marked this pull request as draft January 29, 2025 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
misc A miscellaneous change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants