Skip to content

Fix freezard graphics crash with enemy health scaling#5232

Merged
aMannus merged 1 commit intoHarbourMasters:developfrom
Archez:fix-fz-health-crash
Mar 28, 2025
Merged

Fix freezard graphics crash with enemy health scaling#5232
aMannus merged 1 commit intoHarbourMasters:developfrom
Archez:fix-fz-health-crash

Conversation

@Archez
Copy link
Contributor

@Archez Archez commented Mar 27, 2025

Freezards use a calculation of their health as an index for which display list to use for their body. If the health value is too large, then the index would go out of bounds and place garbage into the graphics instructions.

To fix this, a check for enemy health scaling is used and the index recalculated by scaling the health from a ratio of the "new" maximum health, back down to the original max of 6, and then a final safety clamp to get the index into range.

This should make it so that Freezards broken state will linearly match the scaled health.

Fixes #5225

Build Artifacts

@aMannus
Copy link
Contributor

aMannus commented Mar 28, 2025

I don't want to block this as it fixes a crash but would be nice to have this inside a hook or VB should somehow (not sure which makes more sense here thb)

@Malkierian
Copy link
Contributor

I don't know if it's possible to do from within a hook. We don't have one for ActorDraw, and it looks like this is mid draw anyway, but I don't really know much about VB principles.

@aMannus
Copy link
Contributor

aMannus commented Mar 28, 2025

The only thing I'm not sure of is if it's possible to change something you pass into a VB should by reference, but I think you can. It should probably be around where the index is set in vanilla though.

Copy link
Contributor

@aMannus aMannus left a comment

Choose a reason for hiding this comment

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

Let's get this in now then and consider to move this when we move everything enemy rando related to hooks/shipinit

@aMannus aMannus merged commit b66623c into HarbourMasters:develop Mar 28, 2025
5 checks passed
@Archez Archez deleted the fix-fz-health-crash branch March 28, 2025 15:36
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.

Freezards crashing with random enemy size and scale to health on

3 participants