Aller au contenu

Photo

Anti-pickpocket bag?


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Grani

Grani
  • Members
  • 560 messages
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 .


#2
Shadooow

Shadooow
  • Members
  • 4 474 messages
sure, such bag needs a unique power that will set all items inside undroppable(cursed) and second usage back

#3
Grani

Grani
  • Members
  • 560 messages

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 .


#4
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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 .


#5
Grani

Grani
  • Members
  • 560 messages
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 .


#6
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
NWNX Events for Windows also has the pickpocket hook.