Skip to content

Nixprime's auto equalize shields#324

Open
z64555 wants to merge 5 commits into
scp-fs2open:masterfrom
z64555:nixprime-auto_equalize_shields
Open

Nixprime's auto equalize shields#324
z64555 wants to merge 5 commits into
scp-fs2open:masterfrom
z64555:nixprime-auto_equalize_shields

Conversation

@z64555

@z64555 z64555 commented Aug 25, 2015

Copy link
Copy Markdown
Member
  • Verify singleplayer operation
  • Check with multiplayer
  • Check localization support and XSTR's
  • Should this be a default enabled or default disabled feature?

Original Post follows:
Salvages PR #111, whose author hasn't updated in some time. PR #310 added needed functionality to enable controls within a .tbl/.tbm that are disabled by default (either through controlsconfigdefaults.tbl or hard-coded).

@z64555

z64555 commented Aug 26, 2015

Copy link
Copy Markdown
Member Author

Some notes, concerns from the PR #111 conversation:

niffiwan:
Should auto-equalize be controled by a mod_table setting? Should the default-to-off setting be controled by a mod_table setting?

Yes, it is controlled by controlsconfigdefaults.tbl, and the original commit has the control enabled by default. PR #310 added the functionality needed to enable default-disabled items, so this can be done.

MageKing17:
there appears to be no way to interact with auto-equalization via script

He managed to add the control in lua.cpp, but I don't believe there's a way to activate the command yet.

MageKing17:
It should just require not enabling the defaults by default and adding "+Enable" capability... is this the sort of thing that should wait for the antipodes merge?

Antipodes doesn't have this capability, as PR #310 was based on master. Going ahead with PR #319 won't affect this PR.

@niffiwan niffiwan added the enhancement A new feature or upgrade of an existing feature to add additional functionality. label Aug 27, 2015
@z64555 z64555 force-pushed the nixprime-auto_equalize_shields branch from c75b1b6 to 190b0b2 Compare September 14, 2015 15:18
@z64555

z64555 commented Sep 14, 2015

Copy link
Copy Markdown
Member Author

Ok, 2/3 concerns addressed, now all that's left is the scripting support

@z64555 z64555 force-pushed the nixprime-auto_equalize_shields branch from 190b0b2 to 5987a02 Compare September 14, 2015 15:57
@z64555

z64555 commented Sep 14, 2015

Copy link
Copy Markdown
Member Author

A new concern that cropped up regards multiplayer. If auto-equalize shields is active, then the server can handle the shield management like it does with AI. I am not sure at the moment how the additions behave, whether the hit player sends a packet with shield info to the server or the server already handles the equalization.

@z64555

z64555 commented Sep 24, 2015

Copy link
Copy Markdown
Member Author

Ok, AI shield management, along with other AI controls, is handled by the host server and checked at a semi-regular frequency. AI adjust their shields by diverting power to the quadrant that was most recently hit. The ai code also suggest they balance their shields if not hit within a second, but I haven't observed them doing so in some past tests.

I'd like to try to use the AI's shield management routine instead of the new auto-equalize routine since it'll be a consistent behavior. Essentially, this would enable a portion of AI that will handle the player's shields for them. Could possibly add a flag to always equalize when hit to achieve this PR's original goals.

@chief1983

Copy link
Copy Markdown
Member

Actually I was under the impression that the AI had a difficulty multiplier for how long they wait to equalize shields, which on Very Easy scales down to 'never', and on very hard can be nearly immediate.

@z64555

z64555 commented Sep 24, 2015

Copy link
Copy Markdown
Member Author

Yes, it actually does have a difficulty multiplier on there. Friendlies in single-player are hardcoded to stay at the "average" difficulty while hostiles vary.

@z64555

z64555 commented Feb 19, 2016

Copy link
Copy Markdown
Member Author

Ok, I might be able to enable the AI shield management routines by turning on the Player_ai and setting it to a new AIM mode that would only activate the shield management. This would require moving things around a bit in ai_frame so as to not trigger things that would interfere with movement, etc.

I'll get that going in a separate PR, and maybe make a pair of test builds for folks to compare the two methods to see which one they like.

@z64555 z64555 added the unfinished (Deprecated by PR Drafts) A feature or issue that's unfinished, but still wants feedback/review label Nov 27, 2016
nixprime and others added 4 commits November 27, 2016 15:47
Automatic shield equalization is an optional feature that is toggled by
pressing Alt-Q (this key combination is remappable). When enabled,
damage to shields triggers shield equalization. Automatic shield
equalization can be temporarily overriden by manually adjusting shield
distribution; to re-enable automatic shield equalization, manually
equalize your shields.

Automatic shield equalization is subject to the same 2% power penalty
per equalization (max 1/second) as manual shield equalization; it is
therefore functionally equivalent to mashing Q as fast as possible.
@z64555 z64555 force-pushed the nixprime-auto_equalize_shields branch from 5987a02 to fe7a18e Compare November 27, 2016 21:59
@z64555

z64555 commented Nov 27, 2016

Copy link
Copy Markdown
Member Author

Rebased onto current master.

Comment thread code/io/keycontrol.cpp
if (!Sel_NextNav())
gamesnd_play_iface(SND_GENERAL_FAIL);
break;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like an accidental whitespace insertion.

@z64555 z64555 added unfinished (Deprecated by PR Drafts) A feature or issue that's unfinished, but still wants feedback/review and removed unfinished (Deprecated by PR Drafts) A feature or issue that's unfinished, but still wants feedback/review labels Dec 30, 2016
@z64555

z64555 commented Dec 30, 2016

Copy link
Copy Markdown
Member Author

After a discussion with jg18 in the forums, I'm comfortable with my decision to get this merged in before I look for an AI alternative.

I'll need to do a bit of maintenance on it beforehand, however.

…b.com into nixprime-auto_equalize_shields

# Conflicts:
#	code/controlconfig/controlsconfigcommon.cpp
#	code/scripting/lua.cpp
@z64555 z64555 removed the unfinished (Deprecated by PR Drafts) A feature or issue that's unfinished, but still wants feedback/review label Dec 31, 2016
advance_to_eoln(NULL);
ignore_white_space();
return;
mprintf((" Deprecated option '+Disable' found. Please use '$Disable: true' instead\n"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is dead code since it appears after a return.

Comment thread code/io/keycontrol.cpp
if (Players[Player_num].flags & PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE) {
Players[Player_num].flags &= ~PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE;
button_function(SHIELD_EQUALIZE);
HUD_printf(XSTR("Auto shield equalization activated", 1638));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this uses a printf style format string, the format string should not be supplied from a function call. This should use "%s" as the format string and the XSTR call should be the format parameter.

Comment thread code/io/keycontrol.cpp
button_function(SHIELD_EQUALIZE);
HUD_printf(XSTR("Auto shield equalization activated", 1638));
} else {
HUD_printf(XSTR("Auto shield equalization deactivated", 1639));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here.

@Goober5000 Goober5000 added this to the Release 26.0 milestone Oct 14, 2025
@BMagnu BMagnu added the Waiting for Stable Marks a pull request that is to be merged after the next stable release, due to a release cycle label May 31, 2026
@BMagnu BMagnu modified the milestones: Release 26.0, Release 26.2 May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A new feature or upgrade of an existing feature to add additional functionality. Waiting for Stable Marks a pull request that is to be merged after the next stable release, due to a release cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants