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

No damage effects on hp_max change #11846

Merged
merged 1 commit into from
Jun 11, 2022

Conversation

appgurueu
Copy link
Contributor

#10569 rebased and fixed. Closes #7876 - should this also alter the punch command being sent, to suppress the punch effect?

Test using the following code (EPILEPSY WARNING):

minetest.register_globalstep(function()
    for _, player in pairs(minetest.get_connected_players()) do
        local hp_max = math.random(1, 20)
        player:set_properties{hp_max = hp_max}
        player:set_hp(hp_max)
    end
end)

@sfan5 sfan5 added the Bugfix 🐛 PRs that fix a bug label Dec 10, 2021
@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Dec 19, 2021

Will the damage effect also happen if hp_max increases? Because that shouldn’t happen.

@appgurueu
Copy link
Contributor Author

Will the damage effect also happen if hp_max increases? Because that shouldn’t happen.

A increase of hp_max has no effect, as the HP stays the same. Only a decrease used to trigger a damage flash, as the reduced HP had to be sent, which is what this PR fixes.

@ghost
Copy link

ghost commented Jan 13, 2022

Could you rebase this on master and test on your end? It's no longer possible to compile this on the latest IrrlichtMT, and after performing a local rebase I saw incorrect results from a quick test (no effect on fall damage, effect present on max hp changes). To me, that implies either this doesn't function as advertised, or (more likely) something relevant has changed in the interim that needs addressing.

@ghost ghost added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jan 13, 2022
@appgurueu appgurueu force-pushed the fix-set-max_hp branch 2 times, most recently from 1996fa7 to e914e0a Compare January 13, 2022 18:14
@ghost
Copy link

ghost commented Jan 16, 2022

Tested again, still seeing incorrect results. First of all, just changing max hp still seems to trigger a damage flash. Additionally, fall damage no longer causes a flash. To help you out a bit, I did some digging for the latter. Fall damage in singleplayer is triggering ClientEnvironment::damageLocalPlayer, which does not set the effect field in its damage event. While this damage does pass through Client::handleCommand_HP which can send an event with the flag set, at that point the player's HP has already changed so no event is sent. Thus, any damage received via ClientEnvironment::damageLocalPlayer no longer triggers an effect even though it should.

I should not that I'm testing in singleplayer, so if you've been using a separate server to test this may be the source of your bugs.

@appgurueu
Copy link
Contributor Author

Tested again, still seeing incorrect results. First of all, just changing max hp still seems to trigger a damage flash. Additionally, fall damage no longer causes a flash. To help you out a bit, I did some digging for the latter. [...]

Thanks, you were correct with your digging. Fixed.

@appgurueu appgurueu force-pushed the fix-set-max_hp branch 2 times, most recently from 1e7ee94 to c5638df Compare January 17, 2022 19:39
@ghost
Copy link

ghost commented Jan 17, 2022

Thanks for the quick turnaround. I'm too tired for a full test tonight, but I can at least confirm that in singleplayer fall damage is displaying the proper effect again, and max hp changes are not. So far so good.

I'll try to give this a more thorough test and review by the end of the week.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Tested the following in an actual game context, using Mineclone 2 and an unreleased game prototype:

  • node damage_per_second: Effect
  • PVP damage: Effect
  • non-PVP combat damage (ie. getting punched by a mob): Effect
  • Drowning damage: Effect
  • Fall damage: Effect
  • Max HP reduction from a status effect wearing out: No Effect

I tested all of these in singleplayer, locally-hosted multiplayer as host, and locally-hosted multiplayer as a client and got consistent results in each test. I also tested locally-hosted multiplayer with an unpatched host and with an unpatched client. In both cases the bug persisted (as expected), but no errors occurred due to the packet changes.

I'm satisfied with this result, and while I think you could improve the name of effect the code is still readable as-is so I'll leave that to your discretion and approve now.

@@ -87,6 +87,7 @@ struct ClientEvent
struct
{
u16 amount;
bool effect;
Copy link

Choose a reason for hiding this comment

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

I think this could stand to be more explicit. Something like show_effect would make the purpose clearer at a glance imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might call this something like silent, quiet, hidden or the like if inverted, but show_effect may be slightly misleading as setting this to false will also suppress the audio effect.

Copy link

Choose a reason for hiding this comment

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

I'd be fine with those options as well.

@ghost ghost added One approval ✅ ◻️ and removed Action / change needed Code still needs changes (PR) / more information requested (Issues) labels Jan 19, 2022
@sfan5 sfan5 added this to the 5.6.0 milestone Jun 5, 2022
@sfan5 sfan5 self-requested a review June 6, 2022 14:21
src/server/player_sao.h Outdated Show resolved Hide resolved
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

Not tested but lgtm

@SmallJoker SmallJoker added Action / change needed Code still needs changes (PR) / more information requested (Issues) and removed Action / change needed Code still needs changes (PR) / more information requested (Issues) labels Jun 11, 2022
@SmallJoker SmallJoker merged commit f4a53f7 into minetest:master Jun 11, 2022
@appgurueu appgurueu deleted the fix-set-max_hp branch March 31, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Max HP change damage flash
4 participants