| Roi |
 |
 |
Inscrit le: 13 Aoû 2006, 00:00 Messages: 2417 Localisation: Montréal, QC Logiciel(s) préféré(s): RMXP, VS2008 Point(s) Fort(s): Script Points d'aide: Illimité
Créations :
- Séparation d'inventaire
- Sprite_Text
Voir ses créations
|
Ce script gère l'inventaire de chaque personnage dans le menu - Code: Tout sélectionner
#============================================================================== # ▼ Window_Item #------------------------------------------------------------------------------ # Fenêtre affichant tout les objets possèdés par un personnage #============================================================================== class Window_Item #============================================================================ # ● initialize # actor : le personnage duquel on affiche les objets #---------------------------------------------------------------------------- # Initialise la fenetre #============================================================================ alias inventory_window_item_initialize initialize def initialize(actor) @actor = actor inventory_window_item_initialize end #============================================================================ # ● refresh #---------------------------------------------------------------------------- # Fonction de raffréchissement de la fenetre #============================================================================ def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 1...$data_items.size if @actor.item_number(i) > 0 @data.push($data_items[i]) end end unless $game_temp.in_battle for i in 1...$data_weapons.size if @actor.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if @actor.armor_number(i) > 0 @data.push($data_armors[i]) end end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max draw_item(i) end end end #============================================================================ # ● draw_item # index : l'index de l'objet dans le tableau de la fenetre #---------------------------------------------------------------------------- # Fonction permet d'afficher un objet #============================================================================ def draw_item(index) item = @data[index] case item when RPG::Item number = @actor.item_number(item.id) when RPG::Weapon number = @actor.weapon_number(item.id) when RPG::Armor number = @actor.armor_number(item.id) end if item.is_a?(RPG::Item) and @actor.item_can_use?(item.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) 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 end
#============================================================================== # ▼ Window_EquipItem #------------------------------------------------------------------------------ # Fenêtre affichant l'equipement possédé par un personnage #============================================================================== class Window_EquipItem < Window_Selectable #============================================================================ # ● refresh #---------------------------------------------------------------------------- # Fonction de raffréchissement de la fenetre #============================================================================ def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set for i in 1...$data_weapons.size if @actor.weapon_number(i) > 0 and weapon_set.include?(i) @data.push($data_weapons[i]) end end end if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for i in 1...$data_armors.size if @actor.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 @data.push(nil) @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max-1 draw_item(i) end end
#============================================================================ # ● draw_item # index : l'index de l'objet dans le tableau de la fenetre #---------------------------------------------------------------------------- # Fonction permet d'afficher un objet #============================================================================ def draw_item(index) item = @data[index] x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 case item when RPG::Weapon number = @actor.weapon_number(item.id) when RPG::Armor number = @actor.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 end
#============================================================================== # ▼ Scene_Item #------------------------------------------------------------------------------ # Scene de gestion des objets #============================================================================== class Scene_Item #============================================================================ # ● initialize # actor_index : index du personnage duquel on gere les objets #---------------------------------------------------------------------------- # Initialise la scene #============================================================================ def initialize(actor_index) @actor_index = actor_index end #============================================================================ # ● main #============================================================================ def main @actor = $game_party.actors[@actor_index] @help_window = Window_Help.new @item_window = Window_Item.new(@actor) @item_window.help_window = @help_window @target_window = Window_Target.new @target_window.visible = false @target_window.active = false Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @help_window.dispose @item_window.dispose @target_window.dispose end #============================================================================ # ● update_item #---------------------------------------------------------------------------- # Fonction de mise à jour de la fenetre d'objet #============================================================================ def update_item if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Menu.new(0) return end if Input.trigger?(Input::C) @item = @item_window.item unless @item.is_a?(RPG::Item) $game_system.se_play($data_system.buzzer_se) return end unless @actor.item_can_use?(@item.id) $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) if @item.scope >= 3 @item_window.active = false @target_window.x = (@item_window.index + 1) % 2 * 304 @target_window.visible = true @target_window.active = true if @item.scope == 4 || @item.scope == 6 @target_window.index = -1 else @target_window.index = 0 end else if @item.common_event_id > 0 $game_temp.common_event_id = @item.common_event_id $game_system.se_play(@item.menu_se) if @item.consumable @actor.lose_item(@item.id, 1) @item_window.draw_item(@item_window.index) end $scene = Scene_Map.new return end end return end end #============================================================================ # ● update_target #---------------------------------------------------------------------------- # Fonction de mise à jour de la fenetre de cible #============================================================================ def update_target if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) unless @actor.item_can_use?(@item.id) @item_window.refresh end @item_window.active = true @target_window.visible = false @target_window.active = false return end if Input.trigger?(Input::C) if @actor.item_number(@item.id) == 0 $game_system.se_play($data_system.buzzer_se) return end if @target_window.index == -1 used = false for i in $game_party.actors used |= i.item_effect(@item) end end if @target_window.index >= 0 target = $game_party.actors[@target_window.index] used = target.item_effect(@item) end if used $game_system.se_play(@item.menu_se) if @item.consumable @actor.lose_item(@item.id, 1) @item_window.draw_item(@item_window.index) end @target_window.refresh if $game_party.all_dead? $scene = Scene_Gameover.new return end if @item.common_event_id > 0 $game_temp.common_event_id = @item.common_event_id $scene = Scene_Map.new return end end unless used $game_system.se_play($data_system.buzzer_se) end return end end end
#============================================================================== # ▼ Scene_Menu #------------------------------------------------------------------------------ # Scene du Menu principal #============================================================================== class Scene_Menu #============================================================================ # ● update_command #---------------------------------------------------------------------------- # Fonction de mise à jour de la fenetre de commande #============================================================================ def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if Input.trigger?(Input::C) if $game_party.actors.size == 0 and @command_window.index < 4 $game_system.se_play($data_system.buzzer_se) return end case @command_window.index when 0 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 1 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 if $game_system.save_disabled $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) $scene = Scene_Save.new when 5 $game_system.se_play($data_system.decision_se) $scene = Scene_End.new end return end end #============================================================================ # ● update_status #---------------------------------------------------------------------------- # Fonction de mise à jour de la fenetre des status #============================================================================ def update_status if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @command_window.active = true @status_window.active = false @status_window.index = -1 return end
if Input.trigger?(Input::C)
case @command_window.index when 0 $game_system.se_play($data_system.decision_se) $scene = Scene_Item.new(@status_window.index) when 1 if $game_party.actors[@status_window.index].restriction >= 2 $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) $scene = Scene_Skill.new(@status_window.index) when 2 $game_system.se_play($data_system.decision_se) $scene = Scene_Equip.new(@status_window.index) when 3 $game_system.se_play($data_system.decision_se) $scene = Scene_Status.new(@status_window.index) end return end end end
|
|