![]() |
|
[XP] AN Equip Script - Wersja do druku +- Ultima Forum (https://forum.ultimateam.pl) +-- Dział: RPG Maker (/Forum-RPG-Maker) +--- Dział: Skrypty (/Forum-Skrypty) +---- Dział: RGSS (/Forum-RGSS) +---- Wątek: [XP] AN Equip Script (/Thread-XP-AN-Equip-Script) |
AN Equip Script - Adrapnikram - 11-03-15 11:11 Krótki opis: Taki prosty skrypt na modyfikacje standardowego menu. Efekt: Spoiler: (Otwórz) ![]() Adrapnikram Skrypt: Spoiler: (Otwórz) #============================================================= # • AN Equip Script [XP] #------------------------------------------------------------------------------ # by Adrapnikram # 1.1 # 15/07/15 #------------------------------------------------------------------------------ =begin Version 1.1 - Fixed problem with disapearing items - Script in one window! =end #Jesli korzystasz ze starej wersji RPG Makera XP to musisz zamienic wszystkie: #"$fontface" na "$defaultfonttype" oraz: #"$fontsize" na "$defaultfontsize" #============================================================= #============================================================================== # ■ Window_EquipLeft #------------------------------------------------------------------------------ # 装備画面で、アクターのパラメータ変化を表示するウィンドウです。 #============================================================================== class Window_EquipLeft < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor : アクター #-------------------------------------------------------------------------- def initialize(actor) super(320, 64, 320, 416) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $defaultfonttype # "Equip" left side (Status) window font self.contents.font.size = $fontsize @actor = actor refresh end #-------------------------------------------------------------------------- # ● リフレッシュ def refresh self.contents.clear draw_actor_graphic(@actor, 152, 55) draw_actor_name(@actor, 4, 0) draw_actor_level(@actor, 4, 32) draw_actor_parameter(@actor, 4, 93, 0) draw_actor_parameter(@actor, 4, 134, 1) draw_actor_parameter(@actor, 4, 175, 2) draw_actor_parameter(@actor, 4, 216, 3) draw_actor_parameter(@actor, 4, 257, 4) draw_actor_parameter(@actor, 4, 298, 5) draw_actor_parameter(@actor, 4, 340, 6) end #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # ● 装備変更後のパラメータ設定9 # new_atk : 装備変更後の攻撃力 # new_pdef : 装備変更後の物理防御 # new_mdef : 装備変更後の魔法防御 #-------------------------------------------------------------------------- def set_new_parameters(new_atk, new_pdef, new_mdef) if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef @new_atk = new_atk @new_pdef = new_pdef @new_mdef = new_mdef refresh end end end #============================================================================== # ■ Window_EquipRight #------------------------------------------------------------------------------ # 装備画面で、アクターが現在装備しているアイテムを表示するウィンドウです。 #============================================================================== class Window_EquipRight < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor : アクター #-------------------------------------------------------------------------- def initialize(actor) super(0, 64, 320, 192) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $defaultfonttype # "Equip" right side (Equiped Items) window font self.contents.font.size = $fontsize @actor = actor refresh self.index = 0 end #-------------------------------------------------------------------------- # ● アイテムの取得 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] @data.push($data_weapons[@actor.weapon_id]) @data.push($data_armors[@actor.armor1_id]) @data.push($data_armors[@actor.armor2_id]) @data.push($data_armors[@actor.armor3_id]) @data.push($data_armors[@actor.armor4_id]) @item_max = @data.size self.contents.font.color = system_color self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon) self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1) self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2) self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3) self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4) draw_item_name(@data[0], 92, 32 * 0) draw_item_name(@data[1], 92, 32 * 1) draw_item_name(@data[2], 92, 32 * 2) draw_item_name(@data[3], 92, 32 * 3) draw_item_name(@data[4], 92, 32 * 4) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end #============================================================================== # ** Window_EquipItem #------------------------------------------------------------------------------ # This window displays choices when opting to change equipment on the # equipment screen. #============================================================================== class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization # actor : actor # equip_type : equip region (0-3) #-------------------------------------------------------------------------- def initialize(actor, equip_type) super(0, 256, 320, 224) @actor = actor @equip_type = equip_type @column_max = 1 refresh self.active = false self.index = -1 end #-------------------------------------------------------------------------- # * Item Acquisition #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # Add equippable weapons if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 and weapon_set.include?(i) @data.push($data_weapons[i]) end end end # Add equippable armor if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 and armor_set.include?(i) if $data_armors[i].kind == @equip_type-1 @data.push($data_armors[i]) end end end end # Add blank page @data.push(nil) # Make a bit map and draw all items @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max-1 draw_item(i) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] x = 4# + index % 2 * (288 + 32) y = index * 32 case item when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end #============================================================================== # ■ Scene_Equip #------------------------------------------------------------------------------ # 装備画面の処理を行うクラスです。 #============================================================================== class Scene_Equip #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor_index : アクターインデックス # equip_index : 装備インデックス #-------------------------------------------------------------------------- def initialize(actor_index = 0, equip_index = 0) @actor_index = actor_index @equip_index = equip_index end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # アクターを取得 @actor = $game_party.actors[@actor_index] # ウィンドウを作成 @help_window = Window_Help.new @left_window = Window_EquipLeft.new(@actor) @right_window = Window_EquipRight.new(@actor) @item_window1 = Window_EquipItem.new(@actor, 0) @item_window2 = Window_EquipItem.new(@actor, 1) @item_window3 = Window_EquipItem.new(@actor, 2) @item_window4 = Window_EquipItem.new(@actor, 3) @item_window5 = Window_EquipItem.new(@actor, 4) # ヘルプウィンドウを関連付け @right_window.help_window = @help_window @item_window1.help_window = @help_window @item_window2.help_window = @help_window @item_window3.help_window = @help_window @item_window4.help_window = @help_window @item_window5.help_window = @help_window # カーソル位置を設定 @right_window.index = @equip_index refresh # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @help_window.dispose @left_window.dispose @right_window.dispose @item_window1.dispose @item_window2.dispose @item_window3.dispose @item_window4.dispose @item_window5.dispose end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh # アイテムウィンドウの可視状態設定 @item_window1.visible = (@right_window.index == 0) @item_window2.visible = (@right_window.index == 1) @item_window3.visible = (@right_window.index == 2) @item_window4.visible = (@right_window.index == 3) @item_window5.visible = (@right_window.index == 4) # 現在装備中のアイテムを取得 item1 = @right_window.item # 現在のアイテムウィンドウを @item_window に設定 case @right_window.index when 0 @item_window = @item_window1 when 1 @item_window = @item_window2 when 2 @item_window = @item_window3 when 3 @item_window = @item_window4 when 4 @item_window = @item_window5 end # ライトウィンドウがアクティブの場合 if @right_window.active # 装備変更後のパラメータを消去 @left_window.set_new_parameters(nil, nil, nil) end # アイテムウィンドウがアクティブの場合 if @item_window.active # 現在選択中のアイテムを取得 item2 = @item_window.item # 装備を変更 last_hp = @actor.hp last_sp = @actor.sp @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id) # 装備変更後のパラメータを取得 new_atk = @actor.atk new_pdef = @actor.pdef new_mdef = @actor.mdef # 装備を戻す @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id) @actor.hp = last_hp @actor.sp = last_sp # レフトウィンドウに描画 @left_window.set_new_parameters(new_atk, new_pdef, new_mdef) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @left_window.update @right_window.update @item_window.update refresh # ライトウィンドウがアクティブの場合: update_right を呼ぶ if @right_window.active update_right return end # アイテムウィンドウがアクティブの場合: update_item を呼ぶ if @item_window.active update_item return end end #-------------------------------------------------------------------------- # ● フレーム更新 (ライトウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_right # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # メニュー画面に切り替え $scene = Scene_Map.new return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 装備固定の場合 if @actor.equip_fix?(@right_window.index) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アイテムウィンドウをアクティブ化 @right_window.active = false @item_window.active = true @item_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_Equip.new(@actor_index, @right_window.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_Equip.new(@actor_index, @right_window.index) return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アイテムウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_item # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ライトウィンドウをアクティブ化 @right_window.active = true @item_window.active = false @item_window.index = -1 return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 装備 SE を演奏 $game_system.se_play($data_system.equip_se) # アイテムウィンドウで現在選択されているデータを取得 item = @item_window.item # 装備を変更 @actor.equip(@right_window.index, item == nil ? 0 : item.id) # ライトウィンドウをアクティブ化 @right_window.active = true @item_window.active = false @item_window.index = -1 # ライトウィンドウ、アイテムウィンドウの内容を再作成 @right_window.refresh @item_window.refresh return end end end Włącz RPG Maker XP, Kliknij F11, pod zakładką main stwórz nową, skopiuj kod. Ta da! Jakby coś komuś nie działało instrukcja w skrypcie na początku RE: Adrapnikram's Equip - Venesard - 11-03-15 11:15 Zedytuj spoiler "Skrypt" bo jest nieczytelny. Właściwie to tylko przestawiłeś okienka Fajno by też było gdybyś wrzucił to do pojedynczego samodzielnego skryptu. Poza tym wygląda ok :-) RE: Adrapnikram's Equip - Adrapnikram - 11-03-15 11:28 Teraz powinno być OK. Skrypt robiłem dla siebie więc nie myślałem o bajerach. Głównie zależało mi na tym aby było widać ile dana broń daje siły i jak zmienia parametry. "Fajno by też było gdybyś wrzucił to do pojedynczego samodzielnego skryptu." Dla mnie to na razie czarna magia jest. RE: AN Equip Script - Adrapnikram - 15-07-15 18:26 Zmiana nazwy skryptu, teraz wystarczy skopiować 1 całość do edytora skryptów pod Main. Usunąłem jeden problem: Niewidoczny co drugi przedmiot |
