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

Enhancement: Enemy Health Bar #3035

Merged
merged 4 commits into from
Jul 13, 2023

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Jun 22, 2023

This adds an enhancement to display health bars above enemies when Z-Targeted.

This health bar is rendered by reusing the magic bar textures with a red color by default (supports cosmetic editor overrides). The health bar is placed above the actors projected target center by following similar logic of the Z-Target placement. The health bar will slide in from the top edge of the screen, mimicking the Z-Target triangle fly in effect.

In HUD placements, the health bar can either be anchored to the actor, or anchored to the top/bottom edges. The up/down offset values apply to all anchor positions, where as left/right apply only to top/bottom anchor types. The health bar width can be changed from here as well.

The actor struct was updated to add a new maximumHealth property that is set after init, to track the total health of all actors.

Some enemies may use their own health calculation outside of the collision health, meaning the bar may not drain in those instances.

This health bar will only apply to enemies and not bosses. In a future PR, I will investigate what it would take to add boss health bars.

enemy-health-bar.mp4

image


Other additions in here is adding support for alpha setting in the cosmetic editor. When enabled, randomize/rainbow changes will retain the last set alpha value. This allows the enemy health bar to have an alpha applied to it. This is controlled by supportsAlpha.
Similarly, there was a supportsRainbow flag, but it wasn't hiding the rainbow toggle. Now it is.

Build Artifacts

Comment on lines 905 to 906
UIWidgets::PaddedEnhancementCheckbox("Enemy Health Bars", "gEnemyHealthBar", true, false);
UIWidgets::Tooltip("Renders a health bar above enemies when Z-Targeted");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm torn between this being added under "Enhancements > Graphics", or "Enhancements > Gameplay"

Looking for feedback on placement.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would argue for gameplay since we're effectively changing the state of the game in a minor manner.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed with Enhancements > Gameplay


// Build vertex coordinates for a quad command
// In order of top left, top right, bottom left, then bottom right
void Interface_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking forward to trying this out on kaleidoscope 🔥

Comment on lines +405 to +408
// For alpha supported options, retain the last set alpha instead of overwriting
if (cosmeticOption.supportsAlpha) {
newColor.a = cosmeticOption.currentColor.w * 255;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this PR enables support for alpha control in the cosmetic editor (on supported options, currently only the health bar), I decided that alpha should not be change for rainbow and randomize.

Randomizing alpha seems like a weird idea. My thinking is that the user can choose their own alpha (i.e. a 50% opacity health bar), and then they can still randomize/rainbow it while keeping the alpha they chose.

Looking for feedback here on this decision.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, randomizing alpha feels odd to me, i'm on board with this decision

@garrettjoecox garrettjoecox added this to the MacReady milestone Jun 27, 2023
@leggettc18
Copy link
Contributor

Some enemies may use their own health calculation outside of the collision health, meaning the bar may not drain in those instances.

Maybe a new GameInteractor Hook is in order for these situations? i.e. an OnActorHealthChange hook that can be called manually at the places in the code those calculations happen.

@Archez
Copy link
Contributor Author

Archez commented Jun 28, 2023

Some enemies may use their own health calculation outside of the collision health, meaning the bar may not drain in those instances.

Maybe a new GameInteractor Hook is in order for these situations? i.e. an OnActorHealthChange hook that can be called manually at the places in the code those calculations happen.

I don't actually have the list of enemies that treat health differently. That statement was more so a reflection of decomp mentioning that colíder health isn't used for all actors. This mostly applied for bosses, which I have omitted in this PR.

I think eventually it will be useful to have it for bosses and any other edge cases. But I was considering treating boss health bars in a different way (large bar at the top maybe). I figure that could be v2 territory.

@leggettc18
Copy link
Contributor

Oh yeah agreed v2 territory, just spitballing something that could make it easier to handle all forms of enemy health in the future. Bosses are especially tricky when you get to stuff like Barinade that don't track their health in a traditional way.

Copy link
Contributor

@PurpleHato PurpleHato left a comment

Choose a reason for hiding this comment

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

LGTM!
That's a great idea! I may have some suggestion on the V2 side of it.
Allowing players to choose whether a mask (maybe the Mask of Truth?) can be used to show the life bar (or not), similar to the Amulet in The Wind Waker. It would offer more customization options.

Additionally and because of my last point, it might be worth considering the possibility of implementing further quality-of-life improvements for other masks in the future?

@leggettc18 leggettc18 merged commit e90c8af into HarbourMasters:develop Jul 13, 2023
8 checks passed
Archez added a commit to Archez/Shipwright that referenced this pull request Aug 5, 2023
* add enemy health bar

* add more cosmetic editor options to health bar

* add tooltip

* fix enemy health texture when no magic bar
louist103 pushed a commit to louist103/Shipwright-1 that referenced this pull request Aug 11, 2023
* add enemy health bar

* add more cosmetic editor options to health bar

* add tooltip

* fix enemy health texture when no magic bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants