Project1
标题:
VX 分类物品的默认商店
[打印本页]
作者:
八云紫
时间:
2009-9-4 22:08
标题:
VX 分类物品的默认商店
本帖最后由 八云紫 于 2009-9-4 22:28 编辑
结合 小幽酱 的分类脚本一起使用, 让商店也有分类效果. 仅仅用在默认的商店里.
核心使用的是 小幽酱 的 分类脚本, 该脚本没有任何技术含量, 有 BUG 请联系咱.
class Harts_Window_ItemCommand < Window_Selectable
def initialize(x = 0, y = 64, w = 160, h = 296)
super(x, y, w, h)
@type = true
self.index = 0
refresh
end
alias old_byz_addcommand addcommand
def addcommand()
if @type
old_byz_addcommand
else
@commands = []
for i in $game_temp.shop_goods
case i[0]
when 0
item = $data_items[i[1]]
when 1
item = $data_weapons[i[1]]
when 2
item = $data_armors[i[1]]
end
if
[email protected]
?(item.desc)
@commands << item.desc
end
end
@item_max = @commands.size
end
end
def setType(bool)
@type = bool
refresh()
end
def getCommand()
return @commands[self.index]
end
end
#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
#--------------------------------------------------------------------------
alias old_byz_initialize initialize
def initialize(x, y, command = nil)
@command = command
old_byz_initialize(x, y)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@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 and item.desc == @command
@data.push(item)
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
def setCommand(command)
@command = command
refresh()
end
end
#==============================================================================
# ■ Window_ShopSell
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以卖掉的商品的窗口。
#==============================================================================
class Window_ShopSell < Window_Item
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
#--------------------------------------------------------------------------
alias old_byz_initialize initialize
def initialize(x, y, w, h)
@command = nil
old_byz_initialize(x, y, w, h)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
return if @command == nil
@data = []
for item in $game_party.items
next if @command != item.desc
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
def setCommand(command)
@command = command
refresh()
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
@type = 0
create_menu_background
create_command_window
@item_type_window = Harts_Window_ItemCommand.new(0, 112, 304, 304)
@item_type_window.active = false
@item_type_window.visible = false
@help_window = Window_Help.new
@gold_window = Window_Gold.new(384, 56)
@dummy_window = Window_Base.new(0, 112, 544, 304)
@buy_window = Window_ShopBuy.new(0, 112)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@sell_window = Window_ShopSell.new(0, 112, 544, 304)
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
@number_window = Window_ShopNumber.new(0, 112)
@number_window.active = false
@number_window.visible = false
@status_window = Window_ShopStatus.new(304, 112)
@status_window.visible = false
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
alias old_byz_terminate terminate
def terminate
old_byz_terminate
@item_type_window.dispose
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@item_type_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
if @command_window.active
update_command_selection
elsif @buy_window.active
update_buy_selection
elsif @sell_window.active
update_sell_selection
elsif @number_window.active
update_number_input
elsif @item_type_window.active
update_type_window()
end
end
#--------------------------------------------------------------------------
# ● 更新指令窗口
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
case @command_window.index
when 0 # 购买
Sound.play_decision
@command_window.active = false
@dummy_window.visible = false
@item_type_window.visible = true
@item_type_window.active = true
@item_type_window.setType(false)
@status_window.visible = true
@type = 1
when 1 # 卖出
if $game_temp.shop_purchase_only
Sound.play_buzzer
else
Sound.play_decision
@item_type_window.visible = true
@item_type_window.refresh
@command_window.active = false
@dummy_window.visible = false
@item_type_window.active = true
@item_type_window.setType(true)
@type = 2
end
when 2 # 取消
Sound.play_decision
$scene = Scene_Map.new
end
end
end
def update_type_window()
if Input.trigger?(Input::B)
Sound.play_cancel
@dummy_window.visible = true
@item_type_window.active = false
@command_window.active = true
@item_type_window.visible = false
@status_window.visible = false
if @type == 1
@buy_window.active = false
@buy_window.visible = false
else
@sell_window.active = false
@sell_window.visible = false
end
@type = 0
elsif Input.trigger?(Input::C)
command = @item_type_window.getCommand()
if @type == 1
@buy_window.setCommand(command)
@buy_window.active = true
@buy_window.visible = true
else
@sell_window.setCommand(command)
@sell_window.active = true
@sell_window.visible = true
end
@item_type_window.active = false
@item_type_window.visible = false
end
end
#--------------------------------------------------------------------------
# ● 更新选择购买物品
#--------------------------------------------------------------------------
def update_buy_selection
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
Sound.play_cancel
@item_type_window.active = true
@item_type_window.visible = true
@item_type_window.setType(false)
@buy_window.active = false
@buy_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
number = $game_party.item_number(@item)
if @item == nil or @item.price > $game_party.gold or number == 99
Sound.play_buzzer
else
Sound.play_decision
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# ● 更新选择卖出物品
#--------------------------------------------------------------------------
def update_sell_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@item_type_window.active = true
@item_type_window.visible = true
@item_type_window.setType(true)
@sell_window.active = false
@sell_window.visible = false
@status_window.item = nil
@help_window.set_text("")
elsif Input.trigger?(Input::C)
@item = @sell_window.item
@status_window.item = @item
if @item == nil or @item.price == 0
Sound.play_buzzer
else
Sound.play_decision
max = $game_party.item_number(@item)
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# ● 更新输入个数
#--------------------------------------------------------------------------
def update_number_input
if Input.trigger?(Input::B)
cancel_number_input
if @type == 1
@item_type_window.setType(true)
else
@item_type_window.setType(false)
end
elsif Input.trigger?(Input::C)
decide_number_input
if @type == 1
@item_type_window.setType(true)
else
@item_type_window.setType(false)
end
end
end
end
复制代码
作者:
yy461530593
时间:
2009-9-4 22:12
这个必须顶,我用XP。。嘿嘿
作者:
killkill2298
时间:
2009-9-6 07:33
谢谢云紫~~~~
不客气的收下了
作者:
八云紫
时间:
2009-9-6 11:49
谢谢云紫~~~~
不客气的收下了
killkill2298 发表于 2009-9-6 07:33
八云 紫, 不是 八 云紫
作者:
小幽的马甲
时间:
2009-9-6 12:22
啊呜啊呜,核心用的是那个物品分类脚本么……
那个似乎是我在换号前复刻的,好怀念的感觉呢。
作者:
八云紫
时间:
2009-9-6 12:25
呵呵, 发现 小幽酱 了~~
作者:
小幽的马甲
时间:
2009-9-6 12:39
嗯。紫sama也是、好久不见了呢。啊呜♪
作者:
银元
时间:
2009-10-4 12:52
我才找到55555555555
作者:
精灵使者
时间:
2009-10-4 13:09
XP版的古树曾经做出来过……但没有独立
啥时候帮我做个XP的独立版本吧,恩。
作者:
s554187203
时间:
2010-8-10 14:51
我没有物品分类~(飘过~)
作者:
流星落
时间:
2010-8-12 15:49
这个要顶,玩vx游戏逛商店很痛苦。
作者:
a598829998
时间:
2010-8-19 03:27
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1