#============================================================================== # 経験値消費でスキル修得スクリプト ver1.02 #------------------------------------------------------------------------------ #[特徴] # 経験値を消費して、スキルを修得します。 # #[スキル設定方法] # スキルのメモ欄に <必要経験値:数値> と書く。 # <必要経験値1:数値> と書くと、アクターID 1 の必要経験値を個別に設定できます。 # #[使用方法] # $scene = Scene_LearnSkillExp.new # と、コマンドスクリプトに入力する。 # # 作成:ぶちょー # ホム:http://nyannyannyan.bake-neko.net/ # 著作:自分で作ったとか言わないで>< # 改造はご自由にどうぞ。 # リードミーとかに私の名前の載せたりするのは任意で。 #============================================================================== #============================================================================== # バージョンアップ情報 # ver1.02 Kamesoft様の【ヘルプウィンド機能拡張】に対応 # ver1.01 修得済みのスキルが修得画面で表示されないのを修正 # ver1.00 公開 #============================================================================== #============================================================================== # 設定項目 #============================================================================== module Kazari module LearnSkillExp # このシーンから戻るとき # メニュー画面に戻るなら true # マップ画面に戻るなら  false RETURN_SCENE = true # メニュー画面に戻る場合の戻るメニューのインデックス MENU_INDEX = 4 # メニュー画面にスキル修得のコマンドを簡易設定するなら true # メニューコマンドを変更するスクリプトを導入している場合は 100% 競合してしまいます。 EASY_SETUP = true # メニュー画面に表示するスキル修得のコマンド名 LEARNING_SKILL = "スキル修得" # スキル修得時に鳴らす音 ["名前", 音量, ピッチ] LEARN_SOUND = ["Item2", 80, 100] # 修得時に確認ウィンドウを表示する場合は true LEARN_CHECK = true # スキルを覚えるとき、レベルが下がっても覚えることができるのなら true # false にすると、必要経験値が大きいスキルを序盤は覚えられなくなったりします。 # 5000 でレベルアップしてしまう場合、必要経験値が 10000 のスキルは覚えられない。 LEARN_FLAG = false # スキルの色 # COLOR1 : 修得可能なスキル # COLOR2 : 修得不可能なスキル # COLOR3 : 修得済みのスキル COLOR1 = Color.new(255, 255, 64) COLOR2 = Color.new(255, 255, 255, 128) COLOR3 = Color.new(255, 255, 255) # 修得済みのスキルはウィンドウに表示しない場合は true LEARN_SKILL_HIDE = false # 修得済みのスキルも表示する場合、必要経験値の場所に描画する文字 SKILL_LEARN = "修得済み" # 必要経験値の描画方法 NEED_EXP = "%d exp" # 修得できるスキルの設定 # アクターID => [スキルID, スキルID], ACTOR_LEARN = { # ID 1 のアクターが修得できるスキル 1 => [1, 2, 3, 87], # 最後の 『,』 を忘れないように 2 => [6, 7, 8, 9, 10], 3 => [11, 12, 13, 14, 15], } # 職業ID => [スキルID, スキルID], CLASS_LEARN = { # ID 1 の職業のアクターが修得できるスキル 1 => [4, 5, 6], 2 => [7, 8, 9], } end end #============================================================================== # ここまで #============================================================================== $imported = {} if $imported == nil #============================================================================== # ■ Scene_LearnSkillExp #============================================================================== class Scene_LearnSkillExp < Scene_Base include Kazari::LearnSkillExp #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor_index = 0) @actor_index = actor_index end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background @actor = $game_party.members[@actor_index] @help_window = Window_Help.new @status_window = Window_SkillStatusExp.new(0, 56, @actor) @skill_window = Window_LearnSkill.new(0, 112, @actor) @skill_window.help_window = @help_window @learn_window = Window_Learn.new adjust_window_size if $imported["HelpExtension"] end #-------------------------------------------------------------------------- # ● ウィンドウサイズ調整 #-------------------------------------------------------------------------- def adjust_window_size @help_window.row_max = KGC::HelpExtension::ROW_MAX @status_window.y = @help_window.height @status_window.refresh @skill_window.y = @status_window.y + @status_window.height @skill_window.height = Graphics.height - @skill_window.y @skill_window.refresh end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @help_window.dispose @status_window.dispose @skill_window.dispose @learn_window.dispose end #-------------------------------------------------------------------------- # ● 元の画面へ戻る #-------------------------------------------------------------------------- def return_scene if RETURN_SCENE $scene = Scene_Menu.new(MENU_INDEX) else $scene = Scene_Map.new end end #-------------------------------------------------------------------------- # ● 次のアクターの画面に切り替え #-------------------------------------------------------------------------- def next_actor @actor_index += 1 @actor_index %= $game_party.members.size $scene = Scene_LearnSkillExp.new(@actor_index) end #-------------------------------------------------------------------------- # ● 前のアクターの画面に切り替え #-------------------------------------------------------------------------- def prev_actor @actor_index += $game_party.members.size - 1 @actor_index %= $game_party.members.size $scene = Scene_LearnSkillExp.new(@actor_index) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_menu_background @help_window.update @status_window.update @skill_window.update @learn_window.update if @skill_window.active update_skill_selection elsif @learn_window.active update_learn_skill end end #-------------------------------------------------------------------------- # ● スキル選択の更新 #-------------------------------------------------------------------------- def update_skill_selection if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::R) Sound.play_cursor next_actor elsif Input.trigger?(Input::L) Sound.play_cursor prev_actor elsif Input.trigger?(Input::C) @skill = @skill_window.skill if @actor.skill_can_learn?(@skill) if LEARN_CHECK Sound.play_decision @learn_window.index = 0 @learn_window.open @learn_window.active = true @skill_window.active = false else RPG::SE.new(LEARN_SOUND[0], LEARN_SOUND[1], LEARN_SOUND[2]).play @actor.learning_skill(@skill) @skill_window.refresh @status_window.refresh end else Sound.play_buzzer end end end #-------------------------------------------------------------------------- # ● スキル修得の更新 #-------------------------------------------------------------------------- def update_learn_skill if Input.trigger?(Input::B) Sound.play_cancel @learn_window.close @learn_window.active = false @skill_window.active = true elsif Input.trigger?(Input::C) case @learn_window.index when 0 RPG::SE.new(LEARN_SOUND[0], LEARN_SOUND[1], LEARN_SOUND[2]).play @actor.learning_skill(@skill) @skill_window.refresh @status_window.refresh when 1 Sound.play_decision end @learn_window.close @learn_window.active = false @skill_window.active = true end end end if Kazari::LearnSkillExp::EASY_SETUP #============================================================================== # ■ Scene_Menu #============================================================================== class Scene_Menu < Scene_Base #-------------------------------------------------------------------------- # ● コマンドウィンドウの作成 #-------------------------------------------------------------------------- def create_command_window s1 = Vocab::item s2 = Vocab::skill s3 = Vocab::equip s4 = Vocab::status s5 = Vocab::save s6 = Vocab::game_end s7 = Kazari::LearnSkillExp::LEARNING_SKILL command = [s1, s2, s3, s4, s7, s5, s6] @command_window = Window_Command.new(160, command) @command_window.index = @menu_index if $game_party.members.size == 0 # パーティ人数が 0 人の場合 @command_window.draw_item(0, false) # アイテムを無効化 @command_window.draw_item(1, false) # スキルを無効化 @command_window.draw_item(2, false) # 装備を無効化 @command_window.draw_item(3, false) # ステータスを無効化 @command_window.draw_item(4, false) # スキル修得を無効化 end if $game_system.save_disabled # セーブ禁止の場合 @command_window.draw_item(5, false) # セーブを無効化 end end #-------------------------------------------------------------------------- # ● コマンド選択の更新 #-------------------------------------------------------------------------- def update_command_selection if Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Map.new elsif Input.trigger?(Input::C) if $game_party.members.size == 0 and @command_window.index < 5 Sound.play_buzzer return elsif $game_system.save_disabled and @command_window.index == 5 Sound.play_buzzer return end Sound.play_decision case @command_window.index when 0 # アイテム $scene = Scene_Item.new when 1,2,3,4 # スキル、装備、ステータス、スキル修得 start_actor_selection when 5 # セーブ $scene = Scene_File.new(true, false, false) when 6 # ゲーム終了 $scene = Scene_End.new end end end #-------------------------------------------------------------------------- # ● アクター選択の更新 #-------------------------------------------------------------------------- def update_actor_selection if Input.trigger?(Input::B) Sound.play_cancel end_actor_selection elsif Input.trigger?(Input::C) $game_party.last_actor_index = @status_window.index Sound.play_decision case @command_window.index when 1 # スキル $scene = Scene_Skill.new(@status_window.index) when 2 # 装備 $scene = Scene_Equip.new(@status_window.index) when 3 # ステータス $scene = Scene_Status.new(@status_window.index) when 4 # スキル修得 $scene = Scene_LearnSkillExp.new(@status_window.index) end end end end end # 簡易設定の終了 #============================================================================== # ■ Window_LearnSkill #============================================================================== class Window_LearnSkill < Window_Selectable include Kazari::LearnSkillExp #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, actor) super(x, y, Graphics.width, Graphics.height - y) @actor = actor @column_max = 1 self.index = 0 refresh end #-------------------------------------------------------------------------- # ● スキルの取得 #-------------------------------------------------------------------------- def skill return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh @data = [] skill_list = [] skill_list += ACTOR_LEARN[@actor.id] if ACTOR_LEARN[@actor.id] skill_list += CLASS_LEARN[@actor.class_id] if CLASS_LEARN[@actor.class_id] for skill in @actor.skills skill_list.push(skill.id) end skill_list.uniq! skill_list.sort! for skill_id in skill_list skill = $data_skills[skill_id] next if skill == nil next if LEARN_SKILL_HIDE && @actor.skill_learn?(skill) @data.push(skill) end @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) skill = @data[index] if skill != nil rect.width -= 4 draw_skill_name(skill, rect.x, rect.y) if @actor.skill_learn?(skill) && ! LEARN_SKILL_HIDE text = SKILL_LEARN else text = sprintf(NEED_EXP, @actor.calc_need_exp(skill)) end self.contents.draw_text(rect, text, 2) end end #-------------------------------------------------------------------------- # ● スキル名の描画 #-------------------------------------------------------------------------- def draw_skill_name(skill, x, y) draw_icon(skill.icon_index, x, y) if @actor.skill_learn?(skill) color = COLOR3 elsif @actor.skill_can_learn?(skill) color = COLOR1 else color = COLOR2 end self.contents.font.color = color self.contents.draw_text(x + 24, y, 172, WLH, skill.name) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(skill == nil ? "" : skill.description) end end #============================================================================== # ■ Window_Learn #============================================================================== class Window_Learn < Window_Command #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(132, ["修得する", "修得しない"]) self.active = false self.openness = 0 self.x = (Graphics.width - self.width) / 2 self.y = (Graphics.height - self.height) / 2 @item_max = 2 self.index = 0 refresh end end #============================================================================== # ■ Window_SkillStatusExp #============================================================================== class Window_SkillStatusExp < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, actor) super(x, y, Graphics.width, WLH + 32) @actor = actor refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear draw_actor_name(@actor, 4, 0) draw_actor_level(@actor, 140, 0) draw_actor_exp(@actor, 388, 0) end #-------------------------------------------------------------------------- # ● 経験値情報の描画 #-------------------------------------------------------------------------- def draw_actor_exp(actor, x, y) exp = actor.exp exp -= actor.exp_list[actor.level] unless Kazari::LearnSkillExp::LEARN_FLAG self.contents.font.color = system_color self.contents.draw_text(x, y, 60, WLH, "経験値") self.contents.font.color = normal_color self.contents.draw_text(x, y, 120, WLH, exp, 2) end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler include Kazari::LearnSkillExp #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :exp_list #-------------------------------------------------------------------------- # ● 必要経験値の計算 #-------------------------------------------------------------------------- def calc_need_exp(skill) memo = skill.note.scan(/<#{"必要経験値"}(\d+):(\d+)>/) memo = memo.flatten if memo[0].to_i == @actor_id need_exp = memo[1].to_i else memo = skill.note.scan(/<#{"必要経験値:"}(\d+)>/) memo = memo.flatten need_exp = memo[0].to_i end return need_exp end #-------------------------------------------------------------------------- # ● スキルの修得可能判定 #-------------------------------------------------------------------------- def skill_can_learn?(skill) return false if skill_learn?(skill) if LEARN_FLAG usable_exp = @exp else usable_exp = @exp - @exp_list[@level] end return usable_exp >= calc_need_exp(skill) end #-------------------------------------------------------------------------- # ● スキルの修得(経験値消費) #-------------------------------------------------------------------------- def learning_skill(skill) learn_skill(skill.id) need_exp = calc_need_exp(skill) gain_exp(-need_exp, false) end end