Support NPC

I want to create a support NPC that follows the player and heals and casts buffs on the PC, henchmen and anyone from the NPC’s faction.

I created a cleric using a copy of White Thesta. The problem is, that it doesn’t cast any spell on anyone besides herself. How to fix this?

Hello !
Do you want the NPC to follow your party (like a henchman), or just waiting somewhere like some king of seller, healing you automatically?

Following me around. Btw i already figured out the part about following in another thread.

You probably have to write your own healing AI. Here’s a starter pack.

Put this as NPC’s OnHeartbeat. It will cause it to heal itself, all nearby faction members and PCs. You can experiment with talents to implement buffs, cures, etc.

The NPC needs to know healing spells to make this work.

#include "x0_i0_talent"

void main()
{
    object oTarget;
    location lLocation;

    // Proceed only when idle or walking
    switch(GetCurrentAction())
    {
        case ACTION_INVALID:
        case ACTION_FOLLOW:
        case ACTION_RANDOMWALK:
        case ACTION_MOVETOPOINT:
        {
            break;
        }
        default:
        {
            return;
        }
    }

    // Cycle through all PCs and faction members seen in 20m sphere and
    // heal everyone who has less than 50% HP.

    lLocation = GetLocation(OBJECT_SELF);
    oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 20.0, lLocation, TRUE);

    while(GetIsObjectValid(oTarget))
    {
        if((GetIsPC(oTarget) || GetFactionEqual(oTarget)) &&
            (GetCurrentHitPoints(oTarget) * 2 < GetMaxHitPoints(oTarget)))
        {
            if(TalentHeal(TRUE, oTarget))
            {
                SpeakString("Healing " + GetName(oTarget) + ".");
            }
            else
            {
                SpeakString("I can't heal " + GetName(oTarget) + ".");
            }
            return;
        }
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, 20.0, lLocation, TRUE);
    }
}

Note that writing AI is tough as you need to cover a lot of situations, some of which may not be obvious. For example, AI should prioritize itself (survival), then PC master (when being a hench), then faction memebers. This is not present in this example.

Thank you! I will use your script as a template and refine it to my needs.