Leveluphenchmen in while loop

Hi im trying to dynamically level up an enemy NPC in relation to the PC entering the area. What I have tried so far is to use leveluphenchmen in a while loop with no success. I have also tried to split it up and spam it and that worked for some reason.

Try to adjust this to your needs, it should do what you’re asking for:

void main()
    object oPC = GetEnteringObject();
    if (GetIsPC(oPC) == FALSE) return;

    int nPC = GetHitDice(oPC);
    object oMOB = GetObjectByTag("enemy_tag");
    int nCLASS = GetClassByPosition(1, oMOB);
    int nMOB = GetHitDice(oMOB);
    while (nMOB < nPC)
        LevelUpHenchman(oMOB, nCLASS, TRUE);
        nMOB = nMOB + 1;
1 Like

Thanks for quick response. Works like a charm!