赞 | 1 |
VIP | 337 |
好人卡 | 3 |
积分 | 1 |
经验 | 37815 |
最后登录 | 2021-7-9 |
在线时间 | 379 小时 |
Lv1.梦旅人 魔王 ⑨
- 梦石
- 0
- 星屑
- 90
- 在线时间
- 379 小时
- 注册时间
- 2006-10-16
- 帖子
- 4299

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
RT,这个是66黑剑的物品分类脚本
#==============================================================================
# ■ Window_ItemTitle
#------------------------------------------------------------------------------
# 选择类别
#==============================================================================
class Window_ItemTitle < Window_Base #"使用物品"四个字的窗口
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
end
end
#==============================================================================
# ■ Window_ItemCommand
#------------------------------------------------------------------------------
# 选择类别
#==============================================================================
class Window_ItemCommand < Window_Selectable
#———— 初始化 ————
def initialize
super(0, 64, 160, 224)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 6
#——各类物品的判别标志————
#——药物:分散度0 ——————
#——食物:分散度1 ——————
#——书报杂志:分散度2 ——————
#——装备:根据原本类push———
#——曲谱:分散度3 ——————
#——特殊:分散度4 ——————
@commands = ["药物类", "食物类", "书报杂志", "各种装备", "曲谱乐谱", "特殊道具"]
refresh
self.index = 0
end
#———— 刷新 ————
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#—— 描绘项目 ——| index:编号,color:颜色——————
def draw_item(index, color)
self.contents.font.color = color
y = index * 32
self.contents.draw_text(4, y, 128, 32, @commands[index])
end
#—— 帮助部分更新 ————
def update_help
case self.index
when 0
@text = @commands[0]
when 1
@text = @commands[1]
when 2
@text = @commands[2]
when 3
@text = @commands[3]
when 4
@text = @commands[4]
when 5
@text = @commands[5]
end
@help_window.set_text(@text)
end
end # Window_ItemCommand的
#==============================================================================
# ■ Window_ItemList
#------------------------------------------------------------------------------
# 物品窗口。 item.variance是物品的"分散度",借来用做分类
#==============================================================================
class Window_ItemList < Window_Selectable
#———— 初始化 ————
def initialize
super(160, 0, 480, 416)
refresh
self.index = 0
end
#—— 取得现在选择的物品 ——
def item
return @data[self.index]
end
#—— 刷新 ———
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
end
#—— 设置不同类别的物品 ———
def set_item(command)
refresh
#—— 根据现在的选项决定物品 ——
case command
when 0 #药品,特点是分散度为0
for i in 1...$data_items.size
if ($data_items.variance == 0 and $game_party.item_number(i) > 0)
@data.push($data_items)
end
end
when 1 #食物类,特点是分散度为1
for i in 1...$data_items.size
if ($data_items.variance == 1 and $game_party.item_number(i) > 0)
@data.push($data_items)
end
end
when 2 #杂货类,特点是分散度为2
for i in 1...$data_items.size
if ($data_items.variance == 2 and $game_party.item_number(i) > 0)
@data.push($data_items)
end
end
when 3 #各种装备:根据原本类push
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
when 4 #各类曲谱:特点是分散度为3
for i in 1...$data_items.size
if ($data_items.variance == 3 and $game_party.item_number(i) > 0)
@data.push($data_items)
end
end
when 5 #特殊物品:特点是分散度为4
for i in 1...$data_items.size
if ($data_items.variance == 4 and $game_party.item_number(i) > 0)
@data.push($data_items)
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
#——— 单类物品的个数 ————
def item_number
return @item_max
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 item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = half_disabled_color
end
#—— 描绘物体图标、物体名、数量 ——
x = 4
y = index * 32
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 + 400, y, 16, 32, ":", 1)
self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
end
#——— 更新帮助窗口 ————
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end #—— Window_ItemList 的 ——
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品
#==============================================================================
class Scene_Item
#—— 透明度的准备 ——
include OPACITY
#——— 主处理 ————
def main
create_screen_print # 创建截图
#——— 各种窗口预定义 ————
@itemtitle_window = Window_ItemTitle.new
@itemcommand_window = Window_ItemCommand.new
@command_index = @itemcommand_window.index
@itemlist_window = Window_ItemList.new
@itemlist_window.active = false
@itemlist_window.set_item(@command_index)
@help_window = Window_Help.new
@help_window.x = 0
@help_window.y = 416
@itemcommand_window.help_window = @help_window
@itemlist_window.help_window = @help_window
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
Graphics.transition
#—— 主循环 ——
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
#—— 释放窗口 ——
Graphics.freeze
@itemtitle_window.dispose
@itemcommand_window.dispose
@itemlist_window.dispose
@help_window.dispose
@target_window.dispose
dispose_screen_print # 释放截图
end # main的
#—— update的定义 ——
def update
@itemtitle_window.update
@itemcommand_window.update
@itemlist_window.update
@help_window.update
@target_window.update
if @command_index != @itemcommand_window.index
@command_index = @itemcommand_window.index
@itemlist_window.set_item(@command_index)
end
#—— 当某窗体在active的时候,更新之 ——
if @itemcommand_window.active
update_itemcommand
return
end
if @itemlist_window.active
update_itemlist
return
end
if @target_window.active
update_target
return
end
end # update的
#————具体更新定义————
def update_itemcommand
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(0,1)
return
end
if Input.trigger?(Input::C)
if @itemlist_window.item_number == 0
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@itemcommand_window.active = false
@itemlist_window.active = true
@itemlist_window.index = 0
return
end
end
#————具体更新定义————
def update_itemlist
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@itemcommand_window.active = true
@itemlist_window.active = false
@itemlist_window.index = 0
@itemcommand_window.index = @command_index
return
end
if Input.trigger?(Input::C)
@item = @itemlist_window.item
unless @item.is_a?(RPG::Item)
$game_system.se_play($data_system.buzzer_se)
return
end
unless $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
if @item.scope >= 3
@itemlist_window.active = false
@target_window.x = 304
@target_window.visible = true
@target_window.active = true
if @item.scope == 4 || @item.scope == 6
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$game_system.se_play(@item.menu_se)
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
if @item.consumable
$game_party.lose_item(@item.id, 1)
end
$game_switches[25] = true
$scene = Scene_Map.new
return
else
@target_window.index = -1
end
else
@target_window.index = 0
end
else
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$game_system.se_play(@item.menu_se)
if @item.consumable #——消耗品的情况
$game_party.lose_item(@item.id, 1)
@itemlist_window.draw_item(@itemlist_window.index) #——重新描绘
end
$game_switches[25] = true
$scene = Scene_Map.new
return
end
end
return
end
end
#———— 更新target窗口————
def update_target
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
unless $game_party.item_can_use?(@item.id)
@itemlist_window.refresh
end
@itemlist_window.active = true
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@command_index)
return
end
if Input.trigger?(Input::C)
if $game_party.item_number(@item.id) == 0
$game_system.se_play($data_system.buzzer_se)
return
end
if @target_window.index == -1
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
if @target_window.index >= 0
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
if used
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@command_index)
end
@target_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
return
end
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = Scene_Map.new
return
end
end
unless used
$game_system.se_play($data_system.buzzer_se)
end
return
end
end #target窗口的
end #Class Scene_Item的
怎么加多一个选项……可以的话把思路跟我说说 版务信息:本贴由楼主自主结贴~ |
|