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 .