Block a monster from using an area transition?

Is it possible to block a monster from using an area transition (i.e. a door)?

The basic concept I have in this module is that a 1st level PC finds a powerful monster, escapes from it, gains the necessary XP and equipment, then returns to defeat it.

So the PC learns about a haunted shack. When he enters it he discovers it is inhabited by a ghoul. The ghoul has a shuffling walk like a zombie. So it is easy enough for the PC to outrun it. And the PC has previously been advised that if he encounters anything in the shack that is too much for him to handle - to run out of the shack, into the sunlight, and he’ll be safe.

This is where the problem occurs. The PC should be able to freely move back and forth, in and out of the shack, using the area transition of the shack door. But the monster needs to stay inside the shack and never leave. Except the monster tends to follow the PC outside.

I’ve tried lowering the intelligence of the ghoul to a 3 (he is just a mindless undead after all). That seems to work some of the time. But other times it doesn’t. I need a fix that works all the time.

Any help would be appreciated.

Easily done.

By default, the area transition script is nw_g0_transition. If you modify it, that will affect every transition in the module. If you make a copy with a new name, you can specify that version on the door in question (only).

Either way, at the start of the script, if the tag of the entering creature is the ghoul, return.

The easiest thing is to just put a new OnAreaTransitionClick script on the door. It default to nw_g0_transition which you could take a copy of, but basically it’d be something like this that only lets PCs and their associates pass (and takes out all the horse rubbish):

void main()
{
    object oClicker = GetClickingObject();
    object oTarget = GetTransitionTarget(OBJECT_SELF);

    if(GetIsPC(oClicker) || GetIsPC(GetMaster(oClicker)))
    {
        AssignCommand(oClicker, JumpToObject(oTarget));
    }
}

When modifying default scripts, unless know what you’re doing, it’s safer to let the original script handle all other cases.

nw_g0_transition begins

void main()
{
    object oClicker=GetClickingObject();
    object oTarget=GetTransitionTarget(OBJECT_SELF);
    :
    :

You can change that in the version on the door to

void main()
{
    object oClicker=GetClickingObject();
    if (GetTag(oClicker) == "MyGhoul") return;
    object oTarget=GetTransitionTarget(OBJECT_SELF);
    :
    :

Alternatively, if you want to keep your script simple but still benefit from the default code, don’t edit nw_g0_transition, but instead use a brand new script:

// Custom transition script to block ghoul
void main()
{
    object oClicker=GetClickingObject();
    if (GetTag(oClicker) == "MyGhoul") return;
    ExecuteScript("nw_g0_transition");
}

All other cases - not just horses, but, for example, other monsters or NPCs who happen to use the door - will then work normally.

If you think this case will often arise in your module, you can use a local variable on the monster rather than a tag, so that one script fits all.

1 Like

Don’t edit the default script I said put a new one in that event. Unless they’re using horses (another pain in the ass) it’s perfectly safe.

Half assed edits to default scripts people then forget about is bound to mess up somewhere down the line.

I just tried it out and it works great.

The only character in the module who would be using this particular door is the PC. So its probably best just to keep it simple.

Thanks for the help. I really appreciate it!