[HELP] Persistence for Horses of Henchmen - SOLVED

Anyone got any ideas on how to modify these functions to store and retrieve the henchmen or henchmen (e.g. unmounted horses assigned to a henchman)?

// from x0_i0_henchman

void StoreCampaignHenchman(object oPC)
{
    object oHench;
    string sHench;
    int ret, iSlot, iMax = GetMaxHenchmen();

    for (iSlot = 1; iSlot <= iMax; iSlot++)
    {
        oHench = GetHenchman(oPC, iSlot);
        if (!GetIsObjectValid(oHench))
            DBG_msg("No valid henchman to store");
        else
        {
            DBG_msg("Storing henchman: " + GetTag(oHench));
            sHench = "Henchman" + IntToString(iSlot);
            ret = StoreCampaignDBObject(oPC, sHench, oHench);
            if (!ret)
                DBG_msg("Error attempting to store henchman " + GetName(oHench));
            else
                DBG_msg("Henchman " + GetName(oHench) + " stored successfully");
        }
    }
}

and this one…

// from x0_i0_henchman

void RetrieveCampaignHenchman(object oPC)
{
    string sHench;
    object oHench, oDupe;
    location lLoc = GetLocation(oPC);
    int iSlot, iMax = GetMaxHenchmen();

    for (iSlot = 1; iSlot <= iMax; iSlot++)
    {
        sHench = "Henchman" + IntToString(iSlot);
        oHench = RetrieveCampaignDBObject(oPC, sHench, lLoc);
        DelayCommand(0.5, DeleteCampaignDBVariable(oPC, sHench));
        if (GetIsObjectValid(oHench))
        {
            DelayCommand(0.5, HireHenchman(oPC, oHench));
            oDupe = GetNearestObjectByTag(GetTag(oHench), oHench);
            if ((oDupe != OBJECT_INVALID) && (oDupe != oHench))
            {
                AssignCommand(oDupe, SetIsDestroyable(TRUE));
                SetPlotFlag(oDupe,FALSE);
                SetImmortal(oDupe,FALSE);
                DestroyObject(oDupe);
            }
        }
        else
            DBG_msg("No valid henchman retrieved");
    }
}

I’m thinking for each one, I need to dupe the for loop, replacing the oPC w/ oHench, and nest it within the for loop that uses oPC as the object. Thing is, I’m not sure WHERE to nest it exactly within the oPC loop…

SOLVED

I need to check @Proleric 's Horse Guide more closely before posting stuff like this :smiley:
The solution is to have your henchmen use the X2 Henchman AI.

1 Like