Weird question perhaps - Can you spawn an item to a store?

I have an item that I would like wasn’t available at a store until a certain point in time in my module. Would it be possible (somehow) to spawn an item into a store (or make it unavailable until a certain thing has happened)?

I mean, looking at a store there’s a slot for OnOpenStoreScript. Could you do something with that?

Edit: Could you use CreateItemOnObject perhaps, or is a store not considered an object?

1 Like

Ok, I tried it. And it worked! Wow. Never would have thought that.

For anyone else who would like to do something like this. This is the script I made that I put on the store object’s OnOpenStoreScript:

void main()
{

	object oStore = OBJECT_SELF;

	CreateItemOnObject("pbox_it",oStore,1,"pbox_it",FALSE);

}

Now I will just have to modify the script with an “if” statement, so that the item only spawns in the store when I want it to.

5 Likes

in Soz, “shipments” are added as the plot progresses

2 Likes

Ah, and they do it like in a similar way I did it too then perhaps?

1 Like

I think they do it in the OnClientEnter scripts … conditioned by if(Journal state) …

 
i kinda like your way, it strikes me as more to-the-point

2 Likes

You can also copy items from whatever source to your merchant’s inventory.

1 Like

Yes, that’s how you can restock a store. I believe you can delete as well.

1 Like

@andgalf

I discovered that stores are very flexible in NWN2. I even managed to have a system where the vendor will start a conversation with the buyer as they buy the item! The effect is really neat. It allows a feeling of seller/buyer interaction rather than just a dump or collect system.

Restocking and destocking is a core part of my own store systems as the module economy relies upon it. :wink: Bottom line … as other have said … definitely. :+1:

Lance.

3 Likes

Thanks for all the replies, guys!

I was a bit unsure of the CreateItemOnObject function first since it says in the description:

// Create an item with the template sItemTemplate in oTarget's inventory.

And technically it isn’t the object’s inventory where I want to spawn/create the item, but the object’s store, but maybe the game sees those two as the same thing?

That sounds very neat, indeed. I’ve never tried that, but I’ll keep that in mind if need something like that in the future.

1 Like

A creature is OBJECT_TYPE_CREATURE and a store is OBJECT_TYPE_STORE but they are both “objects”.

the point is they are both containers, they both have Inventories.

1 Like

Yes, I understand that. However, if you look at this screenshot:

stores

There are two different slots when you look at Properties on an object. That’s what I meant when thinking that the game may see them as the same thing although, at least to me, there seems to be a difference.
I hope you understand my reasoning (or confusion).

I think that’s just for convenience… to show store items in appropriate panels. That is, i don’t think its necessary to have two tabs there, because in BaseItems.2da there’s a column “StorePanel” that likely does the ingame sorting.

1 Like

Is there a utility that will auto-sort all the items into the right containers for a store blueprint? It’s mighty tedious to do it manually in the toolset.

not that I’ve heard of. But here’s a quirk : as a test I threw an assortment of items all into a store’s Armor tab in the toolset. But ingame they were each sorted to their respective panel …

however the UTM file does keep them sorted as they were assigned in the toolset …

Lance_Botelle… I love the idea of the shop keeper commenting ! Do they say things like “not exactly my choice but up to you” when you buy some new shiny plus one throwing axes that you can never pick up again ?

As for the shop adding things I’d take the easy option that store owners can have more than one shop and when you hit the point in the story you just open the “new improved” store from the conversation.

Yeah, that’s one way of doing it, I guess. I my case I’d rather do it my way, because it’s only regarding one item.

@Tsongo

When a certain item is bought, the shopkeeper starts an entire conversation about it. As it only happens for certain “unique” items, its not as intrusive as that may sound. It actually gives a great interactive feel about what you just bought. i.e. I use the system sparingly.

I imagine you could add simple comments like the type you mention too. In fact, I even have notice text fired on some items. E.g. The store keeper carts the item sold to somewhere safe. (i.e. It will not appear for sale in the store after being sold.)

Thanks, Lance.

2 Likes

https://github.com/kevL/nwn2_pi_storesorter/blob/master/StoreSort.cs

It seems to be working. will upload a build to the vault tomorrow-ish

 
edit @rjshae
https://neverwintervault.org/project/nwn2/other/tool/sort-merchant-store

if it kludges pls let me know. As always, back up your modules and custom blueprints first – although it’s well behaved on my end

4 Likes

How about adding a random item from a chest to a store inventory? Say there is a creative smith in the city who sells masterwork weapons through a local vendor.