The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: LoganF on November 18, 2011, 01:46:14 AM

Title: Enhanced Shopping (v1.0d.01)
Post by: LoganF on November 18, 2011, 01:46:14 AM
Overture 1.0: A Different Kind of Shopping Experience
aka Enhanced Shopping (v1.0d.01)
Version: 1.0d.01
Author: Logan Forrests
Date: December 25, 2011

Version History



Planned Future Versions


- Allow individual shop restock amounts
- Provide additional callable functions to enhance shopping experience including the ability to remove items from shop stock
- Introduction of Unique Items that can be bought only once to shops and never sold
- Create additional Plug 'n' Play shop scenes
[/list]

Description


The default system involves buying from a predefined list of items on sale by the shop and selling any unwanted goods for a pretty penny (or in some cases peanuts).

But what happens to all those items we sell? And how come the shops never really run out of items despite having only a small counter or a cloak from which our friendly shopkeeper makes his sales? Well, now we can answer those questions for our players.

With this script, we can set up our shops to behave in various ways. From a shop who runs out of items to shops who will receive occassional shipments to replenish shops. We can even make shops sell us back the things we sold him
(for a reduced price if we want too). Of course, we can't forget about the traveling merchant with only a cloak or a pack mule to hold his items - We can limit the amount of items a shop is able to hold altogether.

Features


An Example of Advanced Use:

Taken from the In-Depth Guide provided with the script. It probably won't make much sense straight away, but the plan is to get you to take a further look into the script.

Bob's Shop gets flattened

We decide to make a shop for our pal, Bob. We anticipate he might need to make use of these special features so we give him a proper shop. We didn't set up any initial properties though (because they aren't necessary).

Imagine, now, we come across a scenerio in which our heroes have released an unknown evil onto the world and this evil happened to decimate our village. A village where Bob's Shop, a shop which normallty sells us an infinite number of Potions and other healing goods was making good business. The problem now, though, is that Bob's Shop also got flattened. But he's not giving up. He'll still continue to sell items. However, he only has a small amount of space left and he really isn't interested in selling anything back if you change your mind later.

Well, along with our village destruction event we can also add in the following script command:

Code: [Select]
      s = "Bob's Shop"
      $game_shops.make_limited(s, 100)
      $game_shops.disallow_resell(s)

And just like that, we have made Bob very unhappy but at least the game will now accurately reflect the new scenario. Maybe some day, when the Heroes vanquish the evil, his shop can be returned to glory. Or maybe, some donations to Bob might help his return along the way (that's another scenario you could implement with this script).


Screenshots

Just a few select screenshots. I actually took about 20, but figured I'd just put up some show off ones rather than all of them.

Spoiler for:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi671.photobucket.com%2Falbums%2Fvv73%2FTohme_Rhiazanho%2FShopBuyNormal.png&hash=296e10c6ff41085b390ef2de417c32a6380630da)
The Shop scene: A normal shop with all of the normal quirks.

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi671.photobucket.com%2Falbums%2Fvv73%2FTohme_Rhiazanho%2FBobNoMore.png&hash=83479ce4a822ca361d12a3c13c99761f34027986)
Our Shopkeep, Bob, has sold all of his goods at last. Now can go on that vacation he was always telling you about.

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi671.photobucket.com%2Falbums%2Fvv73%2FTohme_Rhiazanho%2FBarneyNoSpace.png&hash=bc719b443a43878891b0b15a4eb5933a2a985c68)
Whilst the Player does have 99 in stock, he can only sell off 20 of them to our Shopkeep with limited space.

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi671.photobucket.com%2Falbums%2Fvv73%2FTohme_Rhiazanho%2FJamesBuyBackRepriced.png&hash=9f8d83f040fca8a138a637377ccfc97aa83e4015)
Buying back your once-thought trash is as easy as. But shops might charge you more than he gave you for the item just because he can.


Instructions

This system currently comprises of 4 necessary scripts and 1 guide. All scripts are provided in the demo.

Necessary
- Enhanced Shopping: Configuration
- Logan Forrests' FF7-style Shop Scene
- Enhanced Shopping: FF7 Shop Scene Add-On
- Enhanced Shopping: Overture
- Modern Algebra's Bitmap Add-on
Guide
- Enhanced Shopping: How To

All of these can be found in the Demo provided.

Script


Scripts can be found in the Demo at the end of this post.

Please note that the RPG Maker VX RTP is required to be installed prior to loading the demo. This is to keep the filesize of the demo to a minimum.


Credit



Thanks


With thanks: Bug Finders

Support


Support for compatibility fixes, bug reports, errors or issues can (and should only) be made here.

Known Compatibility Issues

The Shop Scene script overwrites a lot of the original Shop Scene, so any script that requires the old one of those or modifies it probably won't be too happy to see this. Other than that, I can't imagine too many other compatibility issues popping up. If it does, though, make them known here.

Demo


One has been made, and the latest version can be downloaded from here:

http://www.mediafire.com/?y9t0mqha24cm82r

Latest versions of each script can also be downloaded via the attachments to this post (requires Log On).

Author's Notes


This was designed from scratch after a more botched version I quickly made, where I learned that RPG classes aren't saved making it almost useless to use for anything special. So, I began working on it again to make it useful. Then, along the way, I got some other funny ideas (that, sure, have been seen in other games) and figured I'd try to implement them too. And this is the result.


Restrictions

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi.creativecommons.org%2Fl%2Fby-nc-sa%2F3.0%2F88x31.png&hash=6e1657b010ee0d7b04145ffc62b5f00a1de63ec7)
The series of Enhanced Shopping scripts by Logan Forrests are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License (http://creativecommons.org/licenses/by-nc-sa/3.0/)
Title: Re: Enhanced Shopping (v1.0a)
Post by: modern algebra on November 18, 2011, 02:24:04 AM
Looks great Logan! I'll take a look at the actual code when I get the chance, but the idea is great - shopping in RM has always been terrible.

And I'm glad you feel that rmrk is almost a home; I feel that way too.

Title: Re: Enhanced Shopping (v1.0a)
Post by: cozziekuns on November 18, 2011, 05:05:59 AM
Very neat! It's so customizable and configurable too; really shows the effort you put into this LF!
Title: Re: Enhanced Shopping (v1.0a)
Post by: pacdiggity on November 18, 2011, 05:48:40 AM
This is gorgeous. That is all.
Title: Re: Enhanced Shopping (v1.0a)
Post by: Wiimeiser on November 18, 2011, 06:00:12 AM
Don't think it will work with any of Yanfly's item scripts. Although the only thing I really need this for, if anything, is a joke item you can only buy once.
Title: Re: Enhanced Shopping (v1.0a)
Post by: LoganF on November 18, 2011, 09:28:42 AM
It's likely the code will go through rigorous revamping at some point in the future, especially in the conversion to VX Ace when that arrives in English and I have some spare money to buy a licence for it. So, it may not always be pretty code but as I start to learn more it will get better. Also, I'm very open to suggestions and ideas on improvements to code.

It's not intended to be written with compatibility in mind, but if people do require such a thing I will look into them on an individual request basis.

I'm not sure when I'll get to updating this script to feature unique items that can only be purchased once as I have a number of other important things to get out of the way first.

You can emulate this already though if you use the add_new_item and only add 1 of those items to the shop. As long as the shop isn't "restockable" you won't be able to get more than 1 of them. Whilst this does limit you to having these items in non-restockable shops, for now it's an alternative.

The problem now, though, is that you can sell this item. If you wanted to prevent this, you could make a check after the shop processing to 'swap' the item with an unsellable one - one that has a price of 0.

---

I've updated the OP to include the randomly thought up scenario that makes use of some of the features of this script - namely the easy-access calls to obtain or amend key data during run-time.

Glad you guys like it. It's very warming to hear others' thoughts on it, especially from those of you who I hold with quite high regards in my continuing education in programming. And feel free to offer some suggestions on what other things can be added to the shops. It doesn't matter how crazy or complex it might appear. I'll give it thought and possibly an attempt (though when is an unknown factor).
Title: Re: Enhanced Shopping (v1.0a)
Post by: JonFawkes on November 18, 2011, 11:54:00 PM
Whoa, awesome! The feature I like most is the ability to update the shop items after certain events in the game. I was planning to do it with just events, but this is much better. Great script Logan
Title: Re: Enhanced Shopping (v1.0a)
Post by: yuyu! on November 25, 2011, 02:22:25 AM
Oh my goodness! I was searching tirelessly for a shop script that displayed "ATK, AGI, SPI, DEF" rather then just ATK. But it seems this has even more cool features! Thank you so much for scripting this! I love it :)  +rep to you :)

EDIT:

I might have found a little bug... When on the Buyback screen, I tried to "buyback" nothing and got an error message that crashed the game. I'll attach an image file of it. Just a little bitty bug, unless it's caused by my other scripts somehow xD haha
Title: Re: Enhanced Shopping (v1.0a)
Post by: LoganF on November 25, 2011, 03:24:13 AM
Thanks for the like.

I'll take a look at that issue right now. I remember getting that in a previous version, and must have forgotten about it in the many rewrites I do.

Edit:

For a quick fix on that -

In the script: OV ES FF7 Shop Scene Add-on

change line 425:

Code: [Select]
    return if state #prevents nil:NilClass error

to

Code: [Select]
    return true if state #prevents nil:NilClass error

That will make it work properly. I've uploaded a new demo to fix that issue. Thanks for the find. I intend to rewrite that little method but I find that it gets a little messy trying to write conditionals that include many statements.

Also added something to the features list:


This was already there, just not included. I figured it is actually a good feature.
Title: Re: Enhanced Shopping (v1.0a)
Post by: yuyu! on November 25, 2011, 03:50:30 AM
Perfect fix! That was fast, too! Thank you very much :)

Yeah, I imagine conditionals would be a pain... :(

And that's a wonderful feature. Beforehand, I was actually including those stats in the wep/armor description (which was tacky) and now I don't have to do that! Sweetness :)
Title: Re: Enhanced Shopping (v1.0a)
Post by: yuyu! on November 25, 2011, 06:44:17 AM
Sorry for the double-post, and I hate to be a jerk... but I think I found another bug :( (sorry...) it's just a little one, but I thought I should bring it to your attention.

I made two (normal-style infinite item) shops on my game - one sells items and the other sells weapons/armor. I checked out the item shop, then visited the weapon one to see that all the items from the item shop were included on the buy list of the armor. I exited it, and re-entered the shop and it was fixed. Then I visited the item shop again and the weapon shop's items were included in that shop, as well. Exit, then visit again and it fixed. It seems that it wants to include whatever shop's items last visited on the next shop's list, too... but, upon visiting that shop twice in a row, it fixes. Kinda confusing haha...

Anyways, sorry to have to bring up all these annoying bugs... I guess the bugs really like me. :-[
Title: Re: Enhanced Shopping (v1.0a)
Post by: LoganF on November 25, 2011, 07:24:07 AM
I thought I'd got that one fixed when I found it originally. Seems like I didn't. It used to happen when going from any shop to a general/normal shop, but with only 1 general shop in the demo I'd overlooked the possibility of it affecting normal shops still.

I know what the issue is, but I won't be able to fix it at least until tomorrow now. I'll get to it though, as soon as I can.

Thanks for finding it again.
Title: Re: Enhanced Shopping (v1.0a)
Post by: yuyu! on November 25, 2011, 09:23:10 AM
Thanks again, LoganForrests :) I owe you more rep points for all this trouble!
<----(is an obvious enjoyer of the rep system)
Title: Re: Enhanced Shopping (v1.0b)
Post by: LoganF on November 26, 2011, 12:21:18 AM
Updated the demo with a quick fix to solve that problem. Issue was simply me forgetting that I needed to clear the dummy shop holder (I use for general stores) of its stock once the scene has terminated.
Title: Re: Enhanced Shopping (v1.0b)
Post by: yuyu! on November 26, 2011, 12:44:38 AM
It works perfectly! Thanks as always, LoganForrests! :)

I love the bug finders list haha 8) thank you!
Title: Re: Enhanced Shopping (v1.0b)
Post by: teknoarcanist on November 30, 2011, 08:39:12 PM
Just thought I'd pop on to offer my thanks.  This script is fantastic.  Little touches like the visible stock items on the shelves/counters are GREAT.  I'm fiddling with a game oriented around travel and trade, and this is EXACTLY what I was looking for.  The user guide is very well-done also.

EDIT: I just set up a shop which restocks every seven in-game days, and which raises and lowers its sell price based on remaining supply.  IE, you can buy at the beginning of the week when his supply is high, to save money, or wait until the end of the week to sell him things, as he's getting low on product.  Pretty damn slick man ^^
Title: Re: Enhanced Shopping (v1.0b)
Post by: mitsanaga on December 17, 2011, 05:27:03 AM
so i am new to this and all and its likely my own mistake, but i would really appreciate any help i can get with this lil problem im having.
i keep getting this error.

Script 'OV Enhanced Shopping' line 1104: NoMethodError occurred.
undefined method 'new_shop_flag' for nil:NilClass

i have attached the game without the rtp and there is money in the log to the right hand corner for use to test the shop.
it only happens so far after i have boughten an item and return to the shop. i do have the shop set to 6 seconds before restock, but this happened even when at 30 min as well.

Edit: also i tried seeing if i needed to add true to line 1104 like in line 425 for that other bug but to no avail.
Title: Re: Enhanced Shopping (v1.0b)
Post by: LoganF on December 17, 2011, 06:03:37 AM
Thanks for uploading the project. I'll take a good look at it and see what might be the problem.

Edit:

Ok, it does work as it should do.

The problem is that shops which are made as general stores, like the one you have in the demo, should not be given the properties like make_restockable or make_exhaustable. Only shops with names given by a comment should be made to have these properties.

A shop instance isn't actually created for general stores which is why the nil error comes up when you try to use these extra shop properties for them. Thus, to fix the problem you should either:

a) Create a standard general shop (like the default shop scene) by removing script commands that give the shop properties such as make_restockable, or;

b) Make the shop an enhanced shop by giving it a name in a comment and leaving the properties as they are.

I did want this to only show up for play test mode but for some reason the $DEBUG flag is always false even in debug mode.

I've also fixed it so that it doesn't crash the game when this scenario happens, so you can continue testing/playing regardless of this message.

I have uploaded a version of your demo with the changes and two shop events so that you can see how general shops and enhanced shop differ. The new script can also be found in the opening post of this thread.

Thanks for bringing this to my attention.

The demo can be downloaded via the following link:

http://www.mediafire.com/?rjyd4d8rym8p5y1
Title: Re: Enhanced Shopping (v1.0c)
Post by: mitsanaga on December 18, 2011, 06:24:53 PM
Excellent, that helps a lot. thank you Logan.
i especially like how you put up a warning for the shop that was setup incorrectly. helps a lot more than a nil error lol.
i have some work to go do now and hopefully i dont run into any more problems with anymore scripts in general....
Title: Re: Enhanced Shopping (v1.0a)
Post by: Infinate X on December 18, 2011, 10:42:16 PM
Thanks for the like.

Here, have some more!


A good shop script is always a nice feature to have in a game.



You deserve a: nvm I don't feel like searching through all the emoticons....