logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
xp_pickpocket - Allows custom/disabled pickpocketting
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
GodBeastX



Joined: 09 Aug 2006
Posts: 65

PostPosted: Tue Aug 19, 2008 9:32    Post subject: xp_pickpocket - Allows custom/disabled pickpocketting Reply with quote

*High fives skywing again for input*

Well, someone came on my server and spammed pick pocket again and ran off with someones items... again.

Frustration had me rush out to implement this plugin. Essentially you can disable pickpocketting completely or implement your own pickpocket routines or simply let defaults occur.

Note: To update source code just change function offsets to their locations in NWN2Server module. Defines are in pickpocket.cpp.

Source Code
Server: v1.22 (Standard, NX1, and NX2)
NWNX: 1.09
http://www.retrosmack.com/nwn2/pickpocket_src.zip

Latest
Server: v1.22 (Standard, NX1, and NX2)
NWNX: 1.09/1.08
http://www.necrosisonline.com/downloads/xp_pickpocket_v1.22.zip

(Out of Date)
Server: v1.21 (Standard, NX1, and NX2)
NWNX: 1.09/1.08
http://www.necrosisonline.com/downloads/xp_pickpocket_v1.21.zip

(Out of Date)
Server: v1.13 (Standard, NX1)
NWNX: 1.08
http://www.necrosisonline.com/downloads/xp_pickpocket.zip

Known Issue:

If you allow the default pickpocket to occur, your script will get called once when someone begins the pickpocket action (From any distance) and if they come within range to execute the pickpocket it'll be called again. Looking for a workaround to this, but for now, just know it will be called twice if the person doesn't cancel before executing the pickpocket.


Last edited by GodBeastX on Wed Feb 16, 2011 22:55; edited 3 times in total
Back to top
View user's profile Send private message
TroveLord



Joined: 22 Nov 2006
Posts: 136
Location: Italy

PostPosted: Tue Sep 16, 2008 14:06    Post subject: Re: xp_pickpocket - Allows custom/disabled pickpocketting Reply with quote

I've been playing around a bit with this plugin and I love it. Although, it seems that it requires MadChook.dll to work, so who's interested in this must bear it in mind.

GodBeastX wrote:
Known Issue:
If you allow the default pickpocket to occur, your script will get called once when someone begins the pickpocket action (From any distance) and if they come within range to execute the pickpocket it'll be called again.

A workaround can be scripted like this.

Code:

void PickpocketCancel()
{
   NWNXGetInt("PICK", "1", "", 1);
}

void PickpocketContinue()
{
   NWNXGetInt("PICK", "1", "", 1);
}

object PickpocketGetTarget()
{
   int nOID = NWNXGetInt("PICK", "0", "", 0);   
   return IntToObject(nOID);
}

void main()
{
   object oThief = OBJECT_SELF;
   object oVictim = PickpocketGetTarget();
   
   if(GetLocalInt(oThief, "server_pickpocket"))
   {   
      AssignCommand(oThief, SpeakString("I'm the thief."));
      AssignCommand(oVictim, SpeakString("I've been robbed by "+GetName(oThief)+"."));
      DeleteLocalInt(oThief, "server_pickpocket");
   }
   else
      SetLocalInt(oThief, "server_pickpocket", TRUE);
}
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Thu Sep 18, 2008 1:48    Post subject: Reply with quote

This can't work.

I haven't even got NWN2 but I think I can guess how it works. I think that your assume that, if script run second time for this person it must be point where he is robbed, is bad.

Look at this:

Code:
const int PICKPOCKET_EVENTTYPE_PICKPOCKET_INVALID = -1;
const int PICKPOCKET_EVENTTYPE_PICKPOCKET_STARTED = 0;
const int PICKPOCKET_EVENTTYPE_PICKPOCKET_PASSED = 1;

int GetLastPickpocketEventType();

int GetLastPickpocketEventType()
{
object oThief = OBJECT_SELF;
 if(GetObjectType(oThief)!=OBJECT_TYPE_CREATURE)
 {
 return PICKPOCKET_EVENTTYPE_PICKPOCKET_INVALID;
 }
object oVictim = PickpocketGetTarget();
 if(!GetIsObjectValid(oVictim))
 {
 return PICKPOCKET_EVENTTYPE_PICKPOCKET_INVALID;
 }
object oLastVictim =  GetLocalObject(oThief,"GetLastPickpocketEventType()");
 if(!GetIsObjectValid(oLastVictim) || oLastVictim!=oVictim)
 {
 SetLocalObject(oThief,"GetLastPickpocketEventType()",oVictim);
 return PICKPOCKET_EVENTTYPE_PICKPOCKET_STARTED;
 }
DeleteLocalObject(oThief,"GetLastPickpocketEventType()");
return PICKPOCKET_EVENTTYPE_PICKPOCKET_PASSED;
}

void main()
{
object oThief = OBJECT_SELF;
object oVictim = PickpocketGetTarget();
int nEvent = GetLastPickpocketEventType();
 if(nEvent==PICKPOCKET_EVENTTYPE_PICKPOCKET_STARTED)
 {
 //PC just clicked with pickpocket to target
 }
 else if(nEvent==PICKPOCKET_EVENTTYPE_PICKPOCKET_PASSED)
 {
 //someone was actually robbed! (or maybe not)
 }
}


Untested, writen in late night Smile but hope its right.

GodBeastX: Make this code as a oficial plugin function is very good idea IMO. Why bother to distinguish it in plugin if it's possible via scripting.

EDIT: a very little optimize, morning!
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
CASchoeps



Joined: 22 Oct 2008
Posts: 1

PostPosted: Wed Oct 22, 2008 13:12    Post subject: Reply with quote

Does this work?

The ERF contains the following include file:

Code:
// Pickpocketting Framework
// By: GodBeastX

void PickpocketCancel()
{
   NWNXGetInt("PICK", "1", "", 1);
}

void PickpocketContinue()
{
   NWNXGetInt("PICK", "1", "", 1);
}

object PickpocketGetTarget()
{
   int nOID = NWNXGetInt("PICK", "0", "", 0);
   
   return IntToObject(nOID);
}


Notice that both the PickpocketCancel as well as the PickpocketContinue function call exactly the same code. I have yet to implement this on my server but I think that one of them should have a 0 somewhere Smile
Back to top
View user's profile Send private message
TroveLord



Joined: 22 Nov 2006
Posts: 136
Location: Italy

PostPosted: Wed Oct 22, 2008 15:25    Post subject: Reply with quote

CASchoeps wrote:
Notice that both the PickpocketCancel as well as the PickpocketContinue function call exactly the same code.

They probably activate/disactivate a variable like a switch. It worked for me, and my workaround works as well, I tested it.
Back to top
View user's profile Send private message
Urlord



Joined: 17 Nov 2006
Posts: 122

PostPosted: Fri Oct 31, 2008 23:56    Post subject: Reply with quote

This plugin does not seem to work with NWNX4 v 1.09.
_________________
Jim (aka, Urlord)
Visit the Persistent World of Nymri
Back to top
View user's profile Send private message Send e-mail
GodBeastX



Joined: 09 Aug 2006
Posts: 65

PostPosted: Thu Nov 20, 2008 21:14    Post subject: Reply with quote

Waiting on some info for new NWN2Server then I'll upgrade this to 1.09.
Back to top
View user's profile Send private message
barfubaz



Joined: 03 Dec 2008
Posts: 8

PostPosted: Wed Dec 03, 2008 23:08    Post subject: xp_pickpocket with 1.21 servercrash Reply with quote

GodBeastX wrote:
Waiting on some info for new NWN2Server then I'll upgrade this to 1.09.


FYI - using the current (initial) version of xp_pickpocket with 1.21 creates a servercrash on pickpocket. (in NWNX4 1.08) And in my case I ended up with a loop of attempted restarts that caused me to need to restart the server machine.

Skywing and I spent some time tracking this down yesterday.

This plugin needs to turn itself off if it's not the right patch level like skywing's does.

Am hoping to see a 1.21 compatible version soon. I love this plugin, and thanks for past and future work.

- Bar
_________________
Bar Fubaz, Head DM & Builder NWNHaven.com - Kingdom of Haven - Adult Roleplaying Server, Social Category
Back to top
View user's profile Send private message
GodBeastX



Joined: 09 Aug 2006
Posts: 65

PostPosted: Thu Dec 04, 2008 21:29    Post subject: Reply with quote

By upgrade to 1.09, I meant to latest server too. That was the info I was waiting on, which was provided to me.

I have a build right now that is both NWNX 1.09 compatible and 1.21 patch compatible. Just waiting to get home from work to test it. If it's A'OK then this thread will have the latest version in a reply.
Back to top
View user's profile Send private message
barfubaz



Joined: 03 Dec 2008
Posts: 8

PostPosted: Thu Dec 04, 2008 23:56    Post subject: Reply with quote

GodBeastX wrote:
By upgrade to 1.09, I meant to latest server too. That was the info I was waiting on, which was provided to me.

I have a build right now that is both NWNX 1.09 compatible and 1.21 patch compatible. Just waiting to get home from work to test it. If it's A'OK then this thread will have the latest version in a reply.


Great to hear! Looking forward to it.

Errrr... will it be backward compatible to 1.08 by any chance? We haven't made the leap.

If not oh well, thanks anyway. I understand how it can be a pain to keep compatibilities.

- Bar
_________________
Bar Fubaz, Head DM & Builder NWNHaven.com - Kingdom of Haven - Adult Roleplaying Server, Social Category
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Fri Dec 05, 2008 0:14    Post subject: Reply with quote

barfubaz wrote:
Great to hear! Looking forward to it.

Errrr... will it be backward compatible to 1.08 by any chance? We haven't made the leap.

If not oh well, thanks anyway. I understand how it can be a pain to keep compatibilities.

- Bar
There are no compatibility problems with 1.09. You can use 1.08 plugins on 1.09 and vice versa.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
barfubaz



Joined: 03 Dec 2008
Posts: 8

PostPosted: Fri Dec 05, 2008 7:22    Post subject: Reply with quote

virusman wrote:
barfubaz wrote:
Great to hear! Looking forward to it.

Errrr... will it be backward compatible to 1.08 by any chance? We haven't made the leap.

If not oh well, thanks anyway. I understand how it can be a pain to keep compatibilities.

- Bar
There are no compatibility problems with 1.09. You can use 1.08 plugins on 1.09 and vice versa.


*Points up* Hate to contradict, but this plugin is incompatible with 1.09 at the moment at least by report.

- Bar
_________________
Bar Fubaz, Head DM & Builder NWNHaven.com - Kingdom of Haven - Adult Roleplaying Server, Social Category
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Fri Dec 05, 2008 7:55    Post subject: Reply with quote

barfubaz wrote:
*Points up* Hate to contradict, but this plugin is incompatible with 1.09 at the moment at least by report.

- Bar
Are you sure it's incompatible with NWNX 1.09 and not NWN2 1.21?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
barfubaz



Joined: 03 Dec 2008
Posts: 8

PostPosted: Fri Dec 05, 2008 18:10    Post subject: Reply with quote

virusman wrote:
barfubaz wrote:
*Points up* Hate to contradict, but this plugin is incompatible with 1.09 at the moment at least by report.

- Bar
Are you sure it's incompatible with NWNX 1.09 and not NWN2 1.21?


Me sure? No. That's why I used the term "by report". Urlord reported it, GodBeastX seems to have confirmed. I'd have to do some work that would disturb my other efforts to confirm or deny this report. Apologies for not being in a position to test this.

- Bar
_________________
Bar Fubaz, Head DM & Builder NWNHaven.com - Kingdom of Haven - Adult Roleplaying Server, Social Category
Back to top
View user's profile Send private message
GodBeastX



Joined: 09 Aug 2006
Posts: 65

PostPosted: Mon Dec 08, 2008 20:13    Post subject: Reply with quote

Okay, the compatibility with 1.09 is that it will use Detours instead of Madchook. Sorry I didn't get it tested because... well... I got drunk and forgot to test it when I got off work Smile TODAY FOR SURE!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Development All times are GMT + 2 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group