#职业备注栏填写 <skill_max: 4> 最多可学习4个技能,第五个以后需要遗忘技能
#正则表达式
class RPG::Actor < RPG::BaseItem
#--------------------------------------------------------------------------
# ● 获取技能最大数
#--------------------------------------------------------------------------
def skill_max
classes = $data_classes[@class_id]
classes.note =~ /<skill_max\s*[::](.*)>/i # 你好歹让人家用半角冒号吧
return $1.to_i if $1#!= nil
end
end
#使用时的情况
class Game_Actor
#--------------------------------------------------------------------------
# ● 领悟技能
#--------------------------------------------------------------------------
def learn_skill(skill_id)
unless skill_learn?($data_skills[skill_id])
@skills.push(skill_id)
@skills.sort!
skill_learn_max#(@skills)
end
end
def skill_learn_max#(new_skill)
return unless actor.skill_max # 好好缩进啦~
if @skills.size > actor.skill_max
SceneManager.call(Scene_skill_learn)
end
end
end
#窗口
#场景
class Scene_skill_learn < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_skill_learn_window
create_skill_forget_command
@skill_window.activate
#~ @have_learn = false
#~ @forget_skill_id = 0
end
def create_skill_learn_window
# Window_skill_command.init_command_position
@skill_window = Window_skill_command.new(@actor)
@skill_window.set_handler(:skill, method(:on_skill_ok))
#~ @skill_window.set_handler(:skill_name1, method(:on_skill_ok))
#~ @skill_window.set_handler(:skill_name2, method(:on_skill_ok))
#~ @skill_window.set_handler(:skill_name3, method(:on_skill_ok))
#~ @skill_window.set_handler(:skill_name4, method(:on_skill_ok))
@skill_window.x = (Graphics.width - @skill_window.width)/2
@skill_window.y = (Graphics.height- @skill_window.height)/2
end
def create_skill_forget_command
# @skill_select_window.init_command_position
@skill_select_window = Window_skill_forget_command.new
@skill_select_window.set_handler(:forget_skill, method(:forget_skill))
@skill_select_window.set_handler(:cancel, method(:skill_select_cancel))
@skill_select_window.x = @skill_window.x + @skill_window.width
@skill_select_window.y = @skill_window.y
end
#更新
def forget_skill
#~ msgbox @actor.skills
@actor.forget_skill(@skill_window.current_ext)
#~ msgbox @actor.skills
# @actor.skills.sort!
#~ @have_learn = true
return_scene
end
#~ def return_scene1
#~ if @have_learn then
#~ SceneManager.return
#~ end
#~ end
def skill_select_cancel
@skill_select_window.hide
@skill_select_window.deactivate
@skill_window.activate
end
#--------------------------------------------------------------------------
# ● 个人指令“确定”
#--------------------------------------------------------------------------
def on_skill_ok
#~ case @skill_window.current_symbol
#~ when :skill_name0
#~ @forget_skill_id = @actor.skills[0].id
#~ when :skill_name1
#~ @forget_skill_id = @actor.skills[1].id
#~ when :skill_name2
#~ @forget_skill_id = @actor.skills[2].id
#~ when :skill_name3
#~ @forget_skill_id = @actor.skills[3].id
#~ when :skill_name4
#~ @forget_skill_id = @actor.skills[4].id
#~ end
@skill_window.deactivate
@skill_select_window.show
@skill_select_window.activate
end
#~ def update
#~ super
#~ @skill_select_window.y = @skill_window.y + @skill_window.index * 24
#~ end
end
#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
# 技能遗忘选择列表
#==============================================================================
class Window_skill_command < Window_Command
#--------------------------------------------------------------------------
# ● 初始化指令选择位置(类方法)
#--------------------------------------------------------------------------
#~ def self.init_command_position
#~ @@last_command_symbol = nil
#~ end
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(actor)
@actor = actor
#~ @skill_name = []
#~ @skill_name[0] = actor.skills[0].name
#~ @skill_name[1] = actor.skills[1].name
#~ @skill_name[2] = actor.skills[2].name
#~ @skill_name[3] = actor.skills[3].name
#~ @skill_name[4] = actor.skills[4].name
super(0, 0)
#~ select_last
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# ● 获取显示行数
#--------------------------------------------------------------------------
#~ def visible_line_number
#~ item_max
#~ end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
#~ add_commands
#~ end
#~ #--------------------------------------------------------------------------
#~ # ● 向指令列表添加主要的指令
#~ #--------------------------------------------------------------------------
#~ def add_commands
@actor.skills.each do |skill|
add_command(skill.name, :skill, true, skill.id)
end
#~ add_command(@skill_name[0], :skill_name0)
#~ add_command(@skill_name[1], :skill_name1)
#~ add_command(@skill_name[2], :skill_name2)
#~ add_command(@skill_name[3], :skill_name3)
#~ add_command(@skill_name[4], :skill_name4)
end
#~ #--------------------------------------------------------------------------
#~ # ● 按下确定键时的处理
#~ #--------------------------------------------------------------------------
#~ def process_ok
#~ @@last_command_symbol = current_symbol
#~ super
#~ end
#~ #--------------------------------------------------------------------------
#~ # ● 返回最后一个选项的位置
#~ #--------------------------------------------------------------------------
#~ def select_last
#~ select_symbol(@@last_command_symbol)
#~ end
end
#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
# 技能是否遗忘
#==============================================================================
class Window_skill_forget_command < Window_Command
def initialize
super(100,120)
self.visible = false
self.active = false
#~ @index = 0
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command("遗忘",:forget_skill)
add_command("取消",:cancel)
end
end