# ▼▲▼ XSE_S4 スキル・マトリクス ▼▲▼ # # update 2007/ 7/13 # #============================================================================== # カスタマイズポイント #============================================================================== module XSE_S4 # # 画像ファイル名 (Windowskins) # CURSOR = "XSE_Cursor" SKIN = "XSE_Matrixs" # [アニメーション] レベルアップ時 ANIMATION_ID = 18 # [用語] ASK_S = " 消費して、習得しますか?" YES_S = "はい" NO_S = "いいえ" UP1 = " が " UP2 = " 上昇する。" # 基本データ DATA = [] # # (スキルIDか1xnnnデータを指定する。) # (1万台のデータは # 千の位で種類 1:HP, 2:SP, 3:STR, 4:DEX, 5:AGI, 6:INT を、 #  一〜百の位で、パラメータ上昇値を設定する。) # # (例: 57 → クロスカット習得) # (例:11010 → 最大HP 10アップ) # # ↓ここにクラスID DATA[1] = [ 0, 0, 0, 0,13015, 60, 0, 0, 0, 0, 0, 0,14010, 59, 0, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0,15015, 0, 0, 0,11020,13005, 57,15005, 45, 54, 0, 0, 0, 25, 1,11010, 0, 0,12020,12050, 16020, 26,16015, 0, 7,16010, 0, 53, 0, 27, 0, 2, 0, 0, 8, 37, 31, 0, 0, 0,12030, 0, 0, 0, 9,16020, 0, 0, 0, 3, 0, 0, 0, 0, 32, 0 ] DATA[2] = [ 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0,11010,14010,13015,14020,13020, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] DATA[3] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,11010, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] # パラメータ上昇に必要なAPの式 def self.ap_as(n) # パラメータ値の倍をAPとする # (例 : HP10アップ、には20AP消費) return n * 2 end end module XSE BG = "XSE_S4" # 背景画像(windowskinフォルダ) BG_OPACITY = 192 # 背景画像の不透明度(0〜255) OPACITY = 128 # 各ウィンドウの不透過度(0〜255) end #============================================================================== # スキルの習得済みデータ #============================================================================== module XSE_S4_GA def xse_data @xse_data = [] if @xse_data == nil return @xse_data end end class Game_Actor < Game_Battler include XSE_S4_GA end #============================================================================== # シーン管理 #============================================================================== class Scene_XSE #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor_index : アクターインデックス #-------------------------------------------------------------------------- def initialize(actor_index = 0, equip_index = 0) @actor_index = actor_index end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # アクターを取得 @actor = $game_party.actors[@actor_index] # 作成 @bg_sprite = Spriteset_Map.new @bg = MenuBG.new @matrix_base = XSE_MatrixBase.new(@actor) @skillhelp_window = Window_XSEHelp.new @target = RPG::Sprite.new @ask_window = Window_SkillLevelAsk.new @name_plate = NamePlate.new(@actor) @info_window = Window_XSEInfo.new(@actor) @face = FaceSprite.new(@actor) @help_window = Window_Help2.new @help_window.y = 424 # ヘルプの関連付け @skillhelp_window.help_window = @help_window @matrix_base.help_window = @skillhelp_window # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # 解放 @face.dispose @help_window.dispose @name_plate.dispose @ask_window.dispose @skillhelp_window.dispose @info_window.dispose @bg_sprite.dispose @bg.dispose @target.dispose @matrix_base.dispose end #-------------------------------------------------------------------------- # フレーム更新 #-------------------------------------------------------------------------- def update @ask_window.update @target.update if @ask_window.active update_ask else update_main end end #-------------------------------------------------------------------------- # 更新:メイン #-------------------------------------------------------------------------- def update_main @matrix_base.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # メニュー画面に切り替え $scene = Scene_Menu.new(XSE::MENU_INDEX) return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 無い場合 or APが高すぎた場合 if not @matrix_base.enabled? or @matrix_base.skill_id == 0 or @matrix_base.ap > @actor.ap_now # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 選択ウィンドウへ移行 @ask_window.set(@matrix_base.ap) @ask_window.active = true @ask_window.index = 0 return end # R ボタンが押された場合 if Input.trigger?(Input::R) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # 次のアクターへ @actor_index += 1 @actor_index %= $game_party.actors.size # 別のアクターに切り替え $scene = Scene_XSE.new(@actor_index) return end # L ボタンが押された場合 if Input.trigger?(Input::L) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # 前のアクターへ @actor_index += $game_party.actors.size - 1 @actor_index %= $game_party.actors.size # 別のアクターに切り替え $scene = Scene_XSE.new(@actor_index) return end end #-------------------------------------------------------------------------- # 更新 アスク部分 #-------------------------------------------------------------------------- def update_ask # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # 戻る @ask_window.fadeout! @ask_window.active = false return end # C ボタンが押された場合 if Input.trigger?(Input::C) case @ask_window.index when 0 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # APを消費してマトリクス・オン! @actor.ap_used += @matrix_base.ap @actor.xse_data[@matrix_base.index] = true # スキルを習得! if @matrix_base.skill_id >= 10000 type = @matrix_base.skill_id/1000 % 10 n = @matrix_base.skill_id % 1000 @actor.parameter_plus(type, n) else @actor.learn_skill(@matrix_base.skill_id) end # 適用 animation = $data_animations[XSE_S4::ANIMATION_ID] @target.x = @matrix_base.cursor_x @target.y = @matrix_base.cursor_y @target.animation(animation, true) @matrix_base.refresh @info_window.refresh else # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) end # 戻る @ask_window.fadeout! @ask_window.active = false return end end end #============================================================================== # パラメータアップ #============================================================================== class Game_Actor < Game_Battler def parameter_plus(type, n) # パラメータで分岐 case type when 1 # MaxHP @maxhp_plus += n when 2 # MaxSP @maxsp_plus += n when 3 # 腕力 @str_plus += n when 4 # 器用さ @dex_plus += n when 5 # 素早さ @agi_plus += n when 6 # 魔力 @int_plus += n end end end #============================================================================== # マトリクスベース #============================================================================== class XSE_MatrixBase attr_reader :index #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) @actor = actor @base = Sprite.new @base.bitmap = Bitmap.new(288,288) @base.x = 288 @base.y = 64 @base.z = 11 @cursor = Sprite.new @cursor.bitmap = RPG::Cache.windowskin(XSE_S4::CURSOR) @oy = @cursor.bitmap.height / 2 @cursor.oy = @oy @cursor.z = 12 @help_window = nil @index = 40 refresh_cursor @cursor.x = @cursor_dest_x @cursor.y = @cursor_dest_y @cursor_anime_count = 0 @data = [] @enables = [] refresh end #-------------------------------------------------------------------------- # カーソルの位置予約 #-------------------------------------------------------------------------- def refresh_cursor @cursor_dest_x = @base.x + @index%9 * 32 @cursor_dest_y = @base.y + @index/9 * 32 if @help_window != nil @help_window.set_skill(self.skill_id) end end #-------------------------------------------------------------------------- # ヘルプ #-------------------------------------------------------------------------- def help_window=(window) @help_window = window refresh_cursor end #-------------------------------------------------------------------------- # 更新 #-------------------------------------------------------------------------- def update # キー moved = false if Input.repeat?(Input::UP) and @index >= 9 @index -= 9 moved = true elsif Input.repeat?(Input::DOWN) and @index <= 71 @index += 9 moved = true elsif Input.repeat?(Input::LEFT) and @index%9 >= 1 @index -= 1 moved = true elsif Input.repeat?(Input::RIGHT) and @index%9 <= 7 @index += 1 moved = true end if moved # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) refresh_cursor end # カーソル移動 if @cursor.x > @cursor_dest_x @cursor.x -= 8 elsif @cursor.x < @cursor_dest_x @cursor.x += 8 end if @cursor.y > @cursor_dest_y @cursor.y -= 8 elsif @cursor.y < @cursor_dest_y @cursor.y += 8 end # カーソルゆれ @cursor_anime_count += 1 @cursor_anime_count %= 16 @cursor.oy = @oy + (8 - @cursor_anime_count).abs / 4 end #-------------------------------------------------------------------------- # 土台の描画 #-------------------------------------------------------------------------- def refresh @base.bitmap.clear # 可能データの初期化 @enables = [] # skin = RPG::Cache.windowskin(XSE_S4::SKIN) rect = Rect.new(0,0,32,32) # クラスからデータの取得 @data = XSE_S4::DATA[@actor.class_id] @data = [0] * 81 if @data == nil # 描画 for x in 0..8 for y in 0..8 index = x + y * 9 if @data[index] != 0 # 横ライン if index%9 <= 7 and @data[index+1] != 0 rect.x = 32 if @actor.xse_data[index] or (index%9 <= 7 and @actor.xse_data[index+1]) rect.y = 32 else rect.y = 0 end @base.bitmap.blt(16 + 32 * x, 32 * y, skin, rect) end # 縦ライン if @data[index+9].to_i != 0 rect.x = 0 if @actor.xse_data[index] or (index <= 72 and @actor.xse_data[index+9]) rect.y = 32 else rect.y = 0 end @base.bitmap.blt(32 * x, 16 + 32 * y, skin, rect) end # 玉 if @actor.xse_data[index] rect.x = @data[index] >= 10000 ? 32 : 0 rect.y = 96 elsif (index >= 1 and @actor.xse_data[index-1]) or (index%9 <= 7 and @actor.xse_data[index+1]) or (index >= 9 and @actor.xse_data[index-9]) or (index <= 72 and @actor.xse_data[index+9]) or (index == 40) rect.x = 32 rect.y = 64 @enables[index] = true else rect.x = 0 rect.y = 64 end @base.bitmap.blt(32 * x, 32 * y, skin, rect) end end end end #-------------------------------------------------------------------------- # 現在の選択情報取得 #-------------------------------------------------------------------------- def skill_id return @data[self.index] end def ap return 0 if self.skill_id == 0 return XSE_S4.ap_as(self.skill_id % 1000) if self.skill_id >= 10000 return $data_skills[self.skill_id].ap end def enabled? return @enables[self.index] end def cursor_x return @cursor_dest_x + 16 end def cursor_y return @cursor_dest_y + 16 end #-------------------------------------------------------------------------- # 解放 #-------------------------------------------------------------------------- def dispose @base.dispose @cursor.dispose end end #============================================================================== # スキルヘルプ #============================================================================== class Window_XSEHelp < Window_Base include XRXS_FitWindow #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(400,376, 256, 80) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 18 self.z = 56 @skill_id = 0 end #-------------------------------------------------------------------------- # ヘルプ #-------------------------------------------------------------------------- def help_window=(window) @help_window = window end #-------------------------------------------------------------------------- # スキル設定 #-------------------------------------------------------------------------- def set_skill(skill_id) # 同じ内容は再描画しない return if @skill_id == skill_id or skill_id == nil @skill_id = skill_id # 描画 self.contents.clear if skill_id == 0 n = 64 text = "---" ap = -1 if @help_window != nil @help_window.set_text("") end elsif skill_id >= 10000 n = 32 pram_s = ["", $data_system.words.hp, $data_system.words.sp, $data_system.words.str, $data_system.words.dex, $data_system.words.agi, $data_system.words.int ][skill_id /1000 % 10] plus = skill_id % 1000 text = pram_s + " + " + plus.to_s ap = XSE_S4.ap_as(plus) skin = RPG::Cache.windowskin(XSE_S4::SKIN) rect = Rect.new(n, 96, 32, 32) self.contents.blt(4,0, skin, rect) if @help_window != nil @help_window.set_text(pram_s + XSE_S4::UP1 + plus.to_s + XSE_S4::UP2) end else skill = $data_skills[skill_id] text = skill.name ap = skill.ap icon = RPG::Cache.icon(skill.icon_name) self.contents.blt(8,4, icon, icon.rect) # if @help_window != nil @help_window.set_text(skill.description) end end self.contents.font.color = normal_color self.contents.draw_text(42, 2, 180, 28, text) # if ap >= 0 self.contents.draw_text( 42, 28,144,16, ap.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(192, 28, 20,16, XSE::AP_S) end end end #============================================================================== # Window_SkillLevelAsk #============================================================================== class Window_SkillLevelAsk < Window_Selectable #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize @ask_base = Window_Base.new(160, 192, 320, 32) @ask_base.back_opacity = 160 @ask_window = Window_Base.new(160, 176, 320, 64) @ask_window.opacity = 0 @ask_window.contents = Bitmap.new(288,32) @ask_base.visible = false @ask_window.visible = false @ask_window.contents.font.size = 18 skin = RPG::Cache.windowskin($game_system.windowskin_name) @yes = Sprite.new @yes.bitmap = Bitmap.new(128,24) @yes.bitmap.blt( 0, 0, skin, Rect.new(0,0,128,24), 96) @yes.bitmap.font.size = 20 @yes.bitmap.draw_text(0,0,128,24, XSE_S4::YES_S, 1) @yes.opacity = 0 @no = Sprite.new @no.bitmap = Bitmap.new(128,24) @no.bitmap.blt( 0, 0, skin, Rect.new(0,0,128,24), 96) @no.bitmap.font.size = 20 @no.bitmap.draw_text(0,0,128,24,XSE_S4::NO_S, 1) @no.opacity = 0 super(240, 224, 160, 84) self.opacity = 0 self.active = false @fadein_count = 0 @fadeout_count = 0 @item_max = 2 self.index = 0 self.z = 41 end def set(ap) text = ap.to_s + " " + XSE::AP_S + XSE_S4::ASK_S @ask_window.contents.clear @ask_window.contents.draw_text(4,0,280,32, text) self.fadein! end #-------------------------------------------------------------------------- # 更新 #-------------------------------------------------------------------------- def update super if @fadein_count > 0 @fadein_count -= 1 @yes.x = 256 - [(@fadein_count - 2),0].max * 4 @no.x = 256 - @fadein_count * 4 @yes.opacity = (10 - @fadein_count) * 32 @no.opacity = (8 - @fadein_count) * 32 return end if @fadeout_count > 0 @fadeout_count -= 1 @yes.x = 320 - [(@fadeout_count - 2),0].max * 4 @no.x = 320 - @fadeout_count * 4 @yes.opacity = [(@fadeout_count - 2),0].max * 32 @no.opacity = @fadeout_count * 32 return end end #-------------------------------------------------------------------------- # カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect if self.active self.cursor_rect.set(0, self.index * 28, 128, 24) else self.cursor_rect.empty end end #-------------------------------------------------------------------------- # 各種プロパティ #-------------------------------------------------------------------------- def x=(n) @yes.x = n + 16 @no.x = n + 16 super end def y=(n) @yes.y = n + 16 @no.y = n + 44 super end def z=(n) @ask_base.z = n - 1 @ask_window.z = n @yes.z = n + 1 @no.z = n + 1 super end def fadein! @ask_base.visible = true @ask_window.visible = true @fadein_count = 8 @fadeout_count = 0 end def fadeout! @ask_base.visible = false @ask_window.visible = false @fadein_count = 0 @fadeout_count = 8 end def dispose @ask_base.dispose @ask_window.dispose @yes.dispose @no.dispose super end end