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

Add UI and supporting code to set custom loadouts for rebel troops #3392

Open
wants to merge 2 commits into
base: unstable
Choose a base branch
from

Conversation

jaj22
Copy link

@jaj22 jaj22 commented Aug 28, 2024

What type of PR is this.

  1. Bug
  2. Change
  3. Enhancement

What have you changed and why?

Added a UI and supporting code to set partial custom loadouts for rebel troops. This is strictly vetted by unit type to avoid exploits: Only grenadiers can use grenade launchers, for example. Ammunition is only lightly configurable (choice of "normal" or "high"). If there aren't enough weapons of a type, they can't be selected although in some cases they may spawn with the "random" option. If you only want to force some aspects of a loadout and leave the rest random, this is also possible.

Optics button is a placeholder. Not sure whether to implement anything here. There's currently no vetting for item existence, so if you change modset within a saved game then you might need to reset the loadouts in the UI.

The button to access the UI is on the right in the commander menu. There was a free slot after I switched it to 2x5.

Please specify which Issue this PR Resolves.

closes #XXXX

Please verify the following and ensure all checks are completed.

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

Needs a DS test but it uses similar mechanics to A3A_rebelGear so it should be fine.

Is further testing or are further changes required?

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

@jaj22 jaj22 added Enhancement New feature or request Review pending labels Aug 28, 2024
@jaj22 jaj22 added this to the 3.8.0 milestone Aug 28, 2024
@jaj22
Copy link
Author

jaj22 commented Sep 2, 2024

UI screenshot as requested:
20240901193949_1

Copy link

@killerswin2 killerswin2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

tooltip = "";
action = "";
tooltip = "Customize loadouts for rebel AI troops"; //$STR_antistasi_dialogs_commander_comm_customLoadouts_tooltip;
action = "if (player == theBoss) then {closeDialog 0; createDialog ""A3A_customLoadoutsDialog""} else {[""Custom Loadouts"", ""Only commanders have access to this function""] call A3A_fnc_customHint}";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO: Localize
Or just localize it yourself.

Copy link

@ante185 ante185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will to a degree invalidate #3083, but i suppose it's fine.

the optics selection should probably be removed for now, or set to always display random until there's any particular way we want it to work

Copy link

@ante185 ante185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, lgtm

@ante185 ante185 added the Technically ready for merge This can be merge, but there is some politics involved label Nov 10, 2024
@jaj22
Copy link
Author

jaj22 commented Dec 1, 2024

This will to a degree invalidate #3083, but i suppose it's fine.

To check I'm not missing something here, I don't see how it affects #3083, because the pistols are only used before a rifle is unlocked, and this UI only gives you any control once a rifle is unlocked?

Going to put the fix for Tiny's click-spam bug in here too, otherwise it'll collide.

@jaj22
Copy link
Author

jaj22 commented Dec 2, 2024

Added the likely fix for #3449. It's not easy to prove because it depends on specific network & thread timings.

if !(primaryWeapon _unit isEqualTo "") then {
if (_weapon == primaryWeapon _unit) exitWith {};
private _magazines = getArray (configFile / "CfgWeapons" / (primaryWeapon _unit) / "magazines");
{_unit removeMagazines _x} forEach _magazines; // Broken, doesn't remove mags globally. Pain to fix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{_unit removeMagazines _x} forEach _magazines; // Broken, doesn't remove mags globally. Pain to fix.
{
_unit removePrimaryWeaponItem _x;
_unit removeMagazineGlobal _x;
} forEach _magazines;


private _categories = _weapon call A3A_fnc_equipmentClassToCategories;

if ("GrenadeLaunchers" in _categories && {"Rifles" in _categories} ) then {
Copy link

@rautamiekka rautamiekka Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ("GrenadeLaunchers" in _categories && {"Rifles" in _categories} ) then {
if (_categories findAny ["GrenadeLaunchers", "Rifles"] isNotEqualTo -1) then {

In my testing, the old seemed to average 20ms, while the new 15. Also the new one is way cleaner.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's wrong though. Should be comparing to -1

Copy link

@rautamiekka rautamiekka Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I only just now realized that mistake, which you beat me to. I keep forgetting this thing doesn't return boolean. Fixed.

_secWeapon lbSetCurSel 0;
_curClass = _roleGear getOrDefault ["SecWeapon", "Random"];
if (_roleData#3 != "") then { [_secWeapon, _roleData#3, _curClass] call _fnc_addItems };
// disable if not valid?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// disable if not valid?
// TODO disable if not valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Technically ready for merge This can be merge, but there is some politics involved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants