Sujet n°5078
Posté par Slash le 21 Sep - 17:27 (2009)
Titre : Les CTs en Bleu dans le menu pokémon
Bon une petite trouvaille que je vient de faire et qui s'avere sympatique ,c'est d'afficher le nom des CTs dans le Menu pokemon en bleu comme dans le vrai jeu.

Pour ce faire, Remplacer le script Window_Command (le 2eme) par ce script :


 
Script

Code:




 #==============================================================================
# ■ Window_Message
# Pokemon Script Project - Krosk 
# 18/07/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Modifications portant sur la gestion de la fenêtre commande
#   pour qu'elle supporte des colonnes, et des changements de taille
#   de police.
# Nécessaire au combat (fenêtre skill et menu)
#
# Introduit:
#   @height : hauteur (largeur) d'une ligne
#   @heightsize : hauteur du texte
#   @column_max
#-----------------------------------------------------------------------------

class Window_Command < Window_Selectable
  attr_reader :item_max
  attr_reader :commands
  
  def initialize(width, commands, size = $fontsize, column = 1, height = nil)
    # コマンドの個数からウィンドウの高さを算出
    # ADD
    if size == $fontsize
      @heightsize = 32
    elsif size == $fontsizebig
      @heightsize = 43
    else
      @heightsize = 32
    end
    if height != nil
      @height = height
    else
      @height = @heightsize
    end
    super(0, 0, width, commands.size * @height + 32, @height)
    @item_max = commands.size
    @commands = commands
    @column_max = column
    self.contents = Bitmap.new(width, @item_max * @height)
    self.contents.font.name = $fontface
    self.contents.font.size = size
    refresh
    self.index = 0
  end

  def draw_item(index, color = normal_color)
    self.contents.font.color = color
    # Modification pour le tracé du texte
    rect = Rect.new(4 + 8 + (index % @column_max) * (width/@column_max), 
      @height * (index/@column_max) + (@height-@heightsize)/2, self.contents.width/@column_max, @heightsize)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
    if @commands[index] == "COUPE" or  @commands[index] == "VOL" or @commands[index] == "SURF" or @commands[index] == "FORCE" or @commands[index] == "FLASH" or @commands[index] == "ECLATE-ROC" or @commands[index] == "CASCADE" or @commands[index] == "PLONGEE"
      self.contents.font.color = Color.new(64,144,208,255)
      self.contents.draw_text(rect, @commands[index])
    end  
  end
  
  def enable_item(index)
    # Nouvelle fonction
      draw_item(index, normal_color)

  end
end





et voila le tour est joué

si vous souhaiter changer la couleur,
modifier cette ligne self.contents.font.color = Color.new(64,144,208,255) en remplacant les 3 premier nombre par ceux de la couleur désiré.

et voici ce que cela donne dans pokémon Noir Nacré par exemple :
Spoiler




PS: Ce script a été tester sous PSP 0.7
EDIT : Programme tester et opérationel sous PSP4G+ (merci de ton test palbolsky)

Posté par Heiwka le 21 Sep - 17:44 (2009)
How Nice, c'est ce genre de petit détails qui font que PSP ressemble de plus en plus aux vrai version, voir mieux, félicitation =3

Posté par Masharu-Law le 21 Sep - 21:00 (2009)
Vraiment intéressant ^^.

Posté par Slash le 21 Sep - 21:09 (2009)
Merci pour vos coms positif heiwka et Makash

Posté par Yondaime59 le 21 Sep - 22:34 (2009)
Très bon script.
On se rapproche beaucoup plus des vrais jeux

Posté par Sphinx le 22 Sep - 07:29 (2009)
^o^ great job ! Si quelqu'un peut m'assurer que c'est compatible 4G+ je pense qu'avec ton accord, je l'intègrerai =)

Posté par Slash le 22 Sep - 10:55 (2009)
Sphinx, palbosky l'a tester sur 4G+ et cela fonctionne parfaitement et tu as mon accord pour l'utiliser autant que tu veut

Posté par Disccat le 10 Oct - 12:15 (2009)
Et pour ceux qui souhaitent rajouté d'autres capacités en bleu (comme TUNNEL), il suffit d'ajouter à la ligne 56:

if @commands[index] == "COUPE" or @commands[index] == "VOL" or @commands[index] == "SURF" or @commands[index] == "FORCE" or @commands[index] == "FLASH" or @commands[index] == "ECLATE-ROC" or @commands[index] == "CASCADE" or @commands[index] == "PLONGEE"

Ceci:

or @commands[index] == "TUNNEL"

À la fin de la ligne, ce qui donne:

if @commands[index] == "COUPE" or @commands[index] == "VOL" or @commands[index] == "SURF" or @commands[index] == "FORCE" or @commands[index] == "FLASH" or @commands[index] == "ECLATE-ROC" or @commands[index] == "CASCADE" or @commands[index] == "PLONGEE" or @commands[index] == "TUNNEL"

Et ainsi de suite pour toutes autres CT, en remplaçant juste "TUNNEL" par "NOM_DE_LA_CT".

Voilà, j'ai juste trouvé utile d'en parler, pour ceux qui ne s'en sortent pas un minimum avec les scripts.

Posté par Sphinx le 10 Oct - 12:29 (2009)
Imbécile heureux je crois qu'une autre forme aurait été plus intéressante et plus maléable :


Ajouter au début du script une constante CS :
Code:
MAPSKILLS = ["COUPE", "VOL", "SURF", "FORCE", "FLASH", "ECLAT-ROC", "CASCADE", "PLONGEE", "TUNNEL"]


et remplacer la condition :
Code:
if @commands[index] == "COUPE" or @commands[index] == "VOL" or @commands[index] == "SURF" or @commands[index] == "FORCE" or
   @commands[index] == "FLASH" or @commands[index] == "ECLATE-ROC" or @commands[index] == "CASCADE" or @commands[index] == "PLONGEE" or
   @commands[index] == "TUNNEL"


par :
Code:
if MAPSKILLS.include?(@commands[index])


Clin d'œil foireux Restera plus qu'à ajouter les noms des attaques dans MAPSKILLS en ajoutant :
Code:
, "NOM DE L'ATTAQUE"

avant le crochet fermant de la ligne MAPSKILLS = [...]

et toute attaque qui se trouvera dans cette liste sera automatiquement coloriée en bleu =)
>> on peut également même penser à intégrer toutes les attaques paramétrées dans une liste au démarrage du jeu ^o^

Posté par Evilmad le 11 Oct - 03:40 (2009)
C'est bien trouvé Sphinx !
On ne s'attendait pas a une solution aussi simple eviter de tout réecrire.