Quest shops

dombo813
23 Jun 2013, 14:05
Im trying to make a realistic rpg with many options that could be done in real life eg. buying something/selling something. I am using the score system as money, so i dont clutter inventories with coins, and that works fine. My only problem is making shops. I would like some way of making a container in which an item inside requires that it has a special verb used on it first (check) so to buy a sword the player would have to use check sword which would display price and uses of item which is easy enough and then could use either buy sword (which would only work if the sword was in it's original container) and then the score would be deducted by say 50 and the sword would be added to inventory, and then a similar function with sell, in which the player has to check first, then sell. the buy and sell would not be able to be used with the "all" thing, like can be done by take all for example. However, I also want it so that the object cannot be taken from the original container, but can be dropped and taken after that. Also is there a way to put an item inside a container?

HegemonKhan
24 Jun 2013, 02:53
Are you able to work with code, or only the GUI~Editor?

-------

here's some libraries for you, though you may have to combine parts of them and also add in the code lines needed for what you want done:

Sora's Stackable Library: viewtopic.php?f=18&t=3515
Pixie's Shop Library: viewtopic.php?f=18&t=2557

-------

I'll try to make my own code for you too, though I'm still a noob with coding, it'll be a good and fun challenge for me, hehe. I'm not anywhere near Sora's (or Pixie's) level, so the container part might be too difficult for me to do, at least at the level of it in Sora's Stackable Library, anyways.

dombo813
27 Jun 2013, 17:52
Thanks very much.. i dont know how to use the code window and want to stick to gui as much as possible, although i think i may have found a very rough way of doing it using a custom verb for each item, although it would be time consuming and rather odd, since the player would be able to buy the same item twice, even if it were already in their inventory.

HegemonKhan
29 Jun 2013, 07:36
this will take too long to try to do in GUI~Editor instructions for you, so hopefully you can figure out how to do this code stuff with the GUI~Editor's capabilities. If not, just ask, and, I or others, can help you.

you could add in some simple coding, to check if you got the item in your inventory, and then prevent you from buying it, if you do, to keep you from getting two of the same items in your inventory.

I don't know how you got your code set up, but hopefully you can take this general guideline, and apply it to your own code:

<command name="buy_command">
<pattern>buy #text#</pattern>
<script>
if (GetBoolean(game.pov.parent, "shop")) {
item=GetObject(text)
if (item=null) {
foreach (obj,ScopeVisibleNotHeldForRoom(game.pov.parent)) {
if (obj.alias=text) {
item=obj
} else {
msg ("Seemingly " + text + "isn't an item that you can buy.")
}
}
}
foreach (inv_obj,ScopeInventory()) {
if (not inv_obj.alias=item.alias) {
if (HasInt(item, "price")) {
if (item.price < game.pov.cash) {
msg ("You bought the " + item.alias +".")
item.take=true
item.scenery=false
item.parent=game.pov
game.pov.cash = game.pov.cash - item.price
} else {
msg ("Sorry, but you can't afford it.")
}
} else {
msg ("Sorry, but it's not for sale.")
}
} else {
msg ("You already have " + item.article +".")
}
}
} else {
msg ("You're not in a shop, so you can't buy anything.")
}
</script>
</command>


you'll need to add in all the needed attributes and stuff of course.

---------

P.S.

I'm working on a full code for what you wanted in your OP, but it's very extensive of what you ask, and will take me a very long time to complete, if I can even do so. I didn't realize how massive and complex a project it was at the time, so don't expect any code from me on it for quite a long while, if at all. Though, I'll try to work on it, as I've got the time to do so, but don't be waiting around for me, or you'll be waiting a very long time.