Aller au contenu

Photo

Scripting a more realistic store


  • Veuillez vous connecter pour répondre
15 réponses à ce sujet

#1
rjshae

rjshae
  • Members
  • 4 485 messages
In theory it ought to be possible to create scripts for a Store that produce more realistic re-stocking rates than the current all or nothing approach (either an infinite supply or a single copy that is not replentished). However, this proved a little more challenging than I first imagined. I believe you would need to track the inventory via variables on the store, then use a restocking rate and a maximum stock level to determine how many are added over a given time interval. The appropriate data would need to be kept in the script for each item type; or possibly it could use a restocking formula based on item type and cost. You would probably also want some churn in the high end items, so that they are periodically replaced by randomly selected equivalent items.

Has anybody worked out the details on a scheme like this? It seems doable, but tedious. Thoughts?

#2
rjshae

rjshae
  • Members
  • 4 485 messages
Guess not.

#3
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Sorry I missed this earlier.
The store's stock is an inventory like any other object's inventory, so you can use the same functions to manipulate store items.
So, a simple solution might be a script on-store-open that
1. Calculates the time passed from the last time the store was opened.
2. Checks the number of each kind of item.
3. Restocks an appropriate number of items based on 1 and 2.
4. Handle odd events, like the high-end churn or adding items based upon special events, like completing a quest.
I would keep all the data on item tags, restock rate, and max inventory in the script, as you say. Then each store gets its own copy of the script, with various modifications. You seem to have it all planned out well, why don't you just try it? It's really not that tedious, just work it out for one item, and then add in others as you go along. No need to put the whole item list in there, just a few key expendables.

#4
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi rjshae,

I have added a couple of scripts to my own shops to add a more realistic re-stocking feel. I have also added more shop info in another GUI that opens up at the same time as the store.

Posted Image

Check out these couple of blog links to learn more:

http://worldofalthea...up-roll-up.html

http://worldofalthea...patch-v123.html

A quote from one link: "In addition to this, I have now created a system that randomly adds new stock items and informs the player of such in the new GUI. New stock may simply be other useful items, or may be a special item that will add more to the game. Note, however, items that don't sell will be removed from stock after a time and new items added, so if there is an item you want and you have the gold, buy it!"

Lance.

Modifié par Lance Botelle, 07 mars 2011 - 10:40 .


#5
dethia

dethia
  • Members
  • 146 messages
Does anyone know an effective way to get item cost from item blueprints. We can get modify cost I think but not the cost value (which may have to be looked up in 2da's or whatnot. I would like to make a custom shop system but this is a big stopping point for me.

#6
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

dethia wrote...

Does anyone know an effective way to get item cost from item blueprints. We can get modify cost I think but not the cost value (which may have to be looked up in 2da's or whatnot. I would like to make a custom shop system but this is a big stopping point for me.



Hi,

Surely the function int GetGoldPieceValue(object oItem); does this? Or have I misunderstood what you need?

Lance.

Modifié par Lance Botelle, 12 mars 2011 - 02:53 .


#7
dethia

dethia
  • Members
  • 146 messages

Lance Botelle wrote...

dethia wrote...

Does anyone know an effective way to get item cost from item blueprints. We can get modify cost I think but not the cost value (which may have to be looked up in 2da's or whatnot. I would like to make a custom shop system but this is a big stopping point for me.



Hi,

Surely the function int GetGoldPieceValue(object oItem); does this? Or have I misunderstood what you need?

Lance.


It may indeed, I must have overlooked it ;P

#8
Quilistan

Quilistan
  • Members
  • 111 messages
There is also a dynamic merchant script set on the vault, It was developed for NWN1 but works with NWN2 also. Allows for haggeling, pick pocketing, inventory cleaning, inventory restock, random items, prejudice, favoritism. It is a pretty nice system.

nwvault.ign.com/View.php

http://nwvault.ign.c...s.Detail&id=191

I think there is a small script fix that it needs, but it was easy to fix. I just can't remember what it was (it was a while ago that I looked at it).

Modifié par Quilistan, 13 mars 2011 - 03:52 .


#9
Quilistan

Quilistan
  • Members
  • 111 messages
Sorry about the double post, the site freaked on me.

Modifié par Quilistan, 13 mars 2011 - 03:52 .


#10
dethia

dethia
  • Members
  • 146 messages
Well I started working on my shop now that I know how to get the gold value and it is almost finished but I am running into a small problem.  I had hoped to make the shop fully integrateable (if there is such a word) without any modification.  Thus I merely modified the ga_store_open script.  My trouble now is that I am unable to get the "Will not buy" and "Will not sell" values from the store via a script or at least don't know how?  Before I begin to use variables am wondering if anyone knows how those values can be determined as it'd be great if the shop can be added without any actual modifications to every store in the game.

What I have tried so far is adding the item to the store before selling it to see if maybe the store would reject it (drop it or whatnot) sadly that doesn't happen.  The gui functions themselves are hard-coded, so if anyone has managed to achieve this feat I'd greatly appreciate the help.

And here's the link to how the store looks:

Posted Image

#11
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

dethia wrote...

Well I started working on my shop now that I know how to get the gold value and it is almost finished but I am running into a small problem.  I had hoped to make the shop fully integrateable (if there is such a word) without any modification.  Thus I merely modified the ga_store_open script.  My trouble now is that I am unable to get the "Will not buy" and "Will not sell" values from the store via a script or at least don't know how?  Before I begin to use variables am wondering if anyone knows how those values can be determined as it'd be great if the shop can be added without any actual modifications to every store in the game.

What I have tried so far is adding the item to the store before selling it to see if maybe the store would reject it (drop it or whatnot) sadly that doesn't happen.  The gui functions themselves are hard-coded, so if anyone has managed to achieve this feat I'd greatly appreciate the help.

And here's the link to how the store looks:

Posted Image



Hi dethia,

That GUI looks really good. It looks like you decided to use silver and copper coins as well ... is that correct? If so, I would be interested to hear how you have altered item costs. Did you alter any 2da file, etc? If so, how did you calculate your figures? What baseline did you use?

To answer your question, unfortunately, I do not know of any way to get the "will only buy" or "will not buy" information. However, wouldn't this be something the builder would have set when preparing the store anyway? In other words, you do not have to sort this ... unless, of course, your GUI is completely new (i.e. does not use any aspect of the OC version at all)? Looking at the different options you have available would imply you may have had to completely rewrite the GUI. Is this the case?

And from what I can see, it looks like you have added a "steal" option and seperated the "buy" and "sell" pages. Is this correct?
Anyway, I guess I have asked you more questions than I answered for you. Posted Image Hope you don't mind sharing.

EDIT: Any chance of sharing your XML code and GUI textures? Are the textures already in the game somewhere? I would like to rework the OC version to look more like yours in colour, and I can easily add my own code to the parts you have added like Max gold, store gold, etc.

Lance.

Modifié par Lance Botelle, 18 mars 2011 - 02:15 .


#12
dethia

dethia
  • Members
  • 146 messages
Hi Lance, to answer all the questions:

I do not alter the item cost at all. I simply treat the gold piece as the least valueable currency, that being copper, and then simply convert the total item cost into copper/silver and gold. I have modified the default gold peice and merely changed its name to Copper Coin and icon to look more copper than gold. So item prices are exactly the same as the default prices but just converted into this new currency system. Of course the shop is 100% customized as you had thought so prices can be manually set anyway a developer sees fit.

The reason why I hoped people do not need to make modifications is so the system could then be added to existing stores without any additional work, sadly that isn't the case it seems. The GUI is indeed a completely separate xml file.

There is the buy page with the 5 options to choose from on top (armors and shields, weaopns, potions and scrolls, trinkets and miscellaneous). The 6th option is sell, yes I had to make a separate sell page because the ondroprecieved functions only work with the default stores and thus would not work in the custom gui. If I could use the hardcoded gui functions i wouldn't even need to get the willnotbuy willonly buy lists since they are already incorporated into themsomehow.

and for the last question I do intend to release the store on the vault, it is almost done, I wll probably make a new post when I do. I am in the process of scripting the steal button effect and then the store is done. The last two things will be updating player inventory gui screen to show the player's gold in terms of the coins and also ugh the probably more difficult task of modifying the trade window. Once that is done I will post the shop on the vault and probably make a new post for that.

#13
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi dethia,

The problems you encountered explain one of the reasons why I ended up avoiding lesser coin denominations. I did, however, rework all the 2das to rework the economy to something more "realistic".

I will be interested to take a look at your scripts and GUI when released, as I want to amalgamate my own GUI with the official shop GUI - and your XML file with textures look like they could save me some work. ;)

I look forward to seeing your release.

Lance.

#14
dethia

dethia
  • Members
  • 146 messages
http://social.biowar...3/index/6697490

I have released all the stuff so have at it ;P.

Sadly I could not alter the trade coin window, i would need to redo the whole thing which isn't that difficult but it is something I will leave for another time.

#15
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

dethia wrote...

http://social.biowar...3/index/6697490

I have released all the stuff so have at it ;P.

Sadly I could not alter the trade coin window, i would need to redo the whole thing which isn't that difficult but it is something I will leave for another time.



Thanks dethia,

I have downloaded now and will take a look.

Many thanks.

Lance.

#16
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi dethia,

I managed to find the textures you used from your code thanks. Posted Image

Here are images of my latest version of my store:

600x400http://4.bp.blogspot.com/-LcipmkpqyFI/TZHWD3PVy6I/AAAAAAAAA8w/O-ZjiPwm5ks/s1600/Shopping.jpg[/img]

You can read more about it from here.

Many Thanks.

Lance.

Modifié par Lance Botelle, 29 mars 2011 - 01:37 .