I have a script that runs as an activation of an item. When activating it, a henchman creature appears. I want the henchman to automatically level up if the PC has leveled up earlier. For some reason that part of the script doesn’t run. I’ve tried with a bunch of SendMessageToPC but get no message ingame. I wonder what I’m doing wrong here:
int GetCanLevelUp(object oPC, object oSprif)
{
int nMasterLevel = GetHitDice(oPC);
int nMyLevel = GetHitDice(oSprif);
if (nMasterLevel >= (nMyLevel + 4))
{
return TRUE;
}
return FALSE;
}
void PrepForDestruction(object oTarget)
{
SetPlotFlag(oTarget,FALSE);
SetImmortal(oTarget,FALSE);
AssignCommand(oTarget,SetIsDestroyable(TRUE,FALSE,FALSE));
}
void KillSprif(object oSprif)
{
PrepForDestruction(oSprif);
DestroyObject(oSprif);
}
void AddSprif(object oPC)
{
object oSprif = GetObjectByTag("sprif");
AddHenchman(oPC,oSprif);
}
void CheckLevel(object oPC)
{
SendMessageToPC(oPC,"Check level script is running");
object oSprif = GetObjectByTag("sprif");
if (GetCanLevelUp(oPC, oSprif))
{
SendMessageToPC(oPC,"Sprif should have leveled up");
LevelUpHenchman(oSprif,CLASS_TYPE_MAGICAL_BEAST,FALSE,PACKAGE_MAGICBEAST);
//SendMessageToPC(oPC,"Sprif should have leveled up");
int nLevel = GetLevelByClass(CLASS_TYPE_MAGICAL_BEAST,oSprif);
string sLevel = IntToString(nLevel);
SendMessageToPC(oPC,"Sprif has leveled up! Sprif's level is now (" + sLevel + ").");
}
else
SendMessageToPC(oPC,"Sprif can't level up for some reason.");
}
void main()
{
object oFreya = GetObjectByTag("freya");
object oSprif = GetObjectByTag("sprif");
object oPC = GetFirstPC();
if(GetIsObjectValid(oSprif))
{
RemoveHenchman(oPC,oSprif);
DelayCommand(0.2,KillSprif(oSprif));
return;
}
location lLocation = GetLocation(oFreya);
CreateObject(OBJECT_TYPE_CREATURE,"sprif",lLocation,TRUE);
DelayCommand(0.5,AddSprif(oPC));
DelayCommand(0.8,CheckLevel(oPC));
}
It’s the CheckLevel part of the script that doesn’t run at all.