# * Regex# Auction Chance: <auction chance (\d+)># Auction Buy Price Range %: <auction range (\d+) (\d+)># Auction Sell Price Range %: <auction sell (\d+) (\d+)># Auction Limit: <auction limit (\d+) (\d+)># * Script Calls# $zetu_auction.activate_auction(id)# Use a Different id for each unique auction house, prior to shop processing# $zetu_auction.clear_auction(id)# Clears an auction, so that next time it is activated, a different randomization occurs# $zetu_auction.houses[id].set_timer(seconds, symbol)# Sets a timer that runs on the map, while Interpreter is not running.# Note, symbol can be a string ("active") or symbol (:active)# $zetu_auction.houses[id].time_left(symbol)# Returns a number of seconds left before timer is finished.# ex. "$game_variables[5] = $zetu_auction.houses[id].time_left(symbol)" will put seconds left in variable 5# $zetu_auction.houses[id].timed_out?(symbol)# Returns true/false, on if the timer has become 0# ex1. "$game_switches[5] = $zetu_auction.houses[id].timed_out?(symbol)" will put the condition in switch 5# ex2. On Conditional Branch, use Script: $zetu_auction.houses[id].timed_out?(symbol)module ZEV module AuctionHouse SwitchesToHoldAuctions = [21] module Regex AuctionChance = /<auction chance (\d+)>/i AuctionRange = /<auction range (\d+) (\d+)>/i AuctionSell = /<auction sell (\d+) (\d+)>/i AuctionLimit = /<auction limit (\d+) (\d+)>/i end end if !Imported msgbox 'One or More Scripts Require Zetu Engine V' exit end puts 'LOAD: Zetu Engine V - Auction House' Imported[:auction] = true GameObjects[:auction] = ['$zetu_auction', 'ZEV::Game_Auctions']endclass ZEV::Game_Auctions attr_reader :houses def initialize @houses = ZEV::Houses.new @active = nil end def update unless $game_map.interpreter.running? @houses.values.each do |auction| auction.timer.each do |symbol, time| if time > 0 auction.timer[symbol] -= 1 end end end end end def activate_auction(id) @active = id end def clear_auction(id) @houses[id].reset @active = nil end def close_auction @active = nil end def active_auction @houses[@active] end endclass ZEV::Houses def initialize @data = {} end def [](id) @data[id] = ZEV::Game_Auction.new unless @data[id] @data[id] end def values @data.values end endclass ZEV::Game_Auction attr_accessor :data, :price, :qty, :sell attr_reader :active, :timer def initialize reset @timer = {} end def reset @active = false @data = [] @price = {} @qty = {} @sell = {} end def active? @active end def activate @active = true end def set_timer(seconds, symbol) @timer[symbol] = seconds * Graphics.frame_rate end def timed_out?(symbol) (@timer[symbol] || 0) <= 0 end def time_left(symbol) (@timer[symbol] || 0) / Graphics.frame_rate end endclass Window_ShopBuy < Window_Selectable attr_reader :auction, :qty, :data alias :zev_auction_make_item_list :make_item_list def make_item_list @auction = $zetu_auction.active_auction if @auction if @auction.active? @data = @auction.data @price = @auction.price @qty = @auction.qty else @auction.activate @data = [] @price = {} @qty = {} @shop_goods.each do |goods| case goods[0] when 0; item = $data_items[goods[1]] when 1; item = $data_weapons[goods[1]] when 2; item = $data_armors[goods[1]] end if item and check_pi_for_auction_avalibility(item) @data.push(item) @price[item] = goods[2] == 0 ? get_item_auction_price(item) : goods[3] q = get_item_auction_qty(item) @qty[item] = q if q != -1 end end @auction.data = @data @auction.price = @price @auction.qty = @qty end else zev_auction_make_item_list end end def check_pi_for_auction_avalibility(item) if item.note =~ ZEV::AuctionHouse::Regex::AuctionChance return rand * 100.0 < $1.to_f else return true end end def get_item_auction_price(item) if item.note =~ ZEV::AuctionHouse::Regex::AuctionRange r1 = $1.to_f r2 = $2.to_f dif = (r1 - r2).abs return ((rand(dif + 1) + [r1, r2].min) * item.price / 100).to_i else return item.price end end def get_item_auction_qty(item) if item.note =~ ZEV::AuctionHouse::Regex::AuctionLimit r1 = $1.to_f r2 = $2.to_f dif = (r1 - r2).abs return (rand(dif + 1) + [r1, r2].min).to_i else return -1 end end endclass Scene_Shop < Scene_MenuBase alias :zev_auction_max_buy :max_buy def max_buy if @buy_window.auction max = $game_party.max_item_number(@item) - $game_party.item_number(@item) buying_price == 0 ? max : [max, money / buying_price].min return [max, @buy_window.qty[@item] || 99].min.to_i else return zev_auction_max_buy end end alias :zev_auction_do_buy :do_buy def do_buy(number) zev_auction_do_buy(number) auction = @buy_window.auction if auction if auction.qty[@item] and @buy_window.qty[@item] auction.qty[@item] -= number if auction.qty[@item] == 0 auction.data.delete(@item) end end end end def return_scene super $zetu_auction.close_auction end alias :zev_auction_selling_price :selling_price def selling_price if (a = $zetu_auction.active_auction) s = a.sell[@item] || get_auction_sell_price(@item) puts s return a.sell[@item] = s else return zev_auction_selling_price end end def get_auction_sell_price(item) if item.note =~ ZEV::AuctionHouse::Regex::AuctionSell r1 = $1.to_f r2 = $2.to_f dif = (r1 - r2).abs return ((rand(dif + 1) + [r1, r2].min) * item.price / 100).to_i else return item.price end end endclass Window_ShopStatus < Window_Base def refresh contents.clear draw_possession(4, 0) draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem) auction = $zetu_auction.active_auction if auction draw_auction(4, line_height, auction) end end def draw_auction(x, y, auction) rect = Rect.new(x, y, contents.width - 4 - x, line_height) change_color(system_color) draw_text(rect, "Amount Left") change_color(normal_color) draw_text(rect, auction.qty[@item] || 99, 2) end endclass Scene_Map < Scene_Base alias :zev_auction_update :update def update zev_auction_update $zetu_auction.update end end