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 
 
Using NPCs as Persistant Chests
Goto page 1, 2  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
JollyOrc



Joined: 15 May 2005
Posts: 10

PostPosted: Sun May 15, 2005 18:26    Post subject: Using NPCs as Persistant Chests Reply with quote

Let me explain the general idea:

Using the Object Storage system of NWNx2, we can store NPCs in the database. With their complete inventory.

Now, the system we have come up with does the following:

- A player can buy a chest from a merchant. The merchant puts a chest placeable on the ground, and gives the player a key to it.

- the player can use the chest, which causes it to open. The script checks if this chest already has an NPC in the database assigned. If not, it creates one.

If yes, it retrieves it from the db and spawns it as an invisible NPC,attaches it as the players henchman and opens the henchmen inventory.

- when the player uses the chest again, it closes. The henchmen gets unattached, and the NPC gets written to the database, and despawned.

rinse repeat as the player puts stuff into the chest.


All this works nicely, Sindol even added functionality for moving the chest by picking it up and putting it down again, etc.

BUT: Every now and then, very infrequently, the NPC can't be fetched from the database. Aparently the database entry is "corrupt", and can't be read correctly. Thus, the script creates a completely new one, resulting in an empty chest, with the player loosing everything. Not nice.


The normal NPCs we store and retrieve undergo literally dozens of store-and-retrieve cycles every day, and we don't loose them. But then, they don't change their inventory as much. Does anyone have any idea what might cause this, or wants to have a closer look at everything ?

In this rar are the most important scripts this system uses, although not all. I will make a better package should someone want to go into details.
Back to top
View user's profile Send private message
Acrodania



Joined: 02 Jan 2005
Posts: 208

PostPosted: Sun May 15, 2005 19:34    Post subject: Reply with quote

Try putting a delay on the "save" process of the chest object. It seems to take a certain amount of time to actually put the item in the chest and if you do it too quickly you might be copying an object with an invalid state...

There is a system on the vault that does something similar and works well, so the idea is sound Smile
Back to top
View user's profile Send private message
wendel1978



Joined: 21 Apr 2005
Posts: 5

PostPosted: Fri May 20, 2005 18:39    Post subject: Reply with quote

Did anyone ever reliably solve the issues for this system? We're talking about using npcs as chests in the #nwscript chat, and I would love to use this system.

Thanks!
W
Back to top
View user's profile Send private message
JollyOrc



Joined: 15 May 2005
Posts: 10

PostPosted: Thu Jun 02, 2005 16:38    Post subject: Reply with quote

currently, no user has reported a corrupted chest...
Back to top
View user's profile Send private message
teleri



Joined: 28 Jan 2005
Posts: 21

PostPosted: Sat Jun 04, 2005 3:04    Post subject: Reply with quote

wendel1978 wrote:
Did anyone ever reliably solve the issues for this system? We're talking about using npcs as chests in the #nwscript chat, and I would love to use this system.

Thanks!
W


What server is that on?
Back to top
View user's profile Send private message
Alosynth



Joined: 06 Jan 2005
Posts: 24

PostPosted: Sun Jun 05, 2005 6:07    Post subject: Reply with quote

If you mean what irc server #nwscript is on, I believe it is on irc.neverwinterconnections.com.
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Sun Jun 05, 2005 21:05    Post subject: Reply with quote

One potential problem, NPCs have a finite inventory space but chests hold an infinite amount.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Mon Jun 06, 2005 7:57    Post subject: Reply with quote

I think it is not infinite, but limited to 15 pages or so.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
JollyOrc



Joined: 15 May 2005
Posts: 10

PostPosted: Mon Jun 06, 2005 9:24    Post subject: Reply with quote

Primogenitor wrote:
One potential problem, NPCs have a finite inventory space but chests hold an infinite amount.


well, RL chests don't hold infinite items either.
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Mon Jun 06, 2005 11:35    Post subject: Reply with quote

The point I was making is that a player can put more items in a chest than an NPC can hold, the exact details are irrelevant. So take this example;

A player puts 27 suits of armor in their chest.
The script copies/moves those items to the NPC. However, the NPC cant hold all of them, so some drop to the floor.
The NPC is SCOd, server restarts, NPC is RCO'd.
Player goes to open their chest, items are copied back from the NPC, player finds that 7 suits of armor are missing and is not amused.

Its not an insurmountable problem, but its a potential issue I though people should be aware of. Its not strictly applicable to this process, since it works by attatching the NPC as a henchmen to the player,
Back to top
View user's profile Send private message
JollyOrc



Joined: 15 May 2005
Posts: 10

PostPosted: Mon Jun 06, 2005 12:05    Post subject: Reply with quote

I remember the "putting more items in chest than chest has pages" issue. That happened a few times on Avlis.

If people put in more things than possible and don't see their stuff on the ground, it's their loss if you ask me.
Back to top
View user's profile Send private message
Alosynth



Joined: 06 Jan 2005
Posts: 24

PostPosted: Mon Jun 06, 2005 16:27    Post subject: Reply with quote

I suppose you could put something in the unaquire event that will give the PC back any items the storage NPC's drop with a message saying there is no more room.
Back to top
View user's profile Send private message
JollyOrc



Joined: 15 May 2005
Posts: 10

PostPosted: Tue Mar 09, 2010 17:18    Post subject: Reply with quote

hiya everyone

I'm still using this system (after the server was on hold for a few years) and still have a problem with it. But at least I've narrowed things down a bit:

The Problem seems to be that saving a NPC with a big inventory to the database takes time - sometimes >1 minute. If the PC reopens (and thus triggering a reload of the NPC) before it's fully saved, there's a problem.

Is there a way to check if a setpersistentobject has finished properly?
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Wed Mar 10, 2010 17:31    Post subject: Reply with quote

I'm pretty sure SetPersistentObject is synchronous, so that's unlikely to be the real cause. Could you store each object individually, along with the identity of the owner, and then recreate each object on the invisible NPC when you spawn it?
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
JollyOrc



Joined: 15 May 2005
Posts: 10

PostPosted: Wed Mar 10, 2010 17:45    Post subject: Reply with quote

Zebranky wrote:
I'm pretty sure SetPersistentObject is synchronous, so that's unlikely to be the real cause. Could you store each object individually, along with the identity of the owner, and then recreate each object on the invisible NPC when you spawn it?


Probably, but it would certainly complicate the code quite a bit & necessitate quite a bit of rewriting - and I'd loose one of the cosmetic advantages (namely that the inventory stays sorted)

I do know for sure that if the server is under load or stressed, the chance of chest-content corruption rises. Also, it rises if there are lots of items in the chest (as opposed to just a few).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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