Skip to content

Hit Point Script Question

I've got an OnActivateItem script here - I just want it to take into account the players current hit points and add d10(1) hit points from there???
When I test the script, a lot of the time I get a lower hit point number than I started out with, and I don't want that..
Anyway, any help is welcome.

Code so far:
// Poison Salve
     object oPC = GetItemActivator();
     object oUsed1 = GetItemActivated();
     if (GetTag(oUsed1) == "POISON_SALVE")
     {
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect
        (VFX_IMP_CHARM), oPC);
        int nCurHP = GetCurrentHitPoints();

        SetCurrentHitPoints(oPC, nCurHP + d10());

        RemoveSpecificEffect(EFFECT_TYPE_POISON, oPC);
     }

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    The problem is with SetCurrentHitPoints(). See the lexicon page on SetCurrentHitPoints() where you will see that -
    • For currently dying PCs, you can only set hitpoints in the range of -9 to 0.
    • All other objects need to be alive and the range is clamped to 1 and max hitpoints.

    TR
  • ProlericProleric Member Posts: 1,316
    edited October 2022
    GetCurrentHitPoints() should read GetCurrentHitPoints(oPC).

    Otherwise it will default to OBJECT_SELF, which, OnActivateItem, is the module, not the PC (because it's a module event script).

    If the script is essentially about healing, you might not need to raise hit points above the maximum.

    It can be done using EffectTemporaryHitpoints() but there are limitations, as that article explains.
  • ZephiriusZephirius Member Posts: 419
    Thanks' boys.
  • ZephiriusZephirius Member Posts: 419
    Proleric wrote: »
    GetCurrentHitPoints() should read GetCurrentHitPoints(oPC). .
    (oPC) did the trick... :smile:

Sign In or Register to comment.