My script for finding a secret object gives a "search:failure" message. Can I stop it?

Script in question:
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

if (GetIsSkillSuccessful(oPC, SKILL_SEARCH, 20))
   {
   object oTarget = GetNearestObjectByTag("WP_cent_gal_alrmcnt");

   location lTarget = GetLocation(oTarget);

   object oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "cent_gal_alrmcnt", lTarget);

   object oDone = OBJECT_SELF;

   DestroyObject(oDone, 0.0);
   }
}

It fires off a trigger on the ground. I like it because a) I made it myself, b) it spawns in my special placeable and c) I can use it several times in the same area to spawn the placeable many times in new places. Almost perfect.

The only problem is that when the PC enters the trigger and fails the search check, they get a floating-text-above-head-message saying “search:failure.” On one hand, that’s a clue that you should be searching here, and that might be useful. On the other hand, it sort of defeats the purpose of the secret object, since you know where the secret is even when you fail to find it.

I notice that the default secret object triggers don’t do that. So is there a way to stop the message from appearing?

(Post deleted)

I did something in one of my modules looking like this:

int GetIsSkillSuccessfulPrivate(object oTarget, int nSkill, int nDifficulty)
{
    if (GetSkillRank(nSkill, oTarget) + d20() >= nDifficulty)
    {
        return TRUE;
    }
    return FALSE;
}


void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

if (GetIsSkillSuccessfulPrivate(oPC, SKILL_SEARCH, 20))
   {
   object oTarget = GetNearestObjectByTag("WP_cent_gal_alrmcnt");

   location lTarget = GetLocation(oTarget);

   object oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "cent_gal_alrmcnt", lTarget);

   object oDone = OBJECT_SELF;

   DestroyObject(oDone, 0.0);
   }
}

Again, not 100 % sure it will work in NWN1.

EDIT: I tried compiling it in the NWN1 Toolset and at least it compiled. Maybe try it?

The way to fix your problem is simply to emulate the skill roll without using the stock function, like this:

void main()
{
    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC)) return;
    if ((GetSkillRank(SKILL_SEARCH, oPC) + d20()) < 20) return;

    FloatingTextStringOnCreature("Found secret object.", oPC, FALSE);
    object oTarget = GetNearestObjectByTag("WP_cent_gal_alrmcnt");
    location lTarget = GetLocation(oTarget);
    object oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "cent_gal_alrmcnt", lTarget);
    DestroyObject(OBJECT_SELF);
}

Give this a try, it should work as intended.
I still left the pop up message in case of success, but you can remove that if you don’t like it.

1 Like

You could also temporarily overwrite the message using the new SetTlkOverwrite() function (StrRef should be 10436). Would require build 8193.21 though. See NWN Lexicon for examples how to do that.

This works perfectly, thank you!