P-Storage

For toolset tutorials as well as question and answers.
Locked
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

P-Storage

Post by Teric neDhalir »

Two questions here;
1) What is the definitive blueprint/script for persistent storage placeables? I don't think I have anything in the mod at the moment.

2) I'm still working on making spawns/traps/loot persistent so that once an area is "cleared" it stays that way. With the latest ACR update spawns are now behaving correctly and I've written some routines to make trap triggers/door unlocks persistent too. The most logical way of making chests persistent would seem to be to use a p-storage object. The question is whether if I put something in the inventory of a p-chest in the toolset will it always put it back on a mod reset or be overridden by the database if it has been removed previously? It would also be possible to spawn the chest but there is the issue with placeables dropping their inventory when de-spawning.

Cheers,
Teric
User avatar
AcadiusLost
Chosen of Forumamus, God of Forums
Posts: 5061
Joined: Tue Oct 19, 2004 8:38 am
Location: Montara, CA [GMT -8]
Contact:

Re: P-Storage

Post by AcadiusLost »

Placeables with persistent inventories are handled natively by the ACR; all you have to do is the following:

1. Attach the acf_plc_* scripts to a useable placeable with "has inventory" checked.

2. Define a Local String on the placeable instance or blueprint (if spawned), called ACR_PSO_NAME, with a unique value for that storage container, say: WindingWayChest3

Everything else is automatic. On opening, it will check the local /database folder on the nwn2server host machine for campaign database files corresponding with that pstorage object. If any exist, it will populate the placeable's inventory from those files, and update them again OnClosed. I believe default behaviour is not to drop contents OnDeath of the placeable, but I'm not positive on that. There is another local variable switch to force whether contents should drop OnDeath, which is defined in acr_it_persist_i (viewable in an ACR mod via the "Open Conversataion / Script..." option.

Wynna has some experience with making spawning/despawning persistent placeables, so I'd direct you towards her for recommendations on what settings are best for them.

Also, note that the first campaign DB / p-storage write operation per module load tends to be very laggy, and significantly (+200-600M) bloat up the pagefile use of nwn2server. Subsequent ones run smoothly and pretty reliably. If your module gets big enough, this can cause server crashes. All of the Live ACR mods now perform a single minor pstorage write to a temporary storage object to preinitialize the system so this doesn't inconvenience players. The script for this is only a few lines, and works well in the acf_mod_onmoduleload.nss script; let me know if you'd like that code pasted later.
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Re: P-Storage

Post by Teric neDhalir »

Thanks, AL.
AcadiusLost wrote: Everything else is automatic. On opening, it will check the local /database folder on the nwn2server host machine for campaign database files corresponding with that pstorage object. If any exist, it will populate the placeable's inventory from those files, and update them again OnClosed. I believe default behaviour is not to drop contents OnDeath of the placeable, but I'm not positive on that. There is another local variable switch to force whether contents should drop OnDeath, which is defined in acr_it_persist_i (viewable in an ACR mod via the "Open Conversataion / Script..." option.
Still two questions hanging over from that..
If I make a persistent object as per your instructions, put it in an area and put something in its inventory via the toolset will that object reappear in the container after a mod restart if it's been removed in game?

As for dropping contents OnDeath of the placeable I have that problem with some placeable spawns I have littered around that have bounty objects in their inventory. I posted about it recently and I thought it was on your ACR to-do list. You can find "Remains" bags with the items in question lying around if you've been moving between areas. I have to assume it's the de-spawn of the placeable that's causing it. Hmm, can't remember if the items are droppable - would that make a difference?
User avatar
AcadiusLost
Chosen of Forumamus, God of Forums
Posts: 5061
Joined: Tue Oct 19, 2004 8:38 am
Location: Montara, CA [GMT -8]
Contact:

Re: P-Storage

Post by AcadiusLost »

Persistent Storage objects should never have toolset-placed items in inventory. Most likely, any item so placed would duplicate itself every mod reset (for a placed instance) or every respawn (if a spawned placeable). Single-copy p-storage items are presently best placed via a DM avatar while the module is hosted. They should persist therafter until removed, across multiple respawnings or mod resets.

It is also possible to manually script a onetime addition using ACR_Get/SetPersistentInt() to allow the script to determine whether it should create the object or not. If this method is used, it may be best to check once during the first OnOpen() event for the placeable per mod reset, add to the inventory if appropriate, so OnClose() it will save. OnClose() could also set a local variable on the mod or the container to alleviate the need for additional SQL / persistency variable checks on subsequent OnOpen() operations.


Re: Bounty item dropping; I know I revised the wealth/drop/loot scripts to make special exceptions for plot-flagged items, in order to ensure that they were exempted from the normal math and rolls that occur to generate loot. This could be causing problems OnDespawn, resulting in droppage of said items. I didn't catch the report of this symptom before the last round of debugging, unfortunately (or if I did, I subsequently forgot it before debugging-time). Likely will require adding some better communication between the spawn, death, and wealth systems, such that the OnDeath() event is better equipped to determine under what context it has been called.

Presumably we'd only want them dropping if a PC or a PC-owned creature makes the kill? Or is that to restrictive? Could just delete plot items OnDespawn as a more systematic approach. What would be your preference?
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Re: P-Storage

Post by Teric neDhalir »

Understood about the p-storage. Thanks.

The bounty item issue is not from loot drops of killed creatures - AFAIK the fix to have plot items drop still works. My problem is that I spawn a placeable object such as mushrooms that have an inventory item. The spawns work fine in terms of placing the correct object in the areas and they have the item in their inventory. Problem is when you move out of the area and go back later instead of the placeable there's a "Remains" bag containing the inventory item. I can only assume it's the de-spawn that's causing it. It's possible that the placeables don't have the acf_plc_XX scrpts associated with them, perhaps that will fix it. I'll have an experiment and report back.

Cheers,
TnD
User avatar
AcadiusLost
Chosen of Forumamus, God of Forums
Posts: 5061
Joined: Tue Oct 19, 2004 8:38 am
Location: Montara, CA [GMT -8]
Contact:

Re: P-Storage

Post by AcadiusLost »

Despawning inventoried placeables sounds more familiar... and I do see that among the bullet points of my "To-Do" list. Should be pretty easily fixable, just wasn't something we thought about when initially coding the spawn system.
Locked