(Script) NPC refuses to open gate [EE] SOLVED

Here’s the scenario: PC tries to open locked gate. Gate then executes nw_g0_convdoor which kicks off a convo wherein the NPC (“Turnkey”) grumbles, swears at the PC, etc. PC has no response (i.e. “end dialogue”) which kicks off the following Action Taken Script:

void UnlockGate(object oDoor, object oWP)

void main()
    object oTurnkey = GetNearestObjectByTag("Turnkey");
    object oDoor    = GetNearestObjectByTag("PoL_Gate");
    object oWP      = GetObjectByTag("POST_Turnkey");

    AssignCommand(oTurnkey, UnlockGate(oDoor, oWP));

In actual play, the convo appears to work fine. Once the PC ends the dialogue, the NPC turns to face the gate but does nothing. What am I missing here?



object oDoor = OBJECT_SELF;

I suspect that GetNearestObjectByTag might be returning OBJECT_INVALID because the door is running the script, so implicitly you’re saying “find another object near the door whose tag is the same”.

If POST_Turnkey is the guard’s initial position, ActionJumpToObject is probably making them face the gate. ActionDoCommand(SetFacing) will correct their facing after the jump.

Once the gate opens correctly, if the guard jumps rather than walks back to post, ActionForceMoveToObject might look better.

Final point - to prevent the player interrupting the guard, you could make the guard unresponsive for the duration of those actions (see examples of SetCommandable in the Lexicon.

1 Like

Thanks @Proleric that solved the problem. Also having the guard ForceMoveToObject fixed the facing issue. Interesting idea about SetCommandable, I’ll look into that.