Star Ocean: Shop System
by Hawk-McKain
Version 1.0.2
Oct 20 2006
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
From lurking on the forums for a while I've come to notice a lack of shop scripts. I'm sure not many people actually worry too much about their shops, but the default is rather lacking in my opinion. So I made my own! Based off the Star Ocean: Second Story system since it's very pretty.
Anyway! For starters, and as a disclaimer, I'm using an adapted version of RPG Advocate's Equipment Status Change script, everything else I made on my own, and being rather new to RGSS it means it could probably be coded much better, so any tips or suggestions are welcome.
Now, onto the actual script!
Demo::
You can download the demo from the post attachment.
Installation:
As far as I can tell Installation is a simple copy/paste thing, I'm not using the SDK (I'm considering adding support for it however.) so nothing to worry about there. I can't really help you if you've made changes to the default shop as this is a completely new system not just an addition.
BTW, for those new to scripting, by copy/paste you want to put between "Main" and all the Scenes.
Compatiblity Note:
You may need to add these lines to the beginning or your "Main" script below "begin":
Code:
# This variable determines the default font type
$defaultfonttype = "Tahoma"
# This variable determines the default font size
$defaultfontsize = 22
Also, the system now supports D&D Currencies.
^------------ fix this link for Save-Point
Sctipt::
The script comes in a one lump sum, though I can split it up for people who prefer that.
class Scene_Shop
#--------------------------------------------------------------------------
# - Main Processing
#--------------------------------------------------------------------------
def main
# Displays the item description.
@help_window = Window_Help.new
# It's how you get around.
@command_window = Window_ShopCommand.new
# Displays current amount of gold.
@gold_window = Window_Shop_Gold.new
@gold_window.x = 464
@gold_window.y = 128
@gold_window.z = 200
@gold_window.update
#Used during buying process
@ice_gold = $game_party.gold
# Display shop useage information.
@dummy_window = Window_Base.new(0, 224, 640, 224)
@dummy_window.contents = Bitmap.new(416, 192)
@dummy_window.contents.font.name = $defaultfonttype
@dummy_window.contents.font.size = 20
msg = ['Welcome to the Star Ocean style shop by Hawk-McKain!',
'All transactions are processed when you exit the shop.',
'',
'Press Right or Left to increase or reduce by 1.',
'Hold Shift to augment the number by 10.',
'Shift + Ctrl for all or none.',
'',
'For more informaton about an item press Enter.']
for i in 0..msg.size - 1
y = i * 20
@dummy_window.contents.draw_text(4, y, 567, 20, msg[i])
end
# Displays all items being sold and number being bought.
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# Displays all items on hand and number being sold.
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
#Make lists of the windows that need updating and the rest.
@updaters = [@help_window,@command_window,@buy_window,
@sell_window,@info_window,@status_window,
@inv_window,@yes_no_window, @spriteset]
@stills = [@gold_window,@dummy_window,@confirm_window]
Graphics.transition
while $scene == self
# Update game screen
Graphics.update
# Update input information
Input.update
# Update Windows
@updaters.each {|i| i.update}
# Update Scene
update
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
#Idea thanks to SephirothSpawn
@updaters.concat(@stills).each {|i| i.dispose}
end
#--------------------------------------------------------------------------
# Update all the windows and contol the active window.
#--------------------------------------------------------------------------
def update
if @yes_no_window.active
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
#No
if @yes_no_window.index == 0
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
#Yes
else
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@mode = 1
end
#Cancel or Yes
elsif Input.trigger?(Input::B)
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@mode = 1
end
#Prevents a keystroke from passing into the command window
elsif @mode == 1
@command_window.active = true
@mode = nil
# Check if the command window is active and update it
elsif @command_window.active
update_command
return
# Check if the buy window is active and update it
elsif @buy_window.active
update_buy
return
# Check if the sell window is active and update it
elsif @sell_window.active
update_sell
return
end
@status_window.refresh
end
#--------------------------------------------------------------------------
# - Procedures that happen when the Command Window is active
#--------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
@confirm_window.visible = true
@yes_no_window.visible = true
@yes_no_window.active = true
@command_window.active = false
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0 #Buy
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@inv_window.visible = true
when 1 #Sell
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.redraw
@inv_window.visible = true
when 2 #Settle
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# - Procedures that happen when the Buy Window is active
#--------------------------------------------------------------------------
def update_buy
@item = @status_window.item = @info_window.item = @inv_window.item = @buy_window.item
number = @inv_window.onhand(@item)
#The max decreases as the on hand gold descreases
#so to fix that you must lock the on-hand gold for each item.
max = @item.price == 0 ? 99 : @ice_gold / @item.price
max = [max, 99 - number].min
#If the user changes the item then update the on-hand gold.
if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
@ice_gold = $game_party.gold
end
if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
amount = get_amount(0)
modifier = 1
if Input.repeat?(Input::RIGHT) and amount < max
modifier = [10 - amount, 10].max if Input.press?(Input::SHIFT)
modifier = max - amount if Input.press?(Input::SHIFT) and Input.press?(Input::CTRL)
amount = amount + modifier
total = @status_window.purchase + (@item.price * modifier)
@status_window.set(total, @status_window.sales)
for i in 1..modifier
i += 1
gain_item
end
elsif Input.repeat?(Input::LEFT) and amount > 0
modifier = [amount, 10].min if Input.press?(Input::SHIFT)
modifier = amount if Input.press?(Input::SHIFT) and Input.press?(Input::CTRL)
amount = amount - modifier
total = @status_window.purchase - (@item.price * modifier)
@status_window.set(total, @status_window.sales)
for i in 1..modifier
lose_item
end
end
@buy_window.amount = amount
@buy_window.refresh
@status_window.refresh
end
if Input.press?(Input::B)
if @info_window.visible
@info_window.visible = false
@info_window.refresh
#A pause so it doesn't skip right to the dummy window.
sleep(0.1)
return
else
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@inv_window.visible = false
@info_window.item = @inv_window.item = nil
@help_window.set_text('')
return
end
end
if Input.trigger?(Input::C)
@info_window.visible = @info_window.visible ? false : true
@info_window.refresh
return
end
end
#--------------------------------------------------------------------------
# - Procedures that happen when the Sell Window is active
#--------------------------------------------------------------------------
def update_sell
@item = @status_window.item = @inv_window.item = @sell_window.item
if Input.trigger?(Input::B)
if @info_window.visible
@info_window.visible = false
@info_window.refresh
#A pause so it doesn't skip right to the dummy window.
sleep(0.1)
return
else
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@inv_window.visible = false
@info_window.item = @inv_window.item = nil
@help_window.set_text('')
return
end
end
#Return if the player has no on-hand items.
return if not @inv_window.onhand(@item) or not get_amount(2)
#Get the buy window amount so the player can't sell items they just bought.
max = @inv_window.onhand(@item) - get_amount(2)
if Input.repeat?(Input::LEFT) or Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
amount = get_amount(1)
modifier = 1
if Input.repeat?(Input::RIGHT) and amount < max
modifier = [max - amount, 10].min if Input.press?(Input::SHIFT)
modifier = max - amount if Input.press?(Input::SHIFT) and Input.press?(Input::CTRL)
amount = amount + modifier
total = @status_window.sales + (@item.price / 2) * [modifier, 1].max
@status_window.set(@status_window.purchase, total)
for i in 1..modifier
lose_item
end
elsif Input.repeat?(Input::LEFT) and amount > 0
modifier = [amount, 10].min if Input.press?(Input::SHIFT)
modifier = amount if Input.press?(Input::SHIFT) and Input.press?(Input::CTRL)
amount = amount - modifier
total = @status_window.sales - (@item.price / 2) * [modifier, 1].max
@status_window.set(@status_window.purchase, total)
for i in 1..modifier
gain_item
end
end
@sell_window.amount = amount
@sell_window.redraw
@status_window.refresh
end
if Input.trigger?(Input::B)
if @info_window.visible
@info_window.visible = false
@info_window.refresh
#A pause so it doesn't skip right to the dummy window.
sleep(0.1)
return
else
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@inv_window.visible = false
@info_window.item = @inv_window.item = nil
@help_window.set_text('')
return
end
elsif Input.trigger?(Input::C)
@info_window.visible = @info_window.visible ? false : true
@info_window.refresh
return
end
end
#-----------------------------------------------------------------
# Returns the on hand amount of the currently selected item.
# 0 or nil == Buy
# 1 == Sell
# 2 == amount = 0 if the item in Sell isn't in Buy
#-----------------------------------------------------------------
def get_amount(i = 0)
amount = @buy_window.get_amount
amount = @sell_window.get_amount if i == 1
if i == 2
#print "first", amount
if @sell_window.active
#print amount
for j in 0..@buy_window.get_total
if @buy_window.item(j) != @sell_window.item
amount = 0
else
amount = @buy_window.get_amount(j)
break
end
end
end
end
return amount
end
#-----------------------------------------------------------------
# Return the defined window index.
#-----------------------------------------------------------------
def get_index(window)
case window
when 'Command'
return @command_window.index
when 'Buy'
return @buy_window.index
when 'Sell'
return @sell_window.index
when 'Current'
return @command_window.index if @command_window.active
return @buy_window.index if @buy_window.active
return @sell_window.index if @sell_window.active
end
end
#--------------------------------------------------------------------------
# Perform all transactions.
#--------------------------------------------------------------------------
def gain_item
#--------------------
# When 0, lose all the gold by buying the item
# When 1, lose half gold by not selling the item
$game_party.lose_gold(@item.price / (@command_window.index + 1))
case @item
when RPG::Item
$game_party.gain_item(@item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(@item.id, 1)
when RPG::Armor
$game_party.gain_armor(@item.id, 1)
end
end
def lose_item
#--------------------
# When 0, gain all the gold from buying the item
# When 1, gain half gold from selling the item
$game_party.gain_gold(@item.price / (@command_window.index + 1))
case @item
when RPG::Item
$game_party.lose_item(@item.id, 1)
when RPG::Weapon
$game_party.lose_weapon(@item.id, 1)
when RPG::Armor
$game_party.lose_armor(@item.id, 1)
end
end
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ? ?????
# index : ????
#--------------------------------------------------------------------------
def draw_item(index)
x = 4 + index * (self.width / 3)
self.contents.draw_text(x, 0, 128, 32, @commands[index])
end
end
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# - Initialize the window.
#--------------------------------------------------------------------------
def initialize(shop_goods)
super(0, 224, 448, 224)
@shop_goods = shop_goods
@amount = []
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# - Return the item selected
#--------------------------------------------------------------------------
def item(index = self.index)
return @data[index]
end
#---------------------------------------------------------------
# Set the amount of bought items for the current item.
#---------------------------------------------------------------
def amount=(amount)
@amount[self.index] = amount
end
#---------------------------------------------------------------
# Return the amount of the current index
#---------------------------------------------------------------
def get_amount(index = self.index)
return @amount[index]
end
#---------------------------------------------------------------
# Return the total number of items in the shop.
#---------------------------------------------------------------
def get_total
return @item_max
end
#-----------------------------------------------------------------
# - Refresh the contents of the Window
#-----------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
for i in 0...@item_max
@amount[i] = 0 if not @amount[i]
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# - Draw the items a player can buy.
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.price <= $game_party.gold and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
self.contents.draw_text(x + 355, y, 32, 32, "x")
self.contents.draw_text(x + 360, y, 32, 32, @amount[index].to_s,2)
end
#--------------------------------------------------------------------------
# - Refresh
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Window_ShopSell < Window_Selectable
#--------------------------------------------------------------------------
# - Initalize the window.
#--------------------------------------------------------------------------
def initialize
super(0, 224, 448, 224)
@amount = []
refresh
self.index = 0
end
#---------------------------------------------------------------
# - Return the item selected
#---------------------------------------------------------------
def item
return @data[self.index]
end
#-----------------------------------------------------------------
# Get the number the user set to sell.
#-----------------------------------------------------------------
def amount=(amount)
@amount[self.index] = amount
end
#--------------------------------------------------------------------------
# Return the buy number of the current index
#--------------------------------------------------------------------------
def get_amount
return @amount[self.index]
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
# ???? 0 ??????????????????????
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
@redraw_data = @data
for i in 0...@item_max
@amount[i] = 0 if not @amount[i]
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# - Draw the items in a players invantory.
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.price > 0
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, (item.price / 2).to_s, 2)
self.contents.draw_text(x + 355, y, 32, 32, "x")
self.contents.draw_text(x + 360, y, 32, 32, @amount[index].to_s,2)
end
#---------------------------------------------------------------
#This is to redraw just the numbers and refresh the whole page.
#---------------------------------------------------------------
def redraw
if self.contents != nil
self.contents.dispose
self.contents = nil
end
if @redraw_data
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
@data = @redraw_data
for i in 0...@redraw_data.size
draw_item(i)
end
end
end
#---------------------------------------------------------------
# - Update the item description.
#---------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? '' : self.item.description)
end
end
if int_change > 0
self.contents.font.color = up_color
s = int_change.abs.to_s
self.contents.draw_text(214, 10 + (64 * i), 4, 32, "+")
self.contents.draw_text(216, 10 + (64 * i), 24, 32, s, 2)
elsif int_change < 0
self.contents.font.color = down_color
s = int_change.abs.to_s
self.contents.draw_text(214, 10 + (64 * i), 4, 32, "-")
self.contents.draw_text(216, 10 + (64 * i), 24, 32, s, 2)
end
end
end
end
# ---------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
# ---------------------------------------
def draw_actor_graphic(actor, x, y, id, tone_id)
case id
when 0
@v1 = Viewport.new(x, y, 32, 48)
@v1.z = 9998
@sprite1 = Sprite.new(@v1)
@sprite1.bitmap = RPG::Cache.character(actor.character_name,
actor.character_hue)
@sprite1.tone = tone_id == 0 ? Tone.new(0, 0, 0, 255) : Tone.new(0, 0, 0, 0)
@sprite1.visible = true
when 1
@v2 = Viewport.new(x, y, 32, 48)
@v2.z = 9999
@sprite2 = Sprite.new(@v2)
@sprite2.bitmap = RPG::Cache.character(actor.character_name,
actor.character_hue)
@sprite2.tone = tone_id == 0 ? Tone.new(0, 0, 0, 255) : Tone.new(0, 0, 0, 0)
@sprite2.visible = true
when 2
@v3 = Viewport.new(x, y, 32, 48)
@v3.z = 9999
@sprite3 = Sprite.new(@v3)
@sprite3.bitmap = RPG::Cache.character(actor.character_name,
actor.character_hue)
@sprite3.tone = tone_id == 0 ? Tone.new(0, 0, 0, 255) : Tone.new(0, 0, 0, 0)
@sprite3.visible = true
when 3
@v4 = Viewport.new(x, y, 32, 48)
@v4.z = 9999
@sprite4 = Sprite.new(@v4)
@sprite4.bitmap = RPG::Cache.character(actor.character_name,
actor.character_hue)
@sprite4.tone = tone_id == 0 ? Tone.new(0, 0, 0, 255) : Tone.new(0, 0, 0, 0)
@sprite4.visible = true
end
end
# ---------------------------------------
def update
super
@count += 1
for i in 0..@walk.size
if @walk[i] == false
case i
when 0
@sprite1.ox = 0 if @sprite
when 1
@sprite2.ox = 0 if @sprite2
when 2
@sprite3.ox = 0 if @sprite3
when 3
@sprite4.ox = 0 if @sprite4
end
end
end
if @count == 0
for i in 0..@walk.size
if @walk[i] == true
case i
when 0
@sprite1.ox = 0 if @sprite
when 1
@sprite2.ox = 0 if @sprite2
when 2
@sprite3.ox = 0 if @sprite3
when 3
@sprite4.ox = 0 if @sprite4
end
end
end
end
if @count == 5
for i in 0..@walk.size
if @walk[i] == true
case i
when 0
@sprite1.ox = 32 if @sprite1
when 1
@sprite2.ox = 32 if @sprite2
when 2
@sprite3.ox = 32 if @sprite3
when 3
@sprite4.ox = 32 if @sprite4
end
end
end
end
if @count == 10
for i in 0..@walk.size
if @walk[i] == true
case i
when 0
@sprite1.ox = 64 if @sprite1
when 1
@sprite2.ox = 64 if @sprite2
when 2
@sprite3.ox = 64 if @sprite3
when 3
@sprite4.ox = 64 if @sprite4
end
end
end
end
@count = 0 if @count == 15
end
end
#==============================================================================
# ¦ Window_ShopInv
#------------------------------------------------------------------------------
# Shows the number of items on hand when you entered the shop.
#==============================================================================
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
@number = number
temp1 = $scene.get_amount(2) == nil ? 0 : $scene.get_amount(2)
temp2 = $scene.get_amount(1) == nil ? 0 : $scene.get_amount(1)
#Buying
number = number - temp1 + temp2
#Selling
#number = number + $scene.get_amount(1) if $scene.get_index("Command") == 1
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, 'On Hand: ')
self.contents.font.color = normal_color
self.contents.draw_text(92, 0, 32, 32, number.to_s, 2)
if @item.is_a?(RPG::Item)
return
end
end
#--------------------------------------------------------------------------
# ? ?????
# index : ????
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
#--------------------------------------------------------------------------
# Get current number of item on hand.
#--------------------------------------------------------------------------
def onhand(item)
self.item = item
return @number
end
end
for i in 1..3
case amounts[i]
when 0..9999
gold = amounts[i]
when 10000..99999
gold = amounts[i].to_s
array = gold.split(//)
gold = array[0].to_s+array[1].to_s+","+array[2].to_s+array[3].to_s+array[4].to_s
when 100000..999999
gold = amounts[i].to_s
array = gold.split(//)
gold = array[0].to_s+array[1].to_s+array[2].to_s+","+array[3].to_s+array[4].to_s+array[5].to_s
when 1000000..9999999
gold = amounts[i].to_s
array = gold.split(//)
gold = array[0].to_s+","+array[1].to_s+array[2].to_s+array[3].to_s+","+array[4].to_s+array[5].to_s+array[6].to_s
end
if i == 0
self.contents.font.color = text_color(6)
else
self.contents.font.color = system_color
end
cx = contents.text_size(words[i]).width
cx2=contents.text_size(gold.to_s).width
self.contents.draw_text(4, (i * 64) - 32 , cx, 32, words[i] + ":")
self.contents.font.color = text_color(0)
self.contents.draw_text(160-cx2, i * 64, cx2, 32, gold.to_s, 2)
end
end
#-----------------------------------------------------------------
# Return the total of the items the player is buying.
#-----------------------------------------------------------------
def purchase
return (@purchase)
end
#-----------------------------------------------------------------
# Return the total of the items the player is selling.
#-----------------------------------------------------------------
def sales
return (@sales)
end
#-----------------------------------------------------------------
# Return the balence of the player's transactions.
#-----------------------------------------------------------------
def balance
return (@gold + @sales) - @purchase
end
#--------------------------------------------------------------------------
# ? ???????
# item : ???????
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
class Window_Confirm < Window_Selectable
#--------------------------------------------------------------------------
def initialize(text)
super(120, 188, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
@text = text
@item_max = 2
@column_max = 2
@commands = ["Yes", "No"]
refresh
self.index = 0
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.draw_text(4, 0, 128, 32, @text)
for i in 0...@item_max
x = 4 + i * 80
self.contents.draw_text(x, 32, 128, 32, @commands[i])
end
end
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
row = @index / @column_max
self.top_row = row if row < self.top_row
self.top_row = row - (self.page_row_max - 1) if row > self.top_row + (self.page_row_max - 1)
cursor_width = self.width / @column_max - 32
x = @index % @column_max * (cursor_width + 32)
y = 32
self.cursor_rect.set(x, y, cursor_width, 32)
end
end
I've worked most of the bugs out, no known exploits, but again I'm rather new to RGSS and there's bound to be -something- wrong hopefully nothing major. =3
Variations::
Spriteset Background
This variation, which I may make default if everyone likes it, replaces the back background with the map.
(MISSING IMAGE FROM ORIGINAL POST)
To implement this you need to replace all of "@updaters" (Which you can find around like 96/96 right below all the "@yes_no_window"s) with this :
Code:
@spriteset = Spriteset_Map.new
#Make lists of the windows that need updating and the rest.
@updaters = [@help_window,@command_window,@buy_window,
@sell_window,@info_window,@status_window,
@inv_window,@yes_no_window, @spriteset]
And that's it! Thanks go to Caldaron for the idea ^_^
D&D Currencies
This one is built in by default, meaning all you have to do it add D&D Currencies to your project and you're good to go!