Skip to content

Migrate and overhaul heal event and heal amount expression - #8796

Open
MrScopes wants to merge 11 commits into
SkriptLang:dev/patchfrom
MrScopes:heal
Open

Migrate and overhaul heal event and heal amount expression#8796
MrScopes wants to merge 11 commits into
SkriptLang:dev/patchfrom
MrScopes:heal

Conversation

@MrScopes

@MrScopes MrScopes commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Problem

Currently, heal uses a utility that just set's their health to their current health + the heal amount
this does not call EntityRegainHealthEvent
Also, in the EntityRegainHealthEvent it doesn't take into account Skript using health (10 hearts) instead of hp (20hp), so heal-amount is hp and not hearts.
This is inconsistent with the rest of the code base.
Also, migrating the current system to the new module system.

Update HealUtils to use Damageable.heal instead of setHealth
The reason this was made in the first place is because Spigot has never and still doesn't have a Damageale.heal but now that Skript is paper only, this is appropriate

Testing

currently, heal amount tested with

on heal:
    broadcast "hp: %player's health%"
    broadcast "initial heal amount: %heal amount%"
    add 1.5 to heal amount
    broadcast "add 1.5: %heal amount%"
    remove 3.2 from heal amount
    broadcast "remove 3.2: %heal amount%"
    set heal amount to heal amount * 0.75
    broadcast "set to 75%%: %heal amount%"
    broadcast "modified heal amount: %heal amount%"
    chance of 50%:
        delete heal amount
        broadcast "deleted heal amount: %heal amount%"
    wait 1 tick
    broadcast "hp after heal: %player's health%"
image

here's the current test for the heal event as well
image

command /heal:
    trigger:
        heal player by 0.5
        wait 1 tick
        heal player by 0.75
        wait 1 tick
        heal player by -3
        wait 1 tick
        heal player by 1
        wait 1 tick
        heal player by 1500.23
        wait 1 tick
        heal player by 100000000000000
        wait 1 tick
        heal player by -10000

on heal:
    broadcast "heal %entity% %heal amount%"

on damage:
    broadcast "damage %victim% %damage%"

migrated heal reason test
image

on heal of player:
    broadcast "heal %player% %heal amount% %heal reason%"

Completes: none
Related: none
AI assistance: none

@MrScopes
MrScopes requested a review from a team as a code owner July 27, 2026 01:45
@MrScopes
MrScopes requested review from APickledWalrus and sovdeeth and removed request for a team July 27, 2026 01:45
@MrScopes MrScopes changed the title use Damageable.heal Update health utils to use Damageable.heal Jul 27, 2026
@erenkarakal

Copy link
Copy Markdown
Member

tests failing

@skriptlang-automation skriptlang-automation Bot added the needs reviews A PR that needs additional reviews label Jul 27, 2026
@MrScopes

Copy link
Copy Markdown
Contributor Author

tests failing

ahh that's because I didn't account for skript using health and not hp

@MrScopes MrScopes changed the title Update health utils to use Damageable.heal Migrate and overhaul heal event and heal amount expression Jul 27, 2026
@MrScopes

MrScopes commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

I'm changing the scope of this pr to migrate exprhealreason, exprhealamount, and heal event to player module
also fixing the bug of using hp and not hearts that skript currently has
and of course still updating HealUtils to use Damageable.heal instead of setHealth

"\tcancel event"
)
.since("1.0, 2.9.0 (by reason)");
public static void register(SyntaxRegistry syntaxRegistry, EventValueRegistry registry) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs reviews A PR that needs additional reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants