查看: 1931|回复: 0

[已经过期] 实在是搞不懂这个技能树脚本的用法

[复制链接]
梦石
0
星屑
850
在线时间
160 小时
注册时间
2012-6-3
回帖
89
发表于 2015-12-18 01:55:46 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
对不起我实在是太蠢了,从上次找到作者主页到现在已经四天了……还是搞不懂……
这个技能树脚本真心很赞,主动技能和被动技能都有……
技能树脚本#==============================================================================
#  ■スキルツリーシステム for RGSS3 Ver0.85-α
# □作成者 kure
#
# 呼び出し方法  SceneManager.call(Scene_SkillTree)
#==============================================================================
$kure_integrate_script = {} if $kure_integrate_script == nil
$kure_integrate_script[:SkillTree] = 1
p "スキルツリーシステム"

#--------------------------------------------------------------------------
# ★ 設定項目(各設定の値を変更してください)
#--------------------------------------------------------------------------
module KURE
  module Skill_Tree
    #スキルポイントに関する設定-------------------------------------------------
      #基礎スキルポイントの値
      BASE_SKILL_POINT = 10

    #表示関する設定-------------------------------------------------------------  
      #スキルポイントの名称
      Skill_Point_NAME = "SP"
      
    #動作に関する設定-----------------------------------------------------------
      #スキルポイント回収「←キー」の有効設定
      #USE_LEFT_KEY = [有効にするツリーID配列]
      USE_LEFT_KEY = [0,1,2,3,4]
      
      #リセットモード
      # 1 = 左キ-による回収 2 = フルリセット
      RESET_MODE = 2
  end
end

#==============================================================================
# ▲ Vocab(追加定義)
#==============================================================================
module Vocab
  ObtainSkillP    = "%s のスキルポイントを獲得!"
end


#メモ欄処理モジュール--------------------------------------------------------
module KURE
  #--------------------------------------------------------------------------
  # ★ 数値配列に畳む(追加定義)
  #--------------------------------------------------------------------------  
  def self.arr_num_slice(arr)
    result_arr = Array.new
    unless arr == [] and arr.empty?
      arr.flatten!
      arr.each{|value| value.scan(/\d+/).each { |num| result_arr.push(num.to_i)}}
    end
    return result_arr
  end
  #--------------------------------------------------------------------------
  # ☆ 特徴の文字配列の呼び出し(追加定義)
  #--------------------------------------------------------------------------  
  def self.basic_call_effect_txt(item)
    draw_txt = Array.new   
    #書きだし
    item.effects.each{|effect|
      case effect.code
      #HP回復,MP回復,TP回復
      when 11,12,13
        case effect.code
        when 11 ; txt = "HP "
        when 12 ; txt = "MP "
        when 13 ; txt = "TP "
        end
        if effect.value1 != 0
          txt2 = "% 回復" if effect.value1 > 0
          txt2 = "% 減少" if effect.value1 < 0
          draw_txt.push(txt + (((effect.value1*100).abs).to_i).to_s + txt2)
        end
        if effect.value2 != 0
          txt2 = " 回復" if effect.value2 > 0
          txt2 = " 減少" if effect.value2 < 0
          draw_txt.push(txt + ((effect.value2.abs).to_i).to_s + txt2)
        end
      when 21,22
        case effect.code
        when 21 ; txt = " 付与 "
        when 22 ; txt = " 解除 "
        end
        name = effect.data_id == 0 ? "通常攻撃" : $data_states[effect.data_id].name
        draw_txt.push(name + txt + ((effect.value1*100).to_i).to_s + "%")
      when 31,32,33,34
        case effect.code
        when 31
          txt = " 強化付与 "
          txt2 = (effect.value1.to_i).to_s + "ターン"
        when 32
          txt = " 弱体付与 "
          txt2 = (effect.value1.to_i).to_s + "ターン"
        when 33
          txt = " 強化解除"
          txt2 = ""
        when 34
          txt = " 弱体解除"
          txt2 = ""
        end
        draw_txt.push(Vocab::param(effect.data_id) + txt + txt2)
      when 41
        draw_txt.push("逃走効果")
      when 42
        draw_txt.push(Vocab::param(effect.data_id) + " 成長(" + (effect.value1.to_i).to_s + ")" )
      when 43
        draw_txt.push($data_skills[effect.data_id].name + " 習得")
      when 44
        draw_txt.push("特殊効果")
      end
    }
   
    return draw_txt
  end
end

#==============================================================================
# ●■ RPG::BaseItem(追加定義集積)
#==============================================================================
class RPG::BaseItem
  #--------------------------------------------------------------------------
  # ◆ 使用スキルツリーの定義(追加定義)
  #--------------------------------------------------------------------------  
  def use_skill_tree
    KURE.arr_num_slice(@note.scan(/<使用スキルツリー\s?(\d+(?:\s?*,\s?*\d+)*)>/))
  end
  #--------------------------------------------------------------------------
  # ★ スキルポイントのLv補正定義(追加定義)
  #--------------------------------------------------------------------------  
  def sp_level_revise
    @note.match(/<スキルポイントLv補正\s?([1-9]\d*|0)(\.\d+)?>/)
    return 0 unless $1
    value = $1.to_f
    value += $2.to_f if $2
    return value  
  end
  #--------------------------------------------------------------------------
  # ★ 追加スキルポイント数を保存している変数の定義(追加定義)
  #--------------------------------------------------------------------------  
  def add_msp_var
    @note.match(/<追加ポイント数保存変数\s?(\d+)\s?>/)
    return $1 ? $1.to_i : 0
  end
  #--------------------------------------------------------------------------
  # ★ スキルポイントのアクター補正定義(追加定義)
  #--------------------------------------------------------------------------  
  def sp_revise
    @note.match(/<スキルポイント補正\s?(\d+)\s?>/)
    return $1 ? $1.to_i : 0
  end
end

#==============================================================================
# ●■ RPG::UsableItem(追加定義集積)
#==============================================================================
class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ☆ スキルディレイの定義(追加定義)
  #--------------------------------------------------------------------------  
  def reset_skill_point?
    @note.include?("<スキルポイントリセット>")
  end
end

#==============================================================================
# ■ RPG::Enemy(追加定義)
#==============================================================================
class RPG::Enemy < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ☆ スキルポイントの定義(追加定義)
  #--------------------------------------------------------------------------  
  def skill_exp
    @note.match(/<スキルポイント\s?(\d+)\s?>/)
    return $1 ? $1.to_i : 0
  end
end

#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ◎ スキル/アイテムの適用テスト(エイリアス再定義)
  #--------------------------------------------------------------------------
  alias k_skilltree_before_item_test item_test unless $!
  def item_test(user, item)
    return true if skill_point_reset_effect?(user, item)
    k_skilltree_before_item_test(user, item)
  end
  #--------------------------------------------------------------------------
  # ★ スキルポイントのリセット効果があるかどうか(追加定義)
  #--------------------------------------------------------------------------
  def skill_point_reset_effect?(user, item)
    return true if item.reset_skill_point?
    return false
  end
  #--------------------------------------------------------------------------
  # ◎ スキル/アイテムの効果適用(エイリアス再定義)
  #-------------------------------------------------------------------------
  alias k_skilltree_before_item_apply item_apply unless $!
  def item_apply(user, item)
    k_skilltree_before_item_apply(user, item)
    item_effect_reset_skillpoint(user, item)
  end
  #--------------------------------------------------------------------------
  # ☆ 使用効果[スキルポイントリセット](追加定義)
  #--------------------------------------------------------------------------
  def item_effect_reset_skillpoint(user, item)
    return unless actor?
    return unless skill_point_reset_effect?(user, item)
    case KURE::Skill_Tree::RESET_MODE
    when 1 ; self.reset_skill_flag = true
    when 2 ; self.sp3_full_reset
    end  
  end
end

#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ☆ スキルポイントの取得(追加定義)
  #--------------------------------------------------------------------------
  def skill_exp
    enemy.skill_exp
  end
end


#==============================================================================
# ■ Game_Actor(再定義)
#==============================================================================
class Game_Actor < Game_Battler
  attr_accessor :reset_skill_flag
  #--------------------------------------------------------------------------
  # ● スキルポイントカスタムの開始時処理
  #--------------------------------------------------------------------------
  def skillpoint_3_setting
    #オブジェクトの構築
    @tree_lv_log ||= [] ; @tree_skill_log ||= []
    @used_skill_point ||= [] ; @pre_condition_list ||= []
    @battle_skill_point ||= []
  end
  #--------------------------------------------------------------------------
  # ● フルリセット
  #--------------------------------------------------------------------------
  def sp3_full_reset
    return unless @tree_skill_log
    #複数のスキルデータ更新の為一旦更新をブロック
    @need_refresh = false
   
    #ツリーログを全検索し、すべてのスキルを削除
    @tree_skill_log.each {|class_data|
      next unless class_data
      class_data.each{|tree_data|
        next unless tree_data
        tree_data.each{|lv_data|
          next unless lv_data
          forget_skill(lv_data)
        }
      }
    }
   
    #オブジェクト再構築
    @tree_lv_log = [] ; @tree_skill_log = []
    @used_skill_point = [] ; @pre_condition_list = []
   
    #更新のブロックを解除し、更新する
    @need_refresh = true
    #パッシブスキルを更新する
    set_passive_object if $kure_integrate_script[:integrate]
  end
  #--------------------------------------------------------------------------
  # ● 最大スキルポイントの呼び出し(id = 0 アクター、他 職業)(追加定義)
  #--------------------------------------------------------------------------
  def max_skill_point(id)
    actor = $data_actors[@actor_id]
    job = $data_classes[id]
    #基礎スキルポイントを加算
    msp = KURE::Skill_Tree::BASE_SKILL_POINT   
    #レベル補正を加算
    obj = id == 0 ? actor : job
    msp += obj.sp_level_revise * @level
    #アクター補正を加算
    msp += actor.sp_revise
    #戦闘獲得補正を加算
    msp += call_battle_sp(id)      
    #変数補正を加算
    msp += $game_variables[actor.add_msp_var] if actor.add_msp_var != 0
   
    return msp.to_i
  end
  #--------------------------------------------------------------------------
  # ● スキルポイントの呼び出し(追加定義)
  #--------------------------------------------------------------------------
  def skill_point_log(id)
    @used_skill_point ||= []
    @used_skill_point[id] ||= 0
    return @used_skill_point[id]
  end
  #--------------------------------------------------------------------------
  # ● スキルポイント用の取得(追加定義)
  #--------------------------------------------------------------------------
  def call_battle_sp(class_id)
    return 0 unless @battle_skill_point[class_id]
    return @battle_skill_point[class_id]
  end
  #--------------------------------------------------------------------------
  # ● スキルポイントの追加(追加定義)
  #--------------------------------------------------------------------------
  def add_skill_point(value)
    @battle_skill_point ||= []
    @battle_skill_point[0] ||= 0
    @battle_skill_point[@class_id] ||= 0
  
    @battle_skill_point[0] = [@battle_skill_point[0] + value ,0].max
    @battle_skill_point[@class_id] = [@battle_skill_point[@class_id] + value ,0].max
   
   
    if $kure_integrate_script[:multiclass]
      id_list = adv_class_id.collect{|block| block[0] if block}
      id_list.compact!
      id_list.each{|multi_id|
        @battle_skill_point[multi_id] ||= 0
        @battle_skill_point[multi_id] = [@battle_skill_point[multi_id] + value ,0].max
      }
    end
  end
  #--------------------------------------------------------------------------
  # ● スキルポイントの使用(追加定義)
  #--------------------------------------------------------------------------
  def use_skill_point(value, id)
    @used_skill_point ||= []
    @used_skill_point[id] ||= 0
    @used_skill_point[id] = [@used_skill_point[id] + value ,0].max
  end
  #--------------------------------------------------------------------------
  # ● 指定スキルツリーIDの現在のレベル
  #--------------------------------------------------------------------------
  def tree_lv(tree_id, id)
    @tree_lv_log[id] ||= []
    @tree_lv_log[id][tree_id] ||= 0
    return @tree_lv_log[id][tree_id]
  end
  #--------------------------------------------------------------------------
  # ● 指定スキルツリーの指定レベルの現在のスキル
  #--------------------------------------------------------------------------
  def tree_skill(tree_id, lv, id)   
    return nil if lv == 0
    @tree_skill_log[id] ||= []
    @tree_skill_log[id][tree_id] ||= []
    @tree_skill_log[id][tree_id][lv] ||= nil
    return nil unless @tree_skill_log[id][tree_id][lv]
    return $data_skills[@tree_skill_log[id][tree_id][lv]]
  end
  
  #--------------------------------------------------------------------------
  # ● 指定スキルツリーのレベルを上げる
  #--------------------------------------------------------------------------
  def up_skill_tree_Lv(tree_id, id)
    tree_lv = tree_lv(tree_id, id)
   
    #現在のLvのスキルがFタイプであれば忘れる
    if tree_lv != 0 && KURE::Skill_Tree::SKILL_TREE[tree_id][tree_lv][2] == "F"
      forget_skill_id = KURE::Skill_Tree::SKILL_TREE[tree_id][tree_lv][0]
      forget_skill(forget_skill_id)
    end
   
    #ツリーLv上昇
    @tree_lv_log[id][tree_id] += 1
   
    sp3_learn_skill_process(tree_id, @tree_lv_log[id][tree_id], id)
  end
  #--------------------------------------------------------------------------
  # ● 指定ツリーの指定Lvのスキルを覚えたときの処理
  #--------------------------------------------------------------------------
  def sp3_learn_skill_process(tree_id, tree_lv, id)
    @tree_skill_log[id] ||= []
    @tree_skill_log[id][tree_id] ||= []
    return if tree_lv == 0
    return if @tree_skill_log[id][tree_id][tree_lv]
   
    #新しいLvのスキルを覚える
    learn_skill_data = KURE::Skill_Tree::SKILL_TREE[tree_id][tree_lv]
    learn_skill(learn_skill_data[0])
    use_skill_point(learn_skill_data[1], id)
   
    #前提条件を出力する
    @pre_condition_list[id] ||= []
    learn_skill_data[3].each{|data|
      @pre_condition_list[id].push(data + [learn_skill_data[0], tree_id, tree_lv])
    }

    #ツリーのログに覚えたスキルのIDを出力
    @tree_skill_log[id][tree_id][tree_lv] = learn_skill_data[0]
  end
  #--------------------------------------------------------------------------
  # ● 指定スキルツリーのレベルを下げる
  #--------------------------------------------------------------------------
  def down_skill_tree_Lv(tree_id, id)
    #複数のスキルデータ更新の為一旦更新をブロック
    @need_refresh = false
        
    tree_lv = tree_lv(tree_id, id)
    return if tree_lv == 0
   
    #現在のLvのスキルを忘れる   
    sp3_forget_skill_process(tree_id, tree_lv, id)
   
    #一つ下のLvのスキルを覚えなおす
    if @tree_lv_log[id][tree_id] != 0
      learn_skill_id = KURE::Skill_Tree::SKILL_TREE[tree_id][@tree_lv_log[id][tree_id]][0]
      learn_skill(learn_skill_id)
    end
   
    #前提のチェック
    sp3_pre_condition_cheak(id)
   
    #更新のブロックを解除し、更新する
    @need_refresh = true
    #パッシブスキルを更新する
    set_passive_object  if $kure_integrate_script[:integrate]
  end
  #--------------------------------------------------------------------------
  # ● 指定ツリーの指定Lvのスキルを忘れたときの処理
  #--------------------------------------------------------------------------
  def sp3_forget_skill_process(tree_id, tree_lv, id)
    @tree_skill_log[id] ||= []
    @tree_skill_log[id][tree_id] ||= []
    return if tree_lv == 0
    return unless @tree_skill_log[id][tree_id][tree_lv]
   
    skill_data = KURE::Skill_Tree::SKILL_TREE[tree_id][tree_lv]
    forget_skill(skill_data[0])
    use_skill_point(-1 * skill_data[1], id)

    #ツリーのログを削除
    @tree_skill_log[id][tree_id][tree_lv] = nil
   
    #前提条件より自分のスキルの前提を削除する
    @pre_condition_list[id] ||= []
    @pre_condition_list[id].size.times {|i|
      next if @pre_condition_list[id][2] != skill_data[0]
      @pre_condition_list[id] = nil
    }
    @pre_condition_list[id].compact!
   
    #ツリーLvダウン
    @tree_lv_log[id][tree_id] = [tree_lv - 1, @tree_lv_log[id][tree_id]].min
  end
  #--------------------------------------------------------------------------
  # ● 前提のチェック
  #--------------------------------------------------------------------------
  def sp3_pre_condition_cheak(id)
    roop = 1
   
    while roop > 0 do
      @pre_condition_list[id].each do |data|
        next if tree_lv(data[0], id) >= data[1]
        #現在のツリーLvを保存
        last = @tree_lv_log[id][data[3]]
        #前提を満たさなくなったスキルを削除
        sp3_forget_skill_process(data[3], data[4], id)
        #削除したスキルより上のLvのスキルを削除
        (data[4] + 1).upto(last) {|i|
          sp3_forget_skill_process(data[3], i, id)
        }
        roop += 1
      end
      roop -= 1
    end
  end
end

#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # ☆ スキルポイントの合計計算(追加定義)
  #--------------------------------------------------------------------------
  def skill_exp_total
    skill_exp_total = dead_members.inject(0) {|r, enemy| r += enemy.skill_exp }
    return skill_exp_total.to_i
  end
end

#==============================================================================
# ■ Scene_SkillTree
#==============================================================================
class Scene_SkillTree < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    @actor.skillpoint_3_setting
   
    create_all_window
    window_setting
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウのセット
  #--------------------------------------------------------------------------
  def create_all_window
    create_help_window
    create_small_status_window
    create_command_window
    create_skill_tree_window
    create_info_window
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの作成
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Help.new(1)
  end
  #--------------------------------------------------------------------------
  # ● ステータスウィンドウの作成
  #--------------------------------------------------------------------------
  def create_small_status_window
    wx = 0
    wy = @help_window.height
    ww = 280
    wh = 72
    @small_status_window = Window_Skill_Tree_Small_Status.new(wx,wy,ww,wh)
  end
  #--------------------------------------------------------------------------
  # ● コマンドウィンドウの作成
  #--------------------------------------------------------------------------
  def create_command_window
    wx = 0
    wy = @help_window.height + @small_status_window.height
    ww = 280
   
    @command_window = Window_Skill_Tree_Main_Command.new(wx,wy,ww)
    @command_window.set_handler(:ok,       method(:on_command_ok))
    @command_window.set_handler(:cancel,   method(:return_scene))
    @command_window.set_handler(:pagedown, method(:next_actor))
    @command_window.set_handler(:pageup,   method(:prev_actor))
    @command_window.activate
  end
  #--------------------------------------------------------------------------
  # ● スキルツリーウィンドウの作成
  #--------------------------------------------------------------------------
  def create_skill_tree_window
    wx = 0
    wy = @help_window.height + @small_status_window.height + @command_window.height
    ww = @command_window.width
    wh = Graphics.height - wy
    @skill_tree_window = Window_Skill_Tree_Command.new(wx,wy,ww,wh)
    @skill_tree_window.set_handler(:ok,       method(:on_tree_ok))
    @skill_tree_window.set_handler(:cancel,   method(:on_tree_cansel))
    @skill_tree_window.set_handler(:cursor_right,       method(:on_tree_ok))
    @skill_tree_window.set_handler(:cursor_left,   method(:on_tree_left))
    @skill_tree_window.unselect
    @skill_tree_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● インフォメーションウィンドウの作成
  #--------------------------------------------------------------------------
  def create_info_window
    wx = @small_status_window.width
    wy = @help_window.height
    ww = Graphics.width - @command_window.width
    wh = Graphics.height - wy
    @info_window = Window_Skill_Tree_Info.new(wx,wy,ww,wh)
  end
  #--------------------------------------------------------------------------
  # ● コマンド[決定]
  #--------------------------------------------------------------------------
  def on_command_ok
    @info_window.page_index = 1
    @skill_tree_window.activate
    @skill_tree_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● 呼び出し元のシーンへ戻る
  #--------------------------------------------------------------------------
  def return_scene
    @actor.reset_skill_flag = false if @back_log
    SceneManager.return
  end
  #--------------------------------------------------------------------------
  # ● スキルツリー[決定][右]
  #--------------------------------------------------------------------------
  def on_tree_ok
    #スキル習得処理
    @actor.up_skill_tree_Lv(@skill_tree_window.current_ext[0], @command_window.current_ext)
   
    window_refresh
    @skill_tree_window.activate
  end
  #--------------------------------------------------------------------------
  # ● スキルツリー[左]
  #--------------------------------------------------------------------------
  def on_tree_left
    return if !KURE::Skill_Tree::USE_LEFT_KEY.include?(@skill_tree_window.current_ext[0]) && !@actor.reset_skill_flag
    #スキル習得処理
    @actor.down_skill_tree_Lv(@skill_tree_window.current_ext[0], @command_window.current_ext)
    @back_log = true
   
    window_refresh
    @skill_tree_window.activate
  end
  #--------------------------------------------------------------------------
  # ● スキルツリー[キャンセル]
  #--------------------------------------------------------------------------
  def on_tree_cansel
    @info_window.page_index = 0
    @command_window.activate
    @skill_tree_window.unselect
    @skill_tree_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● 次のアクターに切り替え
  #--------------------------------------------------------------------------
  def next_actor
    @actor.reset_skill_flag = false if @back_log
    @actor.set_passive_object if $kure_integrate_script[:integrate]
    @actor = $game_party.menu_actor_next
    on_actor_change
  end
  #--------------------------------------------------------------------------
  # ● 前のアクターに切り替え
  #--------------------------------------------------------------------------
  def prev_actor
    @actor.reset_skill_flag = false if @back_log
    @actor.set_passive_object if $kure_integrate_script[:integrate]
    @actor = $game_party.menu_actor_prev
    on_actor_change
  end
  #--------------------------------------------------------------------------
  # ● アクターの切り替え後の処理
  #--------------------------------------------------------------------------
  def on_actor_change
    #データ構築
    @actor.skillpoint_3_setting
   
    #表示の更新
    @info_window.actor = @actor
    @small_status_window.actor = @actor
    @skill_tree_window.actor = @actor
    @command_window.actor = @actor
   
    @command_window.activate
    @command_window.select(0)
   
    @back_log = false
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウのセット
  #--------------------------------------------------------------------------
  def window_setting
    @info_window.actor = @actor
    @small_status_window.actor = @actor
    @skill_tree_window.actor = @actor
    @command_window.actor = @actor
   
    @command_window.small_status_window = @small_status_window
    @skill_tree_window.info_window = @info_window
   
    @command_window.help_window = @help_window
    @command_window.skill_tree_window = @skill_tree_window
   
    @command_window.select(0)
   
    @back_log = false
  end
  #--------------------------------------------------------------------------
  # ● 全ウィンドウの再描画
  #--------------------------------------------------------------------------
  def window_refresh
    @info_window.refresh
    @small_status_window.refresh
    @skill_tree_window.refresh
    @info_window.item = @skill_tree_window.current_ext
  end
end

#==============================================================================
# ■ Window_Skill_Tree_Small_Status
#==============================================================================
class Window_Skill_Tree_Small_Status < Window_Base
  attr_accessor :actor
  attr_accessor :draw_index
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y,width,height)
    super(x, y, width, height)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 描画INDEXの設定
  #--------------------------------------------------------------------------
  def draw_index=(index)
    return if @draw_index == index
    @draw_index = index
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_status
  end
  #--------------------------------------------------------------------------
  # ● 半分のフェイスグラフィックを描画
  #--------------------------------------------------------------------------
  def draw_actor_harf_face(x,y,actor)
    bitmap = Cache.face(actor.face_name)
    rect = Rect.new(actor.face_index % 4 * 96, actor.face_index / 4 * 96 + 26 , 96, 44)
    contents.blt(x, y, bitmap, rect)
    bitmap.dispose
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_status
    return unless @actor
    return unless @draw_index
    draw_actor_harf_face(0, 0, @actor)
   
    now = 0 ; max = 1 ; rate = 0;
    if @draw_index == 0
      now = @actor.skill_point_log(0)
      max = @actor.max_skill_point(0)
    else
      now = @actor.skill_point_log(@draw_index)
      max = @actor.max_skill_point(@draw_index)
    end
    rate = now.to_f / max
   
    draw_actor_name(@actor, 100, line_height * 0)
    draw_text(230, line_height * 0, contents.width - 230, contents.font.size, "☆", 2) if @actor.reset_skill_flag
    draw_gauge(100, line_height * 1, 160, rate, tp_gauge_color1, tp_gauge_color2)
   
    change_color(system_color)
    draw_text(100, line_height * 1, 30, contents.font.size, KURE::Skill_Tree::Skill_Point_NAME)
    change_color(normal_color)
        
    draw_text(130, line_height * 1, 55, contents.font.size, now.to_s, 2)
    draw_text(190, line_height * 1, 10, contents.font.size, "/")
    draw_text(205, line_height * 1, 55, contents.font.size, max.to_s, 2)
  end
end

#==============================================================================
# ■ Window_Skill_Tree_Main_Command
#==============================================================================
class Window_Skill_Tree_Main_Command < Window_HorzCommand
  attr_accessor :skill_tree_window
  attr_accessor :small_status_window
  attr_accessor :actor
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    @window_width = width
    super(x, y)
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    @window_width
  end
  #--------------------------------------------------------------------------
  # ● アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    col_max = 2
    col_max += 2 if $kure_integrate_script[:multiclass]
    return col_max
  end
  #--------------------------------------------------------------------------
  # ● カーソル位置の設定
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor
    call_update_help
   
    @skill_tree_window.draw_index = current_ext if @skill_tree_window
    @small_status_window.draw_index = current_ext if @small_status_window
   
    if @help_window
      if current_ext == 0
        @help_window.set_text("アクターの固有スキルを習得します。")
      else
        @help_window.set_text($data_classes[current_ext].name + "のスキルを習得します。")
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    return unless @actor
    add_command("固有", :ok, true, 0)
    add_command(@actor.class.name, :ok, true, @actor.class_id)
   
    if $kure_integrate_script[:multiclass]
      id_list = @actor.adv_class_id.collect{|block| block[0] if block}
      id_list.compact!
      id_list.each{|multi_id| add_command($data_classes[multi_id].name, :ok, true, multi_id)}
    end
  end
end

#==============================================================================
# ■ Window_Skill_Tree_Command
#==============================================================================
class Window_Skill_Tree_Command < Window_Command
  attr_accessor :draw_index
  attr_accessor :actor
  attr_accessor :info_window
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, ww, wh)
    @width = ww
    @height = wh
    super(x, y)
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    return @width
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ高さの取得
  #--------------------------------------------------------------------------
  def window_height
    @height
  end
  #--------------------------------------------------------------------------
  # ● アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 描画INDEXの設定
  #--------------------------------------------------------------------------
  def draw_index=(draw_index)
    return if @draw_index == draw_index
    @draw_index = draw_index
    refresh
  end
  #--------------------------------------------------------------------------
  # ● カーソル位置の設定
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor
    call_update_help
   
    return if index < 0
    @info_window.item = current_ext if @info_window
  end
  #--------------------------------------------------------------------------
  # ● カーソルを右に移動
  #--------------------------------------------------------------------------
  def cursor_right(wrap = false)
    if current_item_enabled?
      Sound.play_ok
      call_handler(:cursor_right)
    else
      Sound.play_buzzer
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルを左に移動
  #--------------------------------------------------------------------------
  def cursor_left(wrap = false)
    call_handler(:cursor_left)
  end
  #--------------------------------------------------------------------------
  # ● 1ページ進める
  #--------------------------------------------------------------------------
  def cursor_pagedown
    return unless @info_window
    pos = @info_window.page_index
    page_list = [1,2,3,4,1]
    for i in 0..page_list.size - 1
      if page_list == pos
        @info_window.page_index = page_list[i + 1]
        break
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 1ページ戻る
  #--------------------------------------------------------------------------
  def cursor_pageup
    return unless @info_window
    pos = @info_window.page_index
    page_list = [4,3,2,1,4]
    for i in 0..page_list.size - 1
      if page_list == pos
        @info_window.page_index = page_list[i + 1]
        break
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目を描画する矩形の取得(テキスト用)
  #--------------------------------------------------------------------------
  def item_rect_for_text(index)
    rect = item_rect(index)
    rect.x += 28
    rect.width -= 32
    rect
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    draw_icon(@icon_list[index], 0, contents.font.size * index)
    draw_text(item_rect_for_text(index), command_name(index), alignment)

    case @info_list[index][0]
    when 0
      change_color(power_up_color)
    when 1
      change_color(power_down_color)
    end
    draw_text(item_rect_for_text(index), @info_list[index][1], 2)
    change_color(normal_color)
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    return unless @draw_index
    data = [] ; @icon_list = [] ; @info_list = []
   
    if @draw_index == 0
      data = $data_actors[@actor.id].use_skill_tree
    else
      data = $data_classes[@draw_index].use_skill_tree
    end
   
    data.each do |tree_id|
      tree_lv = @actor.tree_lv(tree_id, @draw_index)
      skill = @actor.tree_skill(tree_id, tree_lv, @draw_index)
      name = skill ? skill.name : "- 未習得 -"
      icon_index = skill ? skill.icon_index : 0
      add_command(name, :ok, can_learn?(tree_id, tree_lv), [tree_id, tree_lv, @draw_index])
      @icon_list.push(icon_index)
      
      set_infomation_txt(tree_id, tree_lv)
    end
  end
  #--------------------------------------------------------------------------
  # ● インフォメーションテキストの設定
  #--------------------------------------------------------------------------
  def set_infomation_txt(tree_id, tree_lv)
    next_skill = KURE::Skill_Tree::SKILL_TREE[tree_id][tree_lv + 1]
   
    if max_tree_level?(tree_id, tree_lv)
      @info_list.push([0,"Master"])
      return
    end
   
    unless enough_skills?(tree_id, tree_lv, next_skill)
      @info_list.push([1,"前提未修得"])
      return
    end
   
    unless enough_lv?(tree_id, tree_lv, next_skill)
      @info_list.push([1,"前提Lv不足"])
      return
    end
   
    unless enough_mastery?(tree_id, tree_lv, next_skill)
      @info_list.push([1,"熟練度不足"])
      return
    end
   
    unless not_skills?(tree_id, tree_lv, next_skill)
      @info_list.push([1,"選択不可"])
      return
    end
   
    point = need_points?(tree_id, tree_lv, next_skill)
    if point
      @info_list.push([1,"Need " + point.to_s + "P"])
      return
    end
   
    @info_list.push([0,"Next " + next_skill[1].to_s + "P"])  
  end
  #--------------------------------------------------------------------------
  # ● 習得条件判定
  #--------------------------------------------------------------------------
  def can_learn?(tree_id, tree_lv)
    #最大レベル判定
    skill = KURE::Skill_Tree::SKILL_TREE[tree_id][tree_lv + 1]
    return false if max_tree_level?(tree_id, tree_lv)
    return false unless enough_skills?(tree_id, tree_lv, skill)
    return false unless enough_lv?(tree_id, tree_lv, skill)
    return false if need_points?(tree_id, tree_lv, skill)
    return false unless enough_mastery?(tree_id, tree_lv, skill)
    return false unless not_skills?(tree_id, tree_lv, skill)
    return true
  end
  #--------------------------------------------------------------------------
  # ● ツリー最大Lv判定
  #--------------------------------------------------------------------------
  def max_tree_level?(tree_id, tree_lv)
    return true if tree_lv >= KURE::Skill_Tree::SKILL_TREE[tree_id].size - 1
    return false
  end
  #--------------------------------------------------------------------------
  # ● 前提スキル判定
  #--------------------------------------------------------------------------
  def enough_skills?(tree_id, tree_lv, skill)
    list = skill[3] ; flag = 0
    list.each do |skill_data|
      next unless skill_data
      next unless skill_data[0]
      next unless skill_data[1]
      if skill_data[1] > @actor.tree_lv(skill_data[0], @draw_index)
        flag = 1 ; break
      end
    end
    return true if flag == 0
    return false
  end
  #--------------------------------------------------------------------------
  # ● 前提レベル判定
  #--------------------------------------------------------------------------
  def enough_lv?(tree_id, tree_lv, skill)
    level = skill[4]
    unless $kure_integrate_script[:multiclass]
      return false if level > @actor.level
      return true
    end
   
    if @draw_index == 0
      return false if level > @actor.level
    else
      class_level = 1
      while $data_classes[@draw_index].exp_for_level(class_level) <= @actor.adv_exp(@draw_index) do
        class_level += 1
      end
      class_level -= 1
      return false if level > class_level
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 不足しているポイント数を取得
  #--------------------------------------------------------------------------
  def need_points?(tree_id, tree_lv, skill)
    now = @actor.skill_point_log(@draw_index)
    max = @actor.max_skill_point(@draw_index)
    now += skill[1]
    return false if max >= now
    return (now - max).abs
  end
  #--------------------------------------------------------------------------
  # ● 前提習熟度判定
  #--------------------------------------------------------------------------
  def enough_mastery?(tree_id, tree_lv, skill)
    return true unless $kure_integrate_script[:Mastery]
    return true unless skill[5]
    skill[5].each{|block|
      return false if @actor.mastery_value(block[0], block[1]) < block[2]
    }
    return true
  end
  #--------------------------------------------------------------------------
  # ● 未習得前提判定
  #--------------------------------------------------------------------------
  def not_skills?(tree_id, tree_lv, skill)
    list = skill[6] ; flag = 0
    list.each do |skill_data|
      next unless skill_data
      next unless skill_data[0]
      next unless skill_data[1]
      if @actor.tree_lv(skill_data[0], @draw_index) >= skill_data[1]
        flag = 1 ; break
      end
    end
    return true if flag == 0
    return false
  end
end

#==============================================================================
# ■ Window_Skill_Tree_Info
#==============================================================================
class Window_Skill_Tree_Info < Window_Base
  attr_accessor :page_index
  attr_accessor :actor
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    @item = nil
    @page_index = 0
    super
    refresh
  end
  #--------------------------------------------------------------------------
  # ◎ アイテムの設定
  #--------------------------------------------------------------------------
  def item=(item)
    return if @item == item
    @item = item
    refresh
  end
  #--------------------------------------------------------------------------
  # ◎ ページの設定
  #--------------------------------------------------------------------------
  def page_index=(page_index)
    return if @page_index == page_index
    @page_index = page_index
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 描画
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_gauge(0,0, contents.width, 1, mp_gauge_color2,crisis_color)
    case @page_index
    when 0 ; draw_index_0
    when 1 ; draw_index_1
    when 2 ; draw_index_2
    when 3 ; draw_index_3
    when 4 ; draw_index_4
    end
  end
  #--------------------------------------------------------------------------
  # ◎ ページの描画(INDEX = 0)
  #--------------------------------------------------------------------------
  def draw_index_0
    change_color(normal_color)
    draw_text(0, 0, contents.width, contents.font.size, "操作説明")
    draw_text(5, contents.font.size * 2, contents.width, contents.font.size, "LR :アクター切り替え")
    draw_text(5, contents.font.size * 3, contents.width, contents.font.size, "←→:項目選択")   
  end
  #--------------------------------------------------------------------------
  # ◎ ページの描画(INDEX = 1)
  #--------------------------------------------------------------------------
  def draw_index_1
    return unless @item
    draw_text(0, 0, contents.width, contents.font.size, "スキルツリー情報")
    tree_data = KURE::Skill_Tree::SKILL_TREE[@item[0]].clone
    tree_data.delete_at(0)
    next_point = @item[1]
   
    #フォントの設定
    last_font = contents.font.size
    contents.font.size = 20
   
    tree_data.each_with_index{|skill_data, index|
      change_color(mp_gauge_color2)
      draw_text(0, line_height * (index + 1), 50, contents.font.size, "Next→") if index == next_point
      change_color(normal_color)
      draw_item_name($data_skills[skill_data[0]], 50, line_height * (index + 1), @actor.skill_learn?($data_skills[skill_data[0]]))
    }
   
    contents.font.size = last_font
    draw_guide
  end
  #--------------------------------------------------------------------------
  # ◎ ページの描画(INDEX = 2)
  #--------------------------------------------------------------------------
  def draw_index_2
    return unless @item
    skill_data = KURE::Skill_Tree::SKILL_TREE[@item[0]][@item[1] + 1]
    if skill_data
      draw_text(0, 0, contents.width, contents.font.size, "Nextスキル情報")
    else
      draw_text(0, 0, contents.width, contents.font.size, "スキル情報")
      skill_data = KURE::Skill_Tree::SKILL_TREE[@item[0]][@item[1]]
    end
   
    #フォントの設定
    last_font = contents.font.size
    contents.font.size = 20
   
    skill = $data_skills[skill_data[0]]
    draw_item_name(skill, 0, line_height * 1, true)
   
    change_color(system_color)
    draw_text(0, line_height * 2, 90, contents.font.size, "命中タイプ")
   
    draw_text(0, line_height * 3, 60, contents.font.size, "消費TP")
    draw_text(0, line_height * 4, 60, contents.font.size, "消費MP")
   
    if $kure_integrate_script[:integrate]
      draw_text(0, line_height * 5, 60, contents.font.size, "消費HP")
      draw_text(0, line_height * 6, 60, contents.font.size, "消費金額")
    end
   
    draw_text(0, line_height * 8, 40, contents.font.size, "属性")
    draw_text(0, line_height * 9, 40, contents.font.size, "範囲")
   
    draw_text(0, line_height * 10, 40, contents.font.size, "威力")
    draw_text((contents.width / 2) - 20, line_height * 10, 50, contents.font.size, "タイプ")
   
    draw_text(0, line_height * 11, 40, contents.font.size, "連続")
    draw_text((contents.width / 2) - 20, line_height * 11, 50, contents.font.size, "成功率")
   
   
    change_color(normal_color)
    #スキルタイプ
    draw_text(95, line_height * 2, contents.width - 95, contents.font.size, hit_type_text(skill))
    #消費TP、MP
    draw_text(65, line_height * 3, (contents.width / 2) - 55, contents.font.size, tp_cost(skill))
    draw_text(65, line_height * 4, (contents.width / 2) - 55, contents.font.size, mp_cost(skill))
    if $kure_integrate_script[:integrate]
      draw_text(65, line_height * 5, (contents.width / 2) - 55, contents.font.size, hp_cost(skill))
      draw_text(65, line_height * 6, (contents.width / 2) - 60, contents.font.size, skill.gold_cost.to_s)
    end
    #攻撃属性
    draw_text(45, line_height * 8, contents.width - 55, contents.font.size, elements_text(skill))
    #効果範囲
    draw_text(45, line_height * 9, contents.width - 55, contents.font.size, scope_text(skill))
    #威力 ダメージタイプ
    draw_text(45, line_height * 10, (contents.width / 2) - 65, contents.font.size, damage_text(skill))
    draw_text((contents.width / 2) + 35, line_height * 10, (contents.width / 2) - 35, contents.font.size, damage_type_text(skill))
    #成功率、連続数
    draw_text(45, line_height * 11, (contents.width / 2) - 65, contents.font.size, skill.repeats.to_s )
    draw_text((contents.width / 2) + 35, line_height * 11, (contents.width / 2) - 35, contents.font.size, skill.success_rate.to_s + "%" )
   
    contents.font.size = last_font
    draw_guide
  end
  #--------------------------------------------------------------------------
  # ◎ ページの描画(INDEX = 3)
  #--------------------------------------------------------------------------
  def draw_index_3
    return unless @item
    skill_data = KURE::Skill_Tree::SKILL_TREE[@item[0]][@item[1] + 1]
    if skill_data
      draw_text(0, 0, contents.width, contents.font.size, "Nextスキル情報")
    else
      draw_text(0, 0, contents.width, contents.font.size, "スキル情報")
      skill_data = KURE::Skill_Tree::SKILL_TREE[@item[0]][@item[1]]
    end
   
    #フォントの設定
    last_font = contents.font.size
    contents.font.size = 20
   
    skill = $data_skills[skill_data[0]]
    draw_item_name(skill, 0, line_height * 1, true)
  
    change_color(system_color)
    draw_text(0, line_height * 2, contents.width, contents.font.size, "スキル効果")
    change_color(normal_color)
   
    #特徴
    draw_item_effects(0, line_height * 3, skill)
   
    contents.font.size = last_font
    draw_guide
  end
  #--------------------------------------------------------------------------
  # ◎ ページの描画(INDEX = 4)
  #--------------------------------------------------------------------------
  def draw_index_4
    return unless @item
    skill_data = KURE::Skill_Tree::SKILL_TREE[@item[0]][@item[1] + 1]
    if skill_data
      draw_text(0, 0, contents.width, contents.font.size, "Nextスキル情報")
    else
      draw_text(0, 0, contents.width, contents.font.size, "スキル情報")
      skill_data = KURE::Skill_Tree::SKILL_TREE[@item[0]][@item[1]]
    end
   
    #フォントの設定
    last_font = contents.font.size
    contents.font.size = 20
   
    skill = $data_skills[skill_data[0]]
    draw_item_name(skill, 0, line_height * 1, true)
  
    change_color(system_color)
    draw_text(0, line_height * 2, 100, contents.font.size, "必要レベル") if skill_data[4] != 0
    draw_text(0, line_height * 3, 50, contents.font.size, "前提")
    change_color(normal_color)
   
    draw_text(105, line_height * 2, 100, contents.font.size, skill_data[4].to_s) if skill_data[4] != 0
   
    index = 3
    skill_data[3].each{|tree|
      if tree && tree[0] && tree[1]
        draw_skill_id = KURE::Skill_Tree::SKILL_TREE[tree[0]][tree[1]][0]
        next unless draw_skill_id
        draw_item_name($data_skills[draw_skill_id], 55, line_height * index, true)
        index += 1
      end
    }
   
    skill_data[5].each{|tree|
      next unless tree
      if tree[0] && tree[1] && tree[2]
        case tree[0]
        when 0 ; text = $data_skills[tree[1]].name
        when 1 ; text = $data_system.elements[tree[1]]
        when 2 ; text = $data_weapons[tree[1]]
        when 3 ; text = $data_system.weapon_types[tree[1]]
        end
        draw_text(55, line_height * index, contents.width - 70, contents.font.size, text + " 熟練度" + tree[2].to_s)
        index += 1
      end
    }
   
    draw_text(0, line_height * 5, contents.width, contents.font.size, "前提無し" ,1) if index == 3
   
    contents.font.size = last_font
    draw_guide
  end
  #--------------------------------------------------------------------------
  # ☆ 効果範囲のテキストを取得(追加定義)
  #--------------------------------------------------------------------------
  def scope_text(skill)
    case skill.scope
    when 0 ; word2 = "無"
    when 1 ; word2 = "敵単体"
    when 2 ; word2 = "敵全体"
    when 3 ; word2 = "敵1体ランダム"
    when 4 ; word2 = "敵2体ランダム"
    when 5 ; word2 = "敵3体ランダム"
    when 6 ; word2 = "敵4体ランダム"
    when 7 ; word2 = "味方単体"
    when 8 ; word2 = "味方全体"
    when 9 ; word2 = "味単(戦不) "
    when 10 ; word2 = "味全(戦不) "
    when 11 ; word2 = "本人"
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 命中タイプのテキストを取得(追加定義)
  #--------------------------------------------------------------------------
  def hit_type_text(item)
    case item.hit_type
    when 0 ; return "必中攻撃"
    when 1 ; return "物理攻撃"
    when 2 ; return "魔法攻撃"
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 威力を取得(追加定義)
  #--------------------------------------------------------------------------
  def damage_text(item)
    temp_actor = RPG::Actor.new
    return item.damage.eval(@actor, temp_actor, $game_variables).abs
  end
  #--------------------------------------------------------------------------
  # ☆ ダメージタイプのテキストを取得(追加定義)
  #--------------------------------------------------------------------------
  def damage_type_text(item)
    case item.damage.type
    when 0 ; return "ダメージ無"
    when 1 ; return Vocab::hp_a + "ダメージ"
    when 2 ; return Vocab::mp_a + "ダメージ"
    when 3 ; return Vocab::hp_a + "回復"
    when 4 ; return Vocab::mp_a + "回復"
    when 5 ; return Vocab::hp_a + "吸収"
    when 6 ; return Vocab::mp_a + "吸収"
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 適用するスキル/アイテムの属性を取得(追加定義)
  #--------------------------------------------------------------------------
  def elements_text(item)
    return "通常攻撃" if item.damage.element_id < 0
    return "無し" if item.damage.element_id == 0
    e_list = [] ; txt = ""
    e_list += item.reflect_elements if $kure_integrate_script[:integrate]
    e_list.push(item.damage.element_id)
    e_list.uniq!
   
    e_list.each{|id| txt += $data_system.elements[id]  + " "}
    return txt
  end
  #--------------------------------------------------------------------------
  # ☆ TPコストを取得(追加定義)
  #--------------------------------------------------------------------------
  def tp_cost(skill)
    return skill.tp_cost.to_s unless $kure_integrate_script[:integrate]
    data = skill.tp_cost_ex
    return skill.tp_cost.to_s  if data == [0, 0]
   
    text = ""
    text += "MAX" + data[1].to_s + "% + " if data[1] != 0
    text += data[0].to_s + "% + " if data[0] != 0
    text += skill.tp_cost.to_s
    return text
  end
  #--------------------------------------------------------------------------
  # ☆ MPコストを取得(追加定義)
  #--------------------------------------------------------------------------
  def mp_cost(skill)
    return skill.mp_cost.to_s unless $kure_integrate_script[:integrate]
    data = skill.mp_cost_ex
    return skill.mp_cost.to_s  if data == [0, 0]
   
    text = ""
    text += "MAX" + data[1].to_s + "% + " if data[1] != 0
    text += data[0].to_s + "% + " if data[0] != 0
    text += skill.mp_cost.to_s
    return text
  end
  #--------------------------------------------------------------------------
  # ☆ HPコストを取得(追加定義)
  #--------------------------------------------------------------------------
  def hp_cost(skill)
    return 0 unless $kure_integrate_script[:integrate]
    data = skill.hp_cost
    return 0 if data == [0, 0, 0]
   
    text = ""
    text += "MAX" + data[2].to_s + "% + " if data[2] != 0
    text += data[1].to_s + "% + " if data[1] != 0
    text += data[0].to_s if data[0] != 0
    return text
  end
  #--------------------------------------------------------------------------
  # ◎ 特徴の描画
  #--------------------------------------------------------------------------
  def draw_item_effects(x,y,item)
    return unless item
    effect_max = 0
    if $kure_integrate_script[:integrate]
      draw_list = KURE.call_effect_txt(item)
    else
      draw_list = KURE.basic_call_effect_txt(item)
    end
    change_color(normal_color)
    draw_list.each_with_index{|txt, index|
      break if index > 13
      draw_text(x, y + contents.font.size * index , contents.width, contents.font.size, txt)
    }
  end
  #--------------------------------------------------------------------------
  # ◎ ガイドの描画
  #--------------------------------------------------------------------------
  def draw_guide
    last = contents.font.size
    contents.font.size = 20
    change_color(normal_color)
    draw_text(5, contents.height - line_height, contents.width, contents.font.size, "LR:表示切替(" + @page_index.to_s + " / 4)", 1)
    contents.font.size = last
  end
end

#==============================================================================
# ▲ BattleManager(エイリアス再定義)
#==============================================================================
class << BattleManager
  #--------------------------------------------------------------------------
  # ◎ 獲得した経験値の表示(エイリアス再定義)
  #--------------------------------------------------------------------------
  alias k_before_skill_tree_display_exp display_exp
  def display_exp
    k_before_skill_tree_display_exp
    #スキルポイント
    if $game_troop.skill_exp_total > 0
      text_sp = sprintf(Vocab::ObtainSkillP, $game_troop.skill_exp_total)
      $game_message.add('\.' + text_sp)
    end
  end
  #--------------------------------------------------------------------------
  # ◎ 経験値の獲得とレベルアップの表示(エイリアス再定義)
  #--------------------------------------------------------------------------
  alias k_before_skill_tree_gain_exp gain_exp
  def gain_exp
    k_before_skill_tree_gain_exp
    $game_party.all_members.each{|actor| actor.add_skill_point($game_troop.skill_exp_total)}
  end
end


技能树设定脚本#==============================================================================
#  ■スキルツリー設定ファイル Ver0.80-α用
# □作成者 kure
#==============================================================================

module KURE
  module Skill_Tree
    #初期設定(変更しない事)-----------------------------------------------------
    SKILL_TREE = []
   
    #スキルツリー初期設定-------------------------------------------------------
    #SKILL_TREE[ID] = [] 使用するツリーの個数作成
    SKILL_TREE[0] = []
    SKILL_TREE[1] = []
    SKILL_TREE[2] = []
    SKILL_TREE[3] = []
    SKILL_TREE[4] = []
    SKILL_TREE[5] = []
   
    #スキルツリーの設定---------------------------------------------------------
    #SKILL_TREE[ID][level(1~)] = [スキルID, Point, Type, 前提Tree, 前提Lv,拡張前提]
      #設定について
      #スキルID … スキルのIDを設定
      #Point   … 習得に必要なスキルポイント数
      #Type   … "F" → 次のLvになると忘れる "M" → 次のLvでも覚えている
      #
      #前提Tree  … 前提となるツリーのIDとLvを配列で設定[[TreeID,lv],[TreeID,lv]…]
      #
      #前提Lv  … 前提となるレベルの設定
      #
      #熟練前提 … 前提の熟練度を配列で設定[[MasteryID,id,value],[MasteryID,id,value] …]
      #   MasteryID = 熟練度ID(0=スキル 1=属性 2=武器 3=武器タイプ)
      #   id        = 熟練度をチェックするID
      #   value     = 前提とする熟練度
      #
      #非前提Tree  … 非前提となるツリーのIDとLvを配列で設定[[TreeID,lv],[TreeID,lv]…]

    #設定例(ID1のスキルツリーのLv5以上が必要)  
    SKILL_TREE[0][1] = [26, 1, "F", [[1,5]], 0, [], []]
    #設定例(ID26のスキルの熟練度が100以上必要)
    SKILL_TREE[0][2] = [27, 1, "F", [], 0 ,[[0,26,100]], []]
    #設定例(Lvが10以上必要)
    SKILL_TREE[0][3] = [28, 1, "M", [], 10,[], []]
    #設定例(Lv30以上、職業レベルが10以上必要)
    SKILL_TREE[0][4] = [29, 1, "F", [], 5,[], []]
    SKILL_TREE[0][5] = [30, 1, "M", [], 0,[], []]
    SKILL_TREE[0][6] = [31, 1, "F", [], 0,[], []]
    SKILL_TREE[0][7] = [32, 1, "M", [], 0,[], []]
    SKILL_TREE[0][8] = [33, 1, "F", [], 0,[], []]
    SKILL_TREE[0][9] = [34, 1, "M", [], 0,[], []]
   
    SKILL_TREE[1][1] = [51, 1, "F", [], 0, [], [[2,1]]]
    SKILL_TREE[1][2] = [52, 1, "F", [], 0, [], []]
    SKILL_TREE[1][3] = [53, 1, "M", [], 0, [], []]
    SKILL_TREE[1][4] = [54, 1, "F", [], 0, [], []]
    SKILL_TREE[1][5] = [55, 1, "F", [], 0, [], []]
    SKILL_TREE[1][6] = [56, 1, "M", [], 0, [], []]
    SKILL_TREE[1][7] = [57, 1, "F", [], 0, [], []]
    SKILL_TREE[1][8] = [58, 1, "F", [], 0, [], []]
    SKILL_TREE[1][9] = [59, 1, "M", [], 0, [], []]
   
    SKILL_TREE[2][1] = [60, 1, "F", [], 0, [], [[1,1]]]
    SKILL_TREE[2][2] = [61, 1, "F", [], 0, [], []]
  end
end


脚本的原地址在这里
http://blog.livedoor.jp/kurement ... /44927280.html#more

完全搞不懂如何书写技能树……能不能请看得懂的人留个示范工程


另外,虽然用空白工程加这个脚本能够正常呼出技能树的菜单,可能是和我之前增加的技能cp制脚本有冲突
不过我试了一下,把技能cp制里面三处
SceneManager.call(Scene_SetBattleSkill)都改成SceneManager.call(Scene_SkillTree)
能用原本CP制技能的按键正常呼出技能树的菜单……两个脚本的执行应该没有冲突,只是在呼出窗口的时候有问题
如果可以的话,麻烦在菜单里面加个呼出技能树的按钮
技能cp制脚本#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ スキルCP制 - KGC_SkillCPSystem ◆ VX Ace ◆
#_/    ◇ Last update : 2009/09/13 ◇
#_/----------------------------------------------------------------------------
#_/  戦闘中に使用可能なスキルを限定する機能を追加します。
#_/============================================================================
#_/ 【装備】≪スキル習得装備≫ より下に導入してください。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
#    ☆VXAce RGSS3 「スキルCP制」☆
#      EnDlEss DREamER
#     URL:http://mitsu-evo.6.ql.bz/
#     製作者 mitsu-evo
#     Last:2014/5/8
#   KGC様のスキルCP制RGSS3移植版
#     ▼ 素材よりも下に。
#==============================================================================
=begin
5/8:ステータス画面のCPゲージ位置を修正。
メニューコマンドからの挙動を修正。



=end
#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================

module KGC
module SkillCPSystem
  # ◆ 登録スキル最大数
  MAX_SKILLS = 9
  # ◆ CP の名称
  VOCAB_CP   = "Memory"
  # ◆ CP の名称 (略)
  VOCAB_CP_A = "M"
  # ◆ ステータス画面に CP を表示する
  SHOW_STATUS_CP = true

  # ◆ 消費 CP 既定値
  #  消費 CP 未指定のスキルで使用。
  DEFAULT_CP_COST = 0
  # ◆ CP 上限
  #  (固有 CP などを除いた) 素の状態での CP 上限。
  CP_MAX = 99
  # ◆ CP 下限
  CP_MIN = 0
  # ◆ 補正後の CP 上限
  #  固有 CP や装備品による変動を含めた上限。
  REVISED_CP_MAX = 99
  # ◆ 補正後の CP 下限
  REVISED_CP_MIN = 0
  # ◆ 最大 CP 算出式
  #   level..現在のレベル
  #  自動的に整数変換するので、結果が小数になってもOK。
  CP_CALC_EXP = "$game_variables[5]"
  # ◆ アクター毎の最大 CP 算出式
  PERSONAL_CP_CALC_EXP = []
  PERSONAL_CP_CALC_EXP[1] = "$game_variables[5]"
  #  ここから下に、アクターごとの最大 CP を
  #   PERSONAL_CP_CALC_EXP[アクター ID] = "計算式"
  #  という書式で指定。
  #  計算式は CP_CALC_EXP と同様の書式。
  #  指定しなかったアクターは CP_CALC_EXP を使用。
  #   <例> ラルフだけ優遇
  # PERSONAL_CP_CALC_EXP[1] = "level * 0.8 + 2.0"
  # ◆ 戦闘テスト時は無効化
  #  true  : 戦闘テスト時は全スキルを使用可能。
  #  false : 戦闘テスト時は (セットしない限り) 使用不可。
  DISABLE_IN_BATTLETEST  = true
  # ◆ 使用不可スキルもセット可能
  SHOW_UNUSABLE_SKILL    = true
  # ◆ 消費 CP 0 のスキルはセットしなくても使用可能
  USABLE_COST_ZERO_SKILL = true
  # ◆ パッシブスキルはセットしないと効果なし
  #  ≪パッシブスキル≫ 導入時のみ有効。
  PASSIVE_NEED_TO_SET    = false
  # ◆ 新規習得スキルを自動的にセット
  #  true  : 習得したスキルを空きスロットにセット。
  #           ※ ≪スキル習得装備≫ で習得したスキルは無効。
  #  false : 習得しただけではセットされない (手動でセット)。
  AUTO_SET_NEW_SKILL     = false
  # ◆ 消費 CP 0 の場合も消費 CP を表示する
  #  true  : 消費 CP 0 でも表示
  #  false : 消費 CP 1 以上の場合のみ表示
  SHOW_ZERO_COST         = false

  # ◆ CP ゲージの色
  #  数値  : \C[n] と同じ色。
  #  Color : 指定した色。 ( Color.new(255, 128, 128) など )
  GAUGE_START_COLOR = 13  # 開始色
  GAUGE_END_COLOR   =  5  # 終了色

  # ◆ CP ゲージに汎用ゲージを使用する
  #  ≪汎用ゲージ描画≫ 導入時のみ有効。
  ENABLE_GENERIC_GAUGE = true
  # ◆ CP ゲージ設定
  #  画像は "Graphics/System" から読み込む。
  GAUGE_IMAGE  = "GaugeCP"  # 画像
  GAUGE_OFFSET = [-23, -2]  # 位置補正 [x, y]
  GAUGE_LENGTH = -4         # 長さ補正
  GAUGE_SLOPE  = 30         # 傾き (-89 ~ 89)

  # ◆ メニュー画面に「スキル設定」コマンドを追加する
  #  追加する場所は、メニューコマンドの最下部です。
  #  他の部分に追加したければ、≪カスタムメニューコマンド≫ をご利用ください。
  USE_MENU_SET_SKILL_COMMAND = true
  # ◆ メニュー画面の「スキル設定」コマンドの名称
  VOCAB_MENU_SET_SKILL       = "驱动管理"

  # ◆ 未設定項目の表示文字列
  BLANK_TEXT   = "-  EMPTY  -"
  # ◆ 設定解除の表示文字列
  RELEASE_TEXT = "( 卸载 )"
end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["SkillCPSystem"] = true

module KGC::SkillCPSystem
  module Regexp
    module BaseItem
      # 最大 CP
      MAXCP_PLUS = /<(?:MAX|最大)CP\s*([\-\+]?\d+)>/
      # 登録スキル数
      BATTLE_SKILL_MAX = /<(?:BATTLE_SKILL_MAX|登録スキル数)\s*([\-\+]?\d+)>/i
    end

    module Skill
      # 消費 CP
      CP_COST = /<CP\s*(\d+)>/i
      # 同時セット不可
      EXCLUDE = /<(?:EXCLUDE|同時セット不可)\s*(\d+(?:\s*,\s*\d+)*)>/
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# □ KGC::Commands
#==============================================================================

module KGC
module Commands
  module_function
  #--------------------------------------------------------------------------
  # ○ MaxCP 補正値の取得
  #     actor_id    : アクター ID
  #     variable_id : 取得した値を代入する変数の ID
  #--------------------------------------------------------------------------
  def get_actor_own_cp(actor_id, variable_id = 0)
    value = $game_actors[actor_id].maxcp_plus
    $game_variables[variable_id] = value if variable_id > 0
    return value
  end
  alias get_own_cp get_actor_own_cp
  #--------------------------------------------------------------------------
  # ○ MaxCP 補正値の変更
  #     actor_id : アクター ID
  #     value    : MaxCP 補正値
  #--------------------------------------------------------------------------
  def set_actor_own_cp(actor_id, value)
    $game_actors[actor_id].maxcp_plus = value
  end
  alias set_own_cp set_actor_own_cp
  #--------------------------------------------------------------------------
  # ○ アクターの MaxCP 補正値の増加
  #     actor_id : アクター ID
  #     value    : 増加量
  #--------------------------------------------------------------------------
  def gain_actor_cp(actor_id, value)
    $game_actors[actor_id].maxcp_plus += value
  end
  #--------------------------------------------------------------------------
  # ○ 登録スキル最大数の取得
  #     actor_id : アクター ID
  #     variable_id : 取得した値を代入する変数の ID
  #--------------------------------------------------------------------------
  def get_battle_skill_max(actor_id, variable_id = 0)
    value = $game_actors[actor_id].battle_skill_max
    $game_variables[variable_id] = value if variable_id > 0
    return value
  end
  #--------------------------------------------------------------------------
  # ○ 登録スキル最大数の変更
  #     actor_id : アクター ID
  #     value    : 登録可能数
  #--------------------------------------------------------------------------
  def set_battle_skill_max(actor_id, value = -1)
    $game_actors[actor_id].battle_skill_max = value
  end
  #--------------------------------------------------------------------------
  # ○ スキルが登録されているか
  #     actor_id : アクター ID
  #     skill_id : 確認するスキル ID
  #--------------------------------------------------------------------------
  def battle_skill_set?(actor_id, skill_id)
    return $game_actors[actor_id].battle_skill_ids.include?(skill_id)
  end
  #--------------------------------------------------------------------------
  # ○ スキルの登録
  #     actor_id : アクター ID
  #     index    : 登録箇所
  #     skill_id : 登録するスキル ID (nil で解除)
  #--------------------------------------------------------------------------
  def set_battle_skill(actor_id, index, skill_id = nil)
    actor = $game_actors[actor_id]
    if skill_id.is_a?(Integer)
      # 登録
      skill = $data_skills[skill_id]
      return unless actor.battle_skill_settable?(index, skill)  # セット不可

      actor.set_battle_skill(index, skill)
      actor.restore_battle_skill
    else
      # 解除
      actor.remove_battle_skill(index)
    end
  end
  #--------------------------------------------------------------------------
  # ○ スキルの追加登録
  #     actor_id : アクター ID
  #     skill_id : 登録するスキル ID
  #--------------------------------------------------------------------------
  def add_battle_skill(actor_id, skill_id)
    actor = $game_actors[actor_id]
    skill = $data_skills[skill_id]
    return if actor == nil || skill == nil

    actor.add_battle_skill(skill)
  end
  #--------------------------------------------------------------------------
  # ○ スキルの全解除
  #     actor_id : アクター ID
  #--------------------------------------------------------------------------
  def clear_battle_skill(actor_id)
    $game_actors[actor_id].clear_battle_skill
  end
  #--------------------------------------------------------------------------
  # ○ スキル設定画面の呼び出し
  #     actor_index : アクターインデックス
  #--------------------------------------------------------------------------
  def call_set_battle_skill(actor_index = 0)
    #return if $game_party.in_battle
    #$game_temp.next_scene = :set_battle_skill
    #$game_temp.next_scene_actor_index = actor_index
    SceneManager.call(Scene_SetBattleSkill)
    Fiber.yield
  end
end
end

class Game_Interpreter
  include KGC::Commands
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Vocab
#==============================================================================

module Vocab
  # CP
  def self.cp
    return KGC::SkillCPSystem::VOCAB_CP
  end

  # CP (略)
  def self.cp_a
    return KGC::SkillCPSystem::VOCAB_CP_A
  end

  # スキル設定
  def self.set_battle_skill
    return KGC::SkillCPSystem::VOCAB_MENU_SET_SKILL
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  #--------------------------------------------------------------------------
  # ○ スキルCP制のキャッシュを生成
  #--------------------------------------------------------------------------
  def create_skill_cp_system_cache
    @__maxcp_plus = 0
    @__battle_skill_max_plus = 0

    self.note.each_line { |line|
      case line
      when KGC::SkillCPSystem::Regexp::BaseItem::MAXCP_PLUS
        # 最大 CP
        @__maxcp_plus += $1.to_i
      when KGC::SkillCPSystem::Regexp::BaseItem::BATTLE_SKILL_MAX
        # 登録スキル数
        @__battle_skill_max_plus += $1.to_i
      end
    }
  end
  #--------------------------------------------------------------------------
  # ○ 最大 CP 補正
  #--------------------------------------------------------------------------
  def maxcp_plus
    create_skill_cp_system_cache if @__maxcp_plus == nil
    return @__maxcp_plus
  end
  #--------------------------------------------------------------------------
  # ○ 登録スキル数補正
  #--------------------------------------------------------------------------
  def battle_skill_max_plus
    create_skill_cp_system_cache if @__battle_skill_max_plus == nil
    return @__battle_skill_max_plus
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ RPG::Skill
#==============================================================================

class RPG::Skill < RPG::UsableItem
  #--------------------------------------------------------------------------
  # ○ スキルCP制のキャッシュを生成
  #--------------------------------------------------------------------------
  def create_skill_cp_system_cache
    @__cp_cost = KGC::SkillCPSystem::DEFAULT_CP_COST
    # 攻撃・防御設定スキルならコスト0
    @__cp_cost = 0 if @id == 1 or @id == 2
    @__excluded_skills = []

    self.note.each_line { |line|
      case line
      when KGC::SkillCPSystem::Regexp::Skill::CP_COST
        # 消費 CP
        @__cp_cost = $1.to_i
      when KGC::SkillCPSystem::Regexp::Skill::EXCLUDE
        # 同時セット不可
        $1.scan(/\d+/).each { |num| @__excluded_skills << num.to_i }
        @__excluded_skills.uniq!
      end
    }
  end
  #--------------------------------------------------------------------------
  # ○ 消費 CP
  #--------------------------------------------------------------------------
  def cp_cost
    create_skill_cp_system_cache if @__cp_cost == nil
    return @__cp_cost
  end
  #--------------------------------------------------------------------------
  # ○ 同時セット不可
  #--------------------------------------------------------------------------
  def excluded_skills
    create_skill_cp_system_cache if @__excluded_skills == nil
    return @__excluded_skills
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキルセット済み判定
  #     skill : スキル
  #--------------------------------------------------------------------------
  def battle_skill_set?(skill)
    return true
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_writer   :maxcp_plus               # MaxCP 補正値
  #--------------------------------------------------------------------------
  # ○ MaxCP 取得
  #--------------------------------------------------------------------------
  def maxcp
    calc_exp = KGC::SkillCPSystem::PERSONAL_CP_CALC_EXP[self.id]
    if calc_exp == nil
      calc_exp = KGC::SkillCPSystem::CP_CALC_EXP
    end
    n = Integer(eval(calc_exp))
    n = [[n, cp_limit].min, KGC::SkillCPSystem::CP_MIN].max
    n += maxcp_plus + maxcp_plus_equip
    return [[n, revised_cp_limit].min, KGC::SkillCPSystem::REVISED_CP_MIN].max
  end
  #--------------------------------------------------------------------------
  # ○ CP 取得
  #--------------------------------------------------------------------------
  def cp
    return [maxcp - consumed_cp, 0].max
  end
  #--------------------------------------------------------------------------
  # ○ CP 消費量取得
  #--------------------------------------------------------------------------
  def consumed_cp
    n = 0
    battle_skills.compact.each { |skill| n += skill.cp_cost }
    return n
  end
  #--------------------------------------------------------------------------
  # ○ CP 上限取得
  #--------------------------------------------------------------------------
  def cp_limit
    return KGC::SkillCPSystem::CP_MAX
  end
  #--------------------------------------------------------------------------
  # ○ 補正後の CP 上限取得
  #--------------------------------------------------------------------------
  def revised_cp_limit
    return KGC::SkillCPSystem::REVISED_CP_MAX
  end
  #--------------------------------------------------------------------------
  # ○ MaxCP 補正値取得
  #--------------------------------------------------------------------------
  def maxcp_plus
    if @maxcp_plus == nil
      if @own_cp != nil
        @maxcp_plus = @own_cp
        @own_cp = nil
      else
        @maxcp_plus = 0
      end
    end
    return @maxcp_plus
  end
  #--------------------------------------------------------------------------
  # ○ 装備品による MaxCP 補正値取得
  #--------------------------------------------------------------------------
  def maxcp_plus_equip
    n = 0
    equips.compact.each { |item| n += item.maxcp_plus }
    return n
  end
  #--------------------------------------------------------------------------
  # ● スキル取得
  #--------------------------------------------------------------------------
  alias skills_KGC_SkillCPSystem skills
  def skills
    return (skill_cp_restrict? ? restricted_skills : skills_KGC_SkillCPSystem)
  end
  #--------------------------------------------------------------------------
  # ● スキルの習得済み判定
  #--------------------------------------------------------------------------
  def skill_learn?(skill)
    skill.is_a?(RPG::Skill) && @skills.include?(skill.id)
  end
  #--------------------------------------------------------------------------
  # ○ スキルを制限するか
  #--------------------------------------------------------------------------
  def skill_cp_restrict?
    if $game_party.in_battle
      # 戦闘テストでないか、戦闘テストでも制限する場合
      return true unless $BTEST && KGC::SkillCPSystem::DISABLE_IN_BATTLETEST
    end

    return false
  end
  #--------------------------------------------------------------------------
  # ○ スキルを制限
  #--------------------------------------------------------------------------
  def restricted_skills
    result = all_skills
    result.each_with_index { |skill, i|
      # 消費 CP > 0 のスキルを除外
      if !KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL || skill.cp_cost > 0
        result = nil
      end
      # パッシブスキルを除外
      if $imported["PassiveSkill"] && KGC::SkillCPSystem::PASSIVE_NEED_TO_SET
        if skill.passive &&
            (!KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL || skill.cp_cost > 0)
          result = nil
        end
      end
    }
    result.compact!
    # 戦闘スキルを追加
    result |= battle_skills
    result.sort! { |a, b| a.id <=> b.id }
    return result
  end
  #--------------------------------------------------------------------------
  # ○ 全スキル取得
  #--------------------------------------------------------------------------
  def all_skills
    # 一時的に非戦闘中にする
    #last_in_battle = $game_party.in_battle
    #$game_party.on_battle_end

    result = skills_KGC_SkillCPSystem
    if $imported["EquipLearnSkill"]
      result |= (equipment_skills | full_ap_skills)
      result.sort! { |a, b| a.id <=> b.id }
    end

    # 戦闘中フラグを戻す
    #$game_party.on_battle_start#in_battle = last_in_battle

    return result
  end

  #--------------------------------------------------------------------------
  # ○ 登録スキル最大数取得
  #--------------------------------------------------------------------------
  def battle_skill_max
    @battle_skill_max = -1 if @battle_skill_max == nil
    n = (@battle_skill_max < 0 ?
      $game_variables[6] : @battle_skill_max)
    n += equipment_battle_skill_max_plus
    return [n, 0].max
  end
  #--------------------------------------------------------------------------
  # ○ 装備品による登録スキル数補正
  #--------------------------------------------------------------------------
  def equipment_battle_skill_max_plus
    n = 0
    equips.compact.each { |item| n += item.battle_skill_max_plus }
    return n
  end
  #--------------------------------------------------------------------------
  # ○ 登録スキル最大数設定
  #--------------------------------------------------------------------------
  def battle_skill_max=(value)
    @battle_skill_max = value
    if @battle_skills == nil
      @battle_skills = []
    else
      @battle_skills = @battle_skills[0...value]
    end
    restore_passive_rev if $imported["PassiveSkill"]
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキル ID 取得
  #--------------------------------------------------------------------------
  def battle_skill_ids
    @battle_skills = [] if @battle_skills == nil
    return @battle_skills
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキル取得
  #--------------------------------------------------------------------------
  def battle_skills
    result = []
    battle_skill_ids.each { |i|
      next if i == nil           # 無効なスキルは無視
      result << $data_skills
    }
    return result
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキル登録
  #     index : 位置
  #     skill : スキル (nil で解除)
  #--------------------------------------------------------------------------
  def set_battle_skill(index, skill)
    if skill == nil
      @battle_skills[index] = nil
    else
      return unless skill.is_a?(RPG::Skill)  # スキル以外
      return if cp < skill.cp_cost           # CP 不足
      if KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL && skill.cp_cost == 0
        return
      end

      @battle_skills[index] = skill.id
    end
    restore_passive_rev if $imported["PassiveSkill"]
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキル追加登録
  #     skill : スキル
  #--------------------------------------------------------------------------
  def add_battle_skill(skill)
    return unless skill.is_a?(RPG::Skill)  # スキル以外
    skills = battle_skill_ids
    return if skills.include?(skill.id)    # 登録済み
    return if cp < skill.cp_cost           # CP 不足
    return if KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL && skill.cp_cost == 0

    battle_skill_max.times { |i|
      # 空きがあれば登録
      if skills == nil
        set_battle_skill(i, skill)
        break
      end
    }
    restore_battle_skill
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキル解除
  #     index : 位置
  #--------------------------------------------------------------------------
  def remove_battle_skill(index)
    @battle_skills[index] = nil
    restore_passive_rev if $imported["PassiveSkill"]
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキル全解除
  #--------------------------------------------------------------------------
  def clear_battle_skill
    @battle_skills = []
    restore_passive_rev if $imported["PassiveSkill"]
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキルセット可否判定
  #     index : 位置
  #     skill : スキル
  #--------------------------------------------------------------------------
  def battle_skill_settable?(index, skill)
    return false if battle_skill_max <= index  # 範囲外
    return true  if skill == nil               # nil は解除なので OK

    return false if battle_skill_ids.include?(skill.id)  # セット済み

    curr_skill_id = battle_skill_ids[index]
    curr_skill    = (curr_skill_id != nil ? $data_skills[curr_skill_id] : nil)

    # 同時セット不可
    excluded  = excluded_battle_skill_ids
    excluded -= curr_skill.excluded_skills if curr_skill != nil
    return false if excluded.include?(skill.id)

    offset = (curr_skill != nil ? curr_skill.cp_cost : 0)
    return false if self.cp < (skill.cp_cost - offset)  # CP 不足

    return true
  end
  #--------------------------------------------------------------------------
  # ○ Exclude スキル ID 取得
  #--------------------------------------------------------------------------
  def excluded_battle_skill_ids
    result = []
    battle_skills.each { |skill| result |= skill.excluded_skills }
    return result
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキルを修復
  #--------------------------------------------------------------------------
  def restore_battle_skill
    return
=begin
    result = battle_skill_ids.clone
    usable_skills = all_skills

    result.each_with_index { |n, i|
      next if n == nil
      # 未修得の場合は解除
      if (usable_skills.find { |s| s.id == n }) == nil
        result = nil
      end
    }
    @battle_skills = result[0...battle_skill_max]
    # CP 不足のスキルを下から順に外す
    (battle_skill_max - 1).downto(0) { |i|
      @battle_skills = nil if maxcp - consumed_cp < 0
    }
=end
  end
  #--------------------------------------------------------------------------
  # ● 装備の破棄
  #     item : 破棄する武器 or 防具
  #    武器/防具の増減で「装備品も含める」のとき使用する。
  #--------------------------------------------------------------------------
  alias discard_equip_KGC_SkillCPSystem discard_equip
  def discard_equip(item)
    discard_equip_KGC_SkillCPSystem(item)

    restore_battle_skill
    restore_passive_rev if $imported["PassiveSkill"]
  end
  #--------------------------------------------------------------------------
  # ● 経験値の変更
  #     exp  : 新しい経験値
  #     show : レベルアップ表示フラグ
  #--------------------------------------------------------------------------
  alias change_exp_KGC_SkillCPSystem change_exp
  def change_exp(exp, show)
    # 習得したスキルを表示するため、戦闘中フラグを一時的に解除
    #last_in_battle = $game_party.in_battle
    #$game_party.on_battle_end#in_battle = false

    change_exp_KGC_SkillCPSystem(exp, show)

    #$game_party.on_battle_start#in_battle = last_in_battle
  end
  if KGC::SkillCPSystem::AUTO_SET_NEW_SKILL
  #--------------------------------------------------------------------------
  # ● スキルを覚える
  #     skill_id : スキル ID
  #--------------------------------------------------------------------------
  alias learn_skill_KGC_SkillCPSystem learn_skill
  def learn_skill(skill_id)
    unless skill_learn?($data_skills[skill_id])
      learn_skill_KGC_SkillCPSystem(skill_id)
      add_battle_skill($data_skills[skill_id])
    end
  end
  end  # <- if KGC::SkillCPSystem::AUTO_SET_NEW_SKILL
  #--------------------------------------------------------------------------
  # ● スキルを忘れる
  #     skill_id : スキル ID
  #--------------------------------------------------------------------------
  alias forget_skill_KGC_SkillCPSystem forget_skill
  def forget_skill(skill_id)
    # 忘れるスキルを戦闘用スキルから削除
    battle_skill_ids.each_with_index { |s, i|
      remove_battle_skill(i) if s == skill_id
    }

    forget_skill_KGC_SkillCPSystem(skill_id)
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘用スキルセット済み判定
  #     skill : スキル
  #--------------------------------------------------------------------------
  def battle_skill_set?(skill)
    return false unless skill.is_a?(RPG::Skill)  # スキル以外

    return battle_skill_ids.include?(skill.id)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ○ CP の文字色を取得
  #     actor : アクター
  #--------------------------------------------------------------------------
  def cp_color(actor)
    return knockout_color if actor.maxcp > 0 && actor.cp == 0
    return normal_color
  end
  #--------------------------------------------------------------------------
  # ○ CP ゲージの色 1 の取得
  #--------------------------------------------------------------------------
  def cp_gauge_color1
    color = KGC::SkillCPSystem::GAUGE_START_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ CP ゲージの色 2 の取得
  #--------------------------------------------------------------------------
  def cp_gauge_color2
    color = KGC::SkillCPSystem::GAUGE_END_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ CP の描画
  #     actor : アクター
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_cp(actor, x, y, width = 120)
    draw_actor_cp_gauge(actor, x, y, width)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 30, line_height, Vocab::cp_a)
    self.contents.font.color = cp_color(actor)
    xr = x + width
    if width < 120
      self.contents.draw_text(xr - 40, y, 40, line_height, actor.cp, 2)
    else
      self.contents.draw_text(xr - 90, y, 40, line_height, actor.cp, 2)
      self.contents.font.color = normal_color
      self.contents.draw_text(xr - 50, y, 10, line_height, "/", 2)
      self.contents.draw_text(xr - 40, y, 40, line_height, actor.maxcp, 2)
    end
    self.contents.font.color = normal_color
  end
  #--------------------------------------------------------------------------
  # ○ CP ゲージの描画
  #     actor : アクター
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_cp_gauge(actor, x, y, width = 120)
    if KGC::SkillCPSystem::ENABLE_GENERIC_GAUGE && $imported["GenericGauge"]
      # 汎用ゲージ
      draw_gauge(KGC::SkillCPSystem::GAUGE_IMAGE,
        x, y, width, actor.cp, [actor.maxcp, 1].max,
        KGC::SkillCPSystem::GAUGE_OFFSET,
        KGC::SkillCPSystem::GAUGE_LENGTH,
        KGC::SkillCPSystem::GAUGE_SLOPE)
    else
      # デフォルトゲージ
      gw = width * actor.cp / [actor.maxcp, 1].max
      gc1 = cp_gauge_color1
      gc2 = cp_gauge_color2
      self.contents.fill_rect(x, y + line_height - 8, width, 6, gauge_back_color)
      self.contents.gradient_fill_rect(x, y + line_height - 8, gw, 6, gc1, gc2)
    end
  end
end


#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
#  メニュー画面で表示するコマンドウィンドウです。
#==============================================================================

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 独自コマンドの追加用
  #--------------------------------------------------------------------------
  alias add_original_commands_KGC_SkillCPSystem add_original_commands
  def add_original_commands
    add_original_commands_KGC_SkillCPSystem
    add_command(Vocab.set_battle_skill, :battle_skill, battle_skill_enabled)
  end
  #--------------------------------------------------------------------------
  # ● スキル設定の有効状態を取得
  #--------------------------------------------------------------------------
  def battle_skill_enabled
    KGC::SkillCPSystem::USE_MENU_SET_SKILL_COMMAND  
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_Status
#==============================================================================

if KGC::SkillCPSystem::SHOW_STATUS_CP
class Window_Status < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 基本情報の描画
  #     x : 描画先 X 座標
  #     y : 描画先 Y 座標
  #--------------------------------------------------------------------------
  alias draw_basic_info_KGC_SkillCPSystem draw_basic_info
  def draw_basic_info(x, y)
    draw_basic_info_KGC_SkillCPSystem(x, y)

    draw_actor_cp(@actor, x, y + line_height * 1)
  end
end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# □ Window_BattleSkillStatus
#------------------------------------------------------------------------------
#   戦闘スキル設定画面で、設定者のステータスを表示するウィンドウです。
#==============================================================================

class Window_BattleSkillStatus < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x     : ウィンドウの X 座標
  #     y     : ウィンドウの Y 座標
  #     actor : アクター
  #--------------------------------------------------------------------------
  def initialize(x, y, actor)
    super(x, y, Graphics.width, line_height + 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_name(@actor, 4, 0)
    draw_actor_level(@actor, 140, 0)
    draw_actor_cp(@actor, 240, 0)
  end
  #--------------------------------------------------------------------------
  # ● アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# □ Window_BattleSkillSlot
#------------------------------------------------------------------------------
#   戦闘スキル選択画面で、設定したスキルの一覧を表示するウィンドウです。
#==============================================================================

class Window_BattleSkillSlot < Window_Selectable
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x      : ウィンドウの X 座標
  #     y      : ウィンドウの Y 座標
  #     width  : ウィンドウの幅
  #     height : ウィンドウの高さ
  #     actor  : アクター
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height, actor)
    super(x, y, width, height)
    @actor = actor
    self.index = 0
    self.active = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ スキルの取得
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    skill_ids = @actor.battle_skill_ids
    @actor.battle_skill_max.times { |i|
      if skill_ids != nil
        @data << $data_skills[skill_ids]
      else
        @data << nil
      end
    }
    @item_max = @data.size
    create_contents
    @item_max.times { |i| draw_item(i) }
  end
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # ● 前回の選択位置を復帰
  #--------------------------------------------------------------------------
  def select_last
    select(@data.index(@actor.last_skill.object) || 0)
  end
  #--------------------------------------------------------------------------
  # ● アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 決定やキャンセルなどのハンドリング処理
  #--------------------------------------------------------------------------
  alias process_handling_KGC_SkillCPSystem process_handling
  def process_handling
    process_handling_KGC_SkillCPSystem
    return unless open? && active
    return call_handler(:remove_slot) if handle?(:remove_slot) && Input.trigger?(:A)
  end
  #--------------------------------------------------------------------------
  # ● 決定処理の有効状態を取得
  #--------------------------------------------------------------------------
  def ok_enabled?
    handle?(:ok)
  end
  #--------------------------------------------------------------------------
  # ● キャンセル処理の有効状態を取得
  #--------------------------------------------------------------------------
  def cancel_enabled?
    handle?(:cancel)
  end
  #--------------------------------------------------------------------------
  # ○ 消費 CP 描画判定
  #--------------------------------------------------------------------------
  def cp_cost_show?(skill)
    return true if KGC::SkillCPSystem::SHOW_ZERO_COST

    return (skill.cp_cost > 0)
  end
  #--------------------------------------------------------------------------
  # ○ 項目の描画
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    skill = @data[index]
    if skill != nil
      rect.width -= 4
      draw_item_name(skill, rect.x, rect.y)
      self.contents.draw_text(rect, skill.cp_cost, 2) if cp_cost_show?(skill)
    else
      self.contents.draw_text(rect, KGC::SkillCPSystem::BLANK_TEXT, 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(skill)
    #@help_window.set_text(skill == nil ? "" : skill.description)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# □ Window_BattleSkillList
#------------------------------------------------------------------------------
#   戦闘スキル選択画面で、設定できるスキルの一覧を表示するウィンドウです。
#==============================================================================

class Window_BattleSkillList < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :slot_index               # スロット番号
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x      : ウィンドウの X 座標
  #     y      : ウィンドウの Y 座標
  #     width  : ウィンドウの幅
  #     height : ウィンドウの高さ
  #     actor  : アクター
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height, actor)
    super(x, y, width, height)
    @actor = actor
    @slot_index = 0
    self.index = 0
    self.active = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ スキルの取得
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 前回の選択位置を復帰
  #--------------------------------------------------------------------------
  def select_last
    select(@data.index(@actor.last_skill.object) || 0)
  end
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    # 選択可能なスキルのみを取得
    @actor.all_skills.each { |skill|
      @data.push(skill) if selectable?(skill)
    }
    @item_max = @data.size
    create_contents
    @item_max.times { |i| draw_item(i) }
  end
  #--------------------------------------------------------------------------
  # ○ スキル選択可否判定
  #     skill : スキル
  #--------------------------------------------------------------------------
  def selectable?(skill)
    return false if skill == nil

    # 消費 CP 0 なら常に使用可能な場合
    if KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL && skill.cp_cost == 0
      return false
    end
    # 戦闘時に使用可能ならOK
    return true if skill.battle_ok?
    # 使用不可でもセット可能な場合
    if KGC::SkillCPSystem::SHOW_UNUSABLE_SKILL && skill.occasion == 3
      return true
    end

    return false
  end
  #--------------------------------------------------------------------------
  # ○ 消費 CP 描画判定
  #--------------------------------------------------------------------------
  def cp_cost_show?(skill)
    return true if KGC::SkillCPSystem::SHOW_ZERO_COST

    return (skill.cp_cost > 0)
  end
  #--------------------------------------------------------------------------
  # ○ 項目の描画
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    skill = @data[index]
    if skill != nil
      rect.width -= 4
      enabled = @actor.battle_skill_settable?(@slot_index, skill)
      draw_item_name(skill, rect.x, rect.y, enabled)
      self.contents.draw_text(rect, skill.cp_cost, 2) if cp_cost_show?(skill)
    else
      self.contents.draw_text(rect, KGC::SkillCPSystem::RELEASE_TEXT, 1)
    end
  end

  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(skill)
    #@help_window.set_text(skill == nil ? "" : skill.description)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Menu
#==============================================================================

class Scene_Menu < Scene_MenuBase

  #--------------------------------------------------------------------------
  # ● コマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias create_command_window_KGC_SkillCPSystem create_command_window
  def create_command_window
    create_command_window_KGC_SkillCPSystem
    if KGC::SkillCPSystem::USE_MENU_SET_SKILL_COMMAND  
      @command_window.set_handler(:battle_skill,    method(:command_personal))
    end
  end
  #--------------------------------------------------------------------------
  # ● 個人コマンド[決定]
  #--------------------------------------------------------------------------
  alias on_personal_ok_KGC_SkillCPSystem on_personal_ok
  def on_personal_ok
    on_personal_ok_KGC_SkillCPSystem
    case @command_window.current_symbol
    when :battle_skill
      SceneManager.call(Scene_SetBattleSkill)
    end
  end
  #--------------------------------------------------------------------------
  # ● コマンド[スキル設定]
  #--------------------------------------------------------------------------
  def command_set_battle_skill
    SceneManager.call(Scene_SetBattleSkill)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# □ Scene_SetBattleSkill
#------------------------------------------------------------------------------
#   戦闘スキル設定画面の処理を行うクラスです。
#==============================================================================

class Scene_SetBattleSkill < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  HOST_MENU   = 0  # 呼び出し元 : メニュー
  HOST_MAP    = 1  # 呼び出し元 : マップ
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    create_background
    create_help_window
    create_status_window
    create_slot_window
    create_list_window
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの作成
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● ステータスウィンドウの作成
  #--------------------------------------------------------------------------
  def create_status_window
    dy = @help_window.height
    @status_window = Window_BattleSkillStatus.new(0, dy, @actor)
  end
  #--------------------------------------------------------------------------
  # ● スロットウィンドウの作成
  #--------------------------------------------------------------------------
  def create_slot_window
    dy = @help_window.height + @status_window.height
    @slot_window = Window_BattleSkillSlot.new(
      0,
      dy,
      Graphics.width / 2,
      Graphics.height - dy,
      @actor)
    @slot_window.activate
    @slot_window.help_window = @help_window
    @slot_window.set_handler(:ok,    method(:on_slot_skill))
    @slot_window.set_handler(:remove_slot,    method(:remove_skill))
    @slot_window.set_handler(:cancel,   method(:return_scene))
    @slot_window.set_handler(:pagedown, method(:next_actor))
    @slot_window.set_handler(:pageup,   method(:prev_actor))
    @slot_window.select_last
  end
  #--------------------------------------------------------------------------
  # ● アクターの切り替え
  #--------------------------------------------------------------------------
  def on_actor_change
    @status_window.actor = @actor
    @slot_window.actor = @actor
    @list_window.actor = @actor
    @slot_window.activate
    refresh_window
  end
  #--------------------------------------------------------------------------
  # ● スキルの選択
  #--------------------------------------------------------------------------
  def on_slot_skill
    Sound.play_ok
    # リストウィンドウに切り替え
    @slot_window.deactivate
    @list_window.activate
  end
  #--------------------------------------------------------------------------
  # ● スキルを外す
  #--------------------------------------------------------------------------
  def remove_skill
    # 選択しているスキルを外す
    Sound.play_ok
    @actor.remove_battle_skill(@slot_window.index)
    refresh_window
  end
  #--------------------------------------------------------------------------
  # ● リストウィンドウの作成
  #--------------------------------------------------------------------------
  def create_list_window
    dy = @help_window.height + @status_window.height
    @list_window = Window_BattleSkillList.new(
      Graphics.width - @slot_window.width,
      dy,
      Graphics.width - @slot_window.width,
      Graphics.height - dy,
      @actor)
    @list_window.help_window = @help_window
    @list_window.set_handler(:ok,    method(:on_set_list_skill))
    @list_window.set_handler(:cancel,   method(:cancel_list_window))
    @list_window.select_last
  end
  #--------------------------------------------------------------------------
  # ● スキルリストからの選択
  #--------------------------------------------------------------------------
  def on_set_list_skill
    skill = @list_window.skill
    # セットできない場合
    unless @actor.battle_skill_settable?(@slot_window.index, skill)
      Sound.play_buzzer
      @slot_window.activate
      @list_window.deactivate
      return
    end
    Sound.play_ok
    set_skill(@slot_window.index, skill)
    # スロットウィンドウに切り替え
    @slot_window.activate
    @list_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● スキルリストから戻る
  #--------------------------------------------------------------------------
  def cancel_list_window
    Sound.play_cancel
    # スロットウィンドウに切り替え
    @slot_window.activate
    @list_window.deactivate
  end

  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_background
    @help_window.dispose
    @status_window.dispose
    @slot_window.dispose
    @list_window.dispose
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ再描画
  #--------------------------------------------------------------------------
  def refresh_window
    @status_window.refresh
    @slot_window.refresh
    @list_window.refresh
  end

  #--------------------------------------------------------------------------
  # ○ スキル設定
  #     index : 設定する場所
  #     skill : 設定するスキル
  #--------------------------------------------------------------------------
  def set_skill(index, skill)
    @actor.remove_battle_skill(index)
    if skill != nil
      @actor.set_battle_skill(index, skill)
    end
    refresh_window
  end

end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部