Author Sticky: Post Working Scripts Here
Lord Shonsu Posted: Wednesday, 03 July 09:21PM
1. Script Name: Henchman Party Healer

2. What it does: Sets up party Henchman to heal all party members (one at a time of course) when they reach 50% hit points.

3. Notes: The first script should be placed in the module's Heartbeat event. The second one should be placed in the Henchman's UserDefined event. The Henchman will heal party members when they hit 50% hit points. It will use the highest level heal spells that it has memorized first then move down to lower ones as they are used up.

I had to add spaces in the script so that it would post to this board, please go over it and take them out once you paste it into the script editor.

I'm sure that this can be improved upon, feel free!

4. The Script itself:

This one goes in the module's Heartbeat event:
NWScript:
void main()

{

object oPC = GetFirstPC();

object oParty = GetFirstFactionMember (oPC, TRUE);

while (GetIsObjectValid (oParty))

{

    int HPMax = GetMaxHitPoints (oParty);

    int HPCurrent =  GetCurrentHitPoints (oParty);

    if(HPCurrent < (HPMax/2))

    {

        object oHenchman = GetFirstFactionMember (oParty, FALSE);

        while (GetIsObjectValid (oHenchman))

        {

            event evNeedHeal = EventUserDefined (1020);

            SignalEvent (oHenchman, evNeedHeal);

            oHenchman = GetNextFactionMember (oParty, FALSE)

        }

    }

    oParty = GetNextFactionMember (oPC, TRUE);

}

}





This one goes in the Henchman's UserDefined event:

NWScript:
void main()

{

object oPC = GetFirstPC();

object oParty = GetFirstFactionMember (oPC, TRUE);

while (GetIsObjectValid (oParty))

{

    int HPMax = GetMaxHitPoints (oParty);

    int HPCurrent =  GetCurrentHitPoints (oParty);

    if(HPCurrent < (HPMax/(3/2)))

    {

       int spHeal = GetHasSpell (SPELL_HEAL, OBJECT_SELF);

       if (spHeal = TRUE)

       {

            ActionCastSpellAtObject (SPELL_HEAL, oParty, METAMAGIC_ANY, FALSE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);

       }

       return;

       int spCureCrit = GetHasSpell(SPELL_CURE_CRITICAL_WOUNDS, OBJECT_SELF);

       if (spCureCrit = TRUE)

       {

            ActionCastSpellAtObject (SPELL_CURE_CRITICAL_WOUNDS, oParty, METAMAGIC_ANY, FALSE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);

       }

       return;

       int spCureSerious = GetHasSpell (SPELL_CURE_SERIOUS_WOUNDS, OBJECT_SELF);

       if (spCureSerious = TRUE)

       {

            ActionCastSpellAtObject (SPELL_CURE_SERIOUS_WOUNDS, oParty, METAMAGIC_ANY, FALSE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);

       }

       return;

       int spCureModerate = GetHasSpell (SPELL_CURE_MODERATE_WOUNDS, OBJECT_SELF);

       if (spCureModerate = TRUE)

       {

            ActionCastSpellAtObject (SPELL_CURE_MODERATE_WOUNDS, oParty, METAMAGIC_ANY, FALSE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);

       }

       return;

       int spCureLight = GetHasSpell(SPELL_CURE_LIGHT_WOUNDS, OBJECT_SELF);

       if (spCureLight = TRUE)

       {

            ActionCastSpellAtObject (SPELL_CURE_LIGHT_WOUNDS, oParty, METAMAGIC_ANY, FALSE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);

       }

       return;

    }

    oParty = GetNextFactionMember (oPC, TRUE);

}

}



_________________
Lord Shonsu - Swordsman of the Seventh