Author Topic: Anti-pickpocket bag?  (Read 352 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Anti-pickpocket bag?
« on: December 25, 2012, 08:02:52 pm »


               Is it possible to have a bag that cannot be stolen and such that everything inside it cannot be stolen as well? I believe I have seen such thing on some PW, but I have no idea which one and how this was done. I've tried searching the net for this but any pickpocket scripts are rare and nothing similar to this idea was found.
               
               

               


                     Modifié par Grani, 25 décembre 2012 - 08:10 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Anti-pickpocket bag?
« Reply #1 on: December 25, 2012, 08:22:15 pm »


               sure, such bag needs a unique power that will set all items inside undroppable(cursed) and second usage back
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Anti-pickpocket bag?
« Reply #2 on: December 25, 2012, 08:35:59 pm »


               

ShaDoOoW wrote...

sure, such bag needs a unique power that will set all items inside undroppable(cursed) and second usage back


But is it possible to make a script that would launch every time an item is put into or put out from such a bag? This would be the nicest option.
               
               

               


                     Modifié par Grani, 25 décembre 2012 - 08:36 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Anti-pickpocket bag?
« Reply #3 on: December 25, 2012, 09:25:48 pm »


               Short answer. In vanilla NWN, this is not possible. With NWNX on a linux server, it is. Here's why, and how.

No event fires when an item is put into a bag. If you want, you could use nwnx's hooking of the pickpocket event to recode pickpocketing, adding a check to see if the item to be pickpocketed is in a particular container, using this function to get the container, and checking for a particular int set on it:


object GetContainerOfItem (object oItem) {
    object oPossessor = GetItemPossessor(oItem);
    if (!GetIsObjectValid(oPossessor))
        return OBJECT_INVALID;

    object oContents, oCheck;
    object oContainer = GetFirstItemInInventory(oPossessor);
    while (GetIsObjectValid(oContainer)) {
        if (GetItemIsContainer(oContainer)) {
            oCheck = GetFirstItemInInventory(oContainer);
            while (GetIsObjectValid(oCheck)) {
                if (oCheck == oItem)
                    return oContainer;
                oCheck = GetNextItemInInventory(oContainer);
            }
        }
        oContainer = GetNextItemInInventory(oPossessor);
    }
    return OBJECT_INVALID;
}

You could name the int NoPickpocket, for example, and if the bag has it on it, simply block the pickpocket attempt. Here's a very simple chunk of code from our pickpocket event, using the nwnx_events plugin (which is still linux-only, as far as I know). It merely sets a few cirumstances in which pickpocketing is blocked, as you want. You could easily add a very similar one using the container check above.

        case EVENT_TYPE_PICKPOCKET:
            oTarget = GetEventTarget();

            if (GetIsPC(OBJECT_SELF) && GetIsPC(oTarget)) {
                if (GetLocalInt(GetArea(OBJECT_SELF), "nopp")) {
                    FloatingTextStringOnCreature("You cannot pickpocket other players!", OBJECT_SELF, FALSE);
                    BypassEvent();
                }
                if (abs(GetHitDice(oTarget) - GetHitDice(OBJECT_SELF)) > 6) {
                    FloatingTextStringOnCreature("You cannot pickpocket players more than 6 levels above or below you!", OBJECT_SELF, FALSE);
                    BypassEvent();
                }
                if (GetIsHardcore(OBJECT_SELF) || GetIsHardcore(oTarget)) {
                    FloatingTextStringOnCreature("Hardcore players cannot pickpocket or be pickpocketed by other players!", OBJECT_SELF, FALSE);
                    BypassEvent();
                }
            }
            RemoveEffectsOfType(EFFECT_TYPE_ETHEREAL, OBJECT_SELF);
            break;

If you don't want to use NWNX, or aren't running linux, then you'll have to do as Shad suggests. It's probably worth remarking that items that are cursed within a container do not prevent the player from dropping the container itself.

Funky
               
               

               


                     Modifié par FunkySwerve, 25 décembre 2012 - 09:27 .
                     
                  


            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Anti-pickpocket bag?
« Reply #4 on: December 25, 2012, 09:58:55 pm »


               I see. Thanks a lot for the answers! Unfortunately, I don't have linux, so I guess what ShaDoOoW said is my best bet.
               
               

               


                     Modifié par Grani, 25 décembre 2012 - 09:59 .
                     
                  


            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Anti-pickpocket bag?
« Reply #5 on: December 26, 2012, 12:27:52 am »


               NWNX Events for Windows also has the pickpocket hook.