Still having problems leveling up henchmen

Hello, I still seem to be having a problem with henchmen leveling up in my module. As instructed, I went to “Module Properties”, clicked on the “Events” tab, and set the script in the OnPlayerLevelUp script slot to “x1_playerlevelup”. Sometimes they do actually level up, which I was pleased to discover and thought it was working. But sometimes they do not. I thought it was maybe because I modified the henchmens statistics, so I deleted the henchmen and made a new one, unmodified, but it still only says something like “Problem leveling up henchmen Delin Rumnaten in class 0”. My other henchmen will level up once, but are unable to level any farther and it says "Problem leveling up henchmen Nawiiel in class 1. None of these henchmen are multiclass by the way. Does anyone know what this might mean? Any solutions? I appreciate the help thank you.

Investigated a bit:

x1_playerlevelup calls a function from x0_i0_henchman, which is called LevelUpXP1Henchman.

LevelUpXP1Henchman cycles through the PC’s henchmen, checking their tags, and calls LevelHenchmanUpTo on them.

This is where the error message comes from (or, well, a similar-looking error message, anyway):

            if (nClassToLevelUp2==CLASS_TYPE_INVALID ||
                !LevelUpHenchman(oHenchman, nClassToLevelUp2, FALSE, nPackageToUse))
            {
                SendMessageToPC(GetFirstPC(), "Level Up Failed For "
                                              + GetName(oHenchman)
                                              + " in class "
                                              + IntToString(nClassToLevelUp));

                return;
            }

This leads to the function LevelUpHenchman, whose Lexicon page entry has a remark:
https://nwnlexicon.com/index.php?title=LevelUpHenchman

“In order to level up a henchman (or any NPC, it isn’t restricted to henchmen), that NPC must have followed its packages stringently. When you create a creature in the toolset, giving it, say, 5 levels of wizard, it automatically follows its packages. If you then start adding feats manually to it, for instance, you’ll no longer be able to use the LevelUpHenchman() command successfully on that NPC.”

Could this be it?

1 Like

Yes I believe that had something to do with it. I seem to have fixed the issue for the most part. As long as I start the henchmen out at level 1, they will lvl up to the approximate level of the PC which is pretty cool. I mainly had problems because I started them out above lvl 1 or modified something in their package. But now i’ve got it all smoothed out. Anyway, with that issue out of the way, now I am trying to figure out how to create random encounters for wilderness areas and dungeons. Any suggestions?