Fix health pickups being consumed at full health - #5399
Open
Flashmyname wants to merge 1 commit into
Open
Flashmyname wants to merge 1 commit into
Flashmyname wants to merge 1 commit into
Conversation
CanUse compared health against a hard-coded 200 while the armour branch beside it uses the real ceiling, so a player at full health consumed the pickup and got nothing back. Both the check and the cap in Use now go through CPed::GetMaxHealth, which reads the max_health stat. Fixes multitheftauto#4124.
Flashmyname
force-pushed
the
fix/4124-health-pickup-full
branch
from
September 14, 2026 15:09
9fc4305 to
6d5326e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CanUsecompared health against a hard-coded200.0fwhile the armour branch beside it uses thereal ceiling, which is why armour already refused at full armour and health did not. A player at
full health consumed the pickup and got nothing back.
Both the check and the cap in
Usenow go throughCPed::GetMaxHealth, which reads themax_healthstat the same waySetElementHealthalready does, so a raised stat is respected.Motivation
Fixes #4124. There was a
// TODO: calc max health from max_health staton the line beingchanged, and the issue asks for the behaviour of the original game.
Test plan
Walk into a health pickup at full health. Before: it is consumed and no health is gained. After:
it is left alone.
setElementHealth(player, 50)and walk in again - consumed and heals.setPedStat(player, 24, 1000)then walk in at 100 health - usable again, since the ceiling isnow above 100.
Checklist