#=========================================================================== # ◆ A1 Scripts ◆ # リザルトウィンドウ(RGSS3) # # バージョン : 3.00 (2020/06/17) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・戦闘のリザルトウィンドウを表示します #--------------------------------------------------------------------------- # 更新履歴   :2012/01/04 Ver1.00 リリース #    :2012/01/05 Ver1.10 大量にスキルを習得した際の対応 # :2012/01/09 Ver1.11 一部の数値の時に合計値がおかしくなる不具合を修正 # :2012/01/09 Ver1.12 上記不具合を再度修正 # :2012/01/17 Ver1.20 戦闘中入れ替え対応 # :2012/01/18 Ver2.00 A1バトル共通スクリプト対応 # :2012/01/23 Ver2.10 スキル拡張対応 # :2012/01/23 Ver2.10 経験値表示名を設定可能に # :2012/01/23 Ver2.10 デザインを変更 # :2020/06/17 Ver3.00 顔グラフィックモードを追加 #--------------------------------------------------------------------------- # 設置場所 # A1バトル共通スクリプト以下 # 一部再定義メソッドがあるため、なるべく上の方 # # 必要スクリプト # A1バトル共通スクリプト Ver5.40以上 #--------------------------------------------------------------------------- # 使い方 # ■ 設定項目 に設定 # # イベントコマンド「注釈」に記述 # # リザルトウィンドウ非表示 on|off # # on にするとリザルトウィンドウが表示されず、すぐに戦闘終了になります # 戦闘終了後、自動で off になります # # データベース「アクター」のメモに記述 # # <アクターアイコン index> # # アクターアイコンが設定されていると # スキル習得時に歩行グラフィックの代わりにアイコンが表示されます # デフォルト規格外の歩行グラフィックを使用する時などにどうぞ #============================================================================== $imported ||= {} if $imported["A1_BattleCommonScript"] $imported["A1_ResultWindow"] = true old_common_script("リザルトウィンドウ", "5.40") if common_version < 5.40 #============================================================================== # ■ 設定項目 #============================================================================== module A1_System::RwsultWindowConfig #-------------------------------------------------------------------------- # ○ 顔グラフィックを使う #-------------------------------------------------------------------------- USE_FACE_GRAPHIC = true #-------------------------------------------------------------------------- # ○ キャラクター(又は顔グラフィック)のサイズ [幅, 高さ] #-------------------------------------------------------------------------- CHARACTER_SIZE = [96, 32] #-------------------------------------------------------------------------- # ○ 表示させるメンバー数 #-------------------------------------------------------------------------- SHOW_MEMBER_NUM = 5 #-------------------------------------------------------------------------- # ○ 経験値ゲージの色 (グラデーション開始) #-------------------------------------------------------------------------- GAUGE_COLOR_1 = Color.new(150, 0, 255) #-------------------------------------------------------------------------- # ○ 経験値ゲージの色 (グラデーション終わり) #-------------------------------------------------------------------------- GAUGE_COLOR_2 = Color.new(50, 135, 255) #-------------------------------------------------------------------------- # ○ 経験値ゲージ・レベル・経験値の表示x座標 #-------------------------------------------------------------------------- INFOS_X = CHARACTER_SIZE[0] + 18 #-------------------------------------------------------------------------- # ○ 経験値ゲージ・レベル・経験値表示の幅 #-------------------------------------------------------------------------- #INFOS_WIDTH = 150 INFOS_WIDTH = 100 #-------------------------------------------------------------------------- # ○ 経験値ゲージが伸びる毎に鳴らすSE #-------------------------------------------------------------------------- EXP_SE = RPG::SE.new("Decision1", 80, 110) #-------------------------------------------------------------------------- # ○ アイテムドロップ時に鳴らすSE #-------------------------------------------------------------------------- ITEM_GET_SE = RPG::SE.new("Item1", 80, 110) #-------------------------------------------------------------------------- # ○ レベルアップ時に鳴らすSE #-------------------------------------------------------------------------- LVUP_SE = RPG::SE.new("Item2", 80, 110) #-------------------------------------------------------------------------- # ○ 経験値を全て処理するまでの時間(フレーム) #-------------------------------------------------------------------------- EXP_TIME = 60 #-------------------------------------------------------------------------- # ○ 表示する経験値名 #-------------------------------------------------------------------------- EXP_NAME = "Exp" end #============================================================================== # ■ RPG::Actor #============================================================================== class RPG::Actor < RPG::BaseItem #-------------------------------------------------------------------------- # ○ アクターアイコン #-------------------------------------------------------------------------- def actor_icon @actor_icon ||= $a1_common.note_data_one(self.note, "アクターアイコン", 0).to_i return @actor_icon end end #============================================================================== # ■ Window_Result #============================================================================== class Window_Result < Window_Base #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- CHARACTER_WIDTH = A1_System::RwsultWindowConfig::CHARACTER_SIZE[0] CHARACTER_HEIGHT = A1_System::RwsultWindowConfig::CHARACTER_SIZE[1] GAUGE_COLOR_1 = A1_System::RwsultWindowConfig::GAUGE_COLOR_1 GAUGE_COLOR_2 = A1_System::RwsultWindowConfig::GAUGE_COLOR_2 INFOS_X = A1_System::RwsultWindowConfig::INFOS_X INFOS_WIDTH = A1_System::RwsultWindowConfig::INFOS_WIDTH SHOW_MEMBER_NUM = A1_System::RwsultWindowConfig::SHOW_MEMBER_NUM EXP_NAME = A1_System::RwsultWindowConfig::EXP_NAME USE_FACE_GRAPHIC = A1_System::RwsultWindowConfig::USE_FACE_GRAPHIC #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @total_exp = 0 @total_gold = 0 super(0, 0, window_width, window_height) self.openness = 0 self.active = false @can_input = false end #-------------------------------------------------------------------------- # ○ ウィンドウの幅 #-------------------------------------------------------------------------- def window_width INFOS_X + INFOS_WIDTH * max_col + 36 end #-------------------------------------------------------------------------- # ○ ウィンドウの高さ #-------------------------------------------------------------------------- def window_height rect_height * max_row + fitting_height(bottom_num + 1) end #-------------------------------------------------------------------------- # ○ 経験値・Goloなどの項目数合計 #-------------------------------------------------------------------------- def bottom_num return 2 end #-------------------------------------------------------------------------- # ○ 最大の高さ #-------------------------------------------------------------------------- def max_row return SHOW_MEMBER_NUM end #-------------------------------------------------------------------------- # ○ 最大の幅 #-------------------------------------------------------------------------- def max_col return 1 end #-------------------------------------------------------------------------- # ○ 獲得経験値の設定 #-------------------------------------------------------------------------- def total_exp=(value) @total_exp = value end #-------------------------------------------------------------------------- # ○ 獲得Goldの設定 #-------------------------------------------------------------------------- def total_gold=(value) @total_gold = value end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear_rect(INFOS_X, line_height, INFOS_WIDTH, self.contents.height) draw_text(0, 0, self.contents.width, line_height, "Result", 1) $game_party.battle_members.each_with_index {|actor, i| drow_actor_info(actor, i) } end #-------------------------------------------------------------------------- # ○ 水平線の描画 #-------------------------------------------------------------------------- def draw_horz_line(y) contents.fill_rect(0, y, contents_width, 2, line_color) end #-------------------------------------------------------------------------- # ○ 水平線の色を取得 #-------------------------------------------------------------------------- def line_color color = normal_color color.alpha = 48 color end #-------------------------------------------------------------------------- # ○ 情報の幅を取得 #-------------------------------------------------------------------------- def total_infos_width return INFOS_WIDTH end #-------------------------------------------------------------------------- # ○ 経験値情報のリフレッシュ #-------------------------------------------------------------------------- def refresh_exp(exp, gold) contents.clear_rect(INFOS_X, line_height, total_infos_width, self.contents.height) $game_party.battle_members.each_with_index {|actor, i| drow_exp_info(actor, i) } draw_horz_line(horz_line_y) draw_caption change_color(normal_color) @total_gold -= gold @total_exp -= exp draw_text(INFOS_X, gold_y, total_infos_width, line_height, @total_gold, 2) draw_text(INFOS_X, exp_y, total_infos_width, line_height, @total_exp, 2) end #-------------------------------------------------------------------------- # ○ 獲得経験値/Goldの見出しの描画 #-------------------------------------------------------------------------- def draw_caption change_color(system_color) draw_text(INFOS_X, gold_y, INFOS_WIDTH, line_height, Vocab.currency_unit) draw_text(INFOS_X, exp_y, INFOS_WIDTH, line_height, EXP_NAME) end #-------------------------------------------------------------------------- # ○ 水平線のy座標取得 #-------------------------------------------------------------------------- def horz_line_y exp_y - 1 end #-------------------------------------------------------------------------- # ○ 獲得Gold表示y座標取得 #-------------------------------------------------------------------------- def gold_y self.height - fitting_height(1) end #-------------------------------------------------------------------------- # ○ 獲得経験値表示y座標取得 #-------------------------------------------------------------------------- def exp_y gold_y - line_height + 4 end #-------------------------------------------------------------------------- # ○ アクター情報の描画 #-------------------------------------------------------------------------- def drow_actor_info(actor, index) return if index > SHOW_MEMBER_NUM - 1 return drow_actor_face_info(actor, index) if USE_FACE_GRAPHIC rect = create_rect(index) cx = rect.x + CHARACTER_WIDTH / 2 cy = rect.y + CHARACTER_HEIGHT draw_character(actor.character_name, actor.character_index, cx, cy) drow_exp_info(actor, index, rect) end #-------------------------------------------------------------------------- # ○ アクター情報の描画(顔グラフィック) #-------------------------------------------------------------------------- def drow_actor_face_info(actor, index) rect = create_rect(index) draw_face_with_size(actor.face_name, actor.face_index, rect.x, rect.y, CHARACTER_WIDTH, CHARACTER_HEIGHT) drow_exp_info(actor, index, rect) end #-------------------------------------------------------------------------- # ○ 経験値/Gold情報の描画 #-------------------------------------------------------------------------- def drow_exp_info(actor, index, rect = nil) return if index > SHOW_MEMBER_NUM - 1 rect = create_rect(index) unless rect lvup_exp = actor.next_level_exp - actor.current_level_exp left_exp = actor.next_level_exp - actor.exp rate = 1 - left_exp.to_f / lvup_exp.to_f ty = rect.y + rect.height - line_height - 8 gy = ty + 8 draw_text( INFOS_X, ty, INFOS_WIDTH, line_height, "#{Vocab.level_a}:#{actor.level}") draw_text( INFOS_X, ty, INFOS_WIDTH, line_height, actor.exp, 2) draw_gauge(INFOS_X, gy, INFOS_WIDTH, rate, GAUGE_COLOR_1, GAUGE_COLOR_2) end #-------------------------------------------------------------------------- # ○ 経験値/Gold情報を描画する矩形の作成 #-------------------------------------------------------------------------- def create_rect(index) x = 0 y = CHARACTER_HEIGHT * index + line_height width = self.contents.width height = rect_height return Rect.new(x, y, width, height) end #-------------------------------------------------------------------------- # ○ 経験値/Gold情報を描画する矩形の高さを取得 #-------------------------------------------------------------------------- def rect_height CHARACTER_HEIGHT > line_height + 6 ? CHARACTER_HEIGHT : line_height + 6 end end #============================================================================== # ■ Window_ResultDropItem #============================================================================== class Window_ResultDropItem < Window_Base #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(items) super(0, 0, 250, fitting_height(items.size + 1)) self.openness = 0 @items = items end #-------------------------------------------------------------------------- # ○ サイズ変更 #-------------------------------------------------------------------------- def resize(main_window) self.x = main_window.x self.y = main_window.y + main_window.height self.width = main_window.width create_contents end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh draw_text(0, 0, self.contents.width, line_height, "ItemGet!!", 1) @items.each_with_index {|item, i| drow_item_info(item, i) } end #-------------------------------------------------------------------------- # ○ アイテム情報の描画 #-------------------------------------------------------------------------- def drow_item_info(item, i) draw_item_name(item, 0, line_height * (i + 1), true, self.contents.width) end end #============================================================================== # ■ Window_ResultNewSkill #============================================================================== class Window_ResultNewSkill < Window_Base #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- CHARACTER_WIDTH = A1_System::RwsultWindowConfig::CHARACTER_SIZE[0] CHARACTER_HEIGHT = A1_System::RwsultWindowConfig::CHARACTER_SIZE[1] USE_FACE_GRAPHIC = A1_System::RwsultWindowConfig::USE_FACE_GRAPHIC #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @skills = [] super(0, 0, window_width, 0) self.openness = 0 end #-------------------------------------------------------------------------- # ○ ウィンドウの幅 #-------------------------------------------------------------------------- def window_width return CHARACTER_WIDTH + 172 end #-------------------------------------------------------------------------- # ○ サイズ変更 #-------------------------------------------------------------------------- def resize(main_window) self.x = main_window.x + main_window.width self.y = main_window.y create_contents refresh end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear @skills.delete_at(0) while new_height + self.y > Graphics.height self.height = new_height create_contents draw_text(0, 0, self.contents.width, line_height, "NewSkill!!", 1) @skills.each_with_index {|skill, i| drow_skill_info(skill, i) } end #-------------------------------------------------------------------------- # ○ 新しい高さ #-------------------------------------------------------------------------- def new_height fitting_height(@skills.size + 1) end #-------------------------------------------------------------------------- # ○ スキル情報の描画 #-------------------------------------------------------------------------- def drow_skill_info(info, i) return drow_skill_info_face(info, i) if USE_FACE_GRAPHIC y = line_height * (i + 1) cx = CHARACTER_WIDTH / 2 cy = y + CHARACTER_HEIGHT / 2 + CHARACTER_HEIGHT / 4 skill = info[0] actor = info[1] icon_index = actor.actor_icon draw_item_name(skill, 36, y, true, self.contents.width) draw_icon(icon_index, 0, y) if icon_index > 0 draw_character(actor.character_name, actor.character_index, cx, cy) if icon_index == 0 end #-------------------------------------------------------------------------- # ○ スキル情報の描画(顔グラフィック) #-------------------------------------------------------------------------- def drow_skill_info_face(info, i) x = 0 y = line_height * (i + 1) skill = info[0] actor = info[1] icon_index = actor.actor_icon draw_item_name(skill, CHARACTER_WIDTH, y, true, self.contents.width - CHARACTER_WIDTH) draw_face_with_size(actor.face_name, actor.face_index, x, y, CHARACTER_WIDTH, CHARACTER_HEIGHT) end #-------------------------------------------------------------------------- # ○ 新スキル追加 #-------------------------------------------------------------------------- def add_skills(skill, actor) @skills.push([skill, actor]) end end #============================================================================== # ■ BattleManager #------------------------------------------------------------------------------ #  戦闘の進行を管理するモジュールです。 #============================================================================== module BattleManager #-------------------------------------------------------------------------- # ★ 勝利の処理 #-------------------------------------------------------------------------- def self.process_victory play_battle_end_me replay_bgm_and_bgs call_method(:process_victory) $game_temp.disable_result_window = false SceneManager.return battle_end(0) return true end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- EXP_SE = A1_System::RwsultWindowConfig::EXP_SE ITEM_GET_SE = A1_System::RwsultWindowConfig::ITEM_GET_SE LVUP_SE = A1_System::RwsultWindowConfig::LVUP_SE EXP_TIME = A1_System::RwsultWindowConfig::EXP_TIME #-------------------------------------------------------------------------- # ☆ 開始処理 #-------------------------------------------------------------------------- alias a1_result_window_sb_start start def start a1_result_window_sb_start create_result_window end #-------------------------------------------------------------------------- # ○ リザルトウィンドウの作成 #-------------------------------------------------------------------------- def create_result_window @window_result = Window_Result.new @window_new_skill = Window_ResultNewSkill.new @window_gold = Window_Gold.new @window_result.x = (Graphics.width - (@window_result.width + @window_new_skill.width)) / 2 @window_result.y = (Graphics.height - (@window_result.height + @window_gold.height)) / 2 posting_result_window @window_gold.openness = 0 end #-------------------------------------------------------------------------- # ○ リザルトウィンドウの位置設定 #-------------------------------------------------------------------------- def posting_result_window @window_new_skill.resize(@window_result) @window_gold.x = @window_result.x @window_gold.y = @window_result.y + @window_result.height @window_gold.width = @window_result.width @window_gold.create_contents end #-------------------------------------------------------------------------- # ☆ フレーム更新(基本) #-------------------------------------------------------------------------- alias a1_result_window_sb_update_basic update_basic def update_basic a1_result_window_sb_update_basic update_result_window end #-------------------------------------------------------------------------- # ○ リザルトウィンドウの更新 #-------------------------------------------------------------------------- def update_result_window return unless @window_result.can_input? close_result_window if Input.trigger?(:C) end #-------------------------------------------------------------------------- # ○ リザルトウィンドウを閉じる #-------------------------------------------------------------------------- def close_result_window Sound.play_ok @window_result.close @window_new_skill.close @window_drop_item.close if @window_drop_item @window_gold.close end #-------------------------------------------------------------------------- # ○ ドロップアイテムウィンドウの作成 #-------------------------------------------------------------------------- def create_drop_window(items) @window_drop_item = Window_ResultDropItem.new(items) left_height = @window_result.height + @window_gold.height right_height = @window_new_skill.height @window_drop_item.resize(@window_new_skill) y = @window_result.y + left_height if left_height < right_height x = @window_result.x if left_height < right_height width = @window_result.width if left_height < right_height @window_drop_item.x = x if x @window_drop_item.y = y if y @window_drop_item.width = width if width @window_drop_item.create_contents @window_drop_item.refresh @window_drop_item.open ITEM_GET_SE.play end #-------------------------------------------------------------------------- # ☆ 勝利の処理 #-------------------------------------------------------------------------- alias a1_result_window_sb_process_victory process_victory def process_victory a1_result_window_sb_process_victory @window_result.refresh @window_result.active = true @window_result.open status_window_close process_result @window_result.can_input = true wait_for_window_open(@window_result) end #-------------------------------------------------------------------------- # ○ リザルトウィンドウの処理 #-------------------------------------------------------------------------- def process_result display_exp gain_gold get_exp gain_drop_items end #-------------------------------------------------------------------------- # ○ ステータスウィンドウのクローズ #-------------------------------------------------------------------------- def status_window_close return close_actor_windows if $imported["A1_BattlePSXP"] @status_window.close end #-------------------------------------------------------------------------- # ○ 獲得した経験値の表示 #-------------------------------------------------------------------------- def display_exp @window_result.total_exp = $game_troop.exp_total end #-------------------------------------------------------------------------- # ○ お金の獲得と表示 #-------------------------------------------------------------------------- def gain_gold @window_gold.open @window_gold.refresh @window_result.total_gold = $game_troop.gold_total end #-------------------------------------------------------------------------- # ○ ドロップアイテムの獲得と表示 #-------------------------------------------------------------------------- def gain_drop_items items = $game_troop.make_drop_items items.each {|item| $game_party.gain_item(item, 1)} create_drop_window(items) if items.size > 0 end #-------------------------------------------------------------------------- # ○ 経験値の獲得 #-------------------------------------------------------------------------- def get_exp total_exp = $game_troop.exp_total if total_exp >= EXP_TIME up_exp = total_exp / EXP_TIME last_exp = total_exp % EXP_TIME wait_time = 1 count = EXP_TIME elsif total_exp == 0 up_exp = 0 last_exp = 0 wait_time = 1 count = 1 else up_exp = 1 wait_time = EXP_TIME / total_exp last_exp = 0 count = total_exp end total_gold = $game_troop.gold_total up_gold = total_gold / count last_gold = total_gold % count count.times {gain_exp(up_exp, up_gold, wait_time)} gain_exp(last_exp, last_gold) end #-------------------------------------------------------------------------- # ○ 経験値の獲得とレベルアップの表示 #-------------------------------------------------------------------------- def gain_exp(up_exp, up_gold, wait_time = 1) refresh_windows(up_exp, up_gold) EXP_SE.play wait(wait_time) end #-------------------------------------------------------------------------- # ○ 各ウィンドウのリフレッシュ #-------------------------------------------------------------------------- def refresh_windows(up_exp, up_gold) $game_party.all_members.each { |actor| actor_gain_exp(actor, up_exp) } $game_party.gain_gold(up_gold) @window_result.refresh_exp(up_exp, up_gold) @window_gold.refresh end #-------------------------------------------------------------------------- # ○ 経験値の獲得(個別) #-------------------------------------------------------------------------- def actor_gain_exp(actor, up_exp) now_lv = actor.level last_skills = actor.skills actor.gain_exp(up_exp, false) LVUP_SE.play if now_lv < actor.level new_skills = actor.skills - last_skills return if new_skills.empty? new_skills.each {|skill| @window_new_skill.add_skills(skill, actor) } @window_new_skill.open @window_new_skill.refresh reposting_result_window(new_skills.size) end #-------------------------------------------------------------------------- # ○ リザルトウィンドウの位置再設定 #-------------------------------------------------------------------------- def reposting_result_window(size) return unless @window_new_skill.height > @window_result.height + @window_gold.height height = size * @window_new_skill.line_height return if @window_result.y - height < 0 @window_result.y -= height posting_result_window end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ #  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors) # の内部で使用され、Game_Party クラス($game_party)からも参照されます。 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ★ 経験値の獲得(経験獲得率を考慮) #-------------------------------------------------------------------------- def gain_exp(exp, show = true) change_exp(self.exp + (exp * final_exp_rate).to_i, show) end #-------------------------------------------------------------------------- # ○ アクターアイコン #-------------------------------------------------------------------------- def actor_icon return actor.actor_icon end end #============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :disable_result_window #-------------------------------------------------------------------------- # ☆ オブジェクト初期化 #-------------------------------------------------------------------------- alias a1_result_window_gt_initialize initialize def initialize a1_result_window_gt_initialize @disable_result_window = false end end #============================================================================== # ■ A1_System::CommonModule #============================================================================== class A1_System::CommonModule #-------------------------------------------------------------------------- # ☆ 注釈コマンド定義 #-------------------------------------------------------------------------- alias a1_result_window_define_command define_command def define_command a1_result_window_define_command @cmd_108["リザルトウィンドウ非表示"] = :disable_result_window end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ○ リザルトウィンドウ非表示 #-------------------------------------------------------------------------- def disable_result_window(params) $game_temp.disable_result_window = params[0] == "on" ? true : false end end end