# ▼▲▼ XSE_S3 スキル・レベル ▼▲▼ # # update 2007/ 8/ 6 # 必須 : XRXS.ウィンドウ行間可変機構 # #============================================================================== # カスタマイズポイント #============================================================================== module XSE_S3 # 各キャラクターの保有クラスID配列 CLASSES = [] CLASSES[1] = [11,12,13,14,15,17] # (ID:1)アルシェスに 剣技・槍技・治癒魔法 を設定 CLASSES[2] = [12,14] # (ID:2)バジルに 槍技・短剣技 CLASSES[3] = [12,13] # (ID:3)サイラスに 槍技・斧技 # [アニメーション] レベルアップ時 ANIMATION_ID = 18 # [用語] LEARN_S = " を習得した!  " ASK_S = "を使い、レベルアップしますか?" YES_S = "はい" NO_S = "いいえ" NEXT_S = "NEXT" UNABLE_S = "選択可能なスキルがありません" # [画像ファイル名] LV_C = "Caption_Lv" # 文字 SLv1 = "XSE_L1" # スキルレベルアイコン SLv2 = "XSE_L2" # (1:未修得、2:習得済み) # # [スキル出現トリガースキル] ハッシュ # 記述方式 : スキルID=>出現するクラスID (,で区切る。最後に,は不要) # TRIGGERS = { 1=>7, 66=>16 } # [マスターすると欄から消えるクラス] ID配列 AUTO_CLEARS = [13, 21,22] end module XSE BG = "XSE_S3" # 背景画像(windowskinフォルダ) BG_OPACITY = 224 # 背景画像の不透明度(0〜255) OPACITY = 128 # 各ウィンドウの不透過度(0〜255) end #============================================================================== # 各スキル(内部的にはクラス)の値 #============================================================================== module XSE_S3_LV def class_levels @class_levels = {} if @class_levels == nil return @class_levels end end class Game_Actor < Game_Battler include XSE_S3_LV end #============================================================================== # シーン管理 #============================================================================== class Scene_XSE #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- 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 @level_window = Window_SkillLevel.new(@actor) @name_plate = NamePlate.new(@actor) @ask_window = Window_SkillLevelAsk.new @help_window = Window_Help2.new @level_window.help_window = @help_window @target = RPG::Sprite.new @ap_info = Window_XSEInfo.new(@actor) @ap_info.y = 120 @learn_infoing = false # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @target.dispose @ap_info.dispose @ask_window.dispose @help_window.dispose @bg.dispose @level_window.dispose @name_plate.dispose @bg_sprite.dispose end #-------------------------------------------------------------------------- # 更新 #-------------------------------------------------------------------------- def update @target.update @ask_window.update if @learn_infoing update_info elsif @ask_window.active update_ask else update_level end end #-------------------------------------------------------------------------- # 更新 アスク部分 #-------------------------------------------------------------------------- def update_info # ボタンが押されたとき if Input.trigger?(Input::B) or Input.trigger?(Input::C) @help_window.y = 0 @learn_infoing = false @level_window.update 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 @level_window.active = true 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 += @level_window.ap level = @actor.class_levels[@level_window.class_id].to_i @actor.class_levels[@level_window.class_id] = level + 1 # スキルを習得! @actor.learn_skill(@level_window.skill.id) # 適用 animation = $data_animations[XSE_S3::ANIMATION_ID] @target.x = 192 @target.y = @level_window.y + @level_window.index * 32 + 12 @target.animation(animation, true) @help_window.y = @level_window.index * 36 + 164 @help_window.set_text(@level_window.skill.name + XSE_S3::LEARN_S, 1) @learn_infoing = true @level_window.refresh @ap_info.refresh else # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) end # 戻る @ask_window.fadeout! @ask_window.active = false @level_window.active = true return end end #-------------------------------------------------------------------------- # 更新 レベル部分 #-------------------------------------------------------------------------- def update_level @level_window.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 @level_window.skill == nil or @level_window.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(@level_window.ap) @ask_window.active = true @ask_window.index = 0 @level_window.active = false 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 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_S3::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_S3::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_S3::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 #============================================================================== # Window_SkillLevel #============================================================================== class Window_SkillLevel < Window_Selectable include XRXS_FitWindow include Module_SelectableEX #-------------------------------------------------------------------------- # ○ 行間 #-------------------------------------------------------------------------- def line_height return 36 end #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize(actor) super(32, 160, 576, line_height * 6 + 32) @base.opacity = 0 self.index = 0 self.z = 21 @actor = actor refresh end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh @next_aps = [] @skills = [] @classes = [] # 保有スキルを取得 classes = XSE_S3::CLASSES[@actor.id].dup # トリガースキル検索 for skill_id in @actor.skills class_id = XSE_S3::TRIGGERS[skill_id] if class_id != nil and not classes.include?(class_id) classes.push(class_id) end end # 自動消去 for class_id in classes.dup # クラスデータを取得 data = $data_classes[class_id] # マスター確認 level = @actor.class_levels[class_id].to_i max_level = data.learnings.size if level >= max_level classes.delete(class_id) end end # 再作成 if self.contents != nil self.contents.dispose self.contents = nil end self.contents = Bitmap.new(width - 32, (classes == nil ? 1 : classes.size) * self.line_height) self.contents.clear self.contents.font.size = 18 # ない場合 if classes == nil self.contents.font.color = disabled_color self.contents.draw_shadow_text(38, 40, 256, 28, XSE_S3::UNABLE_S) return end # 各画像データ lv_c = RPG::Cache.windowskin(XSE_S3::LV_C) slv_b = RPG::Cache.windowskin(XSE_S3::SLv1) slv_d = RPG::Cache.windowskin(XSE_S3::SLv2) skin_s = RPG::Cache.windowskin(XSE::NumberS) skin_l = RPG::Cache.windowskin(XSE::NumberL) # 現在AP #self.contents.font.color = system_color #self.contents.draw_shadow_text( 2,0, 64,24, XSE::AP_S, 2) #self.contents.blt_number(128,20, skin_l, @actor.ap_now) # スキルジャンルごとにループ @item_max = classes.size x = 4 y = 2 for i in 0...@item_max class_id = classes[i] @classes[i] = class_id next if class_id == nil # クラスデータを取得 data = $data_classes[class_id] # 現在レベル level = @actor.class_levels[class_id].to_i max_level = data.learnings.size # 描画:星 ox = 0 for j in 0...max_level mark = j < level ? slv_d : slv_b self.contents.blt(x + 128 + ox, y+10, mark, mark.rect, 160) ox += 22 end # 描画:文字 self.contents.font.size = 20 if level == 0 self.contents.font.color = disabled_color self.contents.draw_shadow_text(x, y, 128, 28, data.name, 2) else self.contents.font.color = system_color self.contents.draw_shadow_text(x, y, 128, 28, data.name, 2) self.contents.font.color = normal_color self.contents.blt(x+128, y, lv_c, lv_c.rect) self.contents.blt_number(x+176, y+18, skin_l, level) end # 必要AP @skills[i] = next_skill(data, level) if @skills[i] @next_aps[i] = @skills[i].ap self.contents.font.color = system_color self.contents.font.size = 14 self.contents.draw_shadow_text(x+240, y+4, 32,22, XSE_S3::NEXT_S) self.contents.font.color = normal_color self.contents.font.size = 20 self.contents.blt_number(x+312, y+21, skin_s, self.next_ap(i)) # 次のスキル名 self.contents.font.color = disabled_color self.contents.draw_shadow_text(x+360, y, 160,32, @skills[i].name) else # 次のスキル名 self.contents.font.color = disabled_color self.contents.draw_shadow_text(x+360, y, 160,32, "---") end # y += 36 end end #-------------------------------------------------------------------------- # 次のクラスレベルアップに必要なAPの取得 #-------------------------------------------------------------------------- def next_skill(class_data, now_level) # 習得データソート sort_learns = [] for learning in class_data.learnings index = 0 for l in sort_learns index += 1 if l.level <= learning.level end sort_learns.insert(index, learning) end # learning = sort_learns[now_level] if learning skill = $data_skills[learning.skill_id] else skill = nil end return skill end def next_ap(index) return @next_aps[index] end #-------------------------------------------------------------------------- # 各データの取得 #-------------------------------------------------------------------------- def ap return self.next_ap(self.index) end def skill return @skills[self.index] end def class_id return @classes[self.index] end #-------------------------------------------------------------------------- # カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect super case self.index when -1 self.cursor_rect.empty #else # self.cursor_rect.set(4, self.index * 36, 536, 34) end end #-------------------------------------------------------------------------- # ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(@skills[self.index] == nil ? "" : @skills[self.index].description) end end