10-20-2006, 01:00 PM
Star Ocean: Shop System
by Hawk-McKain
Version 1.0.2
Oct 20 2006
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.
Star_Shop_Demo_v1.0.2.exe (Size: 290.5 KB / Downloads: 2)
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":
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.
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::
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.
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.
Star_Shop_Demo_v1.0.2.exe (Size: 290.5 KB / Downloads: 2)
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.
Star Ocean Shop
Code:
#==============================================================================
# Star Ocean Style Shop
#------------------------------------------------------------------------------
# By: Hawk-McKain
# Version: 1.12
# Date: 26.03.07
#==============================================================================
#==============================================================================
# * Window_Shop_Gold
#------------------------------------------------------------------------------
# A clone of Window_Gold with support for D&D Currencies
#==============================================================================
class Window_Shop_Gold < Window_Base
#------------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Gold" window font
self.contents.font.size = $defaultfontsize
refresh
end
#------------------------------------------------------------------------------
def refresh
begin
cost_display(0, self.contents.width, 0, $game_party.gold)
rescue
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
end
#============================================
# * Scene_Shop
#============================================
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
# Displays all transactions.
@status_window = Window_ShopStatus.new
@status_window.visible = true
@status_window.refresh
# Displays the number of an item on hand.
@inv_window = Window_ShopInv.new
@inv_window.visible = false
# Displays all stat changes the selected item has.
@info_window = Window_ShopInfo.new
@info_window.visible = false
@info_window.z = 400
# Text window for transaction confirmation.
@confirm_window = Window_Base.new(120, 188, 400, 64)
@confirm_window.contents = Bitmap.new(368, 32)
@confirm_window.contents.font.name = $defaultfonttype
@confirm_window.contents.font.size = 24
@confirm_window.contents.draw_text(4, 0, 368, 32, 'Finalize Transactions?')
@confirm_window.visible = false
@confirm_window.z = 300
# User input for comfirmation window.
@yes_no_window = Window_Command.new(100, ['Yes', 'No'])
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@yes_no_window.x = 270
@yes_no_window.y = 252
@yes_no_window.z = 300
@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]
@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
#==============================================================================
# ¦ Window_ShopCommand
#------------------------------------------------------------------------------
# Adapted By: Hawk-McKain
# Version: 1
# Date: 07/23/06
#==============================================================================
class Window_ShopCommand < Window_Selectable
#--------------------------------------------------------------------------
# ? ?????????
#--------------------------------------------------------------------------
def initialize
super(0, 160, 288, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
@item_max = 3
@column_max = 3
@commands = ['Buy', 'Sell', 'Settle']
refresh
self.index = 0
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
#==============================================================================
# ¦ Window_ShopBuy
#------------------------------------------------------------------------------
# Adapted By: Hawk-McKain
# Version: 1
# Date: 07/23/06
#==============================================================================
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
#==============================================================================
# ¦ Window_ShopSell
#------------------------------------------------------------------------------
# Adapted By: Hawk-McKain
# Version: 1
# Date: 07/23/06
#==============================================================================
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
#==============================================================================
# Equipment Status Changes
#------------------------------------------------------------------------------
# By: RPG Advocate
# Adapted and optimized by: Hawk-McKain
# Version: 1.5
# Date: 07/20/06
#==============================================================================
class Window_ShopInfo < Window_Base
# ---------------------------------------
def initialize
super(184, 128, 272, 288)
self.back_opacity = 220
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
@item = nil
@sprite1 = nil
@sprite2 = nil
@sprite3 = nil
@sprite4 = nil
@walk = [false, false, false, false]
@count = 0
refresh
end
# ---------------------------------------
def up_color
return Color.new(74, 210, 74)
end
# ---------------------------------------
def down_color
return Color.new(210, 170, 170)
end
# ---------------------------------------
def refresh
self.contents.clear
if @sprite1 != nil
@sprite1.dispose
@sprite1 = nil
end
if @sprite2 != nil
@sprite2.dispose
@sprite2 = nil
end
if @sprite3 != nil
@sprite3.dispose
@sprite3 = nil
end
if @sprite4 != nil
@sprite4.dispose
@sprite4 = nil
end
self.contents.font.name = "Arial"
self.contents.font.size = 24
return if not @item
if @item.is_a?(RPG::Item)
@walk = [false, false, false, false]
return
end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
if not actor.equippable?(@item)
@walk[i] = false
draw_actor_graphic(actor, 12 + self.x, (32 + self.y) + (64 * i), i, 0) if self.visible
self.contents.font.name = "Arial"
self.contents.font.size = 24
self.contents.font.color = normal_color
self.contents.draw_text(32, 22 + (64 * i), 150, 32, "Cannot Equip")
elsif actor.equippable?(@item)
@walk[i] = true
draw_actor_graphic(actor, 12 + self.x, (32 + self.y) + (64 * i), i, 1) if self.visible
str2 = str1 = 0
str1 = item1 ? item1.str_plus : 0
str2 = @item ? @item.str_plus : 0
dex2 = dex1 = 0
dex1 = item1 ? item1.dex_plus : 0
dex2 = @item ? @item.dex_plus : 0
agi2 = agi1 = 0
agi1 = item1 ? item1.agi_plus : 0
agi2 = @item ? @item.agi_plus : 0
int2 = int1 = 0
int1 = item1 ? item1.int_plus : 0
int2 = @item ? @item.int_plus : 0
pdf2 = pdf1 = 0
pdf1 = item1 ? item1.pdef : 0
pdf2 = @item ? @item.pdef : 0
mdf2 = mdf1 = 0
mdf1 = item1 ? item1.mdef : 0
mdf2 = @item ? @item.mdef : 0
if @item.is_a?(RPG::Weapon)
atk2 = atk1 = 0
atk1 = item1 ? item1.atk : 0
atk2 = @item ? @item.atk : 0
atk_change = atk2 - atk1
elsif @item.is_a?(RPG::Armor)
eva2 = eva1 = 0
eva1 = item1 ? item1.eva : 0
eva2 = @item ? @item.eva : 0
eva_change = eva2 - eva1
end
str_change = str2 - str1
dex_change = dex2 - dex1
agi_change = agi2 - agi1
int_change = int2 - int1
pdf_change = pdf2 - pdf1
mdf_change = mdf2 - mdf1
name1 = !item1 ? '' : item1.name
name2 = !@item ? '' : @item.name
if str_change == 0 && dex_change == 0 && agi_change == 0 &&
pdf_change == 0 && mdf_change == 0 && (atk_change == 0 ||
eva_change == 0) && int_change == 0 && name1 != name2
self.contents.font.size = 24
self.contents.font.color = normal_color
self.contents.draw_text(32, 22 + 64 * i, 150, 32, "No Change")
elsif name1 == name2
self.contents.font.size = 24
self.contents.font.color = normal_color
self.contents.draw_text(32, 22 + 64 * i, 200, 32, "Currently Equipped")
end
self.contents.font.name = "Arial"
self.contents.font.size = 16
self.contents.font.color = normal_color
if @item.is_a?(RPG::Weapon) && atk_change != 0
self.contents.draw_text(32, 10 + (64 * i), 32, 32, "ATK")
end
if @item.is_a?(RPG::Armor) && eva_change != 0
self.contents.draw_text(32, 10 + (64 * i), 32, 32, "EVA")
end
if pdf_change != 0
self.contents.draw_text(32, 26 + (64 * i), 32, 32, "PDF")
end
if mdf_change != 0
self.contents.draw_text(32, 42 + (64 * i), 32, 32, "MDF")
end
if str_change != 0
self.contents.draw_text(112, 10 + (64 * i), 32, 32, "STR")
end
if dex_change != 0
self.contents.draw_text(112, 26 + (64 * i), 32, 32, "DEX")
end
if agi_change != 0
self.contents.draw_text(112, 42 + (64 * i), 32, 32, "AGI")
end
if int_change != 0
self.contents.draw_text(192, 10 + (64 * i), 32, 32, "INT")
end
case @item
when RPG::Weapon
if atk_change > 0
self.contents.font.color = up_color
s = atk_change.abs.to_s
self.contents.draw_text(60, 10 + (64 * i), 4, 32, "+")
self.contents.draw_text(62, 10 + (64 * i), 24, 32, s, 2)
elsif atk_change < 0
self.contents.font.color = down_color
s = atk_change.abs.to_s
self.contents.draw_text(60, 10 + (64 * i), 4, 32, "-")
self.contents.draw_text(62, 10 + (64 * i), 24, 32, s, 2)
end
when RPG::Armor
if eva_change > 0
self.contents.font.color = up_color
s = eva_change.abs.to_s
self.contents.draw_text(60, 10 + (64 * i), 4, 32, "+")
self.contents.draw_text(62, 10 + (64 * i), 24, 32, s, 2)
elsif eva_change < 0
self.contents.font.color = down_color
s = eva_change.abs.to_s
self.contents.draw_text(60, 10 + (64 * i), 4, 32, "-")
self.contents.draw_text(62, 10 + (64 * i), 24, 32, s, 2)
end
end
if pdf_change > 0
self.contents.font.color = up_color
s = pdf_change.abs.to_s
self.contents.draw_text(60, 26 + (64 * i), 4, 32, "+")
self.contents.draw_text(62, 26 + (64 * i), 24, 32, s, 2)
elsif pdf_change < 0
self.contents.font.color = down_color
s = pdf_change.abs.to_s
self.contents.draw_text(60, 26 + (64 * i), 4, 32, "-")
self.contents.draw_text(62, 26 + (64 * i), 24, 32, s, 2)
end
if mdf_change > 0
self.contents.font.color = up_color
s = mdf_change.abs.to_s
self.contents.draw_text(60, 42 + (64 * i), 4, 32, "+")
self.contents.draw_text(62, 42 + (64 * i), 24, 32, s, 2)
elsif mdf_change < 0
self.contents.font.color = down_color
s = mdf_change.abs.to_s
self.contents.draw_text(60, 42 + (64 * i), 4, 32, "-")
self.contents.draw_text(62, 42 + (64 * i), 24, 32, s, 2)
end
if str_change > 0
self.contents.font.color = up_color
s = str_change.abs.to_s
self.contents.draw_text(140, 10 + (64 * i), 4, 32, "+")
self.contents.draw_text(142, 10 + (64 * i), 24, 32, s, 2)
elsif str_change < 0
self.contents.font.color = down_color
s = str_change.abs.to_s
self.contents.draw_text(140, 10 + (64 * i), 4, 32, "-")
self.contents.draw_text(142, 10 + (64 * i), 24, 32, s, 2)
end
if dex_change > 0
self.contents.font.color = up_color
s = dex_change.abs.to_s
self.contents.draw_text(140, 26 + (64 * i), 4, 32, "+")
self.contents.draw_text(142, 26 + (64 * i), 24, 32, s, 2)
elsif dex_change < 0
self.contents.font.color = down_color
s = dex_change.abs.to_s
self.contents.draw_text(140, 26 + (64 * i), 4, 32, "-")
self.contents.draw_text(142, 26 + (64 * i), 24, 32, s, 2)
end
if agi_change > 0
self.contents.font.color = up_color
s = agi_change.abs.to_s
self.contents.draw_text(140, 42 + (64 * i), 4, 32, "+")
self.contents.draw_text(142, 42 + (64 * i), 24, 32, s, 2)
elsif agi_change < 0
self.contents.font.color = down_color
s = agi_change.abs.to_s
self.contents.draw_text(140, 42 + (64 * i), 4, 32, "-")
self.contents.draw_text(142, 42 + (64 * i), 24, 32, s, 2)
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.
#==============================================================================
class Window_ShopInv < Window_Base
#--------------------------------------------------------------------------
# ? ?????????
#--------------------------------------------------------------------------
def initialize
super(288, 160, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
@item = nil
refresh
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def refresh
self.contents.clear
return if not @item
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
#==============================================================================
# ¦ Window_ShopStatus
#------------------------------------------------------------------------------
# ?????????????????????????????????????
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ? ?????????
#--------------------------------------------------------------------------
def initialize
super(448, 160, 192, 256)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
@item = nil
@gold = $game_party.gold
@purchase = 0
@sales = 0
refresh
end
#-----------------------------------------------------------------
# Set the transactions.
#-----------------------------------------------------------------
def set(purchase = 0, sales = 0)
@purchase = purchase
@sales = sales
refresh
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def refresh
self.contents.clear
words = [$data_system.words.gold.to_s, 'Purchase', 'Sales', 'Balance']
amounts = [@gold, @purchase, @sales, balance]
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
#==============================================================================
# Confirm Window
#------------------------------------------------------------------------------
# By: Nick
# Version: 1
# Date: 12/07/05
#==============================================================================
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 :And that's it! Thanks go to Caldaron for the idea ^_^
(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]
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!