赞 | 40 |
VIP | 559 |
好人卡 | 234 |
积分 | 47 |
经验 | 251834 |
最后登录 | 2024-10-11 |
在线时间 | 5240 小时 |
Lv3.寻梦者 (版主) 八宝粥的基叔
- 梦石
- 0
- 星屑
- 4684
- 在线时间
- 5240 小时
- 注册时间
- 2009-4-29
- 帖子
- 14318
|
时间太紧了,凑合一下,帮助窗口的坐标你自己调了,不要伸手过长。把以下脚本替换原来的整合物品分类脚本。- #==============================================================================
- # 作者:NaturalBlue
- # 说明:此脚本实现菜单与战斗时的物品分类。
- # protosssonny修改版
- #==============================================================================
- module RPG
- class Weapon
- def note
- note = @note.split(/@/)[0]
- return note != nil ? note : ''
- end
- def nt#在没有备注的情况下,物品被放在此处
- nt = @note.split(/@/)[1]
- return nt != nil ? nt : "普通物品"
- end
- end
- class Item
- def note
- note = @note.split(/@/)[0]
- return note != nil ? note : ''
- end
- def nt
- nt = @note.split(/@/)[1]
- return nt != nil ? nt : "普通物品"
- end
- end
- class Armor
- def note
- note = @note.split(/@/)[0]
- return note != nil ? note : ''
- end
- def nt
- nt = @note.split(/@/)[1]
- return nt != nil ? nt : "普通物品"
- end
- end
- end
- #========================================================================
- class NaturalBlue_Window_ItemTitle < Window_Base
- def initialize
- super(0, 0, 160, 56)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.clear
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 0, 120, 24, Vocab::item, 1)
- end
- end
- #========================================================================
- class NaturalBlue_Window_ItemCommand < Window_Selectable
- attr_accessor :commands
- def initialize
- super(0, 56, 160, 360)
- self.index = 0
- refresh
- end
-
- def addcommand
- @commands = []
- for i in 1..$data_items.size
- if $game_party.item_number($data_items[i]) > 0
- push = true
- for com in @commands
- if com == $data_items[i].nt
- push = false
- end
- end
- if push == true
- @commands.push($data_items[i].nt)
- end
- end
- end
- for i in 1..$data_weapons.size
- if $game_party.item_number($data_weapons[i]) > 0
- push = true
- for com in @commands
- if com == $data_weapons[i].nt
- push = false
- end
- end
- if push == true
- @commands.push($data_weapons[i].nt)
- end
- end
- end
- for i in 1..$data_armors.size
- if $game_party.item_number($data_armors[i]) > 0
- push = true
- for com in @commands
- if com == $data_armors[i].nt
- push = false
- end
- end
- if push == true
- @commands.push($data_armors[i].nt)
- end
- end
- end
- if @commands == []
- @commands.push("普通物品")
- end
- @item_max = @commands.size
- end
-
- def refresh
- addcommand
- create_contents
- for i in 0...@item_max
- draw_item(i, normal_color)
- end
- end
-
- def draw_item(index, color)
- y = index * WLH
- self.contents.font.color = color
- if @commands[index] != nil
- self.contents.draw_text(4,y, 172, WLH, @commands[index])
- end
- end
- def update_help
- @help_window.set_text(@commands[self.index])
- @help_window.visible = false
- end
- end
- #========================================================================
- class NaturalBlue_Window_ItemList < Window_Selectable
-
- def initialize
- super(160, 56, 384, 360)
- self.index = 0
- refresh
- @column_max = 10
- @index = -1
- @spacing = 4
- end
-
- def item
- return @data[self.index]
- end
-
- def refresh
- @data = []
- end
-
- def set_item(command)
- refresh
- for i in 1..$data_items.size
- if $game_party.item_number($data_items[i]) > 0 and $data_items[i].nt == command
- @data.push($data_items[i])
- end
- end
- for i in 1..$data_weapons.size
- if $game_party.item_number($data_weapons[i]) > 0 and $data_weapons[i].nt == command
- @data.push($data_weapons[i])
- end
- end
- for i in 1..$data_armors.size
- if $game_party.item_number($data_armors[i]) > 0 and $data_armors[i].nt == command
- @data.push($data_armors[i])
- end
- end
- @item_max = @data.size
- r = row_max
- r = 1 if r == 0
- if @item_max > 0
- self.contents = Bitmap.new(384 - 32, r * 32)
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
-
- def set_item_sell(command)
- refresh
- for i in 1..$data_items.size
- if $game_party.item_number($data_items[i]) > 0 and $data_items[i].nt == command
- @data.push($data_items[i])
- end
- end
- for i in 1..$data_weapons.size
- if $game_party.item_number($data_weapons[i]) > 0 and $data_weapons[i].nt == command
- @data.push($data_weapons[i])
- end
- end
- for i in 1..$data_armors.size
- if $game_party.item_number($data_armors[i]) > 0 and $data_armors[i].nt == command
- @data.push($data_armors[i])
- end
- end
- @item_max = @data.size
- r = row_max
- r = 1 if r == 0
- if @item_max > 0
- self.contents = Bitmap.new(384 - 32, r * 32)
- self.contents.clear
- for i in 0...@item_max
- draw_item_sell(i)
- end
- end
- end
-
- def item_number
- return @item_max
- end
-
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @data[index]
- if item != nil
- number = $game_party.item_number(item)
- enabled = $game_party.item_can_use?(item)
- rect.width -= 4
- draw_icon(item.icon_index, rect.x, rect.y, enabled)
- self.contents.font.size = 12
- self.contents.draw_text(rect.x, rect.y + 4, rect.width, rect.height, sprintf("%2d", number), 2)
- self.contents.font.size = 20
- end
- end
-
- def draw_item_sell(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @data[index]
- if item != nil
- number = $game_party.item_number(item)
- enabled = jugde_enable(item)
- rect.width -= 4
- draw_icon(item.icon_index, rect.x, rect.y, enabled)
- self.contents.font.size = 12
- self.contents.draw_text(rect.x, rect.y + 4, rect.width, rect.height, sprintf("%2d", number), 2)
- self.contents.font.size = 20
- end
- end
-
- def jugde_enable(item)
- return item.price > 0
- end
-
- #--------------------------------------------------------------------------
- # ● 光标下移
- # wrap : 允许循环
- #--------------------------------------------------------------------------
- def cursor_down(wrap = false)
- if (@index < @item_max - @column_max) or (wrap and @column_max == 1)
- @index += 10
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标上移
- # wrap : 允许循环
- #--------------------------------------------------------------------------
- def cursor_up(wrap = false)
- if (@index >= @column_max) or (wrap and @column_max == 1)
- @index -= 10
- end
- end
-
- #==============================================================================
- # ■ Window_ShopSell
- #------------------------------------------------------------------------------
- # 商店画面、浏览显示可以卖掉的商品的窗口。
- #==============================================================================
- def update_help
- @help_window.set_text(item)
- if item != nil
- @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
- else
- @help_window.x = 1000 #没有物品时,让帮助窗口出界而看不见
- end
- end
- end
- #========================================================================
- class NaturalBlue_Window_MenuStatus < Window_Selectable
- def initialize(x, y)
- super(x, y, 288, 416)
- refresh
- self.active = false
- self.index = -1
- end
- def refresh
- self.contents.clear
- @item_max = $game_party.members.size
- for actor in $game_party.members
- x = 8
- y = actor.index * 96 + WLH / 2
- draw_actor_name(actor, x, y)
- draw_actor_class(actor, x + 120, y)
- draw_actor_level(actor, x, y + WLH * 1)
- draw_actor_state(actor, x, y + WLH * 2)
- draw_actor_hp(actor, x + 120, y + WLH * 1)
- draw_actor_mp(actor, x + 120, y + WLH * 2)
- end
- end
- def update_cursor
- if @index < 0
- self.cursor_rect.empty
- elsif @index < @item_max
- self.cursor_rect.set(0, @index * 96, contents.width, 96)
- elsif @index >= 100
- self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
- else
- self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
- end
- end
- end
- class Scene_Item < Scene_Base
- def start
- super
- $item_self = 0 if $item_self == nil #例如声望之书,使用后$item_self == 0,if $item_self == 0,光标就仍然停留在原物品上面
- @item_self = 0 if @item_self == nil #例如声望之书,使用后它会记录此时光标的index
- @command_self = 0 if @command_self == nil #例如声望之书,使用后它会记录物品分类此时光标的index
- create_menu_background
- @viewport = Viewport.new(0, 0, 544, 416)
- @itemtitle_window = NaturalBlue_Window_ItemTitle.new
- @itemcommand_window = NaturalBlue_Window_ItemCommand.new
- @command_index = @itemcommand_window.index
- @itemcommand_window.refresh
- @itemlist_window = NaturalBlue_Window_ItemList.new
- @itemlist_window.y = 0
- @itemlist_window.height = 416
- @itemlist_window.active = false
- @help_window = Window_Help.new
- @target_window = Window_MenuStatus.new(100, 0)
- @itemcommand_window.help_window = @help_window
- @itemlist_window.help_window = @help_window
- @itemlist_window.help_window.x = 1000 #让它初始化时出界不显示
- @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
- hide_target_window
- end
- def terminate
- super
- dispose_menu_background
- @viewport.dispose
- @itemtitle_window.dispose
- @itemcommand_window.dispose
- @itemlist_window.dispose
- @help_window.dispose
- @target_window.dispose
- end
- def return_scene
- $scene = Scene_Menu.new(0)
- end
- def update
- super
- update_menu_background
- @help_window.update
- @itemlist_window.update
- @itemcommand_window.update
- @target_window.update
- @itemcommand_window.refresh
- if $item_self == 1
- @itemcommand_window.active = false
- @itemcommand_window.index = @command_self
- @itemlist_window.active = true
- @itemlist_window.index = @item_self
- end
- if @command_index != @itemcommand_window.index
- if $item_self == 0
- @itemlist_window.index = 0
- else
- $item_self = 0
- end
- @command_index = @itemcommand_window.index
- @itemcommand_window.update_help
- @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
- end
- if @itemcommand_window.active
- @itemcommand_window.update_help
- update_itemcommand
- elsif @itemlist_window.active
- update_itemlist
- elsif @target_window.active
- update_target_selection
- end
- end
- def update_itemcommand
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- return
- end
- if Input.trigger?(Input::C)
- if @itemlist_window.item_number == 0
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- @itemcommand_window.active = false
- @itemlist_window.index = 0
- @itemlist_window.active = true
- return
- end
- end
- def update_itemlist
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @itemcommand_window.active = true
- @itemlist_window.active = false
- @help_window.visible = false #我加
- @itemcommand_window.index = @command_index
- elsif Input.trigger?(Input::C)
- @item = @itemlist_window.item
- if @item != nil
- $game_party.last_item_id = @item.id
- end
- if $game_party.item_can_use?(@item)
- Sound.play_decision
- determine_item
- else
- Sound.play_buzzer
- end
- end
- end
- def determine_item
- if @item.for_friend?
- show_target_window(@itemlist_window.index % 2 == 0)
- if @item.for_all?
- @target_window.index = 99
- else
- if $game_party.last_target_index < @target_window.item_max
- @target_window.index = $game_party.last_target_index
- else
- @target_window.index = 0
- end
- end
- else
- use_item_nontarget
- end
- end
- def update_target_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- if $game_party.item_number(@item) == 0
- @itemlist_window.refresh
- end
- @itemlist_window.active = true
- @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
- hide_target_window
- @itemlist_window.active = true
- elsif Input.trigger?(Input::C)
- if not $game_party.item_can_use?(@item)
- Sound.play_buzzer
- else
- determine_target
- end
- end
- end
- def determine_target
- used = false
- if @item.for_all?
- for target in $game_party.members
- target.item_effect(target, @item)
- used = true unless target.skipped
- end
- else
- $game_party.last_target_index = @target_window.index
- target = $game_party.members[@target_window.index]
- target.item_effect(target, @item)
- used = true unless target.skipped
- end
- if used
- use_item_nontarget
- else
- Sound.play_buzzer
- end
- end
- def show_target_window(right)
- @help_window.visible = false
- @itemlist_window.active = false
- width_remain = 544 - @target_window.width
- @target_window.x = right ? width_remain : 0
- @target_window.visible = true
- @target_window.active = true
- if right
- @viewport.rect.set(0, 0, width_remain, 416)
- @viewport.ox = 0
- else
- @viewport.rect.set(@target_window.width, 0, width_remain, 416)
- @viewport.ox = @target_window.width
- end
- end
- def hide_target_window
- @help_window.visible = true
- @target_window.visible = false
- @target_window.active = false
- @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
- @viewport.rect.set(0, 0, 544, 416)
- @viewport.ox = 0
- end
- def use_item_nontarget
- Sound.play_use_item
- $game_party.consume_item(@item)
- @itemlist_window.draw_item(@itemlist_window.index)
- @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
- @target_window.refresh
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- elsif @item.common_event_id > 0
- @command_self = @command_index
- @item_self = @itemlist_window.index
- $game_temp.common_event_id = @item.common_event_id
- $last_scene = $scene #声望之书等会还原物品选择的scene
- $scene = Scene_Map.new
- end
- end
- end
- #==============================================================================
- #==============================================================================
- # ■ Scene_Battle 补充定义 ★★★★★★
- #------------------------------------------------------------------------------
- # 实现战斗时物品选择的分类。
- # 作者:NaturalBlue
- # 说明:此脚本参考了柳柳的“战斗技能脚本”。
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始物品选择
- #--------------------------------------------------------------------------
- def start_item_selection
- @help_window = Window_Help.new
- @item_window = NaturalBlue_Window_ItemList.new
- @item_window.help_window = @help_window
- @item_window.y = 0
- @item_window.height = 288
- @itemcommand_window = NaturalBlue_Window_ItemCommand.new
- @itemcommand_window.y = 0
- @itemcommand_window.height = 288
- @itemcommand_window.active = true
- @itemcommand_window.back_opacity = 200
- @itemcommand_window.help_window = @help_window
- @command_index = @itemcommand_window.index
- @item_window.set_item(@itemcommand_window.commands[@command_index])
- @actor_command_window.active = false
- @item_window.active = false
- end
- #--------------------------------------------------------------------------
- # ● 结束物品选择
- #--------------------------------------------------------------------------
- def end_item_selection
- if @item_window != nil
- @item_window.dispose
- @item_window = nil
- @help_window.dispose
- @help_window = nil
- @itemcommand_window.dispose
- @itemcommand_window = nil
- end
- @actor_command_window.active = true
- end
- #--------------------------------------------------------------------------
- # ● 更新物品选择
- #--------------------------------------------------------------------------
- def update_item_selection
- @item_window.visible = true
- @itemcommand_window.visible = true
- @itemcommand_window.update
- if @command_index != @itemcommand_window.index
- @command_index = @itemcommand_window.index
- @item_window.set_item(@itemcommand_window.commands[@command_index])
- @item_window.index = 0
- end
- @item_window.update
- @help_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- if @item_window.active == true
- @itemcommand_window.active = true
- @item_window.active = false
- else
- end_item_selection
- end
- elsif Input.trigger?(Input::C)
- if @item_window.active == false
- @item_window.active = true
- @itemcommand_window.active = false
- Sound.play_decision
- return
- end
- @item = @item_window.item
- if @item != nil
- $game_party.last_item_id = @item.id
- end
- if $game_party.item_can_use?(@item)
- Sound.play_decision
- determine_item
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 确认物品
- #--------------------------------------------------------------------------
- def determine_item
- @active_battler.action.set_item(@item.id)
- @item_window.active = false
- @itemcommand_window.visible = false
- if @item.need_selection?
- if @item.for_opponent?
- start_target_enemy_selection
- else
- start_target_actor_selection
- end
- else
- end_item_selection
- next_actor
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新同伴目标选择
- #--------------------------------------------------------------------------
- def update_target_actor_selection
- @target_actor_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @item_window.active = true if @item_window != nil
- end_target_actor_selection
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- @active_battler.action.target_index = @target_actor_window.index
- end_target_actor_selection
- end_skill_selection
- end_item_selection
- next_actor
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新敌人目标选择
- #--------------------------------------------------------------------------
- def update_target_enemy_selection
- @target_enemy_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @item_window.active = true if @item_window != nil
- end_target_enemy_selection
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- @active_battler.action.target_index = @target_enemy_window.enemy.index
- end_target_enemy_selection
- end_skill_selection
- end_item_selection
- next_actor
- end
- end
- end
复制代码 |
评分
-
查看全部评分
|