=begin ◆概要 ドラクエ8風にスキルを習得します。 ◆機能 ・レベルアップすると適当にスキルポイントが上昇し割り振れます。そのスキルの 上昇により、新たにスキルとか覚えます。 ◆仕様 ・レベルアップによって覚えるスキルと併用できます。 ・「○○になった」というメッセージは面倒なのでないです(すみません)。 ◆使用上の注意 ・☆……エイリアス ●……再定義 ○……新規定義 ・同じインスタンス変数を使用しているスクリプトとは併用できません。 @skill_levelとか絶対被りそう。 =end # レベルアップによって得られるスキルポイントの平均。 GAIN_SKILL_POINT = 6 # レベルアップによって得られるスキルポイントの変動率。 # 最高でGAIN_SKILL_POINT + GAIN_SKILL_POINT_RAND # 最低でGAIN_SKILL_POINT - GAIN_SKILL_POINT_RAND(下限 0) 得られるという鬼畜仕様。 GAIN_SKILL_POINT_RAND = 4 SKILL_LEVEL_NAME = [ # ここから下に["名前",{(習得レベル)=>[(習得スキル)]}]と設定。 # パッシブスキルを使えば擬似的に能力値の上昇も可能。 ["剣",{3 => [1], 7 => [2], 12 => [3]}], ["剣",{5 => [1], 9 => [2], 14 => [8]}], ["弓",{3 => [27], 7 => [28], 12 => [29]}], ["杖",{4 => [40, 44], 7 => [41, 45], 12 => [42, 46]}] # <= 最後だけ「,」が要らない ] # <= 最後消すとエラーでます # 下のスキルの順番をアクターにするか職業にするか NUMBER_ACTOR = true # ↑の設定でtrueの時はアクターごと、falseの時は職業ごとに、どのレベルを持つかの # 設定。番号で設定するから面倒だったりしないでも無い。 # 配列で設定するから、IDが足りないとエラー吐くよ。 SKILL_LEVEL_HAVE = [[], [0,1,2,3], # <= 一番目は「0」です [], # <= 設定しない時は[]で [1,2,3], # <= 複数設定する時は「,」で区切る [] # <= 例によって最後だけ,が要らない ] # <= 最後消すとエラーでます module Vocab # スキルポイントが上がった時の表示。 SkillPointGet = "スキルポイントを %s 手に入れた!" # スキルレベルが上がった時の表示。 SkillLevelUp = "%sの%sレベルは %s に上がった!" end class Game_Actor < Game_Battler attr_accessor :skill_level attr_accessor :skill_point attr_accessor :get_point alias setup_dqsl setup def setup(actor_id) setup_dqsl(actor_id) @skill_point = 0; @get_point = 0; @skill_level = {}; @last_skill_level = {} if NUMBER_ACTOR SKILL_LEVEL_HAVE[actor_id].each{|a| @skill_level[a] = 0 } else SKILL_LEVEL_HAVE[@class_id].each{|a| @skill_level[a] = 0 } end @last_skill_level = @skill_level.clone end alias level_up_dqsl level_up def level_up level_up_dqsl return if @skill_level.empty? rand_s = GAIN_SKILL_POINT_RAND point = [GAIN_SKILL_POINT + rand(rand_s) - rand(rand_s), 0].max @get_point += point @skill_point += point end alias display_level_up_dqsl display_level_up def display_level_up(new_skills) display_level_up_dqsl(new_skills) return if @skill_level.empty? text = sprintf(Vocab::SkillPointGet, @get_point) $game_message.texts.push(text) end def skill_update @skill_level.each{|index,level| ss = [] SKILL_LEVEL_NAME[index][1].each{|i, s| s.each{|skill| next if @skills.include?(skill) learn_skill(skill) if i <= level ss.push(skill) if i <= level } } ss.sort!; if @skill_level[index] > @last_skill_level[index] display_skill_level_up(SKILL_LEVEL_NAME[index][0],level,ss); end } @last_skill_level = @skill_level.clone end def display_skill_level_up(lv_name, level, skills) $game_message.new_page text = sprintf(Vocab::SkillLevelUp, @name, lv_name, level.to_s) $game_message.texts.push(text) for s in skills; text = sprintf(Vocab::ObtainSkill, $data_skills[s].name) $game_message.texts.push(text);end end end class Window_SkillPoint < Window_Selectable attr_accessor :actor_id attr_reader :commands attr_accessor :gain_point def initialize(actor_id) super(0, 0, 544, 288, 12) initialize_a(actor_id) end def initialize_a(actor_id) @actor_id = actor_id; @commands = []; @gain_point = []; @has_level = []; c = 0 $game_actors[@actor_id].skill_level.each_key{|i|@has_level.push(i) @commands.push(SKILL_LEVEL_NAME[i][0]); @gain_point[c] = 0; c += 1} @item_max = @commands.size; @column_max = 1; refresh; self.index = 0 end def refresh self.contents.clear; rect = item_rect(0) self.contents.draw_text(rect, $game_actors[@actor_id].name) for i in 0...@item_max; draw_item(i); end rect = item_rect(@item_max - 1); rect.y += WLH * 3 self.contents.draw_text(rect, "残りスキルポイント"); rect.x += 216 self.contents.draw_text(rect, $game_actors[@actor_id].skill_point) end def draw_item(index, enabled = true) rect = item_rect(index); rect.x += 72; rect.width -= 8; rect.y += WLH self.contents.clear_rect(rect); self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index]); rect.x += 144 self.contents.clear_rect(rect) self.contents.draw_text(rect, "+" + @gain_point[index].to_s); rect.x += 144 self.contents.clear_rect(rect) s = $game_actors[@actor_id].skill_level[@has_level[index]] self.contents.draw_text(rect, s) end def cursor_right(wrap = false) Sound.play_cursor; if $game_actors[@actor_id].skill_point > 0 @gain_point[@index] += 1 $game_actors[@actor_id].skill_level[@has_level[index]] += 1 $game_actors[@actor_id].skill_point -= 1; refresh; end end def cursor_left(wrap = false) Sound.play_cursor; if @gain_point[@index] > 0; @gain_point[@index] -= 1 $game_actors[@actor_id].skill_level[@has_level[index]] -= 1 $game_actors[@actor_id].skill_point += 1; refresh; end end def update_cursor; super; self.cursor_rect.y += WLH end end class Window_SkillPointYesNo < Window_Selectable def initialize(commands, column_max = 2, row_max = 1, spacing = 32) super(132, 148, 280, WLH * 2 + 32, spacing) @commands = commands; @item_max = commands.size; @column_max = column_max create_contents; refresh; self.index = 0 end def refresh; self.contents.clear rect = self.contents.text_size("よろしいですか?") self.contents.draw_text(rect, "よろしいですか?") for i in 0...@item_max; draw_item(i);end;end def draw_item(index) rect = item_rect(index); rect.x += 4; rect.y += WLH; rect.width -= 8 self.contents.clear_rect(rect); self.contents.font.color = normal_color self.contents.draw_text(rect, @commands[index]) end def update_cursor; super; self.cursor_rect.y += WLH; end end class Scene_Battle < Scene_Base alias start_dqsl start def start; start_dqsl @sl_window = Window_SkillPoint.new($game_party.members[0].id) @slyn_window = Window_SkillPointYesNo.new(["はい","いいえ"]) @sl_window.visible = false; @slyn_window.visible = false @sl_window.active = false; @slyn_window.active = false end alias terminate_dqsl terminate def terminate; terminate_dqsl; @sl_window.dispose; @slyn_window.dispose end alias update_dqsl update def update if @slyn_window.active; @slyn_window.update elsif @sl_window.active; @sl_window.update; end if Input.trigger?(Input::C) if @sl_window.active; @sl_window.active = false @slyn_window.active = true; @slyn_window.visible = true elsif @slyn_window.active if @slyn_window.index.zero? @slyn_window.active = false; @slyn_window.visible = false $game_actors[@lvup_ids[0]].skill_update; wait_for_message @lvup_ids.delete(@lvup_ids[0]) if !@lvup_ids.empty?; @sl_window.initialize_a(@lvup_ids[0]); end end @sl_window.active = true; @sl_window.refresh end elsif Input.trigger?(Input::B) if @sl_window.active; @sl_window.active = false @slyn_window.active = true; @slyn_window.visible = true elsif @slyn_window.active; @slyn_window.active = false @slyn_window.visible = false; @sl_window.active = true end end update_dqsl unless (@sl_window.active or @slyn_window.active) end def display_level_up exp = $game_troop.exp_total @lvup_ids = [] for actor in $game_party.existing_members last_level = actor.level last_skills = actor.skills actor.gain_exp(exp, true) @lvup_ids.push(actor.id) if actor.get_point > 0 actor.get_point = 0 end $game_message.new_page $game_message.texts.push("ポイントを振り分けてください。") wait_for_message if @lvup_ids.size > 0 @sl_window.active = true; @sl_window.visible = true @sl_window.refresh while !@lvup_ids.empty? update_basic update end end end end