Random shops items based on level

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV
So, I'm looking for a script that mimic the shop system in skyrim.

The shop will sell random items based on the actors lv, and you can also specify if the shop only sells items, weapon, armors, or a combination of them. This isn't really necessary for me but would be cool if the shop has a sell feature where I can only sell the types of items that the NPC is selling.

The shop will change it's inventory every few days.

This isn't necessary but again would be cool if the script will work together with the Advanced Game Time + Night/Day v1.2.3

if that isn't possible maybe make the time in real time minutes or frames.

Thanks in advance for anyone willing to make this script for me, or point out a script that works like it. I've been looking for one on my own but haven't found any yet.

Almost forgot...

The shop's random feature should have a way to make it so some items has a higher chance to appear in the the shop than others. This way I can put some elite weapons in the shop that has a low chance of appearing.
 
Last edited by a moderator:

Reedo

Coder
Veteran
Joined
Sep 17, 2013
Messages
71
Reaction score
38
First Language
English
Primarily Uses
Please try this script.

This should be most of what you are asking for.  The only thing not implemented is the custom selling.

The script should be able to support your day/night script, providing that day/night script can give you some kind of value representing the current "date" so that you can create a unique integer to use as the random seed in this script.

All of the usage and config info is in the script comments.  Please let me know how this works for you.

Code:
#################################################################################  RRSBL - Reedo's Random Shop-by-Level##  Version 0.2##  September 30, 2013##  By Reedo#################################################################################  REFERENCES####  None.  This is an original script by Reedo.#################################################################################  FEATURES####  + Allows shop processing to use a random selection of items determined##    by the player's current level.##  + Individual items-per-level also have their own chance of appearing.##  + Simple event command script calls control shop processing options.##  + Possible to control "random" selection based on some other value.##  + Selection can be limited by "shop type".###################################################################################  COMPATIBILITY####  Should be compatible with most other scripts.#################################################################################  REQUIREMENTS####  Script commands in events to activate/control random shop processing.#################################################################################  INSTALLATION####  Plug-and-play####  Insert below Materials, above other add-on scripts.#################################################################################  RIGHTS & RESTRICTIONS####  As with most Reedo scripts, this script is free to re-use, as-is, ##  in personal, educational, and commercial RPGVX Ace development projects, ##  providing that:  this script is credited in writing displayed readily ##  to the user of the final compiled code assembly.####  Reedo retains all rights of intellect and ownership.##  You forego all rights of warranty by utilizing this script.################################################################################################################################################################  USER OPTIONS################################################################################# The following variables have been added to the Game_Interpreter to support## using this script:## @reedo_random_shop   <- Set to True to enable random shopping, Nil/False to disable.## @reedo_item_min      <- Set minimum number of items to show in shop.## @reedo_item_max      <- Set maximum number of items to show in shop.## @reedo_random_seed   <- Control the "random" selection by setting this value; set Nil for new random selection ever time.## @reedo_shop_type     <- Set to a single shop type keyword, or array of shop type keywords.## In any event that will show a shop scene where you want to use the random## shopping, be sure to set @reedo_random_shop = true in a script command before## you begin the shop scene processing.## You can set the @reedo_item_min/max variables before shop scene processing to## set the number of items for sale in each shop. If you do not set these values## for each event, then the defaults defined in RSSBL are used instead.## You can set the @reedo_random_seed to specific value to force the "random"## selection to be the same every time.  If you had another script such as a## calendar that could give you a unique value every "day", then you could set## the random seed to this value to force the same selection for an entire day,## and create a new random selection on the next day.## All other options are configured below:module RRSBL  SHOP_ITEMS = {} # Do not modify; configured below.    # Min number of items to show in shop  ITEM_COUNT_MIN = 1  # Max number of items to show in shop; set min = max to always show the same amount  ITEM_COUNT_MAX = 3  # Auto-reset the random shop after use if true.  AUTO_RESET_RANDOM = true    # ITEM CONFIGURATION  #  Enter items as array of sales-item, percent chance to be sold, and optional  #    shop type name used to filter selection with @reedo_shop_type.  #  Sales-item array consists of:  #    [type, id, defaultPrice, price]  #   Where type = 0 for items, 1 for weapons, and 2 for armor  #         id = the item id from the database  #         defaultPrice = 0 to use item price, or 1 to use custom price  #         price = the custom price, or nil when defaultprice = 0  #  Percent chance is a float between 0.0 (0% chance) and 1.0 (100% chance)  #  Shop type name is a single string or array of strings used to further  #    restrict the possible random item selection.    # Configure possible items when level is equal or greater than 1  LEVEL_1_ITEMS = []  LEVEL_1_ITEMS.push([[0, 1, 0, nil], 1.0, "items"])  LEVEL_1_ITEMS.push([[1, 1, 0, nil], 1.0, "weapons"])  LEVEL_1_ITEMS.push([[2, 1, 0, nil], 1.0, "armor"])    # Configure possible items when level is equal or greater than 3  LEVEL_3_ITEMS = []  LEVEL_3_ITEMS.push([[0, 2, 0, nil], 1.0])  LEVEL_3_ITEMS.push([[1, 2, 0, nil], 1.0])  LEVEL_3_ITEMS.push([[2, 2, 0, nil], 1.0])    # Create and configure more items as needed...    # Add all configured items-per-level to the SHOP_ITEMS hash  SHOP_ITEMS[1] = LEVEL_1_ITEMS  SHOP_ITEMS[3] = LEVEL_3_ITEMS  end#################################################################################  MAIN SCRIPT#################################################################################  EDITS BEYOND THIS POINT ARE AT YOUR OWN RISK!!!###############################################################################class Game_Interpreter  #--------------------------------------------------------------------------  # * Shop Processing  #--------------------------------------------------------------------------  alias reedo_rrsbl_gi_command_302 command_302  def command_302    return if $game_party.in_battle    if !@reedo_random_shop      reedo_rrsbl_gi_command_302    else      @reedo_random_shop = nil if RRSBL::AUTO_RESET_RANDOM      index = 1      level = $game_player.actor.level      RRSBL::SHOP_ITEMS.keys.each do |key|        if (key > index - 1) || (key > level) then          break        else          index += 1        end      end      goods = []            min = @reedo_item_min      min = RRSBL::ITEM_COUNT_MIN if !min      max = @reedo_item_max      max = RRSBL::ITEM_COUNT_MAX if !max      oldseed = nil      oldseed = srand(@reedo_random_seed) if @reedo_random_seed            possible = []      RRSBL::SHOP_ITEMS[index].each do |item|        if item.size > 2 && @reedo_shop_type && @reedo_shop_type.size > 0          next if !@reedo_shop_type.include?(item[2])        end        if rand <= item[1]          possible.push(item[0])        end      end                  count = [min, rand(max + 1)].max      count.times do |cnt|        selectedindex = rand(possible.size)        goods.push(possible[selectedindex])        possible.delete_at(selectedindex)        break if possible.size == 0      end            srand(oldseed) if oldseed      SceneManager.call(Scene_Shop)      SceneManager.scene.prepare(goods, @params[4])      Fiber.yield    end  end  end
 
Last edited by a moderator:

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV
It looks like what I've been looking for, I haven't tested it yet. Doing that now.

I saw this line 

AUTO_RESET_RANDOM = trueand was wondering how can I make it so it randomizes every day or every 2 days based on the day/night script?

Edit:

Would all the shop be selling the same things, or can I have shops that sell different things.

It would be cool if there were shop ID where I can have different shops that sell different types of things. 

Like one sells every type of item, another only sells weapons, etc..
 
Last edited by a moderator:

Reedo

Coder
Veteran
Joined
Sep 17, 2013
Messages
71
Reaction score
38
First Language
English
Primarily Uses
It looks like what I've been looking for, I haven't tested it yet. Doing that now.

I saw this line 

AUTO_RESET_RANDOM = trueand was wondering how can I make it so it randomizes every day or every 2 days based on the day/night script?

Edit:

Would all the shop be selling the same things, or can I have shops that sell different things.

It would be cool if there were shop ID where I can have different shops that sell different types of things. 

Like one sells every type of item, another only sells weapons, etc..
The way this works, you will create a event command to show the shop scene like normal.  But when you setup the event shop command, you will just give it one item of any kind just so you can close the window (it won't let you add an empty shop).  You also set the sell checkbox as normal.  The key to using the script is to put a script command in the event before you show the scene, and enter this into the script command text box:

@reedo_random_shop = true

Here's an example of an NPC showing a random shop.  The shop originally showed the Bread, Apple, and Weak Berry Wine, but with the Script line above it, it will show a random selection by level instead:

shopscript1.jpg

But, all shop events on the map will also be random after you call that script command one time.  So the auto-reset option makes it so that you have to use that script command explicitly for each shop that has random items.  If all of your shops have random items, then you only need to call that script command once per map and you can set the auto-reset option to false. 

For your day/night script, you just need a number that represents the current day.  Then you can use this as the seed (use an event script command to set @reedo_random_seed to the day number) and then the shop will have a new random selection every day instead of every time you shop.

If you give me a link to the script I can probably find an appropriate script event call for you to make.

If you want different shops to have a different random selection, just add a unique fixed value to the seed for each event.

-EDIT-

"It would be cool if there were shop ID where I can have different shops that sell different types of things. 

Like one sells every type of item, another only sells weapons, etc.."

Sorry, just realized... I'll probably have to make some modifications for this... but it's doable.
 
Last edited by a moderator:

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV
Thanks a lot dude, I 100% understand how it works now. I still kinda need help with how to add it to the day and night system.

I'm not sure if you would do it like this:

@reedo_random_seed = GameTime.day_week?

here's the script:

#Advanced Game Time + Night/Day v1.2.3#----------##Features: Provides a series of functions to set and recall current game time# as well customizable tints based on current game time to give the# appearance of night and day in an advanced and customizable way.##Usage: Script calls:# GameTime.sec? #current second# GameTime.min? #current minute# GameTime.hour? #current hour# GameTime.hour_nom? #current hour (12-hour)# GameTime.day? #current day of month# GameTime.day_week? #current day of the week# GameTime.month? #current month# GameTime.year? #current year# GameTime.year_post("set") #changes the year post to set# GameTime.pause_tint(true/false) #pauses/unpauses tint# GameTime.notime(true/false) #stops time based on true/false# GameTime.change(s,m,h,d,dw,mn,y) #manually set the time# seconds,minutes,hours,days,weekday,months,years# any can be nil to not be changed# GameTime.set("handle",n) #increases a certain time portion# valid arguments are:# addsec,addmin,addhour,addday# addmonth,addyear# and:# remsec,remmin,remhour,remday# remmonth,remyear# GameTime.clock?(true/false) #hides/shows the clock# GameTime.save_time #saves the current time# GameTime.load_time #loads the saved time## Message Codes:# GTSEC #Inputs the current second# GTMIN #Inputs the current minute# GTHOUR #Inputs the current hour# GTDAYN #Inputs the day of the month# GTDAYF #Inputs the day of the week (full)# GTDAYA #Inputs the day of the week (abbreviated)# GTMONN #Inputs the month of the year# GTMONF #Inputs the name of the month (full)# GTMONA #Inputs the name of the month (abbreviated)# GTYEAR #Inputs the current year## Map Note Tags: (These go in the note box of Map Properties)# Notint #These maps will not tint!# Notime #Stops time from moving in that map# #Customization: Set below, in comments.##Examples: GameTime.pause_tint = false# GameTime.change(nil,30,4,1,1,1,2012)# GameTime.set("addyear",5)# GameTime.clock?(true)##----------##-- Script by: V.M of D.T#--- Free to use in any non-commercial project with credit given#_# BEGIN_CUSTOMIZATION #_##Wether or not to set time to PC (Real) TimeUSE_REAL_TIME = false#Time does not increase while the message window is visible:NOTIMEMESSAGE = false#Time does not increase unless you are on the mapPAUSE_IN_MENUS = false#Time does not increase if you are in battleNOBATTLETIME = false#Date is shown on the clockUSECLOCKDATE = true#Clock is shownUSECLOCK = true#Set to true to have the clock show up in the menu!USECLOCK_MENU = true#True if you want to use 24-hour clock or have a different # of hours in a dayMILITARY_CLOCK = false#Clock window background opacityCLOCK_BACK = 0#Button to be used to toggle the clockCLOCK_TOGGLE = :ALT#X and Y position of clockCLOCK_X = 210 #210, 0CLOCK_Y = 0#Finetune the widuth of the clock window here:CLOCK_WIDTH = 150#Whether or not those little dots on the clock blinkUSE_BLINK = true#The speed at which they blinkBLINK_SPEED = 40#Set to tru if you want to use a custom clockUSE_CUSTOM_CLOCK = false#Here is where you would insert the array of commands for the custom clock:CUSTOM_CLOCK = ["weekshort"]CUSTOM_CLOCK2 =["hour12","blinky","min","","meri"]#Available commands for CUSTOM_CLOCK:# "sec" - seconds "min" - minutes # "hour" - hour (24) "hour12" - hour (12)# "meri" - AM/PM "day" - day of the month# "weekshort" - day of the week abbr# "weeklong" - day of the week long# "month" - month "monthshort" - month name abbr# "monthlong" - month name# "year" - year "yearp" - year post # "blinky" - those blinky dots#Using KHAS lighting effects script? Turn this on to use that tintUSE_KHAS = false#Variables that count down each gametime second/minuteTIMER_VARIABLES = [12]#Use Tint in the BattlesBATTLE_TINT = false#Time it takes for a second (or minute) to pass, in frames#(Frame rate is 60 frames per second)TIMELAPSE = 4#Whether to use seconds or notNOSECONDS = false#Number of seconds in a minuteSECONDSINMIN = 60#Number of minutes in an hourMINUTESINHOUR = 60#Number of hours in a dayHOURSINDAY = 24#Names of the days (As little or as many days in the week as you want)DAYNAMES = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]#Day name abbreviationsDAYNAMESABBR = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]#Number of days in each month (Also represents number of months in a year)MONTHS = [31,28,31,30,31,30,31,31,30,31,30,31]#Names of the monthsMONTHNAMES = ["January","February","March","April","May","June", "July","August","September","October","November","December"]#Abrreviated names of the monthsMONTHNAMESABBR = ["Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"]#The default letters to be posted before the year in datesDEFAULT_YEAR_POST = "AD"#NOT YET IMPLEMENTED *IGNORE*USE_PERIODS = false #Gradual tint effects! (The hardest part)#It may look daunting, and it is, but here is where you put the tint#to be shown at each hour (the actual tint is usually somewhere in between)#The number of Color.new objects here must equal the number of hours in a day#Starts from hour 0 (or 12am)#A color object is -> Color.new(r,g,b,a)# Where r is red,g is green,b is blue,and a is opacity and all are (0-255)TINTS = [Color.new(30,0,40,230), Color.new(20,0,30,220), Color.new(20,0,30,210), Color.new(10,0,30,210), Color.new(10,0,30,205), Color.new(0,0,20,125), Color.new(80,20,20,125), Color.new(130,40,10,105), Color.new(80,20,10,85), Color.new(0,0,0,65), Color.new(0,0,0,35), Color.new(0,0,0,15), Color.new(0,0,0,0), Color.new(0,0,0,0), Color.new(0,0,0,5), Color.new(0,0,0,15), Color.new(0,0,0,25), Color.new(0,0,10,55), Color.new(80,20,20,150), Color.new(0,0,25,200), Color.new(10,0,30,205), Color.new(10,0,50,235), Color.new(20,0,30,210), Color.new(20,0,30,220)]#NOT YET IMPLEMENTED *IGNORE*PERIODS = [["Night",0,5], ["Morning",6,11], ["Afternoon",12,17], ["Evening",18,23]] #_# END CUSTOMIZATION #_# module GameTime def self.run $game_time = Current_Time.new $game_time_tint = Sprite_TimeTint.new end def self.update return if $game_message.busy? and NOTIMEMESSAGE if !SceneManager.scene.is_a?(Scene_Map) and PAUSE_IN_MENUS return unless SceneManager.scene.is_a?(Scene_Battle) and !NOBATTLETIME end $game_time.update $game_time_tint = Sprite_TimeTint.new if $game_time_tint.disposed? $game_time_tint.update end def self.sec? return $game_time.sec end def self.min? return $game_time.min end def self.hour? return $game_time.hour end def self.hour_nom? hour = $game_time.hour hour -= 12 if hour > 11 hour = 12 if hour == 0 return hour end def self.day? return $game_time.day + 1 end def self.day_week? return $game_time.dayweek end def self.day_name return DAYNAMES[$game_time.dayweek] end def self.day_name_abbr return DAYNAMESABBR[$game_time.dayweek] end def self.month_name_abbr return MONTHNAMESABBR[$game_time.month] end def self.month? return $game_time.month + 1 end def self.month_name return MONTHNAMES[$game_time.month] end def self.year? return $game_time.year end def self.pause_tint(set) @pause_tint = set end def self.change(s = nil,m = nil,h = nil,d = nil,mn = nil,y = nil) $game_time.manual(s,m,h,d,mn,y) end def self.set(handle,n) $game_time.forward(handle,n) end def self.clock?(set) SceneManager.scene.clock_visible?(set) end def self.year_post(set) $game_time.year_post = set end def self.save_time $saved_game_time = $game_time.dup end def self.load_time $game_time = $saved_game_time.dup end def self.no_time_map note = $game_map.map_note /Notime/ =~ note return false unless $~ return true end def self.notime(set) $game_time.notime = set end class Current_Time attr_reader :sec attr_reader :min attr_reader :hour attr_reader :day attr_reader :dayweek attr_reader :month attr_reader :year attr_accessor :year_post attr_accessor :notime def initialize reset_all_values end def reset_all_values @sec = 0 @min = 0 @hour = 0 @day = 0 @dayweek = 0 @month = 0 @year = 0 @notime = false @year_post = DEFAULT_YEAR_POST end def update return realtime if USE_REAL_TIME return if GameTime.no_time_map or @notime return unless Graphics.frame_count % TIMELAPSE == 0 NOSECONDS ? addmin(1) : addsec(1) update_timers end def update_timers return unless TIMER_VARIABLES.size > 0 for i in TIMER_VARIABLES $game_variables -= 1 unless $game_variables == 0 end end def realtime @sec = Time.now.sec @sec = 0 if @sec == 60 @min = Time.now.min @hour = Time.now.hour @day = Time.now.day @dayweek = Time.now.wday @month = Time.now.month @year = Time.now.year 0 end def addsec(s) @sec += s return unless @sec == SECONDSINMIN @sec = 0 addmin(1) end def addmin(m) @min += m return unless @min == MINUTESINHOUR @min = 0 addhour(1) end def addhour(h) @hour += h return unless @hour == HOURSINDAY @hour = 0 addday(1) end def addday(d) @day += d @dayweek += d @dayweek = 0 if @dayweek == DAYNAMES.size return unless @day == MONTHS[@month] @day = 0 addmonth(1) end def addmonth(mn) @month += mn return unless @month == MONTHS.size @month = 0 addyear(1) end def addyear(y) @year += y end def manual(s = nil,m = nil,h = nil,d = nil,dw = nil,mn = nil,y = nil) @sec = s if !s.nil? @sec = SECONDSINMIN - 1 if @sec >= SECONDSINMIN @min = m if !m.nil? @min = MINUTESINHOUR - 1 if @min >= MINUTESINHOUR @hour = h if !h.nil? @hour = HOURSINDAY - 1 if @hour >= HOURSINDAY @day = d if !d.nil? @day = MONTHS[@month] - 1 if @day >= MONTHS[@month] @dayweek = dw if !dw.nil? @dayweek = 0 if @dayweek >= DAYNAMES.size @month = mn if !mn.nil? @month = MONTHS.size - 1 if @month >= MONTHS.size @year = y if !y.nil? end def forward(handle,n) handle = handle.to_s + "(1)" n.times do |s| eval(handle) end end def remsec(s) @sec -= s return unless @sec == -1 @sec = SECONDSINMIN remmin(1) end def remmin(m) @min -= m return unless @min == -1 @min = MINUTESINHOUR remhour(1) end def remhour(h) @hour -= h return unless @hour == -1 @hour = HOURSINDAY - 1 remday(1) end def remday(d) @day -= d @dayweek -= d @dayweek = DAYNAMES.size - 1 if @dayweek == -1 return unless @day == -1 @day = MONTHS[@month] - 1 remmonth(1) end def remmonth(mn) @month -= mn return unless @month == -1 @month = MONTHS.size - 1 remyear(1) end def remyear(y) @year -= y end end class Sprite_TimeTint < Sprite_Base def initialize(viewport = nil) super(viewport) self.z = 100 create_contents update end def create_contents self.bitmap = Bitmap.new(Graphics.width,Graphics.height) self.visible = false end def update return use_khas if USE_KHAS create_contents if self.bitmap.height != Graphics.height create_contents if self.bitmap.width != Graphics.width self.visible = SceneManager.scene.is_a?(Scene_Map) self.visible = true if SceneManager.scene.is_a?(Scene_Battle) and BATTLE_TINT self.visible = false if no_tint self.bitmap.clear if no_tint return unless self.visible ctint = TINTS[$game_time.hour] ntint = TINTS[$game_time.hour + 1] unless $game_time.hour + 1 == HOURSINDAY ntint = TINTS[0] if $game_time.hour + 1 == HOURSINDAY return if ctint.nil? or ntint.nil? min = $game_time.min r = ctint.red.to_f - ((ctint.red.to_f - ntint.red) * (min.to_f / MINUTESINHOUR)) g = ctint.green.to_f - ((ctint.green.to_f - ntint.green) * (min.to_f / MINUTESINHOUR)) b = ctint.blue.to_f - ((ctint.blue.to_f - ntint.blue) * (min.to_f / MINUTESINHOUR)) a = ctint.alpha.to_f - ((ctint.alpha.to_f - ntint.alpha) * (min.to_f / MINUTESINHOUR)) self.bitmap.clear self.bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(r,g,b,a)) unless USE_KHAS end def use_khas begin temp = $game_map.light_surface.opacity rescue return end $game_map.effect_surface.change_color(0,0,0,0) if no_tint $game_map.effect_surface.set_alpha(0) if no_tint return if no_tint ctint = TINTS[$game_time.hour] ntint = TINTS[$game_time.hour + 1] unless $game_time.hour + 1 == HOURSINDAY ntint = TINTS[0] if $game_time.hour + 1 == HOURSINDAY min = $game_time.min r = ctint.red.to_f - ((ctint.red.to_f - ntint.red) * (min.to_f / MINUTESINHOUR)) g = ctint.green.to_f - ((ctint.green.to_f - ntint.green) * (min.to_f / MINUTESINHOUR)) b = ctint.blue.to_f - ((ctint.blue.to_f - ntint.blue) * (min.to_f / MINUTESINHOUR)) a = ctint.alpha.to_f - ((ctint.alpha.to_f - ntint.alpha) * (min.to_f / MINUTESINHOUR)) $game_map.effect_surface.change_color(0,r,g, $game_map.effect_surface.set_alpha(a) end def no_tint return if $game_map.nil? note = $game_map.map_note /Notint/ =~ note return false unless $~ return true end end class Window_GameClock < Window_Base def initialize super(CLOCK_X,CLOCK_Y,CLOCK_WIDTH,clock_height) self.opacity = CLOCK_BACK update end def clock_height return 80 unless CUSTOM_CLOCK2.nil? return 56 end def update contents.clear string = normal_clock string = dated_clock if USECLOCKDATE and !MILITARY_CLOCK string = military_clock if MILITARY_CLOCK string = dated_military_clock if MILITARY_CLOCK and USECLOCKDATE string = custom(CUSTOM_CLOCK) if USE_CUSTOM_CLOCK string2 = custom(CUSTOM_CLOCK2) unless CUSTOM_CLOCK2.nil? contents.draw_text(0,0,contents.width,24,string,1) contents.draw_text(0,24,contents.width,24,string2,1) unless CUSTOM_CLOCK2.nil? or !USE_CUSTOM_CLOCK end def military_clock hour = $game_time.hour minute = $game_time.min if hour < 10 then hour = " " + hour.to_s else hour.to_s end if minute < 10 then minute = "0" + minute.to_s else minute.to_s end string = hour.to_s + blinky + minute.to_s return string end def dated_military_clock hour = $game_time.hour minute = $game_time.min dayweek = DAYNAMESABBR[$game_time.dayweek] day = $game_time.day day += 1 unless USE_REAL_TIME if hour < 10 then hour = " " + hour.to_s else hour.to_s end if minute < 10 then minute = "0" + minute.to_s else minute.to_s end if day < 10 then day = " " + day.to_s end string = dayweek.to_s + " " + day.to_s + " " string += hour.to_s + blinky + minute.to_s return string end def normal_clock meri = "AM" hour = $game_time.hour minute = $game_time.min if hour > 11 then meri = "PM" end if hour == 0 then hour = 12; meri = "AM" end if hour > 12 then hour -= 12 end if hour < 10 then hour = " " + hour.to_s else hour.to_s end if minute < 10 then minute = "0" + minute.to_s else minute.to_s end string = hour.to_s + blinky + minute.to_s + " " + meri return string end def dated_clock meri = "AM" hour = $game_time.hour minute = $game_time.min dayweek = DAYNAMESABBR[$game_time.dayweek] day = $game_time.day day += 1 unless USE_REAL_TIME if hour > 11 then meri = "PM" end if hour == 0 then hour = 12; meri = "AM" end if hour > 12 then hour -= 12 end if hour < 10 then hour = " " + hour.to_s else hour.to_s end if minute < 10 then minute = "0" + minute.to_s else minute.to_s end if day < 10 then day = " " + day.to_s end string = dayweek.to_s + " " + day.to_s + " " string += hour.to_s + blinky + minute.to_s + " " + meri return string end def blinky return ":" unless USE_BLINK return " " if Graphics.frame_count % BLINK_SPEED > (BLINK_SPEED / 2) return ":" end def custom(array) sec = $game_time.sec sec = "0" + sec.to_s if sec < 10 hour = $game_time.hour hour >= 12 ? meri = "PM" : meri = "AM" hour = " " + hour.to_s if hour < 10 hour12 = $game_time.hour hour12 -= 12 if hour12 > 12 hour12 = 12 if hour12 == 0 minute = $game_time.min minute = "0" + minute.to_s if minute < 10 dayweek = DAYNAMESABBR[$game_time.dayweek] dayweekn = DAYNAMES[$game_time.dayweek] day = $game_time.day day += 1 unless USE_REAL_TIME month = $game_time.month month += 1 unless USE_REAL_TIME monthn = MONTHNAMES[$game_time.month] monthna = MONTHNAMESABBR[$game_time.month] year = $game_time.year string = "" for command in array case command when "sec" string += sec.to_s when "min" string += minute.to_s when "hour" string += hour.to_s when "hour12" string += hour12.to_s when "meri" string += meri.to_s when "weekshort" string += dayweek.to_s when "weeklong" string += dayweekn.to_s when "day" string += day.to_s when "month" string += month.to_s when "monthshort" string += monthna.to_s when "monthlong" string += monthn.to_s when "year" string += year.to_s when "yearp" string += $game_time.year_post when "blinky" string += blinky else string += command.to_s end end return string end end endGameTime.runclass Window_Base < Window alias real_time_convert_escape_characters convert_escape_characters def convert_escape_characters(text) result = real_time_convert_escape_characters(text) result.gsub!(/GTSEC/) { GameTime.sec? } result.gsub!(/GTMIN/) { GameTime.min? } result.gsub!(/GTHOUR/) { GameTime.hour? } result.gsub!(/GTDAYN/) { GameTime.day? } result.gsub!(/GTDAYF/) { GameTime.day_name } result.gsub!(/GTDAYA/) { GameTime.day_name_abbr } result.gsub!(/GTMONF/) { GameTime.month? } result.gsub!(/GTMONN/) { GameTime.month_name } result.gsub!(/GTMONA/) { GameTime.month_name_abbr } result.gsub!(/GTYEAR/) { GameTime.year? } result endendclass Scene_Base alias game_time_update update def update game_time_update GameTime.update endendclass Scene_Map alias game_time_post_transfer post_transfer alias game_time_init create_all_windows alias game_time_map_update update alias game_time_start start def start game_time_start $game_time_tint.update end def create_all_windows game_time_init @gametimeclock = GameTime::Window_GameClock.new if USECLOCK end def post_transfer $game_time_tint.update game_time_post_transfer end def update game_time_map_update return unless USECLOCK @gametimeclock.update if Input.trigger?(CLOCK_TOGGLE) and @gametimeclock.nil? == false @gametimeclock.visible ? @gametimeclock.visible = false : @gametimeclock.visible = true end end def clock_visible?(set) @gametimeclock.visible = set endendclass Game_Map def map_note return @map.note unless @map.nil? endendclass Scene_Menu alias gt_start start alias gt_update update def start gt_start @clock = GameTime::Window_GameClock.new if USECLOCK_MENU @clock.x = 0 @clock.y = @gold_window.y - @clock.height @clock.width = @gold_window.width @clock.create_contents end def update gt_update @clock.update unless @clock.nil? endendmodule DataManager class << self alias gametime_msc make_save_contents alias gametime_esc extract_save_contents end def self.make_save_contents contents = gametime_msc contents[:gametime] = $game_time contents end def self.extract_save_contents(contents) gametime_esc(contents) $game_time = contents[:gametime] endend 

Also one of the main parts I need is there being different types of shops, so I can make a blacksmith that only sells weapons,armord, etc... people who sell a mix of items, people who sell only potions, and maybe people who only sells spells.
 

Reedo

Coder
Veteran
Joined
Sep 17, 2013
Messages
71
Reaction score
38
First Language
English
Primarily Uses
Probably something like:

seed = GameTime.year? * 1000

seed += GameTime.month? * 100

seed += GameTime.day?

seed = (seed / 2).ceil

@reedo_random_seed = seed

This gives you a distinct number for each day of the year.  The divide by 2 part means you only get a new number every 2 days.  Divide by however many days you want to get a new random selection.

I'll add some categories or something to the script so that you can use a pre-shop script command so specify which selection of possible level items to use.
 

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV
Another thing I forgot to mention is the way you add things to the list. It's kinda of annoying specially if you have 1000+ Items like I do.

You think you can make it something like this?

Lv1 item = weaponchance to show up 0.50items in list = [1,2,3,4,5 etc..] #so I can just use an array to pick the items ID i want to show up Lv1item = weapon #the main things is to put the item IDs in an array with the lv of those #items defined, and rate definedchance to show up 0.60items in list = [5, 7 etc..] Lv1items = itemschance to show up 0.50items in list = [1,2,3]Maybe even like this

Lv1

Items = weapons [1,2,3,4]  chance to shoe up 0.60

items = armors[1,2,3,4] chance to show up 0.80

items = weapons [5,6,7] chance to show up 0.80

etc...
 
Last edited by a moderator:

Reedo

Coder
Veteran
Joined
Sep 17, 2013
Messages
71
Reaction score
38
First Language
English
Primarily Uses
I've posted an update with the shop type filter.  When you define each item you can now optionally add a "shop type" after the percentage chance.

Then in the event, before showing the shop you can use a script command to set @reedo_shop_type to the string or array of string shop types that you want to use for this shop.

As for the configuration, I can't do any of those things directly in the script because they don't represent valid code.

I could create a loader for a text file though, then it would be possible to parse pretty much whatever text format into the required item entries.  I can look into it.
 

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV
I've posted an update with the shop type filter.  When you define each item you can now optionally add a "shop type" after the percentage chance.

Then in the event, before showing the shop you can use a script command to set @reedo_shop_type to the string or array of string shop types that you want to use for this shop.

As for the configuration, I can't do any of those things directly in the script because they don't represent valid code.

I could create a loader for a text file though, then it would be possible to parse pretty much whatever text format into the required item entries.  I can look into it.
I'll checkout the update. I know what I wrote wasn't valid codes lol I was just showing an example of how it could be done to make it easier to add items to the list using arrays.

Thanks dude, the script seems to be getting closer to what I want.

another thing is that the random seed isn't working it changes everytime you leave the map, the items only stays the same if you're on the same map. Once you leave and come back it changes. and shops with the same seed sell the same thing... I have multiple shops in different cities that sells the same kind of things, if I went to them they too would have the same thing as a shop in another city.
 
Last edited by a moderator:

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV

Reedo

Coder
Veteran
Joined
Sep 17, 2013
Messages
71
Reaction score
38
First Language
English
Primarily Uses
Hey, sorry this got dropped; I had a lot going on over the past six months (none of it good :( ).

Anyway, I need to get ACE reinstalled and dig up this project, but I'll try to get this finished before too long.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top