The 'Picking PC's Pockets' article dealt with the basics of using an NPCs pickpocket skill. However, Bioware's implementation leaves a bit to be desired. There's no way to check for success, no way to find out what item was nabbed if any, and hence no way to generate faction changes, etc based on these things.
The solution is to write a custom pickpocket action function, and attach it to the conversations file as described in the 'Picking PC's Pockets' article. If you're comfortable with it, you can also attach this function to pretty much any event you'd like.
A working, debugged script follows which picks the PCs pocket. Feel free to embellish and customise as fits your needs.
1. Create a conversation script for the NPC you want to be your pickpocket
2. Select the line of conversation on which you want the pickpocket to do his/her thing
3. Click on the "Actions Taken" tab
4. Cick "Edit" in the Script area of the Actions Taken panel
5. Paste in the code below:
void PickpocketPC(object oNPC, object oPC)
{
if (GetHasSkill(SKILL_PICK_POCKET,oNPC))
{
int iPickpocketSkill = GetSkillRank(SKILL_PICK_POCKET,oNPC);
int iPCSpotSkill = 20;
if (FloatToInt(((IntToFloat(d10(1)*5)+75)/100) * IntToFloat(iPickpocketSkill)) > iPCSpotSkill)
{
// success!
object oItem = GetFirstItemInInventory(oPC);
int iRandom = d10(1); int iCount = 1;
while (iCount < iRandom)
{
oItem = GetNextItemInInventory(oPC);
if (GetPlotFlag(oItem))
{
// no grabbing this one! don't add to count so the iteration will continue
}
else
{
iCount++;
}
}
if (GetIsObjectValid(oItem)) {
ActionTakeItem(oItem,oPC);
}
else
{
// this PC has few items, take gold instead
TakeGoldFromCreature(d20(2),oPC,FALSE);
}
SetLocalInt(oNPC,"iPickSuccess",1);
}
else
{
// failure
string sMessage = GetName(oNPC);
sMessage += " tried to pick your pocket!";
SendMessageToPC(oPC,sMessage);
SetLocalInt(oNPC,"iPickSuccess",0);
}
}
}
void main()
{
object oPC = GetPCSpeaker();
object oNPC = OBJECT_SELF;
PickpocketPC(oNPC,oPC);
if (GetLocalInt(oNPC,"iPickSuccess") == 0)
{
ActionWait(2.0);
PickpocketPC(oNPC,oPC);
if (GetLocalInt(oNPC,"iPickSuccess") == 0)
{
// failed picking both times
}
}
}
6. Save the script, then the module.
7. Exit, test the thief action, and you're done!
Notes: ------------------------
This script assumes that the PC is neutral/friendly to the NPC, and so sets a DC of 20 for the skill check. The straight comparison of skill to DC is just there because it's simple. There are much better ideas (and, rules even!) on how to handle this check. I'd best look them up, eh? :)
The script checks for success, and picks the PC's pocket twice if need be. It avoids grabbing plot objects. If the PC has less than iRandom items, the pickpocket will grab 3-60 gold pieces on success instead.
For those new to scripting, make sure you paste this in exactly as it appears. If you add a custom function after main(), it will not compile.