Pick Pocket script

#1

How would someone write a script that will cause the target to attack if they catch the PC pick pocketing them? I seem to be having trouble getting this OnDisturbed() event from firing.

#2

I’m getting very unsatisfactory results from the OnDisturbed event using SleightOfHand against a creature.

My script doesn’t fire often, maybe once in 10 tries. clue: The pickpocket animation always (and only) plays when it does fire.

but regardless of the animation and event-script, a check is made every time and loot is gained (as long as target still has loot) if successful.

here’s a script if you want to investigate … (full debug left in)

// 'creature_disturbed'
/*
    OnDisturbed event script for a creature.
*/
// kevL 2019 may 12

#include "nw_i0_generic"

//
void main()
{
    SendMessageToPC(GetFirstPC(FALSE), "creature_disturbed iType= " + IntToString(GetInventoryDisturbType()));

    object oSelf = OBJECT_SELF;

    switch (GetInventoryDisturbType())
    {
        case INVENTORY_DISTURB_TYPE_ADDED:
        case INVENTORY_DISTURB_TYPE_REMOVED:
        case INVENTORY_DISTURB_TYPE_STOLEN:

            SendMessageToPC(GetFirstPC(FALSE), ". action= " + IntToString(GetCurrentAction()));
            SendMessageToPC(GetFirstPC(FALSE), ". dialog= " + IntToString(IsInConversation(oSelf)));

            if (GetCurrentAction() == ACTION_INVALID && !IsInConversation(oSelf))
            {
                object oThief = GetLastDisturbed();
                SendMessageToPC(GetFirstPC(FALSE), ". . thief= " + GetName(oThief));

                if (GetIsObjectValid(oThief))
                {
                    SendMessageToPC(GetFirstPC(FALSE), ". . . VALID");

                    if (GetObjectSeen(oThief))
                    {
                        SendMessageToPC(GetFirstPC(FALSE), ". . . . Seen");

                        ClearAllActions(TRUE);
                        SpeakString("Got you !");

// void SetIsTemporaryEnemy(object oTarget, object oSource=OBJECT_SELF, int bDecays=FALSE, float fDurationInSeconds=180.0f);

//                      ChangeToStandardFaction(oSelf, STANDARD_FACTION_HOSTILE);
                        DetermineCombatRound(oThief);
                    }
                    else
                    {
                        SendMessageToPC(GetFirstPC(FALSE), ". . . . Unseen");

                        ClearAllActions(TRUE);
                        SpeakString("huh");

                        PlayCustomAnimation(oSelf, "scratchhead", FALSE);
                    }
                }
            }
            break;
    }

    if (GetSpawnInCondition(NW_FLAG_DISTURBED_EVENT))
    {
        SignalEvent(oSelf, EventUserDefined(EVENT_DISTURBED));
    }
}

further, i notice that the disturb-type registers as ADDED … (no, i’m not adding anything) … and i notice that the event is fired even when nothing has actually been taken/disturbed.

so am chalking this up to Nwn2 glitchiness, unless someone can say how to fire the OnDisturbed event of a creature consistently,

:\

1 Like
#3

In NWN1, a workaround might be to use the module’s OnAcquireItem event, checking for who the former possessor of the acquired item is. :open_mouth: Not a clue if this’ll be helpful here, but fingers crossed, y’guys.

#4

I’m getting very unsatisfactory results from the OnDisturbed event

Dare I say… DISTURBING results?
badum-tshh

2 Likes
#5

Perhaps first check if the acquired item is flagged as stolen?

1 Like
#6

Thank you everyone.

2 Likes