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

Unexpected behavior when upgrading units to units with lower maximum health #534

Open
Kaitrei opened this issue Oct 10, 2023 · 1 comment

Comments

@Kaitrei
Copy link

Kaitrei commented Oct 10, 2023

This is an issue I've been having in my prototype for a while, but only thought to make this report after testing how this scenario plays out in Starcraft as this will be necessary for Stargus.

Upgrading a unit into a unit with a lower maximum health has unexpected behavior where it only updates the current health and leaves the maximum as what it was on the previous unit. This results in a unit with higher than expected maximum health.

Example from my prototype project:
Upgrading a Human Warrior (60 HP) with full health (60/60) to a Human Archer (40 HP) results in a Human Archer with 40/60 HP.

Subsequent upgrades to units with less than the initial unit's maximum HP (60) warrants even more odd behavior. The unit's current HP drops with each subsequent upgrade while the maximum HP remains unchanged, but ONLY for units with less maximum HP than its current maximum HP. This was tested by upgrading to other units with a maximum health of 40. It should be noted that when upgrading to the original Warrior unit (60 HP) then upgrading to something else, the current HP did not drop, but upgrading to another 40 HP unit did cause it to drop again.

The expected behavior is that the Archer should be at 40/40 HP after upgrading from a unit with higher maximum HP.

I tested this expected behavior in a custom map on Starcraft using Zerg Hydralisks modified with 800 HP in the official map editor. The Zerg Cocoon unit had 200/200 HP and my Lurkers had 125/125 HP. I hadn't anticipated the Zerg Cocoon making it prove this expected behavior a second time as well as the need for it (otherwise any Zerg unit with less health than the Zerg Cocoon will be getting unexpectedly high health.)

@Kaitrei
Copy link
Author

Kaitrei commented Mar 28, 2024

I mentioned this issue to Andrettin, the creator of Wyrmsun/Wyrmgus, while talking about my project being made in Stratagus and this issue was already fixed in his engine. He even pointed to the line of code that was causing this, so I thought I'd post this here if someone else wants to try testing it.

Stratagus: unit.Variable[i].Max = std::max(newstats.Variables[i].Max, unit.Variable[i].Max);

Wyrmgus: unit.Variable[i].Max += newstats.Variables[i].Max - oldstats.Variables[i].Max;

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

No branches or pull requests

1 participant