Okay, what am I doing wrong? I put this successfully compiled script in the npc’s perception yet none of it fires. If I don’t include distance, it does fire or at least the floating text fires. I have a similar script for an activated item that works beautifully. Yet this on perception is driving me bat-sh-crazy.
here is the script;
void main()
{
// We are only interested in “seen” events.
if ( !GetLastPerceptionSeen() )
return;
// Get the creature who triggered this event.
object oPC = GetLastPerceived();
object oself=OBJECT_SELF;
// Only fire for (real) PCs.
if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
return;
// Only fire once per PC.
if ( GetLocalInt(oPC, "DO_ONCE__" + GetTag(OBJECT_SELF)) )
return;
SetLocalInt(oPC, "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE);
// Have us perform a sequence of actions.
// If a will saving throw is successful.
if (GetDistanceBetween(oPC, oself) < 5.0 && !WillSave(oPC, 15))
{
// Have text appear over the PC's head.
FloatingTextStringOnCreature("blah, blah, blah", oPC);
}
else if (GetDistanceBetween(oPC, oself) < 5.0 )
{
FloatingTextStringOnCreature("Will save failed!", oPC);
}
}