# ▽△▽ XRXSv20. イージー・スミシー ▽△▽ # # publish 2010/ 3/18 # update - 11/ 1/11a # #============================================================================== # カスタマイズポイント #============================================================================== module XRXSV20 # # # ※XRXSV50.「アイテムマテリアル/トラッシュ」を導入し、 #  カスタマイズポイント MaterializeEquipments が有効(true)になっている場合、 #  このスクリプトの動作は自動的に変化します。 # # # [基本設定] # #用語文字色 WordsColor = Color.new(255, 224, 64, 255) Space = 32 # 鍛冶SE SE_Name = "Sword2" # 鍛冶SEのウェイト[単位:F] One_Wait = 36 # ゴールドウィンドウの不透明度 GoldOpacity = 0 # # # [マテリアルモード専用設定] # # 鍛冶1回でグラインドポイントをいくつプラスする? # SmithGP = 5 # # 鍛冶の基本価格はその武器の価格の何%? # SmithPriceRate = 60 # # +1,+2〜が大きくなるごとに何%ずつ上昇する? # SmithPriceRising = 5 # # [セリフ] # NoWeapon = "素手" S_Start = "いらっしゃい!" S_Next = "さて、どうする?" S_GO1 = "%s だな、" S_GO2 = "%d ゴールドかかるが、鍛えるかい?" S_NoItem = "さすがに手は鍛えられねぇぜ?" S_NoNext1 = "もうこの武器は最高の状態だ、" S_NoNext2 = "鍛える必要はなさそうだぜ。" S_DEquip1 = "%s は強化した後の武器を" S_DEquip2 = "装備できなさそうだぞ?" S_Limit1 = "すまないが、俺の手に余る武器のようだ。" S_Limit2 = "くやしいが他の鍛冶屋をあたってみてくれ。" S_MoneyS = "金が足らんみたいだな。" S_Work = "おし、ちょっと待ってな!" S_WorkEnd = "できたぜ! %sだ!" end #============================================================================== # 鍛冶実行! #============================================================================== class Game_Actor < Game_Battler if (XRXSV50::MaterializeEquipments rescue false) def smith!(equip_index) item = self.equips[equip_index] if item.materialized? material = item.material else material = Material.new(item) self.equip_materials[equip_index] = material end material.gp_plus(XRXSV20::SmithGP) end else def smith!(equip_index) case equip_index when 0 @weapon_id += 1 when 1 @armor1_id += 1 end end end end #============================================================================== # キャッシュ機能 #============================================================================== class Game_Temp def actor_miniface_cache @actor_miniface_cache = [] if @actor_miniface_cache == nil return @actor_miniface_cache end def actor_miniface_cache_clear for cache in self.actor_miniface_cache if cache != nil cache.dispose end end self.actor_miniface_cache.clear end end #============================================================================== # 各種判定 #============================================================================== module XRXSV20 if (XRXSV50::MaterializeEquipments rescue false) def self.get_next_weapon(weapon) return weapon end def self.get_next_price(weapon) return 0 if self.no_next?(weapon) return 0 if weapon == nil gp = (weapon.materialized? ? weapon.material.gp : 0) n = weapon.price * (XRXSV20::SmithPriceRate + gp * XRXSV20::SmithPriceRising) / 100 return n end def self.no_next?(weapon) if weapon if weapon.materialized? material = weapon.material else material = Material.new(weapon) end return material.gp_max? else return true end end else def self.no_next?(weapon) new_weapon = get_next_weapon(weapon) return (new_weapon == nil) end def self.get_next_weapon(weapon) result = nil if weapon != nil new_item = $data_weapons[weapon.id + 1] if new_item != nil and new_item.name.size >= 1 result = new_item end end return result end def self.get_next_price(weapon) result = 0 if weapon != nil new_weapon = self.get_next_weapon(weapon) if new_weapon != nil result = [new_weapon.price - weapon.price / 2, 1].max end end return result end end end #============================================================================== # 鍛冶屋シーン #============================================================================== class Scene_Smith < Scene_Base #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(smith_face_s = nil, smith_limit = nil) @smith_face_s = smith_face_s @smith_limit = smith_limit super() end #-------------------------------------------------------------------------- # 元の画面へ戻る #-------------------------------------------------------------------------- def return_scene $scene = Scene_Map.new end #-------------------------------------------------------------------------- # 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background @back_window = Window_PartyWeaponBack.new @partyweapon_window = Window_PartyWeapons.new(@smith_limit) @message_window = Window_MessageSmith.new @gold_window = Window_Gold.new(-16, 0) @gold_window.opacity = XRXSV20::GoldOpacity show_message(XRXSV20::S_Start) @smith_count = 0 @smith_count2 = 0 end #-------------------------------------------------------------------------- # 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @partyweapon_window.dispose @back_window.dispose @message_window.dispose @gold_window.dispose $game_message.texts.clear $game_message.choice_max = 0 end #-------------------------------------------------------------------------- # フレーム更新 #-------------------------------------------------------------------------- def update super @message_window.update @partyweapon_window.update if @smith_count2 > 0 update_smithing elsif @message_window.active update_input_choice elsif $game_message.busy # elsif @partyweapon_window.active update_partyweapon end end #-------------------------------------------------------------------------- # フレーム更新 - 鍛冶実行中 #-------------------------------------------------------------------------- def update_smithing @smith_count -= 1 if @smith_count <= 0 case @smith_count2 when 4 @smith_count = XRXSV20::One_Wait * 3 @smith_count2 = 5 when 5 Sound.play_shop actor = @partyweapon_window.actor weapon = @partyweapon_window.weapon #new_weapon = @partyweapon_window.new_weapon price = XRXSV20.get_next_price(weapon) actor.smith!(@partyweapon_window.equip_index) $game_party.lose_gold(price) @gold_window.refresh @gold_window.opacity = XRXSV20::GoldOpacity @partyweapon_window.refresh new_weapon = @partyweapon_window.weapon @smith_count = 4 @message_window.terminate_message str1 = sprintf(XRXSV20::S_WorkEnd, new_weapon.name) show_message(str1) @smith_count2 = 6 when 6 if Input.trigger?(Input::C) @message_window.terminate_message @partyweapon_window.active = true show_message(XRXSV20::S_Next) @smith_count2 = 0 end else pitch = [100, 120, 80][@smith_count2 - 1] begin se = RPG::SE.new(XRXSV20::SE_Name, 70, pitch) se.play rescue nil end @smith_count = XRXSV20::One_Wait @smith_count2 += 1 end end end #-------------------------------------------------------------------------- # フレーム更新 - 選択肢 #-------------------------------------------------------------------------- def update_input_choice if Input.trigger?(Input::B) or (Input.trigger?(Input::C) and @message_window.index == 1) Sound.play_cancel @message_window.terminate_message @message_window.active = false @partyweapon_window.active = true show_message(XRXSV20::S_Next) elsif Input.trigger?(Input::C) @message_window.terminate_message @message_window.active = false show_message(XRXSV20::S_Work) # @smith_count = 1 @smith_count2 = 1 end end #-------------------------------------------------------------------------- # フレーム更新 - パーティ武器 #-------------------------------------------------------------------------- def update_partyweapon if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::C) actor = @partyweapon_window.actor weapon = @partyweapon_window.weapon new_weapon = @partyweapon_window.new_weapon price = XRXSV20.get_next_price(weapon) if weapon == nil Sound.play_buzzer @message_window.terminate_message show_message(XRXSV20::S_NoItem) elsif XRXSV20.no_next?(weapon) Sound.play_buzzer @message_window.terminate_message show_message(XRXSV20::S_NoNext1) show_message(XRXSV20::S_NoNext2) elsif @smith_limit != nil and price > @smith_limit Sound.play_buzzer @message_window.terminate_message show_message(XRXSV20::S_Limit1) show_message(XRXSV20::S_Limit2) elsif not actor.equippable?(new_weapon) Sound.play_buzzer @message_window.terminate_message str1 = sprintf(XRXSV20::S_DEquip1, actor.name) show_message(str1) show_message(XRXSV20::S_DEquip2) elsif $game_party.gold < price Sound.play_buzzer @message_window.terminate_message show_message(XRXSV20::S_MoneyS) else Sound.play_decision @message_window.terminate_message @partyweapon_window.active = false str1 = sprintf(XRXSV20::S_GO1, weapon.name) str2 = sprintf(XRXSV20::S_GO2, price) show_message(str1) show_message(str2) show_message_choice("はい","いいえ") end end end #-------------------------------------------------------------------------- # メッセージの表示 #-------------------------------------------------------------------------- def show_message(str) if str.to_s.size >= 1 if @smith_face_s.to_s.size >= 1 $game_message.face_name = @smith_face_s[0, @smith_face_s.size - 2] $game_message.face_index = [(@smith_face_s[@smith_face_s.size-1, 1].to_i - 1), 0].max end $game_message.texts.push(str) end end def show_message_choice(choice1, choice2) n = $game_message.texts.size $game_message.choice_start = n $game_message.texts.push(choice1) $game_message.texts.push(choice2) $game_message.choice_max = 2 end end #============================================================================== # 専用メッセージウィンドウ #============================================================================== class Window_MessageSmith < Window_Message #-------------------------------------------------------------------------- # ● 選択肢の入力処理 #-------------------------------------------------------------------------- def input_choice end end #============================================================================== # パーティ武器背景ウィンドウ #============================================================================== class Window_PartyWeaponBack < Window_Base def initialize super(-16, 80, 576, 208) refresh end def refresh self.contents.clear self.contents.font.color = XRXSV20::WordsColor.dup w = 64 * Graphics.width / 544 x1 = 24 + XRXSV20::Space x2 = x1 + 172 x5 = x2 + 212 self.contents.draw_text(x1, 0, w, WLH, "武器") self.contents.draw_text(x5, 0, w, WLH, Vocab.gold, 2) end end #============================================================================== # パーティ武器ウィンドウ #============================================================================== class Window_PartyWeapons < Window_Selectable #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(smith_limit = nil) @smith_limit = smith_limit super(-16, 108, 576, 176) self.index = 0 self.opacity = 0 self.z += 1 @column_max = 1 refresh end #-------------------------------------------------------------------------- # 取得 #-------------------------------------------------------------------------- def weapon return @data[self.index] end def new_weapon return XRXSV20.get_next_weapon(self.weapon) end def equip_index return @equip_indexes[self.index] end def actor return @actors[self.index] end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh @data = [] @actors = [] @equip_indexes = [] for actor in $game_party.members for i in 0...actor.weapons.size weapon = actor.weapons[i] @data.push(weapon) @actors.push(actor) @equip_indexes.push(i) end end @item_max = @data.size create_contents for i in 0...@data.size draw_item(i) end end #-------------------------------------------------------------------------- # 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) rect.x += 1 + XRXSV20::Space rect.y += 1 rect.width -= 2 rect.height -= 2 weapon = @data[index] actor = @actors[index] new_weapon = XRXSV20.get_next_weapon(weapon) new_price = XRXSV20.get_next_price(weapon) enable = weapon != nil enable &= new_weapon != nil enable &= $game_party.gold >= new_price enable &= @smith_limit >= new_price if @smith_limit != nil enable &= actor.equippable?(new_weapon) # cache = $game_temp.actor_miniface_cache[actor.id] if cache == nil face_rect = Rect.new(2, 22, 92, 44) cache = Bitmap.new(46,22) cache.stretch_blt(cache.rect, actor.face, face_rect) $game_temp.actor_miniface_cache[actor.id] = cache end self.contents.blt(rect.x, rect.y, cache, cache.rect) # rect.x += 48 rect.width -= 48 draw_item_name(weapon, rect.x, rect.y, enable) arrow_s = "→" if weapon == nil value1_s = "" value2_s = "" arrow_s = "" word = XRXSV20::NoWeapon elsif weapon.atk >= weapon.spi value1_s = weapon.atk.to_s value2_s = (new_weapon != nil ? new_weapon.atk : "") word = Vocab.atk else value1_s = weapon.spi.to_s value2_s = (new_weapon != nil ? new_weapon.spi : "") word = Vocab.spi end new_price_s = new_price.to_s if new_price == 0 value2_s = "" new_price_s = "-" arrow_s = "" elsif @smith_limit.to_i < new_price new_price_s = "????" value2_s = "???" end # original_font = self.contents.font.dup rect.x += 200 rect.width = 64 self.contents.font.color = XRXSV20::WordsColor font = self.contents.font font.size = 14 self.contents.draw_text(rect, word) rect.x += 44 rect.width = 32 self.contents.font = original_font self.contents.draw_text(rect, value1_s, 2) rect.x += 40 font = self.contents.font font.size = 14 font.color.alpha = 128 self.contents.draw_text(rect, arrow_s) unless (XRXSV50::MaterializeEquipments rescue false) rect.x += 20 self.contents.draw_text(rect, value2_s) unless (XRXSV50::MaterializeEquipments rescue false) rect.x += 40 rect.width = 80 self.contents.font = original_font self.contents.draw_text(rect, new_price_s, 2) end #-------------------------------------------------------------------------- # 解放 #-------------------------------------------------------------------------- def dispose $game_temp.actor_miniface_cache_clear super end end #============================================================================== # 顔グラフィックビットマップの取得 #============================================================================== class Game_Actor < Game_Battler def face bitmap = Bitmap.new(96, 96) face = Cache.face(self.face_name) rect = Rect.new(0, 0, 96, 96) rect.x = self.face_index % 4 * 96 rect.y = self.face_index / 4 * 96 bitmap.blt(0, 0, face, rect) face.dispose return bitmap end end