Awarding EXP for the Toggled Pick Pocket Skill

Hi All,
Is there a way to award exp for using the toggled pick pocket skill successfully on an npc?. I know it can be done through dialogue. I’ve tried a few successfully compiled scripts on the On-disturbed npc script but I can’t seem to get it to award the pc exp on a successful attempt. Is it something simple and basic that i’m missing? Thanks in advance for any advice!

1 Like

The problem may be how to detect a successful attempt. As you can see in the Lexicon, OnDisturbed doesn’t fire for creatures unless the pickpocket attempt is detected.

I have seen modules that use OnAcquireItem to reward the theft of specific items (by tag) using GiveXPToCreature. I’m not sure whether this can be generalised to all stolen items though.

1 Like

Thanks Proleric for your feedback. Yeah I had thought about scripting the xp in the module event OnAcquire and I probably will have to go this route for my project. Thanks again for your response! This is what I had in the OnDisturbed script for the npc:

object oPC = GetLastHostileActor();// or object oPC=GetLastDisturbedBy();

// Only fire once per PC.
if ( GetLocalInt(oPC, "DO_ONCE__" + GetTag(OBJECT_SELF)) )
SetLocalInt(oPC, "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE);

// If a skill check (pick pocket) is successful.
if ( GetHasSkill(SKILL_PICK_POCKET, oPC)  &&  GetIsSkillSuccessful(oPC, SKILL_PICK_POCKET, 20) )
  GiveXPToCreature(GetLastHostileActor(), 50);

// Give the speaker the items

  FloatingTextStringOnCreature("You have earned XP!", GetLastHostileActor());

I was hoping to create an Ondisturbed script to reward a pc for a successful pick-pocket attempt on any random npc unfortunately on a success, the pc still only gets the pick pocketable item in the victim npc’s inventory.

1 Like

Yes: check for the stolen flag on the item and confirm it was pulled from a creature.

void main()
    object oPC   = GetModuleItemAcquiredBy();
    object oNPC  = GetModuleItemAcquiredFrom();
    object oItem = GetModuleItemAcquired();

    // Only award XP for stolen items acquired off of living enemies.
    if (GetStolenFlag(oItem) &&
        GetObjectType(oNPC) == OBJECT_TYPE_CREATURE &&
        // Ensure the NPC is not a PC associate to avoid an exploit.
        while (GetIsObjectValid(GetMaster(oNPC)))
            oNPC = GetMaster(oNPC);

        if (!GetIsPC(oNPC))
            GiveXPToCreature(oPC, 50);

Though there’s bound to be edge cases where this won’t work.

EDIT: Thanks, Proleric!


Thanks squattingmonk for your feed back as well. So would this script go in the OnAcquireItem of the module event properties, I’m guessing?

1 Like

Sorry, yes. But look in your current OnAcquireItem’s script first. You’ll probably need to merge this into your script, especially if you want tag-based scripting to still work properly.

1 Like

@squattingmonk - excellent!

I guess it should also check that the item was acquired from a creature (GetObjectType)? Containers can also hold “stolen” items.

The edge case that springs to mind is gold, which fires the event, but returns an invalid item.


Squattingmonk and Proleric AGAIN Thanks for your feedback and help!! Okay I merged the advised script here with my module on acquire event and I have a successful compile. However, I havent tried it yet as proleric brings a good question Will gold be treated as a stolen flag item too? I’m just now getting to the point where i’m creating random npcs in the given areas. I have to equip npc inventories with gold too as I recall? Thanks again to the both of you!

1 Like

D’oh! Edited to fix that. >_<

No. Because gold does not return a valid object, GetStolenFlag() does not work on it. While you can still detect gold using GetModuleItemAcquiredStackSize(), you wouldn’t be able to tell if the gold is stolen or given by an NPC.

1 Like

Thanks very much for the great advice. I will give this a run through and post here for an update!

Okay, works like a charm just as you two said! works on the pickpocketable inventory items and doesn’t on any gold that is pick pocketed. Thanks Proleric and Squattingmonk for taking the time to reply and help me out!

1 Like

Im not sure how you are implementing this but if you have a loot script or are just manually marking things (edit paged up to see you were putting it in inventory)- But either way, in onspawn of creatures where it generates gold you could use that GetModuleItemAcuiredStackSize() method of detecting gold to see if your creature spawned with gold in its inventory, one way or another. If yes, then it flags a user defined on heartbeat for the creature, which I think become more active processor-wise if a PC is near. So, just make the on heartbeat check to see if its gold is still there? Not really sure how that would work, but if your mod is single player, then its easier to reward them for stealing gold. It might still work for multiplayer if you could flag the nearest PC to when the heartbeat notices the money is gone… Oh wait, if youre already keeping a local variable on the creature of how much gold it had, maybe theres some way you could use that to finger… I mean reward the thief. Of course, the PC could have any amount of gold already so youd have to have some thing on each areas on enter and with every merchant doing accounting tasks to actually use that as an ID value ha. Kinda too much work for a pickpocketing xp reward even if it ended up working:

  1. area on enter script: places local variable on characters as to how much gp they have
  2. every merchant onstore close to keep abreast of how much gold each pc has as above
  3. what if they drop it on the ground ><

I give up.

Hi Dreadlord_Anwyn
Thanks very much for your input and ideas as well. I’ve decided just to go with items in an npc’s inventory or special plot items. Thanks again for responding!

Stealing this for my module :slight_smile: Only change I made was to add a check to see if oNPC is still friendly to the PC and if so, only award 25 xp as the pickpocket attempt would have been DC 20 vs DC 30 for an enemy.


    if (!GetIsPC(oNPC))
        int nXP = 50;
        if (!GetIsEnemy(oNPC, oPC))
            nXP = 25;
        GiveXPToCreature(oPC, nXP);
1 Like

Pstemarie thanks for your input and forgive me for not replying sooner. Busy ‘as you know what’ at work. Thanks very much for the script and I may borrow (steal) for when my project gets into the Calimport stages of development. Sure do appreciate the advice!