# ▼▲▼ XRXS24AX. WPXC.「鍛冶屋」 for ver.2 ▼▲▼ built 100212 # # --- # #============================================================================== # □ カスタマイズポイント #============================================================================== module XRXS24AX #-------------------------------------------------------------------------- # システム #-------------------------------------------------------------------------- # # 「付与可能のみをリスト」 # ( true にすると、属性「付与可能」がついているアイテム # しか付与できなくなります。   ) # LIST_ITEM_ONLY_FOR_GRANT = false #-------------------------------------------------------------------------- # 鍛冶屋ウィンドウ #-------------------------------------------------------------------------- # パーティ武器リスト列数 WINDOW_PARTYWEAPON_ROW = 4 # 付与アイテムリスト列数(↑↓あわせて 10 にするとぴったり) WINDOW_SMITHYITEM_ROW = 6 end #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias xrxs24_update update def update xrxs24_update # プレイヤーの移動中ではない場合 unless $game_player.moving? # 鍛冶屋画面の呼び出しを実行 if $game_temp.smithy_calling call_smithy end end end #-------------------------------------------------------------------------- # ● 鍛冶屋の呼び出し #-------------------------------------------------------------------------- def call_smithy # 鍛冶屋呼び出しフラグをクリア $game_temp.smithy_calling = false # プレイヤーの姿勢を矯正 $game_player.straighten # 鍛冶屋画面に切り替え $scene = Scene_Smithy.new end end #============================================================================== # ■ Game_Temp #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :smithy_calling # 鍛冶屋 呼び出しフラグ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias xrxs24_initialize initialize def initialize xrxs24_initialize @smithy_calling = false end end #============================================================================== # ■ Interpreter #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ◇ 鍛冶屋の処理 #-------------------------------------------------------------------------- def command_smithy # バトル中断フラグをセット $game_temp.battle_abort = true # 鍛冶屋呼び出しフラグをセット $game_temp.smithy_calling = true end end #------------------------------------------------------------------------------ # # # ▽ 新規追加部分 # # #============================================================================== # □ Window_SmithyLeft #------------------------------------------------------------------------------ #  鍛冶屋画面で、左側に表示されるウィンドウの土台です。 #============================================================================== class Window_SmithyLeft < Window_Base #-------------------------------------------------------------------------- # ○ インクルード #-------------------------------------------------------------------------- include XRXS24AX #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 64, 368, 416) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 192, 32, "パーティ武器") self.contents.draw_text(4, 32 * (WINDOW_PARTYWEAPON_ROW+1), 192, 32, "付与" + $data_system.words.item) end end #============================================================================== # □ Window_PartyWeapon #------------------------------------------------------------------------------ #  鍛冶屋画面で、パーティ全員の現在装備している武器を表示するウィンドウです。 #============================================================================== class Window_PartyWeapon < Window_Selectable #-------------------------------------------------------------------------- # ○ インクルード #-------------------------------------------------------------------------- include WPXC include XRXS24AX #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize #height = ([$game_party.actors.size, 4].max + 3) * 32 super(0, 96, 368, 32 * (WINDOW_PARTYWEAPON_ROW+1)) h = $game_party.actors.size * 32 self.contents = Bitmap.new(width - 32, h) self.opacity = 0 self.back_opacity = 0 @column_max = 1 refresh self.index = -1 end #-------------------------------------------------------------------------- # ○ アイテムの取得 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] y = 32 * ($game_party.actors.size + 1) for i in 0...$game_party.actors.size actor = $game_party.actors[i] next if actor == nil # キャラ顔 draw_actor_facesquare(actor, 4, 32 * (i)+4) # 武器名描写 weapon_id = actor.weapon_id @data.push($data_weapons[weapon_id]) if weapon_id == 0 self.contents.font.color = disabled_color self.contents.draw_text(36, 32 * (i), 106, 32, "---", 2) else # 武器名 self.contents.font.color = normal_color draw_item_name(@data[i], 36, 32 * (i)) level = $game_party.actors[i].weapon_property[PROPERTY_LEVEL] # レベル if SHOW_WEAPON_LEVEL_SYSTEM self.contents.draw_text(296, 32 * (i), 24, 32, level.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(260, 32 * (i), 32, 32, "Lv.") end end end @item_max = @data.size end #-------------------------------------------------------------------------- # ○ グラフィック→顔&枠の描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_facesquare(actor, x, y, width = 24, height = 24) bitmap = RPG::Cache.character(actor.character_name, actor.character_hue) src_rect = Rect.new((bitmap.width/4 - width)/2, 0, width, height) self.contents.blt(x, y, bitmap, src_rect) self.contents.draw_polygon([[x,y],[x+width,y],[x+width,y+height],[x,y+height]], Color.new(255,255,255,128)) end #-------------------------------------------------------------------------- # ○ ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end #-------------------------------------------------------------------------- # ○ カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect super if @index == -1 self.cursor_rect.set(0, 0, 0,0) else self.cursor_rect.set(0, @index * 32 - self.oy, self.width - 32, 32) end end end #============================================================================== # □ Window_WeaponInfo #------------------------------------------------------------------------------ #  鍛冶屋画面で、武器のパラメータなどを表示するウィンドウです。 #============================================================================== class Window_WeaponInfo < Window_Selectable #-------------------------------------------------------------------------- # ○ インクルード #-------------------------------------------------------------------------- include WPXC #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :level # 表示中の武器のレベル attr_reader :property_elements # 属性 attr_reader :now_free_exp # 現在自由に使えるEXP attr_reader :item_max attr_accessor :item # アイテム #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(368, 64, 272, 416) self.contents = Bitmap.new(width - 32, height - 32) # 消去する set(nil) @item_max = 1 end #-------------------------------------------------------------------------- # ○ レベルを上げられる状況にあるか #-------------------------------------------------------------------------- def levelupable? return @levelupable end #-------------------------------------------------------------------------- # ○ 値をセットする #-------------------------------------------------------------------------- def set(item, room_no = 0) # 初期化 @levelupable = false case item when nil # nilの場合全てを消去 self.contents.clear return when Game_Actor # アクターを指定した場合は装備中の武器の情報 使用例:___.set(actor) @actor = item @item = $data_weapons[@actor.weapon_id] else # アイテムを指定した場合 @actor = nil @item = item @room_no = room_no end refresh end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh # 初期化 @levelupable = false now_free_exp = 0 self.contents.clear # 武器名 draw_item_name(@item, 4, 32) # 武器の場合、Lv: の描写 if @item.is_a?(RPG::Weapon) # 武器のレベルと経験値の取得 if @actor != nil @level = @actor.weapon_property[PROPERTY_LEVEL] exp_p = @actor.weapon_property[PROPERTY_EXP_SECOND] * 32768 exp_p += @actor.weapon_property[PROPERTY_EXP] else @level = $game_party.weapons_table[@item.id, @room_no, PROPERTY_LEVEL] exp_p = $game_party.weapons_table[@item.id, @room_no, PROPERTY_EXP_SECOND] * 32768 exp_p += $game_party.weapons_table[@item.id, @room_no, PROPERTY_EXP] end # 武器Lv./EXP, の表示 if SHOW_WEAPON_LEVEL_SYSTEM # 武器レベル self.contents.font.color = system_color self.contents.draw_text(124, 64, 32, 32, "Lv.") self.contents.font.color = normal_color self.contents.draw_text(216, 64, 24, 32, @level.to_s, 2) # EXPメーター self.contents.draw_line(143, 104, 273, 104, Color.new(0,0,0,255), 3) now_level_exp = ((@level) ** 3) # 現在レベルの所要EXP next_level_exp = ((@level + 1) ** 3) # 次のレベルの所要EXP now_free_exp = [exp_p - now_level_exp, 0].max # 現在自由に使えるEXP next_need_exp = next_level_exp - now_level_exp # 次のレベルに必要なEXP percentile = [[100 * (now_free_exp) / (next_need_exp), 0].max, 100].min if percentile < 100 line_color = Color.new(255, 255, 0, 255) else line_color = Color.new( 0, 255, 0, 255) @levelupable = true end self.contents.draw_line(144, 104, 144 + percentile * 1.28, 104, line_color, 1) # 武器経験値 self.contents.font.size = 10 self.contents.font.color = system_color self.contents.draw_text(124, 96, 32, 16, "EXP.") # EXP数値 self.contents.font.size = 10 self.contents.draw_text(124, 116, 64, 18, "NOW") self.contents.font.size = 16 self.contents.font.color = normal_color self.contents.draw_text(132, 116, 64, 16, now_free_exp.to_s + " /", 2) self.contents.draw_text(140, 116, 96, 16, next_need_exp.to_s, 2) end # 攻撃力 self.contents.font.size = 22 self.contents.font.color = system_color self.contents.draw_text( 96, 160, 96, 32, $data_system.words.atk) atk_p = @actor.base_atk #@item.atk * (100 + @item.atk%10 * level)/100 self.contents.font.color = normal_color self.contents.draw_text(192, 160, 48, 32, atk_p.to_s, 2) # 付与属性数を取得 available_slots = GRANT_SLOT_NUMBER returnar = XRXS.element_check(@actor.element_set, "付与属性数") if returnar[0] available_slots = [returnar[1], 4].min end @item_max = 1 + available_slots # 各々付与されている武器属性の描写 i_no = 0 if available_slots > 0 for i in [PROPERTY_ELEMENT_GRANT_1st, PROPERTY_ELEMENT_GRANT_2nd, PROPERTY_ELEMENT_GRANT_3rd, PROPERTY_ELEMENT_GRANT_4th] if @actor != nil element_id = @actor.weapon_property[i] else element_id = $game_party.weapons_table[@item.id, @room_no, i] end if element_id != 0 and element_id != nil self.contents.font.color = normal_color self.contents.draw_text(112, 192 + 32*i_no, 128, 32, $data_system.elements[element_id]) else self.contents.font.color = disabled_color self.contents.draw_text(112, 192 + 32*i_no, 128, 32, "---") end i_no += 1 # _no _| ̄|○(←似てる(笑 break if available_slots <= i_no end end end @now_free_exp = now_free_exp # 可視状態にする self.visible = true end #-------------------------------------------------------------------------- # ○ カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect if @index == -1 self.cursor_rect.set(0, 0, 0,0) elsif @index == 0 if SHOW_WEAPON_LEVEL_SYSTEM self.cursor_rect.set(0, 64, self.width - 32, 32) else # 武器Lv.表示が無効化されている場合に@indexが0になったばあい、1に修正 @index = 1 update_cursor_rect return end else self.cursor_rect.set(0, 160 + @index * 32, self.width - 32, 32) end end #-------------------------------------------------------------------------- # ○ ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help case self.index when 0 @help_window.set_text("武器の強化を行います。") else @help_window.set_text("武器に属性を付与します。") end end end #============================================================================== # □ Window_CenterAsk #------------------------------------------------------------------------------ #  画面中央で二択の質問を問い掛けるウィンドウです。 #============================================================================== class Window_CenterAsk < Window_Selectable #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(320, 192, 160, 96) self.contents = Bitmap.new(width - 32, height - 32) self.visible = false @first_choice = "" @second_choice = "" @helptext = ["", ""] @disabled = [] self.z = 9999 @item_max = 2 self.index = 0 end #-------------------------------------------------------------------------- # ○ 選択肢の設定 first_choice,second_choice == String #-------------------------------------------------------------------------- def set(first_choice, second_choice, help1 = "", help2 = "") @disabled[0] = false @disabled[1] = false @first_choice = first_choice @second_choice = second_choice @helptext[0] = help1 @helptext[1] = help2 width1 = self.contents.text_size(@first_choice).width width2 = self.contents.text_size(@second_choice).width self.width = (width1 > width2 ? width1 : width2) + 40 self.x = 320 - self.width / 2 self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # ○ 選択肢無効化 #-------------------------------------------------------------------------- def disable(n) @disabled[n] = true refresh end #-------------------------------------------------------------------------- # ○ 選択肢が無効化されているか? #-------------------------------------------------------------------------- def disabled?(n) return @disabled[n] end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear if @disabled[0] self.contents.font.color = disabled_color else self.contents.font.color = normal_color end self.contents.draw_text(4, 0, self.width-8, 32, @first_choice) if @disabled[1] self.contents.font.color = disabled_color else self.contents.font.color = normal_color end self.contents.draw_text(4, 32, self.width-8, 32, @second_choice) # カーソル位置も戻す self.index = 0 end #-------------------------------------------------------------------------- # ○ ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(@helptext[self.index]) end end #============================================================================== # □ Window_SmithyItems #------------------------------------------------------------------------------ #  鍛冶屋画面で、付与のための所持アイテムの一覧を表示するウィンドウです。 #============================================================================== class Window_SmithyItems < Window_ShopSell #-------------------------------------------------------------------------- # ○ インクルード #-------------------------------------------------------------------------- include WPXC include XRXS24AX #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :item_max #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super self.x = 32 self.y = 128 + 32 * WINDOW_PARTYWEAPON_ROW self.width = 336 self.height = 32 * (WINDOW_SMITHYITEM_ROW+1) self.contents = nil self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 self.back_opacity = 0 @column_max = 1 self.index = -1 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ [ 再定義 ] #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] @data_room_no = [] for i in 1...$data_items.size if $game_party.item_number(i) > 0 if get_first_element($data_items[i]) > 0 @data.push($data_items[i]) end end end for i in 1...$data_weapons.size # /--- 武器の個別描写を行う for j in 0...$game_party.weapons_table.ysize if $game_party.weapons_table[i, j, WPXC::PROPERTY_ROOM_FILLED] == 1 if get_first_element($data_weapons[i], j) > 0 # 武器をプッシュ @data.push($data_weapons[i]) # 部屋No.を合わせる @data_room_no[@data.size-1] = j end end end # ---/ end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 if get_first_element($data_armors[i]) > 0 @data.push($data_armors[i]) end end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ○ 現在選択中のアイテムの第一属性の取得 #-------------------------------------------------------------------------- def item_first_element return get_first_element(self.item, self.item_room_no) end #-------------------------------------------------------------------------- # ○ アイテムの第一属性の取得 #-------------------------------------------------------------------------- def get_first_element(item, room_no = 0) return 0 if item.nil? or item.id == 0 # アイテム本来の属性セットを取得 if item.is_a?(RPG::Armor) element_set = item.guard_element_set.dup else element_set = item.element_set.dup end # ウェポンプロパティ付与属性を属性セットに追加 if element_set.size == 0 and item.is_a?(RPG::Weapon) for i in [PROPERTY_ELEMENT_GRANT_1st, PROPERTY_ELEMENT_GRANT_2nd, PROPERTY_ELEMENT_GRANT_3rd, PROPERTY_ELEMENT_GRANT_4th] element_id = $game_party.weapons_table[item.id, room_no, i] if element_id > 0 element_set.push(element_id) break end end end # 例外属性 able_id = element_id_enchantable ban_id = element_id_enchant_ban if LIST_ITEM_ONLY_FOR_GRANT return 0 unless element_set.include?(able_id) else return 0 if element_set.include?(ban_id) end element_set.delete(able_id) element_set.delete(ban_id) # 値を返す if element_set.size == 0 return 0 else return element_set[0] end end #-------------------------------------------------------------------------- # ○ 属性ID #-------------------------------------------------------------------------- def element_id_enchantable for i in 0...$data_system.elements.size if $data_system.elements[i] =~ /^付与可能/ return i end end return 0 end def element_id_enchant_ban for i in 0...$data_system.elements.size if $data_system.elements[i] =~ /^付与禁止/ return i end end return 0 end #-------------------------------------------------------------------------- # ○ ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help element_id = self.item_first_element case element_id when 0 @help_window.set_text("付与できる属性がありません") else @help_window.set_text("付与属性: " + $data_system.elements[element_id]) end end end #============================================================================== # □ Scene_Smithy #------------------------------------------------------------------------------ #  鍛冶屋画面の処理を行うクラスです。 #============================================================================== class Scene_Smithy #-------------------------------------------------------------------------- # ○ インクルード #-------------------------------------------------------------------------- include WPXC include XRXS24AX #-------------------------------------------------------------------------- # ○ メイン処理 #-------------------------------------------------------------------------- def main # ヘルプウィンドウを作成 @help_window = Window_Help.new # レフトウィンドウを作成 @leftwindow = Window_SmithyLeft.new # パーティ武器ウィンドウを作成 @partyweapon_window = Window_PartyWeapon.new @partyweapon_window.help_window = @help_window #@partyweapon_window.height = 480 - @partyweapon_window.y @partyweapon_window.active = true @partyweapon_window.index = 0 @partyweapon_window.z = @leftwindow.z + 1 # アイテムウィンドウを作成 @sellect_window = Window_SmithyItems.new @sellect_window.help_window = @help_window @sellect_window.z = @partyweapon_window.z + 1 @sellect_window.active = false @sellect_window.visible = false if GRANT_SLOT_NUMBER == 0 # 武器インフォウィンドウを作成 @weaponinfo_window = Window_WeaponInfo.new @weaponinfo_window.set(nil) @weaponinfo_window.active = false @weaponinfo_window.index = -1 @weaponinfo_window.help_window = @help_window # ゴールドウィンドウを作成 @gold_window = Window_Gold.new @gold_window.x = 480 @gold_window.y = 416 @gold_window.z = @weaponinfo_window.z + 1 # 訪ねウィンドウを作成 @ask_window = Window_CenterAsk.new @ask_window.active = false @ask_window.help_window = @help_window # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @help_window.dispose @gold_window.dispose @partyweapon_window.dispose @sellect_window.dispose @weaponinfo_window.dispose @leftwindow.dispose @ask_window.dispose end #-------------------------------------------------------------------------- # ○ フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @help_window.update @gold_window.update @partyweapon_window.update @sellect_window.update @weaponinfo_window.update @ask_window.update # パーティ武器ウィンドウがアクティブの場合: update_partyweapon を呼ぶ if @partyweapon_window.active update_partyweapon return end # 武器インフォウィンドウがアクティブの場合: update_weaponinfo を呼ぶ if @weaponinfo_window.active update_weaponinfo return end # アイテム選択ウィンドウがアクティブの場合: update_sellect を呼ぶ if @sellect_window.active update_sellect return end # 中央選択ウィンドウがアクティブの場合: update_ask を呼ぶ if @ask_window.active update_ask return end end #-------------------------------------------------------------------------- # ○ フレーム更新 (パーティ武器ウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_partyweapon # カーソル位置が変わった場合 if @partyweapon_window_now_index == nil or (@partyweapon_window_now_index != @partyweapon_window.index) # ステータスウィンドウのアイテムを設定 @weaponinfo_window.set($game_party.actors[@partyweapon_window.index], 0) @partyweapon_window_now_index = @partyweapon_window.index end # B ボタンが押された場合 if Input.trigger?(Input::B) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # マップ画面に切り替え $scene = Scene_Map.new return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 素手の場合 if @weaponinfo_window.item.nil? # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return # 武器Lv.非表示かつ付与属性数0 elsif @weaponinfo_window.item_max == 1 and !SHOW_WEAPON_LEVEL_SYSTEM # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) @weaponinfo_window.active = true @weaponinfo_window.index = SHOW_WEAPON_LEVEL_SYSTEM ? 0 : 1 @partyweapon_window.active = false end end #-------------------------------------------------------------------------- # ○ フレーム更新 (武器インフォウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_weaponinfo # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) @partyweapon_window.active = true @weaponinfo_window.active = false @weaponinfo_window.index = -1 end # C ボタンが押された場合 if Input.trigger?(Input::C) case @weaponinfo_window.index when 0 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # レベルによる強化金額の取得 price = get_price_for_levelup first_choice = "強化実行!!   " + price.to_s + " " + $data_system.words.gold if @weaponinfo_window.levelupable? help1 = "所定の金額を支払い武器の強化を実行します。" else help1 = "武器の経験値が足りません。" end if $game_party.gold < price help1 = "所持金が不足しています。" end help2 = "強化を取りやめます。" @ask_window.set(first_choice,"やめる", help1, help2) unless @weaponinfo_window.levelupable? @ask_window.disable(0) end if $game_party.gold < price @ask_window.disable(0) end @ask_window.active = true @ask_window.visible = true @weaponinfo_window.active = false return else # 属性付与へ。まずはアイテムウィンドウへ移行 if @sellect_window.item_max <= 0 # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ウィンドウの状態を売却モードへ @weaponinfo_window.active = false @sellect_window.index = 0 @sellect_window.active = true @sellect_window.refresh end end end #-------------------------------------------------------------------------- # ○ フレーム更新 (アイテム選択ウィンドウがアクティヴの場合) #-------------------------------------------------------------------------- def update_sellect # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ウィンドウの状態を初期モードへ @weaponinfo_window.active = true @sellect_window.active = false @sellect_window.index = -1 return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 属性が一つ以上あるか、 if @sellect_window.item_first_element == 0 # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 属性を付与確認 price = get_price_for_grant necessary_exp = get_necessary_exp_for_grant if necessary_exp >= 0 exp_str = " " + necessary_exp.to_s + " EXP" else exp_str = " +" + necessary_exp.abs.to_s + " EXP" end unless SHOW_WEAPON_LEVEL_SYSTEM exp_str = "" end first_choice = "属性を付与する!!   " + price.to_s + " " + $data_system.words.gold + exp_str help1 = $data_system.elements[@sellect_window.item_first_element] + " を武器に付与します。" help2 = "付与を取りやめます。" if @sellect_window.item.price == 0 first_choice = "付与不可能。        " help1 = "このアイテムは付与できません。" elsif $game_party.gold < price help1 = "所持金が不足しています。" end @ask_window.set(first_choice,"やめる", help1, help2) if @sellect_window.item.price == 0 @ask_window.disable(0) elsif $game_party.gold < price @ask_window.disable(0) elsif SHOW_WEAPON_LEVEL_SYSTEM and @weaponinfo_window.now_free_exp < necessary_exp @ask_window.disable(0) end @ask_window.active = true @ask_window.visible = true @sellect_window.active = false return end end #-------------------------------------------------------------------------- # ○ フレーム更新 (中央二択ウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_ask # B ボタン or "やめる"で C ボタン が押された場合 if Input.trigger?(Input::B) or (Input.trigger?(Input::C) and @ask_window.index == 1) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ウィンドウ @ask_window.active = false @ask_window.visible = false if @sellect_window.index >= 0 @sellect_window.active = true else @weaponinfo_window.active = true end return end # "実行"で C ボタンが押された場合 if Input.trigger?(Input::C) and @ask_window.index == 0 if @ask_window.disabled?(0) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 index = @partyweapon_window.index $game_system.se_play($data_system.decision_se) if @sellect_window.index >= 0 # 属性付与 price = get_price_for_grant # 属性付与 SE を演奏 Audio.se_stop Audio.se_play("Audio/SE/027-Door04.ogg") # 付与を実行 # IDNo.の取得 case @weaponinfo_window.index when 1 set_id = PROPERTY_ELEMENT_GRANT_1st when 2 set_id = PROPERTY_ELEMENT_GRANT_2nd when 3 set_id = PROPERTY_ELEMENT_GRANT_3rd when 4 set_id = PROPERTY_ELEMENT_GRANT_4th end # 代入 $game_party.actors[index].weapon_property[set_id] = @sellect_window.item_first_element # 付与に使用したアイテムをなくす if @sellect_window.item.is_a?(RPG::Weapon) $game_party.lose_weapon(@sellect_window.item.id, @sellect_window.item_room_no) elsif @sellect_window.item.is_a?(RPG::Armor) $game_party.lose_armor(@sellect_window.item.id, 1) else $game_party.lose_item(@sellect_window.item.id, 1) end # 武器EXPを消費する if SHOW_WEAPON_LEVEL_SYSTEM # 必要武器経験値の取得 necessary_exp = get_necessary_exp_for_grant # 経験値の更新 now_exp = $game_party.actors[index].weapon_property[PROPERTY_EXP_SECOND] * 32768 now_exp+= $game_party.actors[index].weapon_property[PROPERTY_EXP] now_exp-= necessary_exp $game_party.actors[index].weapon_property[PROPERTY_EXP] = now_exp%32768 $game_party.actors[index].weapon_property[PROPERTY_EXP_SECOND] =(now_exp/32768).floor end else # 武器強化 # 武器レベルアップ ME を演奏 Audio.me_stop Audio.me_play("Audio/ME/011-Item02.mid") # 強化を実行 $game_party.actors[index].weapon_property[PROPERTY_LEVEL] += 1 # レベルによる強化金額の取得 price = get_price_for_levelup end # 金額を支払う $game_party.lose_gold(price) # ウィンドウを戻す @weaponinfo_window.active = true @sellect_window.active = false @sellect_window.index = -1 # ウィンドウを消す @ask_window.active = false @ask_window.visible = false # 再描写する @gold_window.refresh @sellect_window.refresh @partyweapon_window.refresh @weaponinfo_window.refresh end end #-------------------------------------------------------------------------- # ○ レベルアップに必要な金額を取得 # レベルによる強化金額の設定はこちら #-------------------------------------------------------------------------- def get_price_for_levelup base_price = @weaponinfo_window.item.price/10 price = (@weaponinfo_window.level ** (3/2.0)).floor * base_price # "強化必要GOLD(±数字)%"属性による変動 percent = XRXS.element_percent($game_party.actors[@partyweapon_window.index].equip_element_set, "強化必要GOLD") if percent != 0 price = price * (100 + percent) / 100 end # 値を返す return price end #-------------------------------------------------------------------------- # ○ 付与に必要なGOLDの取得 #-------------------------------------------------------------------------- def get_price_for_grant price = @weaponinfo_window.item.price # "付与必要GOLD(±数字)%"属性による変動:付与アイテム側 case @sellect_window.item when RPG::Armor percent = XRXS.element_percent(@sellect_window.item.guard_element_set, "付与必要GOLD") else percent = XRXS.element_percent(@sellect_window.item.element_set, "付与必要GOLD") end if percent != 0 price = price * (100 + percent) / 100 end # "付与必要GOLD(±数字)%"属性による変動 percent = XRXS.element_percent($game_party.actors[@partyweapon_window.index].equip_element_set, "付与必要GOLD") if percent != 0 price = price * (100 + percent) / 100 end return price end #-------------------------------------------------------------------------- # ○ 付与に必要なEXPの取得 #-------------------------------------------------------------------------- def get_necessary_exp_for_grant necessary_exp = @sellect_window.item.price/10 # "付与消費EXP(±数字)%"属性による変動:付与アイテム側 case @sellect_window.item when RPG::Armor percent = XRXS.element_percent(@sellect_window.item.guard_element_set, "付与消費EXP") else percent = XRXS.element_percent(@sellect_window.item.element_set, "付与消費EXP") end if percent != 0 necessary_exp = necessary_exp * (100 + percent) / 100 end # "付与消費EXP(±数字)%"属性による変動:武器 percent = XRXS.element_percent($game_party.actors[@partyweapon_window.index].equip_element_set, "付与消費EXP") if percent != 0 necessary_exp = necessary_exp * (100 + percent) / 100 end # 値を返す return necessary_exp end end #============================================================================== # ◇ 外部ライブラリ #============================================================================== class Bitmap #-------------------------------------------------------------------------- # ○ ライン描画 #-------------------------------------------------------------------------- def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color) # 描写距離の計算。大きめに直角時の長さ。 distance = (start_x - end_x).abs + (start_y - end_y).abs # 描写開始 if end_color == start_color for i in 1..distance x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i if width == 1 self.set_pixel(x, y, start_color) else self.fill_rect(x - (width-1)/2.floor, y - (width-1)/2.floor, width, width, start_color) end end else for i in 1..distance x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i r = start_color.red * (distance-i)/distance + end_color.red * i/distance g = start_color.green * (distance-i)/distance + end_color.green * i/distance b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance if width == 1 self.set_pixel(x, y, Color.new(r, g, b, a)) else self.fill_rect(x - (width-1)/2.floor, y - (width-1)/2.floor, width, width, Color.new(r, g, b, a)) end end end end #-------------------------------------------------------------------------- # ○ 多角形の描画(塗りつぶしなし) by 和希 # peaks : 頂点座標の配列 [[x1,y1],[x2,y2],[x3,y3], ... ] # color : 線の色 # width : 線の幅 #-------------------------------------------------------------------------- def draw_polygon(peaks, color, width = 1) # 辺(=頂点)の個数分だけ辺を描く for i in 0 ... (peaks.size - 1) # 頂点同士を線で結ぶ draw_line( peaks[i][0], peaks[i][1], peaks[i+1][0], peaks[i+1][1], color, width ) end # 最後の頂点と最初の頂点を結ぶ draw_line( peaks[peaks.size - 1][0], peaks[peaks.size - 1][1], peaks[0][0], peaks[0][1], color, width ) end end