Simple shop instructions

I'm trying to get a shop in my games to work, but I can't quite do it. I need some simple instructions on how to make a shop, please! Thank you!


See here:
https://github.com/ThePix/quest/wiki/Setting-Up-Shop


you can add in more too, such as 'ownership' of items (similar to how Pixie uses his 'cloneme' Boolean Attribute for indicating/flagging it as a clone: a bought item, except it'd be a String Attribute of the item's parent's name), like in TES:Morrowind (I've not played Oblivion/Skyrim, so I don't know how they handle shopping), for if you try to sell a stolen item back to the same shop, you get arrested.

also, note that you got two options: either the room has-ownership/holds the items or the 'shop_owner' Object has-ownership/holds the items: as clones, the original items, and/or as list items: references/pointers of the items


Pixie has a shopping system already set up in quest v570 and with his 'shopping' or 'combat 3.0' library file, as described in his link in his post above


the basic implementation of shopping:

transactions and optionally: having various controls/conditions, such as: price (buying/selling), when/where you can shop, stealing/stealth system, 'ownership', 'item stacking', etc etc etc

buying example as scripting (as a 'buy' Verb on your NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT):

// initial: sword.parent = NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT // the shop or the shop owner has the sword

if (player.current_currency < sword.price) {
  msg ("you can't afford the sword!")
} else {
  player.current_currency = player.current_currency - sword.price
  NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT.current_currency = NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT.current_currency + sword.price
  sword.parent = player // you bought the sword, so now you get and have it
}

// --------------------------------------------

selling example as scripting (as a 'sell' Verb on your NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT):

// initial: sword.parent = player // you have the sword

selling_integer_variable = sword.price / 2 // in old RPGs, you can only sell for half price, lol. Otherwise, you can use a haggle/mercantile skill to adjust how much you can sell (and buy too for that matter) it for (see, TES: morrowind, for example)

if (NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT.current_currency < selling_integer_variable) {
  msg ("They/It can't afford to buy the sword from you.")
} else {
  NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT.current_currency = NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT.current_currency - selling_integer_variable
  player.current_currency = Nplayer.current_currency + selling_integer_variable
  sword.parent = NAME_OF_SHOP_ROOM_OR_NAME_OF_SHOP_OWNER_NPC_OBJECT // you sold the sword to them/it, so now they/it get and have the sword
}

Is it a trading shop, like... I'll trade you one diamond for a sword and a screwdriver for a roll of duct tape. Or are you wanting to accumulate/stack gold pieces and buy a shield for 222gp? The first is way easy. The second gets much more complex.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums