赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 214 |
最后登录 | 2012-6-17 |
在线时间 | 89 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 89 小时
- 注册时间
- 2012-1-9
- 帖子
- 40
|
本帖最后由 1163833985 于 2012-4-4 14:46 编辑
- #============================================================================
- # 定义装备等级限制方法:在数据库装备备注里写上[LV n] ,LV后有空格,n为等级,
- # 同理,定义装备能力值限制方法:
- # 备注里写上[ATK n][DEF n][MAT n][MDF n][AGI n][LUK n]。
- # 攻击 防御 魔攻 魔防 敏捷 幸运
- # 若某项限制不写则没有装备限制。
- # 注意这里限制的能力值是人物原始的能力值,不考虑装备、状态的影响,
- # 但是考虑事件对能力值的影响。
- #==============================================================================
- # ■ RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- def param_limit(p_id)
- return if p_id == 0 or p_id > 7
- regexp_strings = ["", "LV", "ATK", "DEF", "MAT", "MDF", "AGI", "LUK"]
- m = 0
- regexp = /\[#{regexp_strings[p_id]} (\d+)\]/
- self.note.split(/[\r\n]+/).each { |line|
- m = $1.to_i if line =~ regexp
- }
- return m
- end
- #--------------------------------------------------------------------------
- # ● 判断是否有要求
- #--------------------------------------------------------------------------
- def has_requirement?
- for i in 1..7
- return true if param_limit(i) > 0
- end
- return false
- end
- end
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 判断是否可以装备
- # item : 物品
- #--------------------------------------------------------------------------
- alias original_equippable? equippable?
- def equippable?(item)
- return unless item
- return true unless item.has_requirement?
- return false if self.level < item.param_limit(1) #等级限制
- for i in 2..7
- return false if actor_param(i) < item.param_limit(i)
- end
- return original_equippable?(item)
- end
- #--------------------------------------------------------------------------
- # ● 计算角色能力值
- #--------------------------------------------------------------------------
- def actor_param(param_id)
- t_p = param_base(param_id) + param_base(param_id)
- return [t_p, param_max(param_id)].min
- end
- end
- #==============================================================================
- # ■ Window_Item
- #------------------------------------------------------------------------------
- # 物品画面、战斗画面、显示浏览物品的窗口。
- #==============================================================================
- class Window_ItemList < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 更新帮助文本(自动显示使用物品的等级能力限制)
- #--------------------------------------------------------------------------
- def update_help
- if item.nil?
- @help_window.set_text("")
- return
- end
- newdes = item.description
- if item.has_requirement?
- newdes += " 要求:" if(item.has_requirement?)
- for i in 1..7
- next if item.param_limit(i) == 0
- limit_str = item.param_limit(i).to_s
- newdes += i==1 ? Vocab.level_a : Vocab.param(i) + limit_str
- end
- end
- @help_window.set_text(newdes)
- end
- end
- class Window_EquipItem < Window_ItemList
- def include?(item)
- o_equippable = original_include?(item)
- if !o_equippable
- return true if [email protected]?(item)
- end
- return o_equippable
- end
- #--------------------------------------------------------------------------
- # ● 判断是否有效化
- #--------------------------------------------------------------------------
- def enable?(item)
- return true unless item
- return @actor.equippable?(item)
- end
- end
复制代码- #==============================================================================
- # ** Scene_Equip
- #------------------------------------------------------------------------------
- # This class performs the equipment screen processing.
- #==============================================================================
- class Scene_Equip < Scene_Base
- #--------------------------------------------------------------------------
- # * Constants
- #--------------------------------------------------------------------------
- EQUIP_TYPE_MAX = 5 # Number of equip region
- #--------------------------------------------------------------------------
- # * Object Initialization
- # actor_index : actor index
- # equip_index : equipment index
- #--------------------------------------------------------------------------
- def initialize(actor_index = 0, equip_index = 0)
- @actor_index = actor_index
- @equip_index = equip_index
- end
- #--------------------------------------------------------------------------
- # * Start processing
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- @actor = $game_party.members[@actor_index]
- @help_window = Window_Help.new
- create_item_windows
- @equip_window = Window_Equip.new(208, 56, @actor)
- @equip_window.help_window = @help_window
- @equip_window.index = @equip_index
- @status_window = Window_EquipStatus.new(0, 56, @actor)
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @help_window.dispose
- @equip_window.dispose
- @status_window.dispose
- dispose_item_windows
- end
- #--------------------------------------------------------------------------
- # * Return to Original Screen
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Menu.new(2)
- end
- #--------------------------------------------------------------------------
- # * Switch to Next Actor Screen
- #--------------------------------------------------------------------------
- def next_actor
- @actor_index += 1
- @actor_index %= $game_party.members.size
- $scene = Scene_Equip.new(@actor_index, @equip_window.index)
- end
- #--------------------------------------------------------------------------
- # * Switch to Previous Actor Screen
- #--------------------------------------------------------------------------
- def prev_actor
- @actor_index += $game_party.members.size - 1
- @actor_index %= $game_party.members.size
- $scene = Scene_Equip.new(@actor_index, @equip_window.index)
- end
- #--------------------------------------------------------------------------
- # * Update Frame
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @help_window.update
- update_equip_window
- update_status_window
- update_item_windows
- if @equip_window.active
- update_equip_selection
- elsif @item_window.active
- update_item_selection
- end
- end
- #--------------------------------------------------------------------------
- # * Create Item Window
- #--------------------------------------------------------------------------
- def create_item_windows
- @item_windows = []
- for i in 0...EQUIP_TYPE_MAX
- @item_windows[i] = Window_EquipItem.new(0, 208, 544, 208, @actor, i)
- @item_windows[i].help_window = @help_window
- @item_windows[i].visible = (@equip_index == i)
- @item_windows[i].y = 208
- @item_windows[i].height = 208
- @item_windows[i].active = false
- @item_windows[i].index = -1
- end
- end
- #--------------------------------------------------------------------------
- # * Dispose of Item Window
- #--------------------------------------------------------------------------
- def dispose_item_windows
- for window in @item_windows
- window.dispose
- end
- end
- #--------------------------------------------------------------------------
- # * Update Item Window
- #--------------------------------------------------------------------------
- def update_item_windows
- for i in 0...EQUIP_TYPE_MAX
- @item_windows[i].visible = (@equip_window.index == i)
- @item_windows[i].update
- end
- @item_window = @item_windows[@equip_window.index]
- end
- #--------------------------------------------------------------------------
- # * Update Equipment Window
- #--------------------------------------------------------------------------
- def update_equip_window
- @equip_window.update
- end
- #--------------------------------------------------------------------------
- # * Update Status Window
- #--------------------------------------------------------------------------
- def update_status_window
- if @equip_window.active
- @status_window.set_new_parameters(nil, nil, nil, nil)
- elsif @item_window.active
- temp_actor = @actor.clone
- temp_actor.change_equip(@equip_window.index, @item_window.item, true)
- new_atk = temp_actor.atk
- new_def = temp_actor.def
- new_spi = temp_actor.spi
- new_agi = temp_actor.agi
- @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi)
- end
- @status_window.update
- end
- #--------------------------------------------------------------------------
- # * Update Equip Region Selection
- #--------------------------------------------------------------------------
- def update_equip_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- next_actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- prev_actor
- elsif Input.trigger?(Input::C)
- if @actor.fix_equipment
- Sound.play_buzzer
- else
- Sound.play_decision
- @equip_window.active = false
- @item_window.active = true
- @item_window.index = 0
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Update Item Selection
- #--------------------------------------------------------------------------
- def update_item_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @equip_window.active = true
- @item_window.active = false
- @item_window.index = -1
- elsif Input.trigger?(Input::C)
- Sound.play_equip
- @actor.change_equip(@equip_window.index, @item_window.item)
- @equip_window.active = true
- @item_window.active = false
- @item_window.index = -1
- @equip_window.refresh
- for item_window in @item_windows
- item_window.refresh
- end
- end
- end
- end
复制代码 |
|