Menu
Eclipso logo
Merry Christmas !
19/04/2024 23:00:23

Merci du partage + des pouains - RitoJS

[XP] Script affichage des objets en combats.

Delta

Star
Delta
  • Messages : 2420

[XP] Script affichage des objets en combats.


jeu. 06 juin 2013 - 19h03

Voilà j'utilise ce script d'inventaires avec objets séparés (Objets, armes, armures et objets clés ) qui marche parfaitement. Seulement il est censé en combat n'afficher que les objets consommables, cependant il m'affiche tout les objets même si on ne peut pas utiliser les non consommables. Par conséquent cela surcharge un peu la fenêtre d'objets en combat. Et je vois pas d'où ça vient. De plus sachez que j'ai modifié le script pour le rendre compatible avec mon CMS menu objet. Si quelqu'un peut m'aider à trouver et résoudre l'origine du problème. Merci d'avance. [code]#============================================================================== # Objets trié par onglets #---------------------------------- # Script de Sunabozu # Ce script permet de trier les objets par onglet. # Merci de ne pas distribuer ce script sans ma permission. # Si vous avez un probleme, contactez moi sur RPG Creative. #------------------------------------------------------------------------------ # ● Mode d'emploi : # ● 1) Pour créer un onglet il faudra créer un nouvel élément dans la base de donnée # contenant le symbole $ et portant le nom de l'onglet # Exemple : Créer l'élément "$Objet" ou encore "$Trésor" # ● 2) Ensuite tout les objets, armes ou armures devant s'afficher dans cet # onglet devra avoir l'élément crée de coché # ● 3) Seul les objets consommables seront affichés en combat # ● 4) Si aucun élément n'est coché l'objet sera affiché en combat uniquement #======================================================================== # class Window_Command_Item # affiche les onglets #======================================================================== class Window_Command_Item < Window_Selectable #---------------------------------------------------------------------------------------------------------------- def initialize super(0, 64, 640, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize self.back_opacity = 80 self.opacity = 0 # initialisation des tableaux @commands = [] # nom des onglets @commands_id = [] # id de l'attribut for i in 0...$data_system.elements.size # clonage d'une case du tableau contenant les éléments tableau_element = $data_system.elements[i].clone # si le mot contient la lettre $ if tableau_element.include?("$") # on remplace $ par rien (on supprime) tableau_element["$"] = "" # ajout de l'element sans le $ au tableau @commands[i] = tableau_element # ajout de l'id de l'element dans le tableau @commands_id[i] = i end end # compactage des tableaux (supression espace vide) @commands.compact! @commands_id.compact! @item_max = @commands.size @column_max = @commands.size refresh self.index = 0 end #---------------------------------------------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i) end end #---------------------------------------------------------------------------------------------------------------- def draw_item(index) x = 4 + index * ((640)/@item_max) w = self.width / @column_max - 32 self.contents.draw_text(x, 0, w-4, 32, @commands[index]) end #---------------------------------------------------------------------------------------------------------------- def commands return @commands end #---------------------------------------------------------------------------------------------------------------- def commands_id return @commands_id end end #======================================================================== # class Window_Item # affiche les objets #======================================================================== class Window_Item < Window_Selectable #---------------------------------------------------------------------------------------------------------------- def initialize(id=0) super(0, 128, 640, 352) @column_max = 2 self.back_opacity = 0 self.opacity = 0 self.index = 0 # If in battle, move window to center of screen # and make it semi-transparent if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end refresh(id) end #---------------------------------------------------------------------------------------------------------------- def refresh(id=0) #----------------------------------------------------------- if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 1...$data_items.size if ($game_party.item_number(i) > 0 and $data_items[i].element_set.include?(id)) or ($game_party.item_number(i) > 0 and $game_temp.in_battle) @data.push($data_items[i]) end end unless $game_temp.in_battle for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 and $data_weapons[i].element_set.include?(id) @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 and $data_armors[i].guard_element_set.include?(id) @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 self.back_opacity = 0 self.opacity = 0 for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● é …ç›®ã®æç”» # index : é …ç›®ç•ªå· #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id) self.contents.font.color = normal_color else self.contents.font.color = Color.new(255, 255, 255, 200) end x = 4 + index % 2 * (270 + 25) + 12 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+10, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id) self.contents.draw_text_outline(x + 48, y, 192, 32, item.name, 0) self.contents.draw_text_outline(x + 230, y, 16, 32, ":", 1) self.contents.draw_text_outline(x + 246, y, 24, 32, number.to_s, 2) else self.contents.draw_text_outline2(x + 48, y, 192, 32, item.name, 0) self.contents.draw_text_outline2(x + 230, y, 16, 32, ":", 1) self.contents.draw_text_outline2(x + 246, y, 24, 32, number.to_s, 2) end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end # class end #======================================================================== # class Scene_Item #======================================================================== class Scene_Item #---------------------------------------------------------------------------------------------------------------- def main #----------------------------------------------------------- # Setting up all the images @background = Sprite.new @background.bitmap = RPG::Cache.picture("background") @background.x = 0 @background.y = 0 #================help window pic==================== @help_picture = Sprite.new @help_picture.bitmap = RPG::Cache.picture("helpwindow12") @help_picture.x = 0 @help_picture.y = - 52 #=================Command======================= @command1 = Sprite.new @command1.bitmap = RPG::Cache.picture("cmscommand1") @command1.x = 15 @command1.y = 40 @command1.z = 100 #=====================shadow======================= @commands1 = Sprite.new @commands1.bitmap = RPG::Cache.picture("cmscommandshadow") @commands1.x = 20 @commands1.y = 45 @commands1.z = 1 @commands1.opacity = 155 #===================item window====================== @item_picture = Sprite.new @item_picture.bitmap = RPG::Cache.picture("itemwindow") @item_picture.x = 7 @item_picture.y = 509 @item_picture.z = 11 #=============================================== @item_shadow = Sprite.new @item_shadow.bitmap = RPG::Cache.picture("itemshadow") @item_shadow.x = 12 @item_shadow.y = 514 @item_shadow.z = 1 @item_shadow.opacity = 155 #=============================================== @help_window = Window_Menuhelp.new @command_window = Window_Command_Item.new @item_window = Window_Item.new(@command_window.commands_id[@command_window.index]) @item_window.help_window = @help_window @target_picture = Sprite.new @target_picture.bitmap = RPG::Cache.picture("targetwindow") @target_picture.z = 998 @target_picture.visible = false @target_window = Window_Target.new @target_window.z = 999 @target_window.opacity = 0 @target_window.visible = false @target_window.active = false #----------------------------------------------------------- @command_window.active = true @command_window.visible = true @item_window.active = false @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 @command_window.dispose @target_picture.bitmap.dispose @background.dispose @command1.dispose @commands1.dispose @help_picture.dispose @item_shadow.dispose end #---------------------------------------------------------------------------------------------------------------- def update #----------------------------------------------------------- @item_window.update @target_window.update @command_window.update @help_window.update @command1.update #----------------------------------------------------------- # enter animation if @item_shadow.y > 114 @item_shadow.y -= 50 end if @item_picture.y > 159 @item_picture.y -= 50 end if @item_window.y > 150 @item_window.y -= 50 end if @help_picture.y < - 4 @help_picture.y += 24 end if @help_window.y < - 7 @help_window.y += 35 end if @command1.x < 215 @command1.x += 100 end if @command1.y < 50 @command1.y += 5 end if @commands1.x < 220 @commands1.x += 100 end if @commands1.y < 55 @commands1.y += 5 end if @item_window.active update_item return end #----------------------------------------------------------- if @target_window.active update_target return end #----------------------------------------------------------- if @command_window.active update_command return end end #-------------------------------------------------------------------------- def delay(seconds) for i in 0...(seconds * 1) sleep 0.01 Graphics.update end end #---------------------------------------------------------------------------------------------------------------- def update_item #----------------------------------------------------------- @help_window.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) loop do if @item_shadow.y < 480 @item_shadow.y += 50 end if @item_picture.y < 480 @item_picture.y += 50 end if @item_window.y < 480 @item_window.y += 50 end if @help_picture.y > - 50 @help_picture.y -= 24 end if @help_window.y > - 64 @help_window.y -= 35 end if @command1.x > 15 @command1.x -= 100 end if @command1.y > 40 @command1.y -= 5 end if @commands1.x > 20 @commands1.x -= 100 end if @commands1.y > 45 @commands1.y -= 5 end delay(0.2) if @item_picture.y >= 480 break end end @command_window.active = true @command_window.visible = true @item_window.active = false @item_window.index = 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 $game_party.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_picture.x = (@item_window.index + 1) % 2 * 304 @target_picture.visible = true @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 $game_party.lose_item(@item.id, 1) @item_window.draw_item(@item_window.index) end $scene = Scene_Map.new return end end return end end #---------------------------------------------------------------------------------------------------------------- def update_command if Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT) @item_window.refresh(@command_window.commands_id[@command_window.index]) end #----------------------------------------------------------- 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) $game_system.se_play($data_system.decision_se) @item_window.active = true @command_window.active = false return end end #---------------------------------------------------------------------------------------------------------------- def update_target # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # If unable to use because items ran out unless $game_party.item_can_use?(@item.id) # Remake item window contents @item_window.refresh(@command_window.commands_id[@command_window.index]) end # Erase target window @item_window.active = true @target_window.visible = false @target_picture.visible = false @target_window.active = false return end # If C button was pressed if Input.trigger?(Input::C) # If items are used up if $game_party.item_number(@item.id) == 0 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # If target is all if @target_window.index == -1 # Apply item effects to entire party used = false for i in $game_party.actors used |= i.item_effect(@item) end end # If single target if @target_window.index >= 0 # Apply item use effects to target actor target = $game_party.actors[@target_window.index] used = target.item_effect(@item) end # If an item was used if used # Play item use SE $game_system.se_play(@item.menu_se) # If consumable if @item.consumable # Decrease used items by 1 $game_party.lose_item(@item.id, 1) # Redraw item window item @item_window.draw_item(@item_window.index) end # Remake target window contents @target_window.refresh # If all party members are dead if $game_party.all_dead? # Switch to game over screen $scene = Scene_Gameover.new return end # If common event ID is valid if @item.common_event_id > 0 # Common event call reservation $game_temp.common_event_id = @item.common_event_id # Switch to map screen $scene = Scene_Map.new return end end # If item wasn't used unless used # Play buzzer SE $game_system.se_play($data_system.buzzer_se) end return end end ######### FIN DE CLASSE ######################################## end[/code]


[size=15] Mon site perso et la démo http://deltaproduction.free-h.net/index.html Téléchargez Yggdrasil la quête du dragon de sang: (05/08/2016) 28 Heures de jeu[/size] [center][url=http://www.alexdor.info/?p=jeu&id=878][img]http://delta.comics.pagesperso-orange.fr/barre.gif[/img][/url][/center] [size=15]Nouvelle démo Sentinelles du (20/07/2016) Environ 6H de jeu[/size] [center][url=http://www.alexdor.info/?p=jeu&id=876][img]http://delta.comics.pagesperso-orange.fr/sentinelles.png[/img][/url][/center] [size=15]Nouvelle démo La Chute d'Atalanta du (18/06/2016) Environ 1H30 de jeu[/size] [center][url=http://www.alexdor.info/?p=jeu&id=874][img]http://delta.comics.pagesperso-orange.fr/Atalanta.png[/img][/url][/center]

Estheone

Amateur
Estheone
  • Messages : 64

[XP] Script affichage des objets en combats.


dim. 09 juin 2013 - 17h00

Ligne 117 (classe Window_Item, fonction refresh), remplace la boucle des $data_items par celle-là : [code] for i in 1...$data_items.size next if $game_temp.in_battle and $data_items[i].occasion > 1 if ($game_party.item_number(i) > 0 and ($data_items[i].element_set.include?(id)) or $game_temp.in_battle) @data.push($data_items[i]) end end[/code]

Delta

Star
Delta
  • Messages : 2420

[XP] Script affichage des objets en combats.


dim. 09 juin 2013 - 21h17

Merci beaucoup je t'ajoute des points. EDIT : J'ai du quand même remplacé par : Parce que sinon cela m'affichait tous les objets même ceux que je ne possédais pas en me mettant par exemple superpotion :0 [code]for i in 1...$data_items.size next if $game_temp.in_battle and $data_items[i].occasion > 1 if ($game_party.item_number(i) > 0 and $data_items[i].element_set.include?(id)) or ($game_party.item_number(i) > 0 and $game_temp.in_battle) @data.push($data_items[i]) end end[/code]


[size=15] Mon site perso et la démo http://deltaproduction.free-h.net/index.html Téléchargez Yggdrasil la quête du dragon de sang: (05/08/2016) 28 Heures de jeu[/size] [center][url=http://www.alexdor.info/?p=jeu&id=878][img]http://delta.comics.pagesperso-orange.fr/barre.gif[/img][/url][/center] [size=15]Nouvelle démo Sentinelles du (20/07/2016) Environ 6H de jeu[/size] [center][url=http://www.alexdor.info/?p=jeu&id=876][img]http://delta.comics.pagesperso-orange.fr/sentinelles.png[/img][/url][/center] [size=15]Nouvelle démo La Chute d'Atalanta du (18/06/2016) Environ 1H30 de jeu[/size] [center][url=http://www.alexdor.info/?p=jeu&id=874][img]http://delta.comics.pagesperso-orange.fr/Atalanta.png[/img][/url][/center]