Skip to content

Making a good healer script (finding maximum HP)

KharlogKharlog Member Posts: 5
edited December 2012 in General Modding
Hi,

I'm making a script for any characters capable of casting healing spells. Generally HPLT or HPPercentLT are used to see if there is a need for healing and then some arbitrary number HPPercentLT(object, 50) or HPPercentLT(object, 75) are used to determine which kind of healing spell to use. This is quite dumb approach because every character has very different maximum HP. I would like to know how to get the maximum HP of the character and then calculate how many HPs have been lost (to determine which healing spell is sufficient). How to do this?

Comments

  • CorianderCoriander Member Posts: 1,667
    You can't really do... math with bgscript. You might be able to make some assumptions based on class, or use CheckStat to figure out a better threshold based on their maxhp.
  • horredtheplaguehorredtheplague Member, Developer Posts: 186
    Coriander said:

    You can't really do... math with bgscript. You might be able to make some assumptions based on class, or use CheckStat to figure out a better threshold based on their maxhp.

    I...wouldn't say that. You just have to do it "sideways" instead of with a nice neat function like other script languages. Here's the gist of it:
    IF
    HaveSpell(CLERIC_CURE_LIGHT_WOUNDS) // cures 8HP
    HPPercentLT(Myself,76) // at 25% (or more) down from Max
    CheckStatGT(Myself,31,MAXHITPOINTS) // I'm at 32 or more HP at maximum, so 25% of 32+ >= 8
    //....your other conditions
    THEN
    RESPONSE #100
    Spell(Myself,CLERIC_CURE_LIGHT_WOUNDS)
    END

    //For 50% or less of maximum
    IF
    HaveSpell(CLERIC_CURE_LIGHT_WOUNDS) // cures 8HP
    HPPercentLT(Myself,51) // at 50% (or more) down from Max
    CheckStatGT(Myself,15,MAXHITPOINTS) // I'm at 16 or more HP at maximum, so 50% of 16+ >= 8
    //....your other conditions
    THEN
    RESPONSE #100
    Spell(Myself,CLERIC_CURE_LIGHT_WOUNDS)
    END
    Tried and tested for years, in BP Series scripts. You can apply this for any percentage you like, and if you do the mathwork yourself it will work as intended. You'll not waste a single HP of "curing power" this way. You can alter the conditions to give a little leeway if you wish it (recommended for lower-level PC's/NPC's).
  • KharlogKharlog Member Posts: 5
    Thanks for informative replies! I guess horredtheplague's method this is better than the "standard" method as BG Scripting language seems to be very limited. I will try it on my scripts.
Sign In or Register to comment.