#===============================================================================
# Leon's Shopping System
#-------------------------------------------------------------------------------
# 3/10/2007
# v. 1.0
#-------------------------------------------------------------------------------
# Instructions:
# Place above main, and below the other default scripts.
# (Yes, that is all of the instructions)
#
# Features:
# Replaces the default shop system.
#
#===============================================================================
def refresh(selection = 0)
self.contents.clear
if selection == 0
self.contents.draw_text(0, 0, 448, 32, "Buy, sell, or leave?", 1)
else
self.contents.draw_text(0, 0, 448, 32, "Press 'Z' for character compatabilitiy.", 1)
end
end
end
#===============================================================================
# END Window_Shop_Info
#===============================================================================
def refresh
self.contents.clear
for i in 0...@option.size
y = i * 32
self.contents.draw_text(0, y, 128, 32, @option[i], 1)
end
end
end
#===============================================================================
# END Window_Shop_Option
#===============================================================================
def refresh(item)
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 48, 32, "Own:")
if item == nil
return
end
self.contents.font.color = normal_color
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
self.contents.draw_text(0, 0, 128, 32, number.to_s, 2)
end
end
#===============================================================================
# END Window_Shop_Own
#===============================================================================
def item
if @data != nil
return @data[index]
end
end
def refresh
@sell = false
@option_index = nil
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)
for i in 0...@item_max
draw_item(i)
end
end
end
def refresh_sell(option_index)
@sell = true
@option_index = option_index
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
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
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 @option_index == nil
if item.price <= $game_party.gold and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
else
self.contents.font.color = normal_color
end
x = 4
y = index * 32
if item.price == 0
self.contents.font.color = disabled_color
else
self.contents.font.color = normal_color
end
if @sell == false
if item.price <= $game_party.gold and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
end
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)
if @option_index == nil
self.contents.draw_text(x + 350, y, 88, 32, item.price.to_s, 2)
else
item_price = (item.price / 2).round
self.contents.draw_text(x + 350, y, 88, 32, item_price.to_s, 2)
end
end
end
#===============================================================================
# END Window_Shop_List
#===============================================================================
if @amount_window.active and @option_window.index == 0
update_amount
return
end
if @amount_window.active and @option_window.index == 1
update_sell
return
end
end
def update_option
@info_window.refresh(0)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @option_window.index
when 0
$game_system.se_play($data_system.decision_se)
@list_window.refresh
@option_window.active = false
@list_window.visible = true
@list_window.active = true
@list_window.index = 0
when 1
$game_system.se_play($data_system.decision_se)
@list_window.refresh_sell(@option_window.index)
@option_window.active = false
@list_window.visible = true
@list_window.active = true
@list_window.index = 0
when 2
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
end
end
def update_list
@info_window.refresh(1)
@item = @list_window.item
if @counter != 1
if @item.is_a?(RPG::Item)
@desc_item_window.refresh(@item)
@counter = 1
else
@desc_equip_window.refresh(@item)
@counter = 1
end
end
@own_window.refresh(@list_window.item)
if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
@counter = 0
end
if @item.is_a?(RPG::Item)
if @counter != 1
@desc_item_window.refresh(@item)
@counter = 1
end
@desc_item_window.visible = true
@desc_equip_window.visible = false
else
if @counter != 1
@desc_equip_window.refresh(@item)
@counter = 1
end
@desc_item_window.visible = false
@desc_equip_window.visible = true
end
if Input.trigger?(Input::B)
@counter = 0
$game_system.se_play($data_system.cancel_se)
@desc_item_window.visible = false
@desc_equip_window.visible = false
@desc_item_window.refresh(nil)
@desc_equip_window.refresh(nil)
@option_window.active = true
@list_window.visible = false
@list_window.active = false
@own_window.refresh(nil)
return
end
if Input.trigger?(Input::A)
unless @item.is_a?(RPG::Item)
$game_system.se_play($data_system.decision_se)
@actor_window.refresh(@item)
@actor_window.visible = true
@list_window.active = false
return
else
$game_system.se_play($data_system.buzzer_se)
end
end
if Input.trigger?(Input::C)
if @item == nil or @item.id == 0 or @item.price == 0
$game_system.se_play($data_system.buzzer_se)
return
end
if @option_window.index == 0
case @item
when RPG::Item
if $game_party.item_number(@item.id) >= 99
$game_system.se_play($data_system.buzzer_se)
return
end
when RPG::Weapon
if $game_party.weapon_number(@item.id) >= 99
$game_system.se_play($data_system.buzzer_se)
return
end
when RPG::Armor
if $game_party.armor_number(@item.id) >= 99
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
$game_system.se_play($data_system.decision_se)
@amount_window.visible = true
@amount_window.active = true
@list_window.active = false
return
end
end
def update_actors
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@actor_window.visible = false
@list_window.active = true
end
end
def update_amount
@amount_window.refresh(@item, @option_window.index)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@amount_window.amount = 1
@amount_window.visible = false
@amount_window.active = false
@list_window.active = true
return
end
if Input.trigger?(Input::C)
if $game_party.gold >= (@amount_window.amount * @item.price)
$game_system.se_play($data_system.decision_se)
$game_party.lose_gold(@amount_window.amount * @item.price)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @amount_window.amount)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @amount_window.amount)
when RPG::Armor
$game_party.gain_armor(@item.id, @amount_window.amount)
end
@gold_window.refresh
@amount_window.amount = 1
@amount_window.visible = false
@amount_window.active = false
@list_window.active = true
@list_window.refresh
return
else
$game_system.se_play($data_system.buzzer_se)
end
end
if Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@amount_window.amount -= 1
if @amount_window.amount == 0
@amount_window.amount = 1
end
return
end
if Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@amount_window.amount += 1
case @item
when RPG::Item
if ($game_party.item_number(@item.id) + @amount_window.amount) > 99
@amount_window.amount = (99 - $game_party.item_number(@item.id))
end
when RPG::Weapon
if ($game_party.weapon_number(@item.id) + @amount_window.amount) > 99
@amount_window.amount = (99 - $game_party.weapon_number(@item.id))
end
when RPG::Armor
if ($game_party.armor_number(@item.id) + @amount_window.amount) > 99
@amount_window.amount = (99 - $game_party.armor_number(@item.id))
end
end
return
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@amount_window.amount += 10
case @item
when RPG::Item
if ($game_party.item_number(@item.id) + @amount_window.amount) > 99
@amount_window.amount = (99 - $game_party.item_number(@item.id))
end
when RPG::Weapon
if ($game_party.weapon_number(@item.id) + @amount_window.amount) > 99
@amount_window.amount = (99 - $game_party.weapon_number(@item.id))
end
when RPG::Armor
if ($game_party.armor_number(@item.id) + @amount_window.amount) > 99
@amount_window.amount = (99 - $game_party.armor_number(@item.id))
end
end
return
end
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@amount_window.amount -= 10
if @amount_window.amount < 1
@amount_window.amount = 1
end
return
end
end
def update_sell
@amount_window.refresh(@item, @option_window.index)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@amount_window.amount = 1
@amount_window.visible = false
@amount_window.active = false
@list_window.active = true
return
end
if Input.trigger?(Input::C)
if @item.price == 0
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
case @item
when RPG::Item
$game_party.gain_gold(@amount_window.amount * (@item.price / 2))
$game_party.lose_item(@item.id, @amount_window.amount)
when RPG::Weapon
$game_party.gain_gold(@amount_window.amount * (@item.price / 2))
$game_party.lose_weapon(@item.id, @amount_window.amount)
when RPG::Armor
$game_party.gain_gold(@amount_window.amount * (@item.price / 2))
$game_party.lose_armor(@item.id, @amount_window.amount)
end
@gold_window.refresh
@amount_window.amount = 1
@amount_window.visible = false
@amount_window.active = false
@list_window.active = true
@list_window.refresh_sell(@option_window.index)
@desc_equip_window.refresh(nil)
@desc_item_window.refresh(nil)
end
if Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@amount_window.amount -= 1
if @amount_window.amount < 1
@amount_window.amount = 1
end
end
if Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
case @item
when RPG::Item
@amount_window.amount += 1
if @amount_window.amount > $game_party.item_number(@item.id)
@amount_window.amount = $game_party.item_number(@item.id)
end
when RPG::Weapon
@amount_window.amount += 1
if @amount_window.amount > $game_party.weapon_number(@item.id)
@amount_window.amount = $game_party.weapon_number(@item.id)
end
when RPG::Armor
@amount_window.amount += 1
if @amount_window.amount > $game_party.armor_number(@item.id)
@amount_window.amount = $game_party.armor_number(@item.id)
end
end
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
case @item
when RPG::Item
@amount_window.amount += 10
if @amount_window.amount > $game_party.item_number(@item.id)
@amount_window.amount = $game_party.item_number(@item.id)
end
when RPG::Weapon
@amount_window.amount += 10
if @amount_window.amount > $game_party.weapon_number(@item.id)
@amount_window.amount = $game_party.weapon_number(@item.id)
end
when RPG::Armor
@amount_window.amount += 10
if @amount_window.amount > $game_party.armor_number(@item.id)
@amount_window.amount = $game_party.armor_number(@item.id)
end
end
end
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@amount_window.amount -= 10
if @amount_window.amount < 1
@amount_window.amount = 1
end
end
end
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum