He and never they because I am male. 😛
Fallout/Elder Scrolls-style Random Vendor Inventory
RGSS3 Script Requests@Roninator2
Thank you SO MUCH for all the help dude, this script will fit my needs almost exactly! I never thought I'd get help making this since Ace may as well be ancient in the community and it was a niche request, so I hope others looking for this sort of thing use it in their games too! 😤
If there's anything else I need help with regarding the script, I'll let you know.
Thank you SO MUCH for all the help dude, this script will fit my needs almost exactly! I never thought I'd get help making this since Ace may as well be ancient in the community and it was a niche request, so I hope others looking for this sort of thing use it in their games too! 😤
If there's anything else I need help with regarding the script, I'll let you know.
Ok, I found 2 weird bugs. Some of my merchants are supposed to look in a box or bag next to them, their shop pops up, and then they turn back to the player after you look in their shop. However, they aren't doing that, and are facing their bag/box after the shop exits. This only happens the first time you access a particular shop.
Also, you can't sell anything to merchants with the random shop.
Here's one of my random merchant events.
Also, you can't sell anything to merchants with the random shop.
Here's one of my random merchant events.
Interesting.
Maybe put a second move route of turn down. Basically copy paste.
I can't think of anything that would cause an issue with the event. But I can do some more testing.
For the selling, that's easy I set it to true in the script but if it is changed to false then it will allow selling. It was my belief that random shops would not buy from the player.
line 163 it has a true in there, just change it to false.
The true is for the question "sell only shop", you know when you make a shop and the check box at the bottom.
Is it something that this would change in the game or will it always be sell to the random shop?
A quick test and it looks like going to the scene stops the event processing. Might have to figure out a way around that.
Some random shops would buy from the player, and some would not. For instance, a merchant who sells a variety of things vs a merchant who only sells 1 type of good, like food/drinks. The latter would not be interested in purchasing the player's stuff.
Cool, I figured out the issues.
updated code below
I added the option to specify if it is a sell only shop. look at the instructions again
Thanks, the merchant's movement works too.
By the way, do Fallout shops also feature a dirty shopkeeper?
I mean, as dirty as to start extorting you out of the blue... 😀
I mean, as dirty as to start extorting you out of the blue... 😀
After a lot of testing, I think adding the rarity function from Galv's Random Loot (with the rarity minimum and maximum) would also be a good idea. That way, I can tweak vendor's inventory better in lower level areas so they don't sell as many expensive weapons, as those outnumber cheaper weapons.
Not tested, but give it a try.
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Hime Random Shop + Stock ║ Version: 1.04.1 ║
# ║ Author: Roninator2 ║ ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function: ║ Date Created ║
# ║ ╠════════════════════╣
# ║ Random Shop for Hime Shop Manager ║ 11 Jul 2023 ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: ║
# ║ Script order ║
# ║ Galv's Random Loot ║
# ║ Hime Shop Manager ║
# ║ Hime Shop Stock ║
# ║ This Script ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description: ║
# ║ Make the shop stock have a random set of items ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions: ║
# ║ ║
# ║ Script Call ║
# ║ random_shop(type, # of items, Quantity minimum, ║
# ║ Quantity maximum, Shop ID, Sell Only, ║
# ║ Family, Rarity, Rarity min, Rarity Max ) ║
# ║ ║
# ║ type = 0 -> items ║
# ║ 1 -> weapons ║
# ║ 2 -> armours ║
# ║ 3 -> mix of all three ║
# ║ ║
# ║ # of items is how many items to have in the shop ║
# ║ ║
# ║ Quantity is the minimum and maximum number available ║
# ║ for each item in the shop. ║
# ║ ║
# ║ Shop ID is the number used to register with the shop ║
# ║ manager script. ║
# ║ ║
# ║ Sell only is to specify is the player can only buy. ║
# ║ ║
# ║ Family is the group of items that will be included. ║
# ║ ║
# ║ Rarity is the odds of it being in the shop ║
# ║ values range from 1-100 ║
# ║ Follow Galv's Random Loot settings ║
# ║ ║
# ║ random_shop(3, 6, 1, 3, 45, true, 1, 5, 10, 70) ║
# ║ ║
# ║ If the shop number 45 exists then it will pull up that ║
# ║ shop and not create a new one. ║
# ║ ║
# ║ Tag items in database with <random shop item> ║
# ║ then it will be included as an item that can be ║
# ║ selected for the random shop. ║
# ║ ║
# ║ ║
# ║ Reset Shops ║
# ║ If you need to clear out a random shop, then you ║
# ║ can use this script command ║
# ║ reset_shop(id) ║
# ║ The id will be the shop id. Be careful this will ║
# ║ also remove any shops created. ║
# ║ If you use the wrong number, it will remove that shop. ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates: ║
# ║ 11 Jul 2023 - Initial Publish ║
# ║ 12 Jul 2023 - Added Galv Random Loot support ║
# ║ 12 Jul 2023 - Added Resetting shops, fixed bug ║
# ║ 13 Jul 2023 - Added sell shops, fixed bug ║
# ║ 11 Nov 2023 - ReAdded random min/max ║
# ║ 11 Nov 2023 - Altered Random to be independent functions ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks: ║
# ║ Roninator2 ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use: ║
# ║ Follow the original Authors terms of use where applicable ║
# ║ - When not made by me (Roninator2) ║
# ║ Free for all uses in RPG Maker except nudity ║
# ║ Anyone using this script in their project before these terms ║
# ║ were changed are allowed to use this script even if it conflicts ║
# ║ with these new terms. New terms effective 03 Apr 2024 ║
# ║ No part of this code can be used with AI programs or tools ║
# ║ Credit must be given ║
# ╚════════════════════════════════════════════════════════════════════╝
module Random_Shop_Item_Tags
def random_item
if @random_shop_item.nil?
if @note =~ /<random shop item>/i
@random_shop_item = true
else
@random_shop_item = false
end
end
@random_shop_item
end
end
class RPG::Item
include Random_Shop_Item_Tags
end
class RPG::Weapon
include Random_Shop_Item_Tags
end
class RPG::Armor
include Random_Shop_Item_Tags
end
module ShopManager
def self.reset_shop(shop_id)
$game_shops[shop_id] = nil
end
end
class Game_Interpreter
def random_shop(type, num, min, max, shop_id, sell, family=0, rarity=0, rmin=0, rmax=0)
# initialize local variables
goods = []
loot = []
list = []
stack = []
# Check if shop exists
shop = ShopManager.get_shop(shop_id)
if shop == nil
#--- Determine Type
if type == 0
loot = $data_items
elsif type == 1
loot = $data_weapons
elsif type == 2
loot = $data_armors
elsif type == 3
loot = $data_items + $data_weapons + $data_armors
end
# Get all qualifing items
loot.each do |itm|
next if itm.nil?
if itm.random_item
list.push(itm)
end
end
# return if list is empty
return if list.empty?
# If family selection is used
if family > 0
# Select based on family
list = list.select do |thing|
thing.loot_family == family
end
end
# return if list is empty
return if list.empty?
if rmax < rmin
rmax = rmin
end
if rarity > 0
list = list.select do |thing|
(100 - (thing.loot_rarity.to_i * 10)) <= rand(100)
end
end
if (rmin > 0) || (rmax > 0)
luck_bonus = random_loot_luck_bonus()
rchance = rand(rmax - rmin) + rmin + luck_bonus + 1
list = list.select do |thing|
thing.loot_rarity <= rchance
end
end
# return if list is empty
return if list.empty?
# Get list size
cnt = list.size
i = 0
# find whichever is larger, list or number requested
count = (cnt < num) ? cnt : num
count.times do
# iterate through numbers if list is small
if cnt < num
n = i
else
n = rand(cnt)
end
item = list[n]
while stack.include?(item) do
n = rand(cnt)
item = list[n]
end
# add item to checking list
stack.push(item)
# Get random item count
q = rand(max) + 1
@shop_stock[i] = q
itype = 0 if item.is_a?(RPG::Item)
itype = 1 if item.is_a?(RPG::Weapon)
itype = 2 if item.is_a?(RPG::Armor)
# create item for Hime's script
good = make_good([itype, item.id, 0, item.price], i)
goods.push(good)
i += 1
end
# create shop
shop = ShopManager.setup_shop(shop_id, goods, sell, :Shop)
setup_shop(shop)
end
# Goto shop
ShopManager.call_scene(shop)
Fiber.yield
end
# Make a shop empty for recreating
def reset_shop(id)
ShopManager.reset_shop(id)
end
end
#===============================================================================
# END OF SCRIPT
#===============================================================================
Sorry, updated the documentation.
You're missing the rarity min and max in the command.
If it is 0 then no items are in the list so no shop is loaded.
By default the values are 0. I could set them to specific values if needed. Line 111
Line 153 the chance value is probably 1, so 1% chance items are in the shop.
*Update
I restructured it so that rarity and rarity min/max can both be used or not used.
If you use rarity value then items will be randomly filtered out and if you use rarity min/max more items will be filtered out.
But if you did not include the rarity min/max values in the command then it will not make an effect.
The family, rarity, rarity min, rarity max are optional, but if you use rarity max then you need to include the others as well.
You can set rarity to 0 and just use rarity min/max values.
Thank you again for the help! It works great!
Original thread: https://forums.rpgmakerweb.com/threads/fallout-elder-scrolls-style-random-vendor-inventory.156837/