Sujet n°1777
Posté par Pαlвσlѕку le 14 Sep - 21:05 (2008)
Titre : Combat à la Platine
[Script] Combat à la Platine
   

Aujourd'hui, je me suis amusé à faire quelque chose, modification de script.

Et devinez quoi, je joue à la ROM (pas de ça ici) de pokémon platine. Et je me suis dis "Pourquoi ne pas faire de même avec PSP"

Cela ne vous dit pas grand chose. Regardez déjà ça :

Exemple


Alors vous trouvez ça comment ?

Alors comme je ne suis pas radin, je vous est fait un tuto pour que vous puissiez en profiter:

Le tuto est là, script + ressources : http://dl.free.fr/pnXhlPOk3

Voilà c'est terminé, j'espère que cela va vous convenir.
Et en faite, vous en pensez quoi ?

Je l'ai fait sur PSP v0.7, donc je sais pas si ça marche pour l'autre version.

Si vous utilisez ce que j'ai fais, alors vous me mettez dans vos crédits, ainsi que Zelda pour ces ressources graphiques.

Newtiteuf: Topic édité et corrigé.

Posté par Krosk le 15 Sep - 06:34 (2008)
Tu devrais agrandire le dummy, il n'est pas aligné avec le bas du battler back. (ou bien descendre le battler back dans le script Bouche extensible)

bon travail sinon Imbécile heureux

Posté par Pαlвσlѕку le 15 Sep - 06:38 (2008)
Merci krosk, et pour le dummy, merci de me le signaler car je l'avais vu mais j'ai oublié de le corriger.

Posté par <€d> le 15 Sep - 07:28 (2008)
Je ne trouve pas dans "Pokmeon_Party_Menu"

 
Code:
 bitmap = RPG::Cache.picture("hpbar.png")
 

Posté par Ink' le 15 Sep - 15:17 (2008)
Oh...

J'ai puisé uniquement quelques informations sur Platine. De ce que j'ai vu, les battlers sont animés sur deux frames, tant pour l'adversaire que pour le joueur. Je pensais que ce script permettait ces animations ^^'.

Sinon, ce changement d'images est plus sympathique. Mais est-ce tout ? Je veux dire, le changement de script apporte quoi ?

Merci sinon pour ce tuto et script Clin d'œil foireux.

Posté par Pαlвσlѕку le 15 Sep - 16:58 (2008)
<€d> Regarde bien car j'ai trouvé la ligne dedans donc elle doir y être aussi.

Je vais corriger le dummy.
Je vais remplacer les icones des changements de statuts pour que ça fasse jolie sur la barre (je risque de mettre toute la soirée la dedans)

Le changement de script (pour te répondre Ink') sert à changer les couleurs de la barre des PV ainsi que celle de la barre des exp. Il sert aussi à repositionner la barre des PV ainsi que la barre d'expérience (son épaisseur a été réduit, la longueur a été augmenté)
Quand vous commencer un combat, on voit le nb de pokémon que possède l'adversaire. Cette barre a été aussi modifier (position)

Voilà pourquoi vous avez besoin de ce morceau de script pour que ça fasse tout ça.
Euh sinon je vais travailler sur les icônes de statut donc le script sera modifier et donc il faudra le reprendre.

En faite, il marche chez vous ?

Posté par <€d> le 15 Sep - 18:25 (2008)
Voila pour moi:

 
Spoiler
 
Code:
 #==============================================================================
# ■ Pokemon_Party_Menu
# Pokemon Script Project - Krosk
# 18/07/07
#-----------------------------------------------------------------------------
# Scène modifiable mais complexe
#-----------------------------------------------------------------------------
# Menu de gestion d'équipe
#-----------------------------------------------------------------------------

module POKEMON_S
  #-----------------------------------------------------------------------------
  # Pokemon_Party_Menu
  #-----------------------------------------------------------------------------
  # Scene
  #   mode: "map", "battle", "give_item"
  #-----------------------------------------------------------------------------
 
 
  class Pokemon_Party_Menu
    attr_accessor :z_level
    attr_accessor :mode
    def initialize(menu_index = 0, z_level = 100, mode = "map", data = nil)
      @menu_index = menu_index
      @z_level = z_level
      @data = data
      @mode = mode # "map", "battle", "hold", "item_use", "item_able", "selection"
      # battle_data: informations diverses du combat en cours
      if $battle_var.in_battle
        @order = $battle_var.battle_order
      else
        @order = [0,1,2,3,4,5]
      end
    end
    
    #-----------------------------------------------------------------------------
    # Déroulement de la scène
    #-----------------------------------------------------------------------------
    def main
      Graphics.freeze
      # Background
      @background = Sprite.new
      @background.bitmap = RPG::Cache.picture("Partyfond.png")
      @background.z = @z_level
      
      # Ensemble de fenêtres individuelles pour chaque Pokémon
      @party_window = []
      for i in 0..($pokemon_party.size-1)
        pokemon = $pokemon_party.actors[@order[i]]
        @party_window.push(Pokemon_Party_Window.new(pokemon, i, @z_level, @mode, @data))
      end
      
      # @on_switch: indicateur d'ordre de permutation
      #   -1: pas d'ordre
      #   sinon: désigne le pokémon à permuter
      @on_switch = -1
      
      @action_window = Window_Command.new(240, ["RETOUR"])
      @action_window.z = @z_level + 10
      @action_window.x = 3
      @action_window.visible = false
      @action_window.active = false
      
      @item_window = Window_Command.new(240, ["DONNER", "PRENDRE", "RETOUR"])
      @item_window.z = @z_level + 11
      @item_window.x = 3
      @item_window.y = 480 - 3 - @item_window.height
      @item_window.visible = false
      @item_window.active = false
      
      @text_window = Window_Base.new(246, 413, 391, 64)
      @text_window.contents = Bitmap.new(602, 64)
      @text_window.z = @z_level + 10
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsize
      @text_window.contents.font.color = @text_window.normal_color
      
      refresh
      
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        if @action_window.active and @on_switch == -1
          if $battle_var.in_battle
            update_action_battle
          else
            update_action
          end
        elsif @item_window.active
          update_item
        else
          update
        end
        if @done == true
          break
        end
      end
      Graphics.freeze
      @background.dispose
      for window in @party_window
        window.dispose
      end
      if @action_window != nil
        @action_window.dispose
      end
      @text_window.dispose
      @item_window.dispose
      @party_window = nil
    end
    
    def update      
      if Input.trigger?(Input::B)
        if @mode == "selection"
          @done = true
          @return_data = -1
          return
        end
        
        if @mode == "hold"
          @done = true
          @return_data = [0, false, 0, false]
          return
        end
        
        if @mode == "item_use" or @mode == "item_able"
          @done = true
          @return_data = [0, false]
          return
        end
        
        if @on_switch == -1 and not($battle_var.in_battle)
          $game_system.se_play($data_system.cancel_se)
          $scene = POKEMON_S::Pokemon_Menu.new(1)
          @done = true
          return
        elsif @on_switch == -1 and $battle_var.in_battle
          if $pokemon_party.actors[@order[0]].dead?
            $game_system.se_play($data_system.buzzer_se)
            return
          else            
            $game_system.se_play($data_system.cancel_se)
            $battle_var.action_id = 0
            # Pas d'action
            @return_data = [0]
            @done = true
            return
          end
        else
          # Annulation de la commande en cours ie @on_switch =/ 1
          $game_system.se_play($data_system.cancel_se)
          @action_window.active = true
          @action_window.visible = true
          @on_switch = -1
          refresh
          return
        end
      end
      
      if Input.repeat?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        @menu_index += (@menu_index == @party_window.size-1) ? 0 : 1
        located_refresh
        return
      end
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        @menu_index -= (@menu_index == 0) ? 0 : 1
        located_refresh
        return
      end
      if Input.trigger?(Input::LEFT)
        $game_system.se_play($data_system.cursor_se)
        @menu_index = 0
        refresh
        return
      end
      if Input.trigger?(Input::RIGHT) and @menu_index == 0 and $pokemon_party.size > 1
        $game_system.se_play($data_system.cursor_se)
        @menu_index = 1
        refresh
        return
      end
      
      if Input.trigger?(Input::C)
        if @mode == "selection"
          $game_system.se_play($data_system.decision_se)
          @done = true
          @return_data = @menu_index
          return
        end
        
        if @mode == "hold"
          $game_system.se_play($data_system.decision_se)
          pokemon = $pokemon_party.actors[@menu_index]
          # Ne porte pas d'item
          if pokemon.item_hold == 0
            pokemon.item_hold = @data
            @return_data = [@data, true, 0, false]
            refresh
            draw_text(pokemon.given_name + " est équippé de " + $item.name(@data) + ".")
            Input.update
            until Input.trigger?(Input::C)
              Input.update
              Graphics.update
            end
          # Porte un item  
          elsif pokemon.item_hold != 0
            replaced_item = pokemon.item_hold
            pokemon.item_hold = @data
            @return_data = [@data, true, replaced_item, true]
            refresh
            if @data == replaced_item
              draw_text(pokemon.given_name + " tient déjà " + $item.name(@data) + "!")
            else
              draw_text($item.name(replaced_item) + " est remplacé par " + $item.name(@data) + ".")
            end
            Input.update
            until Input.trigger?(Input::C)
              Input.update
              Graphics.update
            end
          end
          @done = true
          return
        end
        
        if @mode == "item_use" or @mode == "item_able"
          if $battle_var.in_battle
            pokemon = $pokemon_party.actors[$battle_var.battle_order[@menu_index]]
          else
            pokemon = $pokemon_party.actors[@menu_index]
          end
          if @mode == "item_able" and not($item.able?(@data, pokemon))
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          result = $item.effect_on_pokemon(@data, pokemon, self)
          # result[0] = item utilisé ou non
          # result[1] text
          @return_data = [@data, result[0]]
          refresh
          if result[1] != ""
            draw_text(result[1])
            Input.update
            until Input.trigger?(Input::C)
              Input.update
              Graphics.update
            end
          end
          @done = true
          return
        end
        
        $game_system.se_play($data_system.decision_se)
        if @on_switch == -1
          # Selection d'un Pokémon
          if $battle_var.in_battle
            set_action_battle_window
          else
            set_action_window
          end
          refresh
        else
          # Permutation
          if not($battle_var.in_battle)
            $pokemon_party.switch_party(@on_switch, @menu_index)
          end
          @action_window.active = false
          @action_window.visible = false
          @on_switch = -1
          reset_party_window
          refresh
        end
        return
      end
    end
    
    def update_action
      @action_window.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        @action_window.visible = false
        @action_window.active = false
        text_refresh
      end
      
      if Input.trigger?(Input::C)
        case @action_window.commands[@action_window.index]
        when "RESUME"
          pokemon = $pokemon_party.actors[@menu_index]
          scene = POKEMON_S::Pokemon_Status.new(pokemon, @menu_index, @z_level + 100)
          scene.main
          @menu_index = scene.return_data
          refresh
          Graphics.transition
        when "ORDRE"
          $game_system.se_play($data_system.decision_se)
          # Permutation active
          @on_switch = @menu_index
          @action_window.visible = false
          @action_window.active = false
          refresh
        when "OBJET"
          $game_system.se_play($data_system.decision_se)
          @action_window.visible = false
          @action_window.active = false
          @item_window.active = true
          @item_window.visible = true
          text_refresh
        when "RETOUR"
          $game_system.se_play($data_system.decision_se)
          @action_window.visible = false
          @action_window.active = false
          text_refresh
        else # Attaque
          $game_system.se_play($data_system.decision_se)
          @action_window.visible = false
          @action_window.active = false
          name = @action_window.commands[@action_window.index]
          $game_temp.common_event_id = $skill.map_use($skill.id(name))
          $on_map_call = true
          $scene = Scene_Map.new
          @done = true
        end
        return
      end
    end
    
    def update_item
      @item_window.update
      if Input.trigger?(Input::C)
        case @item_window.index
        # Donner
        when 0
          pokemon = $pokemon_party.actors[@menu_index]
          $game_system.se_play($data_system.decision_se)
          scene = POKEMON_S::Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "hold")
          scene.main
          return_data = scene.return_data
          item = return_data[0]
          hold = return_data[1]
          former_item = pokemon.item_hold
          @item_window.visible = false
          @item_window.active = false
          refresh
          if hold
            $pokemon_party.drop_item(item)
            if former_item == 0
              draw_text(pokemon.given_name + " est équippé de " + $item.name(item) + ".")
            else
              $pokemon_party.add_item(former_item)
              draw_text($item.name(former_item) + " est remplacé par " + $item.name(item) + ".")
            end
            pokemon.item_hold = item
            Input.update
            Graphics.transition
            until Input.trigger?(Input::C)
              Input.update
              Graphics.update
            end
          else
            Graphics.transition
          end
          refresh
          return
        # Prendre
        when 1
          @item_window.visible = false
          @item_window.active = false
          pokemon = $pokemon_party.actors[@menu_index]
          # Pas d'item
          if pokemon.item_hold == 0
            $game_system.se_play($data_system.buzzer_se)
            draw_text(pokemon.given_name + " ne tient rien.")
          else
            $game_system.se_play($data_system.decision_se)
            $pokemon_party.add_item(pokemon.item_hold)
            former_item = pokemon.item_hold
            pokemon.item_hold = 0
            refresh
            draw_text($item.name(former_item) + " récupéré de " + pokemon.given_name + ".")
          end
          Input.update
          until Input.trigger?(Input::C)
            Input.update
            Graphics.update
          end
          refresh
          $game_system.se_play($data_system.decision_se)
        # Retour
        when 2
          $game_system.se_play($data_system.decision_se)
          @item_window.active = false
          @item_window.visible = false
          @action_window.active = true
          @action_window.visible = true
          text_refresh
        end
      end
      
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        @item_window.active = false
        @item_window.visible = false
        @action_window.active = true
        @action_window.visible = true
        text_refresh
      end
    end
    
    def skill_selection(pokemon)
      # Rafraihcisemment fenetre de texte
      @skill_selection == true
      text_refresh
      @skill_selection == false
      # Création liste skill
      list = []
      for skill in pokemon.skills_set
        list.push(skill.name)
      end
      @skill_window = Window_Command.new(240, list)
      @skill_window.y = 480 - @skill_window.height - 3
      @skill_window.x = 3
      @skill_window.z = @z_level + 11
      # Selection
      loop do
        Input.update
        Graphics.update
        @skill_window.update
        if Input.trigger?(Input::C)
          @skill_index = @skill_window.index
          break
        end
        if Input.trigger?(Input::B)
          @skill_window.dispose
          return false
          break
        end
      end
      @skill_window.dispose
      return @skill_index
    end
    
    def refresh
      for window in @party_window
        window.refresh_index(@menu_index)
        window.switch(@on_switch)
        window.refresh
      end
      text_refresh
    end
    
    def text_refresh
      @text_window.contents.clear
      @text_window.width = 391
      @text_window.height = 64
      @text_window.x = 246
      @text_window.y = 480 - @text_window.height - 3
      width = @text_window.width - 32
      height = @text_window.height - 32
      if @on_switch != -1
        @text_window.contents.draw_text(0,0,width,height, "Le mettre où?")
      elsif @action_window.active
        @text_window.contents.draw_text(0,0,width,height, "Que faire avec ce POKéMON?")
      elsif @item_window.active
        @text_window.contents.draw_text(0,0,width,height, "Que faire avec un objet?")
      elsif @mode == "hold"
        @text_window.contents.draw_text(0,0,width,height, "Donner à quel POKéMON?")
      elsif @skill_selection
        @text_window.contents.draw_text(0,0,width,height, "Laquelle restaurer?")
      elsif @mode == "item_use" or @mode == "item_able"
        @text_window.contents.draw_text(0,0,width,height, "Utiliser sur quel POKéMON?")
      else
        @text_window.contents.draw_text(0,0,width,height, "Choisir un POKéMON.")
      end
    end
    
    def draw_text(string = "", string2 = "")
      @text_window.width = 634
      @text_window.x = 3
      @text_window.contents.clear
      if string2 == ""
        @text_window.height = 64
        @text_window.y = 480 - @text_window.height - 3
        width = 602
        height = 32
        @text_window.contents.draw_text(0,0,width,height,string)
      else
        @text_window.height = 96
        @text_window.y = 480 - @text_window.height - 3
        width = 602
        height = 32
        @text_window.contents.draw_text(0,0,width,height,string)
        @text_window.contents.draw_text(0,height,width,height,string2)
      end
    end
    
    def located_refresh
      for window in @party_window
        window.refresh_index(@menu_index)
        window.switch(@on_switch)
      end
      
      for i in @menu_index-1..@menu_index+1
        if @party_window[i] != nil
          @party_window[i].refresh
        end
      end
    end
    
    def hp_refresh
      @party_window[@menu_index].hp_refresh
    end
    
    def item_refresh
      @party_window[@menu_index].refresh
    end
    
    def update_action_battle
      @action_window.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        @action_window.visible = false
        @action_window.active = false
        text_refresh
      end
      if Input.trigger?(Input::C)
        case @action_window.index
        when 0 # Rappel au combat du Poké sélectionné
          if @menu_index == 0 or $pokemon_party.actors[@order[@menu_index]].dead?
            # Le pokémon du premier rang et les morts ne peuvent etre envoyés
            $game_system.se_play($data_system.buzzer_se)
          else #NOTA
            if $battle_var.action_id == 0
              $battle_var.action_id = 2
            end
            # Changement
            @return_data = @menu_index
            @done = true
          end
        when 1 # Résumé
          pokemon = $pokemon_party.actors[@order[@menu_index]]
          scene = POKEMON_S::Pokemon_Status.new(pokemon, @menu_index)
          scene.main
          @menu_index = scene.return_data
          refresh
          Graphics.transition
        when 2 # Annulation
          $game_system.se_play($data_system.cancel_se)
          @action_window.visible = false
          @action_window.active = false
          text_refresh
        end
        return
      end
    end
    
    def return_data
      return @return_data
    end
      
    def set_action_window
      list = []
      for skill in $pokemon_party.actors[@order[@menu_index]].skills_set
        if skill.map_use != 0
          list.push($skill.name(skill.id))
        end
      end
      list += ["RESUME", "ORDRE", "OBJET", "RETOUR"]
      @action_window = Window_Command.new(240, list)
      @action_window.y = 480 - @action_window.height - 3
      @action_window.x = 3
      @action_window.z = @z_level + 10
    end
    
    def set_action_battle_window
      list = ["ECHANGER", "RESUME", "RETOUR"]
      @action_window = Window_Command.new(240, list)
      @action_window.y = 480 - @action_window.height - 3
      @action_window.x = 3
      @action_window.z = @z_level + 10
      if @menu_index == 0 or $pokemon_party.actors[@order[@menu_index]].dead?
        @action_window.disable_item(0)
      end
    end
    
    def reset_party_window # En permutation
      for window in @party_window
        window.dispose
      end
      @party_window = []
      for i in 0..($pokemon_party.size-1)
        pokemon = $pokemon_party.actors[@order[i]]
        @party_window.push(Pokemon_Party_Window.new(pokemon, i, @z_level, @mode, @data))
      end
      refresh
    end
    
  end
 
 
  #-----------------------------------------------------------------------------
  # Pokemon_Party_Window
  #-----------------------------------------------------------------------------
  # Window_Base
  #-----------------------------------------------------------------------------
  # Fenetre individuelle de statut dans la gestion d'équipe
  #-----------------------------------------------------------------------------
  class Pokemon_Party_Window < Window_Base
    def initialize(pokemon, index, z_level = 100, mode = nil, data = nil, menu = -1)
      if index == 0 #Pokémon en tête de rang
        super(14, 68, 254, 167)
      else
        super(275, 17 + (index-1) * 72, 372, 92)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      self.opacity = 0
      self.z = z_level + 8
      @pokemon = pokemon
      @index = index #position de la fenêtre
      @menu_index = menu
      @on_switch = -1
      @mode = mode
      @data = data
      refresh
    end
    
    #fonction qui sert à importer l'information de la position du curseur
    def refresh_index(index)
      @menu_index = index
    end
    
    def switch(value)
      @on_switch = value
    end
    
    def hp_refresh
      if @index == 0
        level = @pokemon.hp / @pokemon.maxhp_basis.to_f
        draw_hp_bar(21, 84, level)
        src_rect = Rect.new(93, 105, 129, 30)
        if @index == @on_switch or (@on_switch != -1 and @menu_index == @index)
          # Cadre vert sélectionné
          bitmap = RPG::Cache.picture("cadretetem.png")
        elsif @menu_index == @index
          # Cadre bleu hover
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadretetedl.png") : RPG::Cache.picture("cadretetel.png")
        else
          # Cadre bleu
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadreteted.png") : RPG::Cache.picture("cadretete.png")
        end
        self.contents.blt(93, 105, bitmap, src_rect, 255)
        draw_text(0, 99, 215, $fs, @pokemon.hp.to_s + " / " + @pokemon.maxhp_basis.to_s, 2)
      else
        level = @pokemon.hp / @pokemon.maxhp_basis.to_f
        draw_hp_bar(160, 9, level, true)
        src_rect = Rect.new(211, 30, 129, 30)
        if @on_switch == @index or (@on_switch != -1 and @menu_index == @index)
          # Cadre vert sélectionné
          bitmap = RPG::Cache.picture("cadrepartym.png")
        elsif @menu_index == @index
          # Cadre bleu hover
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadrepartydl.png") : RPG::Cache.picture("cadrepartyl.png")
        else
          # Cadre bleu
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadrepartyd.png") : RPG::Cache.picture("cadreparty.png")
        end
        self.contents.blt(211, 30, bitmap, src_rect, 255)
        draw_text(0, 24, 330, $fs, @pokemon.hp.to_s + " / " + @pokemon.maxhp_basis.to_s, 2)
      end
    end
    
    def refresh
      self.contents.clear
      if @index == 0
        # fond
        src_rect = Rect.new(0, 0, 222, 135)
        if @index == @on_switch or (@on_switch != -1 and @menu_index == @index)
          # Cadre vert sélectionné
          bitmap = RPG::Cache.picture("cadretetem.png")
        elsif @menu_index == @index
          # Cadre bleu hover
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadretetedl.png") : RPG::Cache.picture("cadretetel.png")
        else
          # Cadre bleu
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadreteted.png") : RPG::Cache.picture("cadretete.png")
        end
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        # Icone
        src_rect = Rect.new(0, 0, 64, 64)
        bitmap = RPG::Cache.battler(@pokemon.icon, 0)
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        # Objet
        if @pokemon.item_hold != 0
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("item_hold.png")
          self.contents.blt(50, 50, bitmap, src_rect, 255)
        end
        # Nom, niveau, genre
        draw_text(69, 18, 150, $fs, @pokemon.given_name)
        draw_text(100, 48, 100, $fs, "N." + @pokemon.level.to_s)
        draw_gender(180, 57, @pokemon.gender)
        if (@pokemon.status > 0 and @pokemon.status < 6) or @pokemon.dead?
          string = "stat" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(15, 108, bitmap, src_rect, 255)
        end
        # HP
        if @mode == "item_able" or ( @mode == "selection" and @data != nil )
          if $item.able?(@data, @pokemon)
            string = "APTE"
          else
            string = "PAS APTE"
          end
          draw_text(0, 98, 215, $fs, string, 2)
        else
          level = @pokemon.hp / @pokemon.maxhp_basis.to_f
          draw_hp_bar(21, 84, level)
          draw_text(0, 99, 215, $fs, @pokemon.hp.to_s + " / " + @pokemon.maxhp_basis.to_s, 2)
        end
      else
        src_rect = Rect.new(0, 0, 340, 60)
        if @on_switch == @index or (@on_switch != -1 and @menu_index == @index)
          # Cadre vert sélectionné
          bitmap = RPG::Cache.picture("cadrepartym.png")
        elsif @menu_index == @index
          # Cadre bleu hover
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadrepartydl.png") : RPG::Cache.picture("cadrepartyl.png")
        else
          # Cadre bleu
          bitmap = @pokemon.dead? ? RPG::Cache.picture("cadrepartyd.png") : RPG::Cache.picture("cadreparty.png")
        end
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        
        src_rect = Rect.new(0, 10, 64, 64)
        bitmap = RPG::Cache.battler(@pokemon.icon, 0)
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        
        if @pokemon.item_hold != 0
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("item_hold.png")
          self.contents.blt(45, 36, bitmap, src_rect, 255)
        end
        
        draw_text(66, -3, 92, $fs, @pokemon.given_name)
        draw_text(72, 24, 100, $fs, "N." + @pokemon.level.to_s)
        
        draw_gender(138, 35, @pokemon.gender)
        if (@pokemon.status > 0 and @pokemon.status < 6)  or @pokemon.dead?
          string = "stat" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(151, 33, bitmap, src_rect, 255)
        end
        
        if @mode == "item_able" or ( @mode == "selection" and @data != nil )
          if $item.able?(@data, @pokemon)
            string = "APTE"
          else
            string = "PAS APTE"
          end
          draw_text(160, 4, 170, 30, string, 1)
        else
          level = @pokemon.hp / @pokemon.maxhp_basis.to_f
          draw_hp_bar(160, 9, level, true)
          draw_text(0, 24, 330, $fs, @pokemon.hp.to_s + " / " + @pokemon.maxhp_basis.to_s, 2)      
        end
      end
    end
    
    def dispose
      super
    end
    
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 45, y + 6, level*144.to_i, 3)
      rect2 = Rect.new(x + 45, y + 9, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 45, y + 6, level*129.to_i, 3)
        rect2 = Rect.new(x + 45, y + 9, level*129.to_i, 6)
      end
      
      if level < 0.1
        color1 = Color.new(170, 70, 70, 255)
        color2 = Color.new(250, 90, 60, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(200, 170, 0, 255)
        color2 = Color.new(250, 225, 50, 255)
      else
        color1 = Color.new(90, 210, 125, 255)
        color2 = Color.new(110, 250, 170, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
    
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)        
      end
    end
  end
end

Posté par Pαlвσlѕку le 15 Sep - 18:51 (2008)
Tu te moque de moi ?? En regardant ce que tu viens de mettre, je l'ai vu, regarde vers la fin et tu verras.

Pour l'animation je vais voir ce que je peux faire, mais je doute que mes compétences soient assez grande pour faire ça.


NEWS: dummy1 corrigé !!

Posté par <€d> le 15 Sep - 19:38 (2008)
Excuse moi :cry: :cry: :cry: :cry:

[Edit]: Il bug quand même:

Posté par Pαlвσlѕку le 15 Sep - 20:49 (2008)
Palbolsky a écrit:
Faite attention dans le script, les lignes se sont déplacées et donc ça risque de buguer si vous ne repassez pas derrière.

As-tu lu ceci ??
Moi je pense que non.
Ton bug vient du faite que "def initialize" est dans la ligne 2421. Donc fait le sauter d'une ligne Clin d'œil foireux


Pour l'animation, je ne sais pas comment faire... Moi ma spécialité c'est de modifier des valeurs (surtout les chiffres), je ne travaille pas sur les animations (et en plus j'aime pas ça.)


NEWS : Script modifier, recopier-le. (plusieurs modification de faite)
NEWS : Ajout de 5 nouvelles images
NEWS : L'image battle_sprite1 a été modifier (un pixel faisait l'incruste^^)

Posté par <€d> le 16 Sep - 07:14 (2008)
ça ne marche pas :(

scripte battle core1
#==============================================================================
# ■ Pokemon_Battle_Core
# Pokemon Script Project - Krosk
# 20/07/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Système de Combat - Squelette général
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé, 8: Toxic
# @confuse (6), @flinch (7)
#-----------------------------------------------------------------------------
# 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
# 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# $battle_var.action_id
#   0 : Phase de Sélection
#   1 : Sélection Item
#   2 : Switch Pokémon
#   4 : Switch Fin de Tour
#-----------------------------------------------------------------------------

module POKEMON_S
  #------------------------------------------------------------ 
  # Pokemon_Battle_Core
  #   noyau possédant les fonctions communes aux combats sauvages/dresseurs
  #------------------------------------------------------------ 
  #------------------------------------------------------------ 
  # Fonctions à définir à l'extérieur
  #   initialize
  #   pre_battle_animation
  #   enemy_skill_decision
  #   end_battle_check
  #   actor_item_use
  #   catch_pokemon
  #   run_able?
  #   end_battle_victory
  #------------------------------------------------------------ 
  class Pokemon_Battle_Core
    attr_accessor :z_level
    attr_accessor :actor_status
    attr_accessor :actor
    attr_accessor :actor_sprite
   
    #------------------------------------------------------------ 
    # ------------------- Squelette Général ---------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # main
    #------------------------------------------------------------
     def main
      # Pré-création des Sprites
      # Fond
      if @battleback_name != ""
      if $game_switches[12] == true # J pour jour
        @battleback_name = $game_map.battleback_name + ".png"
        @ground_name = "ground" + $game_map.battleback_name + ".png"
      elsif $game_switches[16] == true # N pour nuit
        @battleback_name = $game_map.battleback_name + "N" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "N" + ".png"
      elsif $game_switches[18] == true # AC pour matin
        @battleback_name = $game_map.battleback_name + "AC" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "AC" + ".png"
      elsif $game_switches[14] == true # AC pour soir
        @battleback_name = $game_map.battleback_name + "AC" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "AC" + ".png"
      end
      else
        print("Attention, réglez le BattleBack du Tileset.")
        @battleback_name = "battle0.png"
        @ground_name = "groundbattle0.png"
      end
      @background = Sprite.new
      @background.z = @z_level
     
      # Fond du message
      @message_background = Sprite.new
      @message_background.y = 336
      @message_background.z = @z_level + 19
     
      # Sprite de flash
      @flash_sprite = Sprite.new
      @flash_sprite.bitmap = RPG::Cache.picture("black.png")
      @flash_sprite.color = Color.new(255,255,255)
      @flash_sprite.opacity = 0
      @flash_sprite.z = @z_level + 13
     
      # Fenetre de texte
      @text_window = Window_Base.new(4, 340, 632, 136)
      @text_window.opacity = 0
      @text_window.z = @z_level + 20
      @text_window.contents = Bitmap.new(600 + 32, 104 + 32)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsizebig
     
      # Fenetre d'action
      s1 = "ATTAQUE"
      s2 = "SAC"
      s3 = "POKéMON"
      s4 = "FUITE"
     
      @action_window = Window_Command.new(320, [s1, s2, s3, s4], $fontsizebig, 2, 56)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
     
      # Viewport
      battle_viewport = Viewport.new(0, 0, 640, 336)
      battle_viewport.z = @z_level + 15
     
      # Sprites acteurs # Positions par défaut des centres
      @enemy_sprite = RPG::Sprite.new(battle_viewport)
      @enemy_sprite.x = 463
      @enemy_sprite.y = 108
      @enemy_sprite.z = @z_level + 15
      @enemy_ground = RPG::Sprite.new
      @enemy_ground.x = 463
      @enemy_ground.y = 163
      @enemy_ground.z = @z_level + 11
      @actor_sprite = RPG::Sprite.new(battle_viewport)
      @actor_sprite.x = 156
      @actor_sprite.y = 336
      @actor_sprite.z = @z_level + 15
      @actor_ground = RPG::Sprite.new
      @actor_ground.x = 156
      @actor_ground.y = 386
      @actor_ground.z = @z_level + 11
     
      # Création fenêtre de statut
      @actor_status = POKEMON_S::Pokemon_Battle_Status.new(@actor, false, @z_level + 15)
      @enemy_status = POKEMON_S::Pokemon_Battle_Status.new(@enemy, true, @z_level + 15)
      @actor_status.visible = false
      @enemy_status.visible = false
      @enemy_caught = false
     
      @actor_party_status = POKEMON_S::Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10)
      @enemy_party_status = POKEMON_S::Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10)
      @actor_party_status.visible = false
      @enemy_party_status.visible = false
      # note: .active = true activera les animations liées à ces fenêtres
      @actor_party_status.active = false
      @enemy_party_status.active = false
     
      # Lancement des animations
      pre_battle_transition
      pre_battle_animation
     
      # Effets pré-premier round
      post_round_effect
     
     
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
     
      # Fin de scene
      Graphics.freeze
      @background.dispose
      @message_background.dispose
      @flash_sprite.dispose
      @text_window.dispose
      @action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
      end
      if @ball_sprite != nil
        @ball_sprite.dispose
      end
      @enemy_sprite.dispose
      @actor_sprite.dispose
      @actor_status.dispose
      @enemy_status.dispose
      @actor_party_status.dispose
      @enemy_party_status.dispose
    end
   
    #------------------------------------------------------------ 
    # Déroulement
    #------------------------------------------------------------
    def update
      case @phase
      when 0 # Phase d'initialisation
        @phase = 1
       
        # Création fenêtre de skill
        list = []
        for skill in @actor.skills_set
          list.push(skill.name)
        end
        while list.size < 4
          list.push("  ---")
        end
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
       
        # Compétences bloquées
        for i in 0..@actor.skills_set.length-1
          skill = @actor.skills_set
          if not(skill.usable?)
            @skills_window.disable_item(i)
          end
        end
       
        # Curseur sur le dernier choix
        if $battle_var.last_index == nil
          $battle_var.last_index = 0
          @skills_window.index = 0
        else
          @skills_window.index = $battle_var.last_index
        end
       
        # Création fenêtre description de skill
        @skill_descr = Window_Base.new(512, 336, 128, 144)
        @skill_descr.contents = Bitmap.new(96, 144)
        @skill_descr.contents.font.name = $fontface
        @skill_descr.contents.font.size = $fontsizebig
        @skill_descr.visible = false
        skill_descr_refresh
       
        # Activation fenêtre
        @actor_status.visible = true
        @enemy_status.visible = true
               
        # ------- ---------- --------- --------
        #    Saut de phase de sélection actor
        # ------- ---------- --------- --------
        jumped = phase_jump
       
        # Activations fenêtres
        if not(jumped)
          draw_text("Que doit faire", @actor.given_name + "?")
          @action_window.visible = true
          @action_window.active= true
          $battle_var.action_id = 0
        end
       
      when 1 # Phase d'attente d'action
        @action_window.update
        @skills_window.update
        if @skills_window.active and input
          skill_descr_refresh
        end
       
        if Input.trigger?(Input::C) and @action_window.active
          case @action_window.index
          when 0 # Selection ATTAQUE
            $game_system.se_play($data_system.decision_se)
            @action_window.active = false
            @action_window.visible = false
           
            # ------- ---------- --------- --------
            #   Reset compteur de fuite
            # ------- ---------- --------- --------
            $battle_var.run_count = 0
           
            # ------- ---------- --------- --------
            #    Saut de phase de sélection attaque
            # ------- ---------- --------- --------
            if attack_selection_jump
              @actor_action = 1
              @phase = 2
              return
            end
           
            # ------- ---------- --------- --------
            #      Vérification PP // Lutte
            # ------- ---------- --------- --------
            total = 0
            for skill in @actor.skills_set
              if skill.usable?
                total += skill.pp
              end
            end
            if total == 0
              @actor_action = 1
              @phase = 2
              @actor_skill = Skill.new(165) # Lutte
              return
            end
           
            @skills_window.active = true
            @skills_window.visible = true
            @skill_descr.visible = true
            @text_window.contents.clear
          when 1 # Selection ITEM
            $game_system.se_play($data_system.decision_se)
            scene = POKEMON_S::Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "battle")
            scene.main
            return_data = scene.return_data
            @phase = 0
            if $battle_var.action_id == 1
              @phase = 2
              @actor_action = 3
              @item_id = return_data
            end
          when 2 # Selection PKMN
            # ------- ---------- --------- --------
            #    Vérification switch permis
            # ------- ---------- --------- --------
            if not(switch_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            $game_system.se_play($data_system.decision_se)
            $battle_var.window_index = @action_window.index
            scene = POKEMON_S::Pokemon_Party_Menu.new(0, @z_level + 100)
            scene.main
            return_data = scene.return_data
            @phase = 0
            # Enregistrement données Switch de Pokémon
            if $battle_var.action_id == 2
              @phase = 2
              @actor_action = 2
              @switch_id = return_data
            end
          when 3 # sélection FUITE
            # ------- ---------- --------- --------
            #    Vérification fuite permise
            # ------- ---------- --------- --------
            @action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              return
            end
            @action_window.visible = true
           
            @action_window.active = false
            @action_window.visible = false
            @text_window.contents.clear
            run
          end
          return
        end
       
        if Input.trigger?(Input::C) and @skills_window.active
          index = @skills_window.index
          skill = @actor.skills_set[index]
          if skill != nil and skill.usable?
            @actor_action = 1
            @phase = 2
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @actor_skill = @actor.skills_set[index]
            $battle_var.last_index = @skills_window.index
          else
            $game_system.se_play($data_system.buzzer_se)
          end
        end
       
        if Input.trigger?(Input::B) and @skills_window.active
          $game_system.se_play($data_system.decision_se)
          @skills_window.active = false
          @skills_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @phase = 0
        end
       
       
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
       
        enemy_skill_decision
       
        statistic_refresh
        turn_order
        phase2
        phase3
       
        # Phase de switch de fin de tour
        $battle_var.action_id = 4
        end_battle_check
       
        if $battle_var.battle_end?
          return
        end
       
        # Fin de tour / Post_Round effects
        post_round_effect
        @actor_status.refresh
        @enemy_status.refresh
       
        if $battle_var.battle_end?
          return
        end
       
        # Phase de switch post_round
        $battle_var.action_id = 6
        end_battle_check
        @phase = 0
       
        if $battle_var.battle_end?
          return
        end
       
        # Incrémentation nombre de tours
        $battle_var.round += 1
       
      end
      return
    end
   
    #------------------------------------------------------------ 
    # Vérifications préliminaires et ordre d'action
    #------------------------------------------------------------
    def statistic_refresh
      @actor.statistic_refresh
      @enemy.statistic_refresh
    end
   
    #Recherche de priorité
    def turn_order
      # Comparaison des priorités
      if @actor_skill == nil or @enemy_skill == nil
        @strike_first = true
        return
      end
     
      if @actor_action != 1 # Attaque
        @strike_first = false
        return
      end 
     
      if @actor_skill.priority > @enemy_skill.priority
        @strike_first = true
      elsif @actor_skill.priority < @enemy_skill.priority
        @strike_first = false
      else
       
      # En cas d'égalité
        if @enemy.spd > @actor.spd
          @strike_first = false
        elsif @enemy.spd < @actor.spd
          @strike_first = true
        else
          @strike_first = rand(2)>0 ? true : false
        end
      end
    end
   
    #------------------------------------------------------------ 
    # Rounds
    #------------------------------------------------------------           
    def phase2 # Pré_Rounds
      @action_window.visible = false
      @action_window.active = false
      @actor_status.visible = true
      @enemy_status.visible = true
      @actor_status.refresh
      @enemy_status.refresh
      draw_text("","")
     
      # Préround 1: Fuite
      if @actor_action == 4
        run
      end
      if @enemy_action == 4
        enemy_run
      end
     
      # Préround 2: Item
      if @actor_action == 3
        actor_item_use
      end
      if @enemy_action == 3
        enemy_item_use
      end
     
      # Préround 3: Switch Pokémon
      if @actor_action == 2
        actor_pokemon_switch
      end
      if @enemy_action == 2
        enemy_pokemon_switch
      end
     
      @actor_status.refresh
      @enemy_status.refresh
    end
       
    # Round: Attaques
    def phase3
      if @strike_first
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
     
      if not(@strike_first)
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
    end
   
    #------------------------------------------------------------ 
    # Fonctions auxiliaires
    #------------------------------------------------------------    
    def switch(list, id1, id2)
      if id1 <= id2
        list.insert(id1, list[id2])
        list.delete_at(id2+1)
        list.insert(id2 + 1, list[id1+1])
        list.delete_at(id1+1)
        return list
      else
        switch(list, id2, id1)
      end
    end
   
    # Fonction auxiliaire
    def input
      if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
        Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
        Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
        return true
      end
      return false
    end
   
    def draw_text(line1 = "", line2 = "")
      if line1.type == Array
        if line1[1] != nil
          draw_text(line1[0], line1[1])
        else
          draw_text(line1[0])
        end
      else
        Graphics.freeze
        @text_window.contents.clear
        @text_window.draw_text(12, 0, 460, 50, line1)
        @text_window.draw_text(12, 55, 460, 50, line2)
        Graphics.transition(5)
      end
    end
   
    def draw_text_valid(line1 = "", line2 = "")
      draw_text(line1, line2)
      loop do
        Graphics.update
        Input.update
        if Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
    def wait(frame)
      i = 0
      loop do
        i += 1
        Graphics.update
        if i >= frame
          break
        end
      end
    end
   
    def wait_hit
      loop do
        Graphics.update
        Input.update
        if input
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ----------------------- Interface -------------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # Fenêtre de description
    #------------------------------------------------------------       
    def skill_descr_refresh
      @skill_descr.contents.clear
      index = @skills_window.index
      skill = @actor.skills_set[index]
      if skill != nil
        string = skill.pp.to_s + "/" + skill.ppmax.to_s
        type = skill.type
      else
        string = "---"
        type = 0
      end
      normal_color = Color.new(60,60,60)
      @skill_descr.contents.font.color = normal_color
      #@skill_descr.contents.draw_text(0,6,60,39, "PP:")
      @skill_descr.contents.draw_text(0,6,96,39, string, 1)
      #@skill_descr.contents.draw_text(0,60,140,39, "TP:")
      draw_type(0, 60, type)
    end 
     
    def draw_type(x, y, type)
      src_rect = Rect.new(0, 0, 96, 42)
      bitmap = RPG::Cache.picture("T" + type.to_s + ".png")
      @skill_descr.contents.blt(x, y, bitmap, src_rect, 255)
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ------------------ Fonctions de combat --------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------   
    # Fonctions spéciales - programmation des attaques
    #------------------------------------------------------------
    def heal(user, user_sprite, user_status, bonus)
      value = bonus.abs
      for i in 1..value
        if bonus >= 0
          user.add_hp(1)
        else
          user.remove_hp(1)
        end
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.hp >= user.max_hp or user.dead?
          break
        end
      end
    end
   
    def self_damage(user, user_sprite, user_status, damage)
      if damage > 0
        Audio.se_play("Audio/SE/Hit.wav", 100)
        blink(user_sprite)
      end
      for i in 1..damage
        user.remove_hp(1)
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.dead?
          break
        end
      end
    end
   
    #------------------------------------------------------------   
    # Fonctions communes - Programmation des attaques
    #------------------------------------------------------------
    # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé
    # 6: Confus, 7: Flinch, 8: Toxic
    #------------------------------------------------------------
    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre
    #------------------------------------------------------------
   
    # Fonction à appeler en cas d'effets sur le statut
    def status_check(target, status, forcing = false)
      # Immunités
      # Poison
      if (target.type_poison? or target.type_steel?) and
          (status == 1 or status == 8)
        draw_text(target.given_name + " est insensible", "au poison!")
        wait(40)
        return
      end
      # Freeze
      if status == 5 and target.type_ice?
        draw_text(target.given_name + " est insensible", "au gel!")
        wait(40)
        return
      end
      # Burn
      if status == 3 and target.type_fire?
        draw_text(target.given_name + " est insensible", "aux brûlures!")
        wait(40)
        return
      end
      # Soleil
      if status == 5 and $battle_var.sunny?
        draw_text("Le soleil empêche " + target.given_name, "de geler!")
        wait(40)
        return
      end
      # Lumber / Echauffement (ab)
      if status == 2 and target.ability == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.")
        wait(40)
        return
      end
      # Ignifu-voile / Water Veil (ab)
      if status == 3 and target.ability == 41
        draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.")
        wait(40)
        return
      end
      # Insomnia (ab) // Vital Spirit / Esprit Vital (ab)
      if status == 4 and (target.ability == 15 or target.ability == 72)
        draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.")
        wait(40)
        return
      end
      # Vaccin / Immunity (ab)
      if [1, 8].include?(status) and target.ability == 17
        draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.")
        wait(40)
        return
      end
      # Armumagma / Magma Armor (ab)
      if target.ability == 40 and status == 5
        draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.")
        wait(40)
        return
      end
      # Tempo Perso / Own Tempo (ab)
      if status == 6 and target.ability == 20
        draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.")
        wait(40)
        return
      end
      # Attention / Inner focus (ab)
      if target.ability == 39 and status == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.")
        wait(40)
        return
      end
      # Synchronize (ab)
      if target.ability == 28 and [1, 2, 3, 8].include?(status)
        target.ability_token = status
        if status == 8
          target.ability_token = 1
        end
      end
     
      if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status))
        status_string(target, -target.status) # animation
      elsif status == 6 and target.confused? and not(forcing)
        status_string(target, -6)
      elsif target.effect_list.include?(0x7C) and
          status != 7 # Rune Protect/Safeguard
        draw_text(target.given_name + "est", "protégé des altérations!")
        wait(40)
      elsif target.effect_list.include?(0x9F) and
          status == 4 # Uproar
        draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!")
        wait(40)
      else
        case status
        when 1
          target.status_poison(forcing)
        when 2
          target.status_paralyze(forcing)
        when 3
          target.status_burn(forcing)
        when 4
          target.status_sleep(forcing)
        when 5
          target.status_frozen(forcing)
        when 6
          target.status_confuse
        when 7
          target.status_flinch
        when 8
          target.status_toxic(forcing)
        end
        status_string(target, status)
      end
    end
   
    def accuracy_stage(user, target)
      stage = user.acc_stage - target.eva_stage
      stage = stage < -6 ? -6 : stage > 6 ? 6 : stage
     
      # --------------- ---------------- --------------
      #           Programmation des attaques
      # --------------- ---------------- --------------
      # Clairvoyayance / Foresight
      if target.effect_list.include?(0x71)
        stage = user.acc_stage
      end
      # --------------- ---------------- --------------
      # --------------- ---------------- --------------
     
      case stage
      when -6
        return 33.0/100
      when -5
        return 36.0/100
      when -4
        return 43.0/100
      when -3
        return 50.0/100
      when -2
        return 60.0/100
      when -1
        return 75.0/100
      when 0
        return 1
      when 1
        return 133.0/100
      when 2
        return 166.0/100
      when 3
        return 2
      when 4
        return 250.0/100
      when 5
        return 133.0/50
      when 6
        return 3
      end
    end
   
    #------------------------------------------------------------ 
    # Post_round
    #------------------------------------------------------------        
    def post_round_effect
      # --------- -------------- --------------------
      # Fin des effets "at the end of a round"
      # --------- -------------- --------------------     
      # Suppression état appeuré (ne dure que un tour)
      @actor.flinch_check
      @enemy.flinch_check
      # Suppression état autre
      if @actor.dead?
        @actor.cure
        @actor.cure_state
      end
      if @enemy.dead?
        @enemy.cure
        @enemy.cure_state
      end
     
      # --------- -------------- --------------------
      # Programmation des attaques en Post-round
      # --------- -------------- --------------------
      #      Cycle commun 0 - Souhait et Météo
      # --------- -------------- --------------------
      post_round_cycle0
     
      # --------- -------------- --------------------
      #         Cycle individuel 1
      #      Programmation des attaques
      #           Effets du statut
      # --------- -------------- --------------------     
      if @strike_first
        post_round_cycle_1(@actor, @enemy)
        post_round_cycle_1(@enemy, @actor)
      else
        post_round_cycle_1(@enemy, @actor)
        post_round_cycle_1(@actor, @enemy)
      end
     
      # --------- -------------- --------------------
      #                Cycle 2
      #         Programmation des attaques
      #            Dommages finaux
      # --------- -------------- --------------------
      if @strike_first
        post_round_cycle_2(@actor, @enemy)
        post_round_cycle_2(@enemy, @actor)
      else
        post_round_cycle_2(@enemy, @actor)
        post_round_cycle_2(@actor, @enemy)
      end
     
      @actor.skill_effect_clean
      @enemy.skill_effect_clean
     
      faint_check
     
      # Round suivant
      if $battle_var.round == nil
        $battle_var.round = 0
      end
      $battle_var.round += 1
    end
   
   
    # --------- -------------- --------------------
    #     Cycle commun 0 - Météo et Souhait
    # --------- -------------- --------------------
    def post_round_cycle0
      if @strike_first
        list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]]
      else
        list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]]
      end
     
      # Suppression du contrôle pour un pokémon mort
      for array in list
        if array[0].dead?
          list.delete(array)
        end
      end
     
      for array in list
        actor = array[0]
        actor.skill_effect_end_turn
        for effect in actor.effect_list
          case effect
          when 0x56 # Entrave / Disable
            index = actor.effect_list.index(0x56)
            if actor.effect[index][1] == 0
              skill_id = actor.effect[index][2]
              skill = actor.skills_set[skill_id]
              skill.enable
              draw_text(skill.name + " de "+ actor.given_name, "est rétablie!")
              wait(40)
            end
          when 0x5A # Encore
            index = actor.effect_list.index(0x5A)
            if actor.skills_set[index].pp == 0
              actor.effect[index][1] = 0 # Fin de l'effet
            end
          when 0x75 # Rollout
            index = actor.effect_list.index(0x75)
            ## N'a pas fait de dégât ce tour ci >> Supprimé
            #if actor.effect[index][2] != actor.effect[index][1]
            #  actor.effect.delete_at(index)
            #end
            if actor.asleep? or actor.frozen?
              actor.effect.delete_at(index)
            end
          when 0x77 # Taillade / Fury Cutter
            index = actor.effect_list.index(0x77)
            # N'a pas fait de dégât ce tour ci >> Supprimé
            if actor.effect[index][2] != actor.effect[index][1]
              actor.effect.delete_at(index)
            end
          end
        end
      end
     
      weather = $battle_var.weather[0]
      $battle_var.weather[1] -= 1
      count = $battle_var.weather[1]
     
      # Souhait -- Programmation des attaques
      for array in list
        target = array[0]
        target_sprite = array[1]
        target_status = array[2]
        if target.effect_list.include?(0xB3)
          bonus = target.hp / 2
          draw_text("Un souhait est réalisé.")
          heal(target, target_sprite, target_status, bonus)
          wait(40)
        end
      end
     
      # Pluie
      if $battle_var.rain? and count != 0
        draw_text("La pluie continue de", "tomber.")
        animation = $data_animations[379]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.rain? and count == 0
        draw_text("La pluie s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Ensoleillé
      if $battle_var.sunny? and count != 0
        draw_text("Les rayons du soleil","tapent fort.")
        animation = $data_animations[378]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.sunny? and count == 0
        draw_text("Le soleil est parti.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Tempete de sable
      if $battle_var.sandstorm? and count != 0
        draw_text("La tempête de sable souffle.")
        animation = $data_animations[380]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégats
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ground? or target.type_rock? or target.type_steel?
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or
              target.ability == 8
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.sandstorm? and count == 0
        draw_text("La tempête de sable s'est arretée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Grêle
      if $battle_var.hail? and count > 0
        draw_text("Il grêle...")
        animation = $data_animations[381]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégâts
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ice? or
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3)
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.hail? and count == 0
        draw_text("La grêle s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
    end
   
   
   
   
    # --------- -------------- --------------------
    #              Cycle individuel 1
    # --------- -------------- --------------------
    def post_round_cycle_1(actor, enemy)
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un Pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #    Programmation des attaques et des capa
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0xB5 # Ingrain / Racines
          bonus = actor.max_hp / 16
          draw_text(actor.given_name + " puise", "de l'énergie dans la terre.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      end
     
      case actor.ability
      when 44 # Cuvette / Rain Dish (ab)
        if $battle_var.rain?
          bonus = actor.max_hp / 16
          draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.")
          wait(40)
        end
      when 54 # Absentéisme / Truant (ab)
        if actor.ability_token == nil
          actor.ability_token = true
        end
        if actor.ability_token == true
          actor.ability_token = false
        elsif actor.ability_token == false
          actor.ability_token = true
        end
      when 61 # Mue / Shed skin (ab)
        if actor.status != 0 and rand(100) < 30
          actor.cure
          draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.")
          wait(40)
        end
      end
     
      for effect in enemy.effect_list
        case effect
        when 0x54 # Leech Seed / Vampigraine
          malus = actor.max_hp / 8
          draw_text("L'énergie de " + actor.given_name,"est drainée!")
          heal(actor, actor_sprite, actor_status, -malus)
          heal(enemy, enemy_sprite, enemy_status, malus)
          wait(40)
        when 0x2A # Multi_turn attack
          damage = actor.max_hp / 16
          draw_text(actor.given_name, "est piégé!")
          self_damage(actor, actor_sprite, actor_status, damage)
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #          Inspection des statuts
      # --------- -------------- --------------------
      if actor.status == 1 # Poison
        damage = actor.poison_effect
        draw_text(actor.given_name + " souffre", "du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 8 # Toxic
        damage = actor.toxic_effect
        draw_text(actor.given_name + " souffre", "gravement du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 3 #Burn
        damage = actor.burn_effect
        draw_text(actor.given_name + " souffre", "de ses brûlures.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
     
      actor.confuse_decrement
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------     
      for effect in actor.effect_list
        case effect
        when 0x6B # Nightmare / Cauchemar
          if actor.asleep?
            damage = actor.max_hp / 4
            draw_text(actor.given_name + " fait", "un chauchemar!")
            heal(actor, actor_sprite, actor_status, -damage)
            wait(20)
          else
            index = actor.effect_list.index(0x6B)
            actor.effect.delete_at(index)
          end
        when 0x6D # Curse
          damage = actor.max_hp / 4
          draw_text(actor.given_name + " est", "maudit!")
          heal(actor, actor_sprite, actor_status, -damage)
          wait(20)
        when 0x9F # Uproar / Brouhaha
          if actor.asleep?
            actor.cure
            draw_text(actor.given_name + " se réveille", "à cause du brouhaha!")
            wait(40)
          end
          if actor.frozen? #Fin de l'effet
            index = actor.effect_list.index(0x9F)
            actor.effect.delete_at(index)
          end
        when 0xAF # Taunt / Provoc
          index = actor.effect_list.index(0xAF)
          for skill in actor.skills_set
            if skill.power == 0 and actor.effect[index][1] > 0
              draw_text(skill.name + " est bloqué!")
              skill.disable
              wait(40)
            elsif actor.effect[index][1] == 0
              draw_text(skill.name + " est rétablit.")
              skill.enable
              wait(40)
            end
          end
        when 0xBB # Yawn / Baillement
          if actor.status == 0
            status_check(actor, 4)
            actor_status.refresh
          end
        end
      end
     
      if actor.dead?
        return
      end
      # --------- -------------- --------------------
      #                  Berry check
      # --------- -------------- -------------------- 
      if $item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp
        draw_text(actor.given_name + " récupère un peu", "de vie avec " + $item.name(actor.item_hold) + ".")
        bonus = actor.max_hp / 16
        if bonus == 0
          bonus = 1
        end
        heal(actor, actor_sprite, actor_status, bonus)
        wait(40)
      end
    end
     
    # --------- -------------- --------------------
    #              Cycle individuel 2
    # --------- -------------- --------------------    
    def post_round_cycle_2(actor, enemy)
      # Redéfinition
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des capacités
      # --------- -------------- --------------------
      case actor.ability
      when 2 # Crachin / Drizzle (ab)
        if not($battle_var.rain?) # Pluie
          draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.")
          wait(40)
          animation = $data_animations[379]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_rain
      when 45 # Sable Volant / Sand stream (ab)
        if not($battle_var.sandstorm?) # Tempete Sable
          draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.")
          wait(40)
          animation = $data_animations[380]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 70 # Sècheresse / Drought (ab)
        if not($battle_var.sunny?) # Soleil
          draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.")
          wait(40)
          animation = $data_animations[378]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 3 # Speed Boost (ab)
        draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.")
        actor.change_spd(+1)
        stage_animation(actor_sprite, $data_animations[368])
        wait(40)
      when 22 # Intimidate (ab)
        if not(actor.ability_active)
          actor.ability_active = true
          draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".")
          enemy.change_atk(-1)
          stage_animation(enemy_sprite, $data_animations[365])
          wait(40)
        end
      when 59 # Forecast / Meteo (ab)
        if $battle_var.sunny? and not(actor.type_fire?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en FEU!")
          actor.ability_token = 2
        elsif $battle_var.rain? and not(actor.type_water?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en EAU!")
          actor.ability_token = 3
        elsif $battle_var.hail? and not(actor.type_ice?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en GLACE!")
          actor.ability_token = 6
        elsif not(actor.type_normal?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en NORMAL!")
          actor.ability_token = 0
        end
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0x72 # Requiem / Perish Song
          index = actor.effect_list.index(0x72)
          number = actor.effect[index][1]
          if number > 0
            if number > 1
              string = number.to_s + " tours"
            elsif number == 1
              string = number.to_s + " tour"
            end
            draw_text("Plus que " + string, "pour " + actor.given_name + "...")
            wait(40)
          else
            draw_text(actor.given_name + " est", "K.O. par REQUIEM!")
            damage = actor.hp
            heal(actor, actor_sprite, actor_status, -damage)
            wait(40)
          end
        end
      end
     
      # --------- -------------- --------------------
      #      Nettoyage des compteurs d'effets
      # --------- -------------- --------------------
      for effect in actor.effect
        case effect
        when [0x10, 0] # Reflet / Reflect
          draw_text("L'effet de REFLET est", "terminé.")
          wait(40)
        when [0x23, 0] # Light Screen
          draw_text("L'effet de MUR LUMIERE est", "terminé.")
          wait(40)
        when [0x2E, 0] # Brume / Mist
          draw_text("La brume se dissipe.")
          wait(40)
        when [0x7C, 0] # Rune Protect / Safeguard
          draw_text("L'effet de RUNE PROTECT", "est terminé.")
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
    end
   
   
   
    #------------------------------------------------------------ 
    # Items
    #------------------------------------------------------------    
    def actor_item_use # items à utiliser
      # Item déjà utilisé ie remplacé par 0
      if @item_id == 0
        return
      end
    end

    #------------------------------------------------------------ 
    # Switch de pokémon
    #------------------------------------------------------------        
    def actor_pokemon_switch
      if @switch_id != -1
        if not(@actor.dead?)
          @actor_status.visible = true
        else
          @actor_status.visible = false
        end
       
        switch_effect(@actor, @enemy)
       
        if not(@actor.dead?)
          recall_pokemon
        end
       
        @battle_order = switch(@battle_order, 0, @switch_id)
        @actor = @party.actors[@battle_order[0]]
        @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
        @actor_status = POKEMON_S::Pokemon_Battle_Status.new(@actor, false)
        @actor_status.visible = false
        if not($battle_var.have_fought.include?(@actor.party_index))
          $battle_var.have_fought.push(@actor.party_index)
        end
       
        launch_pokemon
        @actor_status.visible = true
        @switch_id = -1
      end
    end
   
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy.dead?)
          @enemy_status.visible = true
        else
          @enemy_status.visible = false
        end
       
        switch_effect(@enemy, @actor)
       
        if not(@enemy.dead?)
          recall_enemy_pokemon
        end
       
        @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id)
        @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]]
        $data_pokedex[@enemy.id][0] = true
        @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
        @enemy_status = POKEMON_S::Pokemon_Battle_Status.new(@enemy, true)
        @enemy_status.visible = false
       
        launch_enemy_pokemon
        @enemy_status.visible = true
        @enemy_switch_id = -1
      end
    end
   
    #------------------------------------------------------------ 
    # Fuite
    #------------------------------------------------------------          
    def run
      if run_able?(@actor, @enemy)
        $battle_var.run_count += 1
        @action_window.active = false
        @action_window.visible = false
        end_battle_flee
      else
        $battle_var.run_count += 1
        fail_flee
        @phase = 2
        @actor_action = 0
        $battle_var.action_id = 0
      end
    end
   
    def run_able?(runner, opponent)
      x = (Integer(opponent.spd/4) % 255)
      rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count))
      if not(flee_able(runner, opponent))
        return false
      end
      if opponent.spd <= runner.spd
        return true
      elsif x == 0
        return true
      elsif rate > 255
        return true
      elsif rand(256) <= rate
        return true
      else
        return false
      end
    end
   
    def run_enemy
      if run_able?(@enemy, @actor)
        end_battle_flee_enemy
      end
    end
   
    #------------------------------------------------------------ 
    # Animations supplémentaires au combat
    #------------------------------------------------------------  
    # Défaites / KO
    #------------------------------------------------------------      
    def enemy_down
      # Si déjà vaincu
      if @enemy_sprite.zoom_y == 0
        return
      end
      # Sinon
      @enemy_sprite.oy = @enemy_sprite.bitmap.height
      @enemy_sprite.y += @enemy_sprite.bitmap.height / 2
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
     
      loop do
        @enemy_status.x -= 20
        #@enemy_sprite.zoom_y -= 0.05
        @enemy_sprite.y += 8
        @enemy_sprite.opacity -= 20
        Graphics.update
        #if @enemy_sprite.zoom_y <= 0.0
        if @enemy_sprite.y >= 348
          @enemy_sprite.zoom_y = 0
          break
        end
      end
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.y -= @enemy_sprite.bitmap.height
      draw_text(@enemy.given_name, "est K.O.!")
      wait(40)
    end
   
    def actor_down
      # Si déjà vaincu
      #if @actor_sprite.zoom_y <= 0.0
      if @actor_sprite.y >= 576
        return
      end
      # Sinon
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
      loop do
        @actor_status.x += 20
        #@actor_sprite.zoom_y -= 0.05
        @actor_sprite.y += 12
        @actor_sprite.opacity -= 20
        Graphics.update
        #if @actor_sprite.zoom_y <= 0.0
        if @actor_sprite.y >= 576
          break
        end
      end
     
      draw_text(@actor.given_name, "est K.O.!")
      wait(40)
    end
   
    #------------------------------------------------------------      
    # Attaques
    #------------------------------------------------------------
    def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite)
      if miss
        wait(40)
        draw_text("Mais cela échoue!")
        wait(40)
        return
      end
     
      if user == @enemy
        reverse = true
      else
        reverse = false
      end
     
      efficiency = info[2]
      if hit and efficiency != -2
        # Animation utilisateur
        animation_user = $data_animations[user_skill.user_anim_id]
        if animation_user != nil
          user_sprite.animation(animation_user, true, reverse)
          until not(user_sprite.effect?)
            user_sprite.update
            Graphics.update
          end
        end
       
        user_sprite.update
        Graphics.update
       
        # Animation Cible
        animation_target = $data_animations[user_skill.target_anim_id]
        if animation_target != nil
          target_sprite.animation(animation_target, true, reverse)
          until not(target_sprite.effect?)
            target_sprite.update
            Graphics.update
          end
        end
       
        target_sprite.update
        Graphics.update
       
        if info[0] > 0
          case efficiency
          when 0 # Normal
            Audio.se_play("Audio/SE/Hit.wav", 100)
            blink(target_sprite, 3, 3)
          when 1 # Super efficace
            Audio.se_play("Audio/SE/Hitplus.wav", 100)
            blink(target_sprite, 2, 5)
          when -1 # Peu efficace
            Audio.se_play("Audio/SE/Hitlow.wav", 100)
            blink(target_sprite, 4, 2)
          end
        end
      elsif not(hit)
        wait(40)
        draw_text(user.given_name, "rate son attaque!")
        wait(40)
      end
    end
   
    def blink(sprite, frame = 4, number = 3)
      for i in 0..number
        wait(frame)
        sprite.opacity = 0
        Graphics.update
        wait(frame)
        sprite.opacity = 255
        Graphics.update
      end
    end
   
    def post_attack(info, damage, power)
      efficiency = info[2]
      if damage == 0 and (efficiency != -2 or power == 0)
        return
      end
      critical = info[1]
      if critical  and efficiency != -2 #critical_hit
        draw_text("Coup critique!")
        wait(40)
      end
      case efficiency
      when 1
        draw_text("C'est super efficace!")
        wait(40)
      when -1
        draw_text("Ce n'est pas très efficace...")
        wait(40)
      when -2
        draw_text("Ca ne l'affecte pas...")
        wait(40)
      end
    end
   
    def faint_check(user = nil)
      if user == nil
        faint_check(@actor)
        faint_check(@enemy)
      end
      if user == @actor and user.dead?
        actor_down
      end
      if user == @enemy and user.dead?
        enemy_down
      end
    end
       
   
    #------------------------------------------------------------      
    # Statut et stats
    #------------------------------------------------------------   
    def status_animation(sprite, status)
      animation = $data_animations[355 + status]
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          break
        end
      end
    end
   
    def stage_animation(sprite, animation)
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          wait(20)
          break
        end
      end
    end

    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
    def type_string(type)
      case type
      when 0
        return "???"
      when 1
        return "NORMAL"
      when 2
        return "FEU"
      when 3
        return "EAU"
      when 4
        return "ELECTRIK"
      when 5
        return "PLANTE"
      when 6
        return "GLACE"
      when 7
        return "COMBAT"
      when 8
        return "POISON"
      when 9
        return "SOL"
      when 10
        return "VOL"
      when 11
        return "PSY"
      when 12
        return "INSECTE"
      when 13
        return "ROCHE"
      when 14
        return "SPECTRE"
      when 15
        return "DRAGON"
      when 16
        return "ACIER"
      when 17
        return "TENEBRES"
      end
    end
   
   
    # Changement (ou pas) de statut
    def status_string(actor, status)
      string = actor.given_name
      case status
      when -1
        draw_text(string + " est", "déjà empoisonné!")
        wait(40)
      when -2
        draw_text(string + " est", "déjà paralysé!")
        wait(40)
      when -3
        draw_text(string,"brûle déjà!")
        wait(40)
      when -4
        draw_text(string,"dort déjà!")
        wait(40)
      when -5
        draw_text(string, "est déjà gelé!")
        wait(40)
      when -6
        draw_text(string, "est déjà confus!")
        wait(40)
      when -8
        draw_text(string + " est", "déjà gravement empoisonné!")
        wait(40)
      when 1
        draw_text(string, "est empoisonné!")
        wait(40)
      when 2
        draw_text(string, "est paralysé!")
        wait(40)
      when 3
        draw_text(string,"brûle!")
        wait(40)
      when 4
        draw_text(string,"s'endort!")
        wait(40)
      when 5
        draw_text(string,"gèle!")
        wait(40)
      when 6
        draw_text("Cela rend " + string, "confus!")
        wait(40)
      when 7
        draw_text(string, "est appeuré!")
        wait(40)
      when 8
        draw_text(string + " est", "gravement empoisonné!")
        wait(40)
      end
    end
   
    # S'occupe du texte et de l'animation
    def raise_stat(string, actor, n = 0)
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == 1
        text = actor.given_name + " augmente!"
      elsif n > 1
        text = actor.given_name + " augmente beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[364])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[366])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[370])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[372])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[368])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[374])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[376])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    def reduce_stat(string, actor, n = true, self_inflicted = false)
      # Mist/Brume
      if actor.effect_list.include?(0x2E)
        draw_text(actor.given_name + " est", "protégé par la brume!")
        wait(40)
        return
      end
      # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab)
      if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted)
        draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!")
        wait(40)
        return
      end
      # Keen Eye / Regard Vif (ab)
      if actor.ability == 51 and string == "ACC"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!")
        wait(40)
        return
      end
      # Hyper Cutter (ab)
      if actor.ability == 52 and string == "ATK"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!")
        wait(40)
        return
      end
     
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == -1
        text = actor.given_name + " baisse!"
      elsif n < -1
        text = actor.given_name + " baisse beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[365])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[367])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[371])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[373])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[369])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[375])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[377])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    #------------------------------------------------------------      
    # Appel / Rappel de Pokémon
    #------------------------------------------------------------          
    def recall_pokemon
      draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!")
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.y = 336
      @actor_sprite.x = 156
      @actor_sprite.color = @actor.ball_color
      @actor_sprite.color.alpha = 0
     
      until @actor_sprite.color.alpha >= 255
        @flash_sprite.opacity += 25
        @actor_sprite.color.alpha += 25
        Graphics.update
      end
     
      Audio.se_play("Audio/SE/Pokeopen.wav")
      loop do
        @actor_status.x += 20
        @actor_sprite.opacity -= 25
        @actor_sprite.color.alpha += 25
        @actor_sprite.zoom_x -= 0.1
        @actor_sprite.zoom_y -= 0.1
        @flash_sprite.opacity -= 25
        Graphics.update
        if @actor_status.x >= 711
          @actor_status.visible = false
          @actor_status.x = 711
          @actor_sprite.color.alpha = 0
          @actor_sprite.opacity = 0
          Graphics.update
          break
        end
      end
    end
   
    def launch_pokemon
      @actor_sprite.x = 156
      @actor_sprite.y = 336
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.zoom_x = 0
      @actor_sprite.zoom_y = 0
     
      #if @actor_party_status.active
      #  @actor_party_status.x = 0
      #  @actor_party_status.visible = true
      #end
     
      name = @actor.given_name
      text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)]
      draw_text(text)
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = -44
      @ball_sprite.y = 324
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x += 5
        @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        #if @actor_party_status.active
        #  @actor_party_status.x -= 80
        #end
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          #if @actor_party_status.active
          #  @actor_party_status.x = 0
          #  @actor_party_status.visible = false
          #end
          break
        end
      end
      @actor_sprite.opacity = 0
      @actor_sprite.color = @actor.ball_color
     
      until @actor_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @actor_sprite.zoom_x += 0.1
        @actor_sprite.zoom_y += 0.1
        @actor_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
     
      @actor_sprite.zoom_x = 1
      @actor_sprite.zoom_y = 1
      @actor_sprite.opacity = 255
     
      @actor_status.x = 711
      @actor_status.visible = true
     
      if @actor.shiny
        animation = $data_animations[382]
        @actor_sprite.animation(animation, true)
      end
     
      until @actor_status.x == 311
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @actor_status.x -= 20
        @actor_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @actor_sprite.update
        Graphics.update
      end
     
      until not(@actor_sprite.effect?)
        @actor_sprite.update
        Graphics.update
      end
     
      @actor_status.x = 311
      @actor_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    def launch_enemy_pokemon
      @enemy_sprite.x = 463
      @enemy_sprite.y = 108
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.zoom_x = 0
      @enemy_sprite.zoom_y = 0
     
      string = $trainer.type(@trainer_id) + " " + $trainer.name(@trainer_id)
      draw_text(@enemy.name + " est envoyé", "par " + string + "!")
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = 663
      @ball_sprite.y = 108
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x -= 5
        @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          break
        end
      end
      @enemy_sprite.opacity = 0
      @enemy_sprite.color = @enemy.ball_color
     
      until @enemy_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @enemy_sprite.zoom_x += 0.08
        @enemy_sprite.zoom_y += 0.08
        @enemy_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      @enemy_sprite.zoom_x = 1
      @enemy_sprite.zoom_y = 1
      @enemy_sprite.opacity = 255
     
      @enemy_status.x = -377
      @enemy_status.visible = true
     
      if @enemy.shiny
        animation = $data_animations[382]
        @enemy_sprite.animation(animation, true)
      end
     
      until @enemy_status.x == 23
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @enemy_status.x += 20
        @enemy_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @enemy_sprite.update
        Graphics.update
      end
     
      until not(@enemy_sprite.effect?)
        @enemy_sprite.update
        Graphics.update
      end
     
      @enemy_sprite.x = 463
      @enemy_status.x = 23
      @enemy_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    #------------------------------------------------------------ 
    # Fin de combat
    #------------------------------------------------------------     
    def end_battle(result = 0)     
      # Reset des variables et effets
      $battle_var.reset
      @actor.skill_effect_reset
      @actor.reset_stat_stage
      @actor.cure_state
      @actor.ability_active = false
      @enemy.skill_effect_reset
      @enemy.reset_stat_stage
      @enemy.cure_state
      @enemy.ability_active = false
      # -----------------------------------
      Audio.me_stop
      wait(10)
      $game_system.bgm_play($game_temp.map_bgm)
      wait(10)
      Graphics.freeze
      # -----------------------------------
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      # Défaite
      $scene = Scene_Map.new
    end
   
    def end_battle_flee(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@actor.given_name, "est expulsé du combat!")
        loop do
          if @actor_sprite.x > -160
            @actor_sprite.x -= 20
          end
          Graphics.update
          Input.update
          if @actor_sprite.x <= -160
            wait(40)
            break
          end
        end
      else
        draw_text("Vous prenez la fuite!")
        wait(40)
      end
      end_battle(1)
    end
   
    def fail_flee
      draw_text("Vous ne pouvez pas","vous enfuir!")
      wait(40)
    end
   
    def end_battle_flee_enemy(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@enemy.given_name, "est expulsé du combat!")
      else
        draw_text(@enemy.given_name + " s'échappe!")
      end
      loop do
        if @enemy_sprite.x < 800
          @enemy_sprite.x += 20
        end
        Graphics.update
        Input.update
        if @enemy_sprite.x >= 800
          wait(40)
          break
        end
      end
      end_battle(1)
    end
   
    def end_battle_defeat
      $battle_var.result_defeat = true
      draw_text("Tous vos Pokémons", "ont été vaincus!")
      wait(40)
      $pokemon_party.money /= 2
      if not(@lose)
        if $game_variables[1] == 0
          print("Réglez votre point de retour!")
        else
          $game_map.setup($game_variables[1])
          $game_map.display_x = $game_variables[2]
          $game_map.display_y = $game_variables[3]
          $game_player.moveto($game_variables[2], $game_variables[3])
        end
        $game_temp.common_event_id = 2
      end
      $game_temp.map_bgm = $game_map.bgm
      end_battle(2)
    end
   
    def draw_choice
      @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig)
      @command.x = 517
      @command.y = 215
      loop do
        Graphics.update
        Input.update
        @command.update
        if Input.trigger?(Input::C) and @command.index == 0
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return true
        end
        if Input.trigger?(Input::C) and @command.index == 1
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return false
        end
      end
    end
  end
 
  #------------------------------------------------------------ 
  # Fenêtre de statut
  #------------------------------------------------------------ 
  class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(0,0,0,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size(@pokemon.name).width + 3
        draw_gender(15 + width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(9, 42, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)

        class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
  
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(248,248,248,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(242 - width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(20, 47, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(46, 99, 1.0 - level, 232)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(268 - width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(44, 68, bitmap, src_rect, 255)
        end
      end
    end
  
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(46, 99, 1.0 - level, 232)
    end
    
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
    
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
  
    def dispose
      super
    end
  
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3)
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3)
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6)
      end
    
      if level < 0.1
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(248, 64, 16, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(232, 168, 50, 255)
      else
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(24, 192, 32, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
  
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*232.to_i, 3)
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255))
    end
  
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)      
      end
    end
  end


  #------------------------------------------------------------
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
  
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
  
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
    
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
    
      for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i]
].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
  
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end
      @run_count = 0
      @money = 0
    end
   
    def reset
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = POKEMON_S::Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
   
    def reset_weather
      @weather = [0, 0]
    end
   
    def set_rain(duration = -1)
      @weather = [1, duration]
    end
   
    def rain?
      if @weather[0] == 1
        return true
      else
        return false
      end
    end
   
    def set_sunny(duration = -1)
      @weather = [2, duration]
    end
   
    def sunny?
      if @weather[0] == 2
        return true
      else
        return false
      end
    end
   
    def sandstorm?
      if @weather[0] == 3
        return true
      else
        return false
      end
    end
   
    def set_sandstorm(duration = -1)
      @weather = [3, duration]
    end
   
    def hail?
      if @weather[0] == 4
        return true
      else
        return false
      end
    end
   
    def set_hail(duration = -1)
      @weather = [4, duration]
    end
   
    def battle_end?
      if @result_flee or @result_win or @result_defeat
        return true
      else
        return false
      end
    end
   
    def add_money(amount)
      if @money == nil
        @money = 0
      end
      @money += amount
    end
   
  end
 
end

 

Posté par naruto66620 le 16 Sep - 08:54 (2008)
erreur de partout je pense que s'est bien mais tu sais pas scripter --'

Mollasse enragé désoler mais ya plein de truck a modifier sa va me prend 1h00

Posté par Drakhaine le 16 Sep - 09:25 (2008)
Naruto, le mec qui vient sauver le monde avec son arrogance... T'as pas déjà été rappelé à l'ordre un nombre incalculable de fois ?
Si ça bug, tu t'écrases, tu corriges sans faire de remarque et quand ça fonctionnera de ton côté, tu postes ta version pour que tout le monde t'acclame et puisse en profiter, c'est clair ?

Maintenant, je doute qu'en 1h tu parviennes à corriger ce script (même si pas testé, pas jeté d'oeil, etc...). M'enfin, bonne chance Clin d'œil foireux


Edit : Petit bug trouvé en lisant le script, en espérant que ça suffira à corriger le tout :
Remplacer ça vers la fin de son script Pokemon_Battle_Core 1 (vers la ligne 2600 quoi)
Code:
for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i][/i]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end

par ça :
Code:
for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end

et si ça bug toujours, modifier for i in 1..@party.size en for i in 1...@party.size
j'aurais mis un point en plus moi, mais peut-être me trompe-je, je me souviens plus de comment fonctionne @party

Posté par naruto66620 le 16 Sep - 12:17 (2008)
yes cetter cette erreur donc drakhaine tu tes tromper tu te tît enfin moi aussi largemen ^^

Posté par Krosk le 16 Sep - 12:56 (2008)
Code:
0..@party.size-1
0...@party.size

sont équivalent

Posté par Happy le 16 Sep - 13:15 (2008)
Bon de 1,Palbolsky a dit que ce script était pour la version 07 donc pour la 4G(celle que j'utilise),ça bug><
Edit : lol désolé Palbolsky j'ai un peu déformé ton nom laà,je corrige plus haut^^

Posté par Pαlвσlѕку le 16 Sep - 17:49 (2008)
Aucune idée... je vais regarder pour la 4G.
Par contre pour PSP v0,5, je ne le ferai pas dessus ; car je pense qu'il est temps de ce mettre à sa mise à jour : PSP v0,7

Je vois que beaucoup de bug apparaisse car le fait de les mettre sur le forum, certaine chose sont rajouter ou supprimer.
Pour information, il fonctionne très bien et il ne peut pas vraiment buguer car j'ai juste modifier des chiffres pour les couleurs et les emplacements (et de trois autre petite chose aussi)

Par contre j'ai remarqué un petit truc qui n'allais pas. Je vous explique :
En modifiant les images, on modifie aussi le menu pokémon (là où on trouve nos 6 pkmn de l'équipe).

C'est pour ça que je vous est demandé de rajouter l'image "hpbar_team" pour éviter ce bug ; car quand je modifie les bars, les bars de l'équipe change aussi et donc une petite modification dans le menu "Pokemon_Party_Menu" est requise pour dire à Mr Ruby de charger une autre image (hpbar_team)

Mais pour les icônes de changement de statut, ce trucage n'a pas fonctionner (je sais porquoi...) mais je vais le corriger ce soir.

Naruto va voir ailleur si j'y suis :evil:

Posté par Zelda le 16 Sep - 18:02 (2008)
Ca serait sympa de citer les personnes qui ont fait les ressources du CBS

Posté par Pαlвσlѕку le 16 Sep - 18:03 (2008)
CBS ??? C'est quoi ??

Posté par Zelda le 16 Sep - 18:05 (2008)
Custom Battle System. En gros les ressoruces que t'utilise qui les a fait Imbécile heureux

( je dit ca car j'ai fait les deux "plaque d'info" )

Posté par Pαlвσlѕку le 16 Sep - 18:13 (2008)
J'ai fait une petite modification dans mon 1er post, tout en bas.

J'ai une question :

Comment je peux faire pour modifier la couleur de l'ombre de l'écriture dans les 2 barres ??

EDIT--> Trouver, plus besoin d'aide

Posté par naruto66620 le 17 Sep - 08:08 (2008)
moi sa ne marche pas voici le script :

Spoiler

Code:
#==============================================================================# ■ Pokemon_Battle_Core
# Pokemon Script Project - Krosk 
# 20/07/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Système de Combat - Squelette général
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé, 8: Toxic
# @confuse (6), @flinch (7)
#-----------------------------------------------------------------------------
# 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
# 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# $battle_var.action_id
#   0 : Phase de Sélection
#   1 : Sélection Item
#   2 : Switch Pokémon
#   4 : Switch Fin de Tour
#-----------------------------------------------------------------------------
module POKEMON_S
  #------------------------------------------------------------  
  # Pokemon_Battle_Core
  #   noyau possédant les fonctions communes aux combats sauvages/dresseurs
  #------------------------------------------------------------  
  #------------------------------------------------------------  
  # Fonctions à définir à l'extérieur
  #   initialize
  #   pre_battle_animation
  #   enemy_skill_decision
  #   end_battle_check
  #   actor_item_use
  #   catch_pokemon
  #   run_able?
  #   end_battle_victory
  #------------------------------------------------------------  
  class Pokemon_Battle_Core
    attr_accessor :z_level
    attr_accessor :actor_status
    attr_accessor :actor
    attr_accessor :actor_sprite
    
    #------------------------------------------------------------  
    # ------------------- Squelette Général ---------------------
    #------------------------------------------------------------
    
    #------------------------------------------------------------  
    # main
    #------------------------------------------------------------
    def main
      # Pré-création des Sprites
      # Fond
      if @battleback_name != ""
        @battleback_name = $game_map.battleback_name + ".png"
        @ground_name = "ground" + $game_map.battleback_name + ".png"
      else
        print("Attention, réglez le BattleBack du Tileset.")
        @battleback_name = "battle0.png"
        @ground_name = "groundbattle0.png"
      end
      @background = Sprite.new
      @background.z = @z_level
      
      # Fond du message
      @message_background = Sprite.new
      @message_background.y = 336
      @message_background.z = @z_level + 19
      
      # Sprite de flash
      @flash_sprite = Sprite.new
      @flash_sprite.bitmap = RPG::Cache.picture("black.png")
      @flash_sprite.color = Color.new(255,255,255)
      @flash_sprite.opacity = 0
      @flash_sprite.z = @z_level + 13
      
      # Fenetre de texte
      @text_window = Window_Base.new(4, 340, 632, 136)
      @text_window.opacity = 0
      @text_window.z = @z_level + 20
      @text_window.contents = Bitmap.new(600 + 32, 104 + 32)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsizebig
      
      # Fenetre d'action
      s1 = "ATTAQUE"
      s2 = "SAC"
      s3 = "POKéMON"
      s4 = "FUITE"
      
      @action_window = Window_Command.new(320, [s1, s2, s3, s4], $fontsizebig, 2, 56)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
      
      # Viewport
      battle_viewport = Viewport.new(0, 0, 640, 336)
      battle_viewport.z = @z_level + 15
      
      # Sprites acteurs # Positions par défaut des centres
      @enemy_sprite = RPG::Sprite.new(battle_viewport)
      @enemy_sprite.x = 464
      @enemy_sprite.y = 104
      @enemy_sprite.z = @z_level + 15
      @enemy_ground = RPG::Sprite.new
      @enemy_ground.x = 464
      @enemy_ground.y = 149
      @enemy_ground.z = @z_level + 11
      @actor_sprite = RPG::Sprite.new(battle_viewport)
      @actor_sprite.x = 153
      @actor_sprite.y = 336
      @actor_sprite.z = @z_level + 15
      @actor_ground = RPG::Sprite.new
      @actor_ground.x = 153
      @actor_ground.y = 386
      @actor_ground.z = @z_level + 11
      
      # Création fenêtre de statut
      @actor_status = Pokemon_Battle_Status.new(@actor, false, @z_level + 15)
      @enemy_status = Pokemon_Battle_Status.new(@enemy, true, @z_level + 15)
      @actor_status.visible = false
      @enemy_status.visible = false
      @enemy_caught = false
      
      @actor_party_status = Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10)
      @enemy_party_status = Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10)
      @actor_party_status.visible = false
      @enemy_party_status.visible = false
      # note: .active = true activera les animations liées à ces fenêtres
      @actor_party_status.active = false
      @enemy_party_status.active = false
      
      # Lancement des animations
      pre_battle_transition
      pre_battle_animation
      
      # Effets pré-premier round
      post_round_effect
      
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
      
      # Fin de scene
      Graphics.freeze
      @background.dispose
      @message_background.dispose
      @flash_sprite.dispose
      @text_window.dispose
      @action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
      end
      if @ball_sprite != nil
        @ball_sprite.dispose
      end
      @enemy_sprite.dispose
      @actor_sprite.dispose
      @actor_status.dispose
      @enemy_status.dispose
      @actor_party_status.dispose
      @enemy_party_status.dispose
    end
    
    #------------------------------------------------------------  
    # Déroulement
    #------------------------------------------------------------
    def update
      # Animation test : séquence de test d'une animation
      if false
        if $temp == nil
          $temp = false
          @actor_sprite.register_position
          @enemy_sprite.register_position
        end
        animation = $data_animations[15] # tappez le numéro de l'anim à tester
        if not @enemy_sprite.effect? and not @actor_sprite.effect?
          if $temp
            @enemy_sprite.reset_position
            @actor_sprite.register_position
            @actor_sprite.animation(animation, true, true)
            $temp = !$temp
          else
            @actor_sprite.reset_position
            @enemy_sprite.register_position
            @enemy_sprite.animation(animation, true)
            $temp = !$temp
          end
        end
        @actor_sprite.update
        @enemy_sprite.update
        return
      end
      
      case @phase
      when 0 # Phase d'initialisation
        @phase = 1
        
        # Création fenêtre de skill
        list = []
        for skill in @actor.skills_set
          list.push(skill.name)
        end
        while list.size < 4
          list.push("  ---")
        end
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
        
        # Compétences bloquées
        for i in [url=mailto:0..@actor.skills_set.length-1]0..@actor.skills_set.length-1[/url]
          skill = @actor.skills_set[i]
          if not(skill.usable?)
            @skills_window.disable_item(i)
          end
        end
        
        # Curseur sur le dernier choix
        if $battle_var.last_index == nil
          $battle_var.last_index = 0
          @skills_window.index = 0
        else
          @skills_window.index = $battle_var.last_index
        end
        
        # Création fenêtre description de skill
        @skill_descr = Window_Base.new(512, 336, 128, 144)
        @skill_descr.contents = Bitmap.new(96, 144)
        @skill_descr.contents.font.name = $fontface
        @skill_descr.contents.font.size = $fontsizebig
        @skill_descr.visible = false
        skill_descr_refresh
        
        # Activation fenêtre
        @actor_status.visible = true
        @enemy_status.visible = true
                
        # ------- ---------- --------- --------
        #    Saut de phase de sélection actor
        # ------- ---------- --------- --------
        jumped = phase_jump
        
        # Activations fenêtres
        if not(jumped)
          draw_text("Que doit faire", @actor.given_name + "?")
          @action_window.visible = true
          @action_window.active= true
          $battle_var.action_id = 0
        end
        
      when 1 # Phase d'attente d'action
        @action_window.update
        @skills_window.update
        if @skills_window.active and input
          skill_descr_refresh
        end
        
        if Input.trigger?(Input::C) and @action_window.active
          case @action_window.index
          when 0 # Selection ATTAQUE
            $game_system.se_play($data_system.decision_se)
            @action_window.active = false
            @action_window.visible = false
            
            # ------- ---------- --------- --------
            #   Reset compteur de fuite
            # ------- ---------- --------- --------
            $battle_var.run_count = 0
            
            # ------- ---------- --------- --------
            #    Saut de phase de sélection attaque
            # ------- ---------- --------- --------
            if attack_selection_jump
              @actor_action = 1
              @phase = 2
              return
            end
            
            # ------- ---------- --------- --------
            #      Vérification PP // Lutte
            # ------- ---------- --------- --------
            total = 0
            for skill in @actor.skills_set
              if skill.usable?
                total += skill.pp
              end
            end
            if total == 0
              @actor_action = 1
              @phase = 2
              @actor_skill = Skill.new(165) # Lutte
              return
            end
            
            @skills_window.active = true
            @skills_window.visible = true
            @skill_descr.visible = true
            @text_window.contents.clear
          when 1 # Selection ITEM
            $game_system.se_play($data_system.decision_se)
            scene = Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "battle")
            scene.main
            return_data = scene.return_data
            @phase = 0
            if $battle_var.action_id == 1
              @phase = 2
              @actor_action = 3
              @item_id = return_data
            end
          when 2 # Selection PKMN
            # ------- ---------- --------- --------
            #    Vérification switch permis
            # ------- ---------- --------- --------
            if not(switch_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            $game_system.se_play($data_system.decision_se)
            $battle_var.window_index = @action_window.index
            scene = Pokemon_Party_Menu.new(0, @z_level + 100)
            scene.main
            return_data = scene.return_data
            @phase = 0
            # Enregistrement données Switch de Pokémon
            if $battle_var.action_id == 2
              @phase = 2
              @actor_action = 2
              @switch_id = return_data
            end
          when 3 # sélection FUITE
            # ------- ---------- --------- --------
            #    Vérification fuite permise
            # ------- ---------- --------- --------
            @action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              draw_text("Que doit faire", @actor.given_name + "?")
              return
            end
            @action_window.visible = true
            
            @action_window.active = false
            @action_window.visible = false
            @text_window.contents.clear
            run
          end
          return
        end
        
        if Input.trigger?(Input::C) and @skills_window.active
          index = @skills_window.index
          skill = @actor.skills_set[index]
          if skill != nil and skill.usable?
            @actor_action = 1
            @phase = 2
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @actor_skill = @actor.skills_set[index]
            $battle_var.last_index = @skills_window.index
          else
            $game_system.se_play($data_system.buzzer_se)
          end
        end
        
        if Input.trigger?(Input::B) and @skills_window.active
          $game_system.se_play($data_system.decision_se)
          @skills_window.active = false
          @skills_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @phase = 0
        end
        
        
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
        
        enemy_skill_decision
        
        statistic_refresh
        turn_order
        phase2
        phase3
        
        # Phase de switch de fin de tour
        $battle_var.action_id = 4
        end_battle_check
        
        if $battle_var.battle_end?
          return
        end
        
        # Fin de tour / Post_Round effects
        post_round_effect
        @actor_status.refresh
        @enemy_status.refresh
        
        if $battle_var.battle_end?
          return
        end
        
        # Phase de switch post_round
        $battle_var.action_id = 6
        end_battle_check
        @phase = 0
        
        if $battle_var.battle_end?
          return
        end
        
        # Incrémentation nombre de tours
        $battle_var.round += 1
        
      end
      return
    end
    
    #------------------------------------------------------------  
    # Vérifications préliminaires et ordre d'action
    #------------------------------------------------------------
    def statistic_refresh
      @actor.statistic_refresh
      @enemy.statistic_refresh
    end
    
    #Recherche de priorité
    def turn_order 
      # Comparaison des priorités
      if @actor_skill == nil or @enemy_skill == nil
        @strike_first = true
        return
      end
      
      if @actor_action != 1 # Attaque
        @strike_first = false
        return
      end  
      
      if @actor_skill.priority > @enemy_skill.priority 
        @strike_first = true
      elsif @actor_skill.priority < @enemy_skill.priority 
        @strike_first = false
      else
        
      # En cas d'égalité
        if @enemy.spd > @actor.spd
          @strike_first = false
        elsif @enemy.spd < @actor.spd
          @strike_first = true
        else
          @strike_first = rand(2)>0 ? true : false
        end
      end
    end
    
    #------------------------------------------------------------  
    # Rounds
    #------------------------------------------------------------            
    def phase2 # Pré_Rounds
      @action_window.visible = false
      @action_window.active = false
      @actor_status.visible = true
      @enemy_status.visible = true
      @actor_status.refresh
      @enemy_status.refresh
      draw_text("","")
      
      # Préround 1: Fuite
      if @actor_action == 4
        run
      end
      if @enemy_action == 4
        enemy_run
      end
      
      # Préround 2: Item
      if @actor_action == 3
        actor_item_use
      end
      if @enemy_action == 3
        enemy_item_use
      end
      
      # Préround 3: Switch Pokémon
      if @actor_action == 2
        actor_pokemon_switch
      end
      if @enemy_action == 2
        enemy_pokemon_switch
      end
      
      @actor_status.refresh
      @enemy_status.refresh
    end
        
    # Round: Attaques
    def phase3 
      if @strike_first
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
      
      faint_check
      
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
      
      if not(@strike_first)
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
      
      faint_check
      
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
    end
    
    #------------------------------------------------------------  
    # Fonctions auxiliaires
    #------------------------------------------------------------     
    def switch(list, id1, id2)
      if id1 <= id2
        list.insert(id1, list[id2])
        list.delete_at(id2+1)
        list.insert(id2 + 1, list[id1+1])
        list.delete_at(id1+1)
        return list
      else
        switch(list, id2, id1)
      end
    end
    
    # Fonction auxiliaire
    def input
      if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
        Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
        Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
        return true
      end
      return false
    end
    
    def draw_text(line1 = "", line2 = "")
      if line1.type == Array
        if line1[1] != nil
          draw_text(line1[0], line1[1])
        else
          draw_text(line1[0])
        end
      else
        Graphics.freeze
        @text_window.contents.clear
        @text_window.draw_text(12, 0, 460, 50, line1)
        @text_window.draw_text(12, 55, 460, 50, line2)
        Graphics.transition(5)
      end
    end
    
    def draw_text_valid(line1 = "", line2 = "")
      draw_text(line1, line2)
      loop do
        Graphics.update
        Input.update
        if Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
    
    def wait(frame)
      i = 0
      loop do
        i += 1
        Graphics.update
        if i >= frame
          break
        end
      end
    end
    
    def wait_hit
      loop do
        Graphics.update
        Input.update
        if input
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
    
    
    def update_sprite
      @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
    end
    
    
    
    
    #------------------------------------------------------------  
    # ----------------------- Interface -------------------------
    #------------------------------------------------------------
    
    #------------------------------------------------------------  
    # Fenêtre de description
    #------------------------------------------------------------        
    def skill_descr_refresh
      @skill_descr.contents.clear
      index = @skills_window.index
      skill = @actor.skills_set[index]
      if skill != nil
        string = skill.pp.to_s + "/" + skill.ppmax.to_s
        type = skill.type
      else
        string = "---"
        type = 0
      end
      normal_color = Color.new(60,60,60)
      @skill_descr.contents.font.color = normal_color
      [url=mailto:#@skill_descr.contents.draw_text(0,6,60,39]#@skill_descr.contents.draw_text(0,6,60,39[/url], "PP:")
      @skill_descr.contents.draw_text(0,6,96,39, string, 1)
      [url=mailto:#@skill_descr.contents.draw_text(0,60,140,39]#@skill_descr.contents.draw_text(0,60,140,39[/url], "TP:")
      draw_type(0, 60, type)
    end  
      
    def draw_type(x, y, type)
      src_rect = Rect.new(0, 0, 96, 42)
      bitmap = RPG::Cache.picture("T" + type.to_s + ".png")
      @skill_descr.contents.blt(x, y, bitmap, src_rect, 255)
    end
    
    
    
    
    
    
    
    #------------------------------------------------------------  
    # ------------------ Fonctions de combat --------------------
    #------------------------------------------------------------
    
    #------------------------------------------------------------    
    # Fonctions spéciales - programmation des attaques
    #------------------------------------------------------------ 
    def heal(user, user_sprite, user_status, bonus)
      value = bonus.abs
      for i in 1..value
        if bonus >= 0
          user.add_hp(1)
        else
          user.remove_hp(1)
        end
        if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
          next
        end
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.hp >= user.max_hp or user.dead?
          break
        end
      end
    end
    
    def self_damage(user, user_sprite, user_status, damage)
      if damage > 0
        Audio.se_play("Audio/SE/Hit.wav", 100)
        blink(user_sprite)
      end
      for i in 1..damage
        user.remove_hp(1)
        user_status.refresh
        if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
          next
        end
        Graphics.update
        Graphics.update
        if user.dead?
          break
        end
      end
    end
    
    #------------------------------------------------------------    
    # Fonctions communes - Programmation des attaques
    #------------------------------------------------------------ 
    # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé
    # 6: Confus, 7: Flinch, 8: Toxic
    #------------------------------------------------------------ 
    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre
    #------------------------------------------------------------ 
    
    # Fonction à appeler en cas d'effets sur le statut
    def status_check(target, status, forcing = false)
      # Immunités
      # Poison
      if (target.type_poison? or target.type_steel?) and 
          (status == 1 or status ==  8)
        draw_text(target.given_name + " est insensible", "au poison!")
        wait(40)
        return
      end
      # Freeze
      if status == 5 and target.type_ice?
        draw_text(target.given_name + " est insensible", "au gel!")
        wait(40)
        return
      end
      # Burn
      if status == 3 and target.type_fire?
        draw_text(target.given_name + " est insensible", "aux brûlures!")
        wait(40)
        return
      end
      # Soleil
      if status == 5 and $battle_var.sunny?
        draw_text("Le soleil empêche " + target.given_name, "de geler!")
        wait(40)
        return
      end
      # Lumber / Echauffement (ab)
      if status == 2 and target.ability == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.")
        wait(40)
        return
      end
      # Ignifu-voile / Water Veil (ab)
      if status == 3 and target.ability == 41
        draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.")
        wait(40)
        return
      end
      # Insomnia (ab) // Vital Spirit / Esprit Vital (ab)
      if status == 4 and (target.ability == 15 or target.ability == 72)
        draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.")
        wait(40)
        return
      end
      # Vaccin / Immunity (ab)
      if [1, 8].include?(status) and target.ability == 17
        draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.")
        wait(40)
        return
      end
      # Armumagma / Magma Armor (ab)
      if target.ability == 40 and status == 5
        draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.")
        wait(40)
        return
      end
      # Tempo Perso / Own Tempo (ab)
      if status == 6 and target.ability == 20
        draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.")
        wait(40)
        return
      end
      # Attention / Inner focus (ab)
      if target.ability == 39 and status == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.")
        wait(40)
        return
      end
      # Synchronize (ab)
      if target.ability == 28 and [1, 2, 3, 8].include?(status)
        target.ability_token = status
        if status == 8
          target.ability_token = 1
        end
      end
      
      if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status))
        status_string(target, -target.status) # animation
      elsif status == 6 and target.confused? and not(forcing)
        status_string(target, -6)
      elsif target.effect_list.include?(0x7C) and
          status != 7 # Rune Protect/Safeguard 
        draw_text(target.given_name + "est", "protégé des altérations!")
        wait(40)
      elsif target.effect_list.include?(0x9F) and
          status == 4 # Uproar
        draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!")
        wait(40)
      else
        case status
        when 1
          target.status_poison(forcing)
        when 2 
          target.status_paralyze(forcing)
        when 3
          target.status_burn(forcing)
        when 4
          target.status_sleep(forcing)
        when 5
          target.status_frozen(forcing)
        when 6
          target.status_confuse
        when 7
          target.status_flinch
        when 8
          target.status_toxic(forcing)
        end
        status_string(target, status)
      end
    end
    
    def accuracy_stage(user, target)
      stage = user.acc_stage - target.eva_stage
      stage = stage < -6 ? -6 : stage > 6 ? 6 : stage
      
      # --------------- ---------------- --------------
      #           Programmation des attaques
      # --------------- ---------------- --------------
      # Clairvoyayance / Foresight
      if target.effect_list.include?(0x71)
        stage = user.acc_stage
      end
      # --------------- ---------------- --------------
      # --------------- ---------------- --------------
      
      case stage
      when -6
        return 33.0/100
      when -5
        return 36.0/100
      when -4
        return 43.0/100
      when -3
        return 50.0/100
      when -2
        return 60.0/100
      when -1
        return 75.0/100
      when 0
        return 1
      when 1
        return 133.0/100
      when 2
        return 166.0/100
      when 3
        return 2
      when 4
        return 250.0/100
      when 5
        return 133.0/50
      when 6
        return 3
      end
    end
    
    #------------------------------------------------------------  
    # Post_round
    #------------------------------------------------------------         
    def post_round_effect
      # --------- -------------- --------------------
      # Fin des effets "at the end of a round"
      # --------- -------------- --------------------      
      # Suppression état appeuré (ne dure que un tour)
      @actor.flinch_check
      @enemy.flinch_check
      # Suppression état autre
      if @actor.dead?
        @actor.cure
        @actor.cure_state
      end
      if @enemy.dead?
        @enemy.cure
        @enemy.cure_state
      end
      
      # --------- -------------- --------------------
      # Programmation des attaques en Post-round
      # --------- -------------- --------------------
      #      Cycle commun 0 - Souhait et Météo
      # --------- -------------- --------------------
      post_round_cycle0
      
      # --------- -------------- --------------------
      #         Cycle individuel 1
      #      Programmation des attaques
      #           Effets du statut
      # --------- -------------- --------------------      
      if @strike_first
        post_round_cycle_1(@actor, @enemy)
        post_round_cycle_1(@enemy, @actor)
      else
        post_round_cycle_1(@enemy, @actor)
        post_round_cycle_1(@actor, @enemy)
      end
      
      # --------- -------------- --------------------
      #                Cycle 2
      #         Programmation des attaques
      #            Dommages finaux
      # --------- -------------- --------------------
      if @strike_first
        post_round_cycle_2(@actor, @enemy)
        post_round_cycle_2(@enemy, @actor)
      else
        post_round_cycle_2(@enemy, @actor)
        post_round_cycle_2(@actor, @enemy)
      end
      
      @actor.skill_effect_clean
      @enemy.skill_effect_clean
      
      faint_check
      
      # Round suivant
      if $battle_var.round == nil
        $battle_var.round = 0
      end
      $battle_var.round += 1
    end
    
    
    # --------- -------------- --------------------
    #     Cycle commun 0 - Météo et Souhait
    # --------- -------------- --------------------
    def post_round_cycle0
      if @strike_first
        list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]]
      else 
        list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]]
      end
      
      # Suppression du contrôle pour un pokémon mort
      for array in list
        if array[0].dead?
          list.delete(array)
        end
      end
      
      for array in list
        actor = array[0]
        actor.skill_effect_end_turn
        for effect in actor.effect_list
          case effect
          when 0x56 # Entrave / Disable
            index = actor.effect_list.index(0x56)
            if actor.effect[index][1] == 0
              skill_id = actor.effect[index][2]
              skill = actor.skills_set[skill_id]
              skill.enable
              draw_text(skill.name + " de "+ actor.given_name, "est rétablie!")
              wait(40)
            end
          when 0x5A # Encore
            index = actor.effect_list.index(0x5A)
            if actor.skills_set[index].pp == 0 
              actor.effect[index][1] = 0 # Fin de l'effet
            end
          when 0x75 # Rollout
            index = actor.effect_list.index(0x75)
            ## N'a pas fait de dégât ce tour ci >> Supprimé
            #if actor.effect[index][2] != actor.effect[index][1]
            #  actor.effect.delete_at(index)
            #end
            if actor.asleep? or actor.frozen?
              actor.effect.delete_at(index)
            end
          when 0x77 # Taillade / Fury Cutter
            index = actor.effect_list.index(0x77)
            # N'a pas fait de dégât ce tour ci >> Supprimé
            if actor.effect[index][2] != actor.effect[index][1]
              actor.effect.delete_at(index)
            end
          end
        end
      end
      
      weather = $battle_var.weather[0]
      $battle_var.weather[1] -= 1
      count = $battle_var.weather[1]
      
      # Souhait -- Programmation des attaques
      for array in list
        target = array[0]
        target_sprite = array[1]
        target_status = array[2]
        if target.effect_list.include?(0xB3)
          bonus = target.hp / 2
          draw_text("Un souhait est réalisé.")
          heal(target, target_sprite, target_status, bonus)
          wait(40)
        end
      end
      
      # Pluie
      if $battle_var.rain? and count != 0
        draw_text("La pluie continue de", "tomber.")
        animation = $data_animations[493]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.rain? and count == 0
        draw_text("La pluie s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
      
      # Ensoleillé
      if $battle_var.sunny? and count != 0
        draw_text("Les rayons du soleil","tapent fort.")
        animation = $data_animations[492]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.sunny? and count == 0
        draw_text("Le soleil est parti.")
        wait(40)
        $battle_var.reset_weather
      end
      
      # Tempete de sable
      if $battle_var.sandstorm? and count != 0
        draw_text("La tempête de sable souffle.")
        animation = $data_animations[494]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        
        # Dégats
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ground? or target.type_rock? or target.type_steel?
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or
              target.ability == 8
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.sandstorm? and count == 0
        draw_text("La tempête de sable s'est arretée.")
        wait(40)
        $battle_var.reset_weather
      end
      
      # Grêle
      if $battle_var.hail? and count > 0
        draw_text("Il grêle...")
        animation = $data_animations[495]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        
        # Dégâts
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ice? or
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3)
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.hail? and count == 0
        draw_text("La grêle s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
      
    end
    
    
    
    
    # --------- -------------- --------------------
    #              Cycle individuel 1
    # --------- -------------- -------------------- 
    def post_round_cycle_1(actor, enemy)
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
      
      # Suppression du contrôle pour un Pokémon mort
      if actor.dead?
        return
      end
      
      # --------- -------------- --------------------
      #    Programmation des attaques et des capa
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0xB5 # Ingrain / Racines
          bonus = actor.max_hp / 16
          draw_text(actor.given_name + " puise", "de l'énergie dans la terre.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      end
      
      case actor.ability
      when 44 # Cuvette / Rain Dish (ab)
        if $battle_var.rain?
          bonus = actor.max_hp / 16
          draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      when 54 # Absentéisme / Truant (ab)
        if actor.ability_token == nil
          actor.ability_token = true
        end
        if actor.ability_token == true
          actor.ability_token = false
        elsif actor.ability_token == false
          actor.ability_token = true
        end
      when 61 # Mue / Shed skin (ab)
        if actor.status != 0 and rand(100) < 30
          actor.cure
          draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.")
          wait(40)
        end
      end
      
      for effect in enemy.effect_list
        case effect
        when 0x54 # Leech Seed / Vampigraine
          malus = actor.max_hp / 8
          draw_text("L'énergie de " + actor.given_name,"est drainée!")
          heal(actor, actor_sprite, actor_status, -malus)
          heal(enemy, enemy_sprite, enemy_status, malus)
          wait(40)
        when 0x2A # Multi_turn attack
          damage = actor.max_hp / 16
          draw_text(actor.given_name, "est piégé!")
          self_damage(actor, actor_sprite, actor_status, damage)
          wait(40)
        end
      end
      
      if actor.dead?
        return
      end
      
      # --------- -------------- --------------------
      #          Inspection des statuts
      # --------- -------------- --------------------
      if actor.status == 1 # Poison
        damage = actor.poison_effect
        draw_text(actor.given_name + " souffre", "du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 8 # Toxic
        damage = actor.toxic_effect
        draw_text(actor.given_name + " souffre", "gravement du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 3 #Burn
        damage = actor.burn_effect
        draw_text(actor.given_name + " souffre", "de ses brûlures.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      
      actor.confuse_decrement
      if actor.dead?
        return
      end
      
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------      
      for effect in actor.effect_list
        case effect
        when 0x6B # Nightmare / Cauchemar
          if actor.asleep?
            damage = actor.max_hp / 4
            draw_text(actor.given_name + " fait", "un chauchemar!")
            heal(actor, actor_sprite, actor_status, -damage)
            wait(20)
          else
            index = actor.effect_list.index(0x6B)
            actor.effect.delete_at(index)
          end
        when 0x6D # Curse
          damage = actor.max_hp / 4
          draw_text(actor.given_name + " est", "maudit!")
          heal(actor, actor_sprite, actor_status, -damage)
          wait(20)
        when 0x9F # Uproar / Brouhaha
          if actor.asleep?
            actor.cure
            draw_text(actor.given_name + " se réveille", "à cause du brouhaha!")
            wait(40)
          end
          if actor.frozen? #Fin de l'effet
            index = actor.effect_list.index(0x9F)
            actor.effect.delete_at(index)
          end
        when 0xAF # Taunt / Provoc
          index = actor.effect_list.index(0xAF)
          for skill in actor.skills_set
            if skill.power == 0 and actor.effect[index][1] > 0
              draw_text(skill.name + " est bloqué!")
              skill.disable
              wait(40)
            elsif actor.effect[index][1] == 0
              draw_text(skill.name + " est rétablit.")
              skill.enable
              wait(40)
            end
          end
        when 0xBB # Yawn / Baillement
          if actor.status == 0
            status_check(actor, 4)
            actor_status.refresh
          end
        end
      end
      
      if actor.dead?
        return
      end
      # --------- -------------- --------------------
      #                  Berry check
      # --------- -------------- --------------------  
      if Item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp
        draw_text(actor.given_name + " récupère un peu", "de vie avec " + Item.name(actor.item_hold) + ".")
        bonus = actor.max_hp / 16
        if bonus == 0
          bonus = 1
        end
        heal(actor, actor_sprite, actor_status, bonus)
        wait(40)
      end
    end
      
    # --------- -------------- --------------------
    #              Cycle individuel 2
    # --------- -------------- --------------------     
    def post_round_cycle_2(actor, enemy)
      # Redéfinition
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
      
      # Suppression du contrôle pour un pokémon mort
      if actor.dead?
        return
      end
      
      # --------- -------------- --------------------
      #         Programmation des capacités
      # --------- -------------- --------------------
      case actor.ability
      when 2 # Crachin / Drizzle (ab)
        if not($battle_var.rain?) # Pluie
          draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.")
          wait(40)
          animation = $data_animations[493]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_rain
      when 45 # Sable Volant / Sand stream (ab)
        if not($battle_var.sandstorm?) # Tempete Sable
          draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.")
          wait(40)
          animation = $data_animations[494]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 70 # Sècheresse / Drought (ab)
        if not($battle_var.sunny?) # Soleil
          draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.")
          wait(40)
          animation = $data_animations[492]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 3 # Speed Boost (ab)
        draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.")
        actor.change_spd(+1)
        stage_animation(actor_sprite, $data_animations[482])
        wait(40)
      when 22 # Intimidate (ab)
        if not(actor.ability_active)
          actor.ability_active = true
          draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".")
          enemy.change_atk(-1)
          stage_animation(enemy_sprite, $data_animations[479])
          wait(40)
        end
      when 59 # Forecast / Meteo (ab)
        if $battle_var.sunny? and not(actor.type_fire?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en FEU!")
          actor.ability_token = 2
          actor.form = 2
          update_sprite
          wait(40)
        elsif $battle_var.rain? and not(actor.type_water?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en EAU!")
          actor.ability_token = 3
          actor.form = 3
          update_sprite
          wait(40)
        elsif $battle_var.hail? and not(actor.type_ice?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en GLACE!")
          actor.ability_token = 6
          actor.form = 6
          update_sprite
          wait(40)
        elsif not(actor.type_normal?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en NORMAL!")
          actor.ability_token = 1
          actor.form = 0
          update_sprite
          wait(40)
        end
      end
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0x72 # Requiem / Perish Song
          index = actor.effect_list.index(0x72)
          number = actor.effect[index][1]
          if number > 0
            if number > 1
              string = "#{number.to_s} tours"
            elsif number == 1
              string = "#{number.to_s} tour"
            end
            draw_text("Plus que #{string}", "pour #{actor.given_name}...")
            wait(40)
          else
            draw_text("#{actor.given_name} est", "K.O. par REQUIEM!")
            damage = actor.hp
            heal(actor, actor_sprite, actor_status, -damage)
            wait(40)
          end
        end
      end
      
      # --------- -------------- --------------------
      #      Nettoyage des compteurs d'effets
      # --------- -------------- --------------------
      for effect in actor.effect
        case effect
        when [0x10, 0] # Reflet / Reflect
          draw_text("L'effet de REFLET est", "terminé.")
          wait(40)
        when [0x23, 0] # Light Screen 
          draw_text("L'effet de MUR LUMIERE est", "terminé.")
          wait(40)
        when [0x2E, 0] # Brume / Mist
          draw_text("La brume se dissipe.")
          wait(40)
        when [0x7C, 0] # Rune Protect / Safeguard
          draw_text("L'effet de RUNE PROTECT", "est terminé.")
          wait(40)
        end
      end
      
      if actor.dead?
        return
      end
    end
    
    
    
    #------------------------------------------------------------  
    # Items
    #------------------------------------------------------------     
    def actor_item_use # items à utiliser
      # Item déjà utilisé ie remplacé par 0
      if @item_id == 0
        return
      end
    end
    #------------------------------------------------------------  
    # Switch de pokémon
    #------------------------------------------------------------         
    def actor_pokemon_switch
      if @switch_id != -1
        if not(@actor.dead?)
          @actor_status.visible = true
        else
          @actor_status.visible = false
        end
        
        switch_effect(@actor, @enemy)
        
        if not(@actor.dead?)
          recall_pokemon
        end
        
        @battle_order = switch(@battle_order, 0, @switch_id)
        @actor = @party.actors[@battle_order[0]]
        @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
        @actor_status = Pokemon_Battle_Status.new(@actor, false)
        @actor_status.visible = false
        if not($battle_var.have_fought.include?(@actor.party_index))
          $battle_var.have_fought.push(@actor.party_index)
        end
        
        launch_pokemon
        @actor_status.visible = true
        @switch_id = -1
      end
    end
    
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy.dead?)
          @enemy_status.visible = true
        else
          @enemy_status.visible = false
        end
        
        switch_effect(@enemy, @actor)
        
        if not(@enemy.dead?)
          recall_enemy_pokemon
        end
        
        @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id)
        @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]]
        $data_pokedex[@enemy.id][0] = true
        @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
        @enemy_status = Pokemon_Battle_Status.new(@enemy, true)
        @enemy_status.visible = false
        
        launch_enemy_pokemon
        @enemy_status.visible = true
        @enemy_switch_id = -1
      end
    end
    
    #------------------------------------------------------------  
    # Fuite
    #------------------------------------------------------------           
    def run
      if run_able?(@actor, @enemy)
        $battle_var.run_count += 1
        @action_window.active = false
        @action_window.visible = false
        end_battle_flee
      else
        $battle_var.run_count += 1
        fail_flee
        @phase = 2
        @actor_action = 0
        $battle_var.action_id = 0
      end
    end
    
    def run_able?(runner, opponent)
      x = (Integer(opponent.spd/4) % 255)
      rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count))
      if not(flee_able(runner, opponent))
        return false
      end
      if opponent.spd <= runner.spd
        return true
      elsif x == 0
        return true
      elsif rate > 255
        return true
      elsif rand(256) <= rate
        return true
      else
        return false
      end
    end
    
    def run_enemy
      if run_able?(@enemy, @actor)
        end_battle_flee_enemy
      end
    end
    
    #------------------------------------------------------------  
    # Animations supplémentaires au combat
    #------------------------------------------------------------   
    # Défaites / KO
    #------------------------------------------------------------       
    def enemy_down
      # Si déjà vaincu
      if @enemy_sprite.zoom_y == 0
        return
      end
      # Sinon
      @enemy_sprite.oy = @enemy_sprite.bitmap.height
      @enemy_sprite.y += @enemy_sprite.bitmap.height / 2
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
      
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
      
      loop do
        @enemy_status.x -= 20
        [url=mailto:#@enemy_sprite.zoom_y]#@enemy_sprite.zoom_y[/url] -= 0.05
        @enemy_sprite.y += 8
        @enemy_sprite.opacity -= 20
        Graphics.update
        #if @enemy_sprite.zoom_y <= 0.0
        if @enemy_sprite.y >= 348
          @enemy_sprite.zoom_y = 0
          break
        end
      end
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.y -= @enemy_sprite.bitmap.height
      draw_text(@enemy.given_name, "est K.O.!")
      wait(40)
    end
    
    def actor_down
      # Si déjà vaincu
      #if @actor_sprite.zoom_y <= 0.0
      if @actor_sprite.y >= 576
        return
      end
      # Sinon
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
      loop do
        @actor_status.x += 20
        [url=mailto:#@actor_sprite.zoom_y]#@actor_sprite.zoom_y[/url] -= 0.05
        @actor_sprite.y += 12
        @actor_sprite.opacity -= 20
        Graphics.update
        #if @actor_sprite.zoom_y <= 0.0
        if @actor_sprite.y >= 576
          break
        end
      end
      
      draw_text(@actor.given_name, "est K.O.!")
      wait(40)
    end
    
    #------------------------------------------------------------       
    # Attaques
    #------------------------------------------------------------
    def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite)
      if miss
        wait(40)

        draw_text("Mais cela échoue!")
        wait(40)
        return
      end
      
      if user == @enemy
        reverse = true
      else
        reverse = false
      end
      
      efficiency = info[2]
      if hit and efficiency != -2
        # Animation utilisateur
        animation_user = $data_animations[user_skill.user_anim_id]
        user_sprite.register_position
        
        if animation_user != nil
          user_sprite.animation(animation_user, true, reverse)
          until not(user_sprite.effect?)
            user_sprite.update
            Graphics.update
          end
        end
        
        user_sprite.reset_position
        
        user_sprite.update
        Graphics.update
        
        # Animation Cible
        animation_target = $data_animations[user_skill.target_anim_id]
        target_sprite.register_position
        
        if animation_target != nil
          target_sprite.animation(animation_target, true, reverse)
          until not(target_sprite.effect?)
            target_sprite.update
            Graphics.update
          end
        end
        
        target_sprite.reset_position
        
        target_sprite.update
        Graphics.update
        
        if info[0] > 0
          case efficiency
          when 0 # Normal
            Audio.se_play("Audio/SE/Hit.wav", 100)
            blink(target_sprite, 3, 3)
          when 1 # Super efficace
            Audio.se_play("Audio/SE/Hitplus.wav", 100)
            blink(target_sprite, 2, 5)
          when -1 # Peu efficace
            Audio.se_play("Audio/SE/Hitlow.wav", 100)
            blink(target_sprite, 4, 2)
          end
        end
      elsif not(hit)
        wait(40)
        draw_text(user.given_name, "rate son attaque!")
        wait(40)
      end
    end
    
    def blink(sprite, frame = 4, number = 3)
      for i in 0..number
        wait(frame)
        sprite.opacity = 0
        Graphics.update
        wait(frame)
        sprite.opacity = 255
        Graphics.update
      end
    end
    
    def post_attack(info, damage, power)
      efficiency = info[2]
      if damage == 0 and (efficiency != -2 or power == 0)
        return
      end
      critical = info[1]
      if critical  and efficiency != -2 #critical_hit
        draw_text("Coup critique!")
        wait(40)
      end
      case efficiency
      when 1
        draw_text("C'est super efficace!")
        wait(40)
      when -1
        draw_text("Ce n'est pas très efficace...")
        wait(40)
      when -2
        draw_text("Ca ne l'affecte pas...")
        wait(40)
      end
    end
    
    def faint_check(user = nil)
      if user == nil
        faint_check(@actor)
        faint_check(@enemy)
      end
      if user == @actor and user.dead?
        actor_down
      end
      if user == @enemy and user.dead?
        enemy_down
      end
    end
        
    
    #------------------------------------------------------------       
    # Statut et stats
    #------------------------------------------------------------    
    def status_animation(sprite, status)
      animation = $data_animations[469 + status]
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          break
        end
      end
    end
    
    def stage_animation(sprite, animation)
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          wait(20)
          break
        end
      end
    end
    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
    def type_string(type)
      case type
      when 0
        return "???"
      when 1
        return "NORMAL"
      when 2
        return "FEU"
      when 3
        return "EAU"
      when 4
        return "ELECTRIK"
      when 5
        return "PLANTE"
      when 6
        return "GLACE"
      when 7
        return "COMBAT"
      when 8
        return "POISON"
      when 9
        return "SOL"
      when 10
        return "VOL"
      when 11
        return "PSY"
      when 12
        return "INSECTE"
      when 13
        return "ROCHE"
      when 14
        return "SPECTRE"
      when 15
        return "DRAGON"
      when 16
        return "ACIER"
      when 17
        return "TENEBRES"
      end
    end
    
    
    # Changement (ou pas) de statut
    def status_string(actor, status)
      string = actor.given_name
      case status
      when -1
        draw_text(string + " est", "déjà empoisonné!")
        wait(40)
      when -2
        draw_text(string + " est", "déjà paralysé!")
        wait(40)
      when -3
        draw_text(string,"brûle déjà!")
        wait(40)
      when -4
        draw_text(string,"dort déjà!")
        wait(40)
      when -5
        draw_text(string, "est déjà gelé!")
        wait(40)
      when -6
        draw_text(string, "est déjà confus!")
        wait(40)
      when -8
        draw_text(string + " est", "déjà gravement empoisonné!")
        wait(40)
      when 1
        draw_text(string, "est empoisonné!")
        wait(40)
      when 2
        draw_text(string, "est paralysé!")
        wait(40)
      when 3
        draw_text(string,"brûle!")
        wait(40)
      when 4
        draw_text(string,"s'endort!")
        wait(40)
      when 5
        draw_text(string,"gèle!")
        wait(40)
      when 6
        draw_text("Cela rend " + string, "confus!")
        wait(40)
      when 7
        draw_text(string, "est appeuré!")
        wait(40)
      when 8
        draw_text(string + " est", "gravement empoisonné!")
        wait(40)
      end
    end
    
    # S'occupe du texte et de l'animation
    def raise_stat(string, actor, n = 0)
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
      
      if n == 1
        text = actor.given_name + " augmente!"
      elsif n > 1
        text = actor.given_name + " augmente beaucoup!"
      end
      
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[478])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[480])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[484])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[486])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[482])
        when "EVA"
          draw_text("Ah, Esquive de",text)        
          stage_animation(actor_sprite, $data_animations[488])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[490])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!")        
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
    
    def reduce_stat(string, actor, n = true, self_inflicted = false)
      # Mist/Brume
      if actor.effect_list.include?(0x2E)
        draw_text(actor.given_name + " est", "protégé par la brume!")
        wait(40)
        return
      end
      # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab)
      if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted)
        draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!")
        wait(40)
        return
      end
      # Keen Eye / Regard Vif (ab)
      if actor.ability == 51 and string == "ACC"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!")
        wait(40)
        return
      end
      # Hyper Cutter (ab)
      if actor.ability == 52 and string == "ATK"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!")
        wait(40)
        return
      end
      
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
      
      if n == -1
        text = actor.given_name + " baisse!"
      elsif n < -1
        text = actor.given_name + " baisse beaucoup!"
      end
      
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[479])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[481])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[485])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[487])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[483])
        when "EVA"
          draw_text("Ah, Esquive de",text)        
          stage_animation(actor_sprite, $data_animations[489])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[491])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!")        
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
    
    #------------------------------------------------------------       
    # Appel / Rappel de Pokémon
    #------------------------------------------------------------           
    def recall_pokemon
      draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!")
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.y = 336
      @actor_sprite.x = 153
      @actor_sprite.color = @actor.ball_color
      @actor_sprite.color.alpha = 0
      
      until @actor_sprite.color.alpha >= 255
        @flash_sprite.opacity += 25
        @actor_sprite.color.alpha += 25
        Graphics.update
      end
      
      Audio.se_play("Audio/SE/Pokeopen.wav")
      loop do
        @actor_status.x += 20
        @actor_sprite.opacity -= 25
        @actor_sprite.color.alpha += 25
        @actor_sprite.zoom_x -= 0.1
        @actor_sprite.zoom_y -= 0.1
        @flash_sprite.opacity -= 25
        Graphics.update
        if @actor_status.x >= 711
          @actor_status.visible = false
          @actor_status.x = 711
          @actor_sprite.color.alpha = 0
          @actor_sprite.opacity = 0
          Graphics.update
          break
        end
      end
    end
    
    def launch_pokemon
      @actor_sprite.x = 153
      @actor_sprite.y = 336
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.zoom_x = 0
      @actor_sprite.zoom_y = 0
      
      #if @actor_party_status.active
      #  @actor_party_status.x = 0
      #  @actor_party_status.visible = true
      #end
      
      name = @actor.given_name
      text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)]
      draw_text(text)
      
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = -44
      @ball_sprite.y = 324
      @ball_sprite.z = @z_level + 14
      
      t = 0
      pi = 3.14
      
      loop do
        t += 1
        @ball_sprite.x += 5
        @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        #if @actor_party_status.active
        #  @actor_party_status.x -= 80
        #end
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          #if @actor_party_status.active
          #  @actor_party_status.x = 0
          #  @actor_party_status.visible = false
          #end
          break
        end
      end
      @actor_sprite.opacity = 0
      @actor_sprite.color = @actor.ball_color
      
      until @actor_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @actor_sprite.zoom_x += 0.1
        @actor_sprite.zoom_y += 0.1
        @actor_sprite.opacity += 25
        Graphics.update
      end
      
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
      
      @actor_sprite.zoom_x = 1
      @actor_sprite.zoom_y = 1
      @actor_sprite.opacity = 255
      
      @actor_status.x = 711
      @actor_status.visible = true
      
      if @actor.shiny
        animation = $data_animations[496]
        @actor_sprite.animation(animation, true)
      end
      
      until @actor_status.x == 311
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @actor_status.x -= 20
        @actor_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @actor_sprite.update
        Graphics.update
      end
      
      until not(@actor_sprite.effect?)
        @actor_sprite.update
        Graphics.update
      end
      
      @actor_status.x = 311
      @actor_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
    
    def launch_enemy_pokemon
      @enemy_sprite.x = 464
      @enemy_sprite.y = 104
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.zoom_x = 0
      @enemy_sprite.zoom_y = 0
      
      string = Trainer_Info.type(@trainer_id) + " " + Trainer_Info.name(@trainer_id)
      draw_text(@enemy.name + " est envoyé", "par " + string + "!")
      
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = 663
      @ball_sprite.y = 104
      @ball_sprite.z = @z_level + 14
      
      t = 0
      pi = 3.14
      
      loop do
        t += 1
        @ball_sprite.x -= 5
        @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          break
        end
      end
      @enemy_sprite.opacity = 0
      @enemy_sprite.color = @enemy.ball_color
      
      until @enemy_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @enemy_sprite.zoom_x += 0.08
        @enemy_sprite.zoom_y += 0.08
        @enemy_sprite.opacity += 25
        Graphics.update
      end
      
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
      
      @enemy_sprite.zoom_x = 1
      @enemy_sprite.zoom_y = 1
      @enemy_sprite.opacity = 255
      
      @enemy_status.x = -377
      @enemy_status.visible = true
      
      if @enemy.shiny
        animation = $data_animations[496]
        @enemy_sprite.animation(animation, true)
      end
      
      until @enemy_status.x == 23
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @enemy_status.x += 20
        @enemy_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @enemy_sprite.update
        Graphics.update
      end
      
      until not(@enemy_sprite.effect?)
        @enemy_sprite.update
        Graphics.update
      end
      
      @enemy_sprite.x = 464
      @enemy_status.x = 23
      @enemy_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
    
    #------------------------------------------------------------  
    # Fin de combat
    #------------------------------------------------------------      
    def end_battle(result = 0)      
      # Reset des variables et effets
      $battle_var.reset
      @actor.skill_effect_reset
      @actor.reset_stat_stage
      @actor.cure_state
      @actor.ability_active = false
      @enemy.skill_effect_reset
      @enemy.reset_stat_stage
      @enemy.cure_state
      @enemy.ability_active = false
      # -----------------------------------
      Audio.me_stop
      wait(10)
      $game_system.bgm_play($game_temp.map_bgm)
      wait(10)
      Graphics.freeze
      # -----------------------------------
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      # Défaite
      $scene = Scene_Map.new
    end
    
    def end_battle_flee(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@actor.given_name, "est expulsé du combat!")
        loop do
          if @actor_sprite.x > -160
            @actor_sprite.x -= 20
          end
          Graphics.update
          Input.update
          if @actor_sprite.x <= -160
            wait(40)
            break
          end
        end
      else
        draw_text("Vous prenez la fuite!")
        wait(40)
      end
      end_battle(1)
    end
    
    def fail_flee
      draw_text("Vous ne pouvez pas","vous enfuir!")
      wait(40)
    end
    
    def end_battle_flee_enemy(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@enemy.given_name, "est expulsé du combat!")
      else
        draw_text(@enemy.given_name + " s'échappe!")
      end
      loop do
        if @enemy_sprite.x < 800
          @enemy_sprite.x += 20
        end
        Graphics.update
        Input.update
        if @enemy_sprite.x >= 800
          wait(40)
          break
        end
      end
      end_battle(1)
    end
    
    def end_battle_defeat
      $battle_var.result_defeat = true
      draw_text("Tous vos Pokémons", "ont été vaincus!")
      wait(40)
      $pokemon_party.money /= 2
      if not(@lose)
        if $game_variables[1] == 0
          print("Réglez votre point de retour!")
        else
          $game_map.setup($game_variables[1])
          $game_map.display_x = $game_variables[2]
          $game_map.display_y = $game_variables[3]
          $game_player.moveto($game_variables[2], $game_variables[3])
        end
        $game_temp.common_event_id = 2
      end
      $game_temp.map_bgm = $game_map.bgm
      end_battle(2)
    end
    
    def draw_choice
      @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig)
      @command.x = 517
      @command.y = 215
      loop do
        Graphics.update
        Input.update
        @command.update
        if Input.trigger?(Input::C) and @command.index == 0
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return true
        end
        if Input.trigger?(Input::C) and @command.index == 1
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return false
        end
      end
    end
  end
  
  #------------------------------------------------------------  
  # Fenêtre de statut
  #------------------------------------------------------------  
class Pokemon_Battle_Status < Window_Base 
    def initialize(pokemon, enemy, z_level = 15) 
      @enemy = enemy # True / False 
      if @enemy 
        super(23,0,332,116) 
      else 
        super(311,203,341,140) 
      end 
      self.contents = Bitmap.new(width - 32, height - 32) 
      self.contents.font.name = $fontsmall 
      self.contents.font.size = $fontsmallsize 
      # self.contents.font.bold = true 
      self.opacity = 0 
      self.z = z_level 
      @pokemon = pokemon 
      refresh 
    end 
    
    def refresh 
      self.contents.clear 
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f 
      normal_color = Color.new(248,248,248,255) 
      if @enemy 
        src_rect = Rect.new(0, 0, 300, 84) 
        bitmap = RPG::Cache.picture("battle_sprite1.png") 
        self.contents.blt(0, 0, bitmap, src_rect, 255) 
        draw_hp_bar(69,45, level) 
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color) 
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) 
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3 
        draw_gender(242 - width_text, 15, @pokemon.gender) 
        if $data_pokedex[@pokemon.id][1] 
          src_rect = Rect.new(0, 0, 21, 21) 
          bitmap = RPG::Cache.picture("ballbattlestatus.png") 
          self.contents.blt(27, 45, bitmap, src_rect, 255) 
        end 
        if @pokemon.status != 0 
          string = "stat_battle" + @pokemon.status.to_s + ".png" 
          src_rect = Rect.new(0, 0, 60, 24) 
          bitmap = RPG::Cache.picture(string) 
          self.contents.blt(20, 47, bitmap, src_rect, 255) 
        end 
      else 
        src_rect = Rect.new(0, 0, 309, 108) 
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe 
        self.contents.blt(0, 0, bitmap, src_rect, 255) 
        draw_hp_bar(93,45, level) 
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color) 
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) 
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp 
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color) 
        if @pokemon.level < 100 
          level = @pokemon.next_exp.to_f / 
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f 
        else 
          level = 0 
        end 
        draw_exp_bar(46, 99, 1.0 - level, 232) 
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3 
        draw_gender(268 - width_text, 15, @pokemon.gender) 
        if @pokemon.status != 0 
          string = "stat_battle" + @pokemon.status.to_s + ".png" 
          src_rect = Rect.new(0, 0, 60, 24) 
          bitmap = RPG::Cache.picture(string) 
          self.contents.blt(44, 68, bitmap, src_rect, 255) 
        end 
      end 
    end 
    
    def exp_refresh 
      level = @pokemon.next_exp.to_f / 
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f 
      draw_exp_bar(46, 99, 1.0 - level, 232) 
    end 
      
    def damage_refresh(info) 
      damage = info[0] 
      if damage == 0 
        return 
      end 
      
      for i in 1..damage 
        @pokemon.remove_hp(1) 
        Graphics.update 
        Graphics.update 
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead? 
          break 
        end 
      end 
    end 
    
    def dispose 
      super 
    end 
    
    def draw_hp_bar(x, y, level, small = false) 
      src_rect = Rect.new(0, 0, 198, 24) 
      bitmap = RPG::Cache.picture("hpbar.png") 
      if small 
        bitmap = RPG::Cache.picture("hpbarsmall.png") 
      end 
      self.contents.blt(x, y, bitmap, src_rect, 255) 
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3) 
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6) 
      if small 
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3) 
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6) 
      end 
      
      if level < 0.1 
        color1 = Color.new(248, 248, 248, 255) 
        color2 = Color.new(248, 64, 16, 255) 
      elsif level >= 0.1 and level < 0.5 
        color1 = Color.new(248, 248, 248, 255) 
        color2 = Color.new(232, 168, 50, 255) 
      else 
        color1 = Color.new(248, 248, 248, 255) 
        color2 = Color.new(24, 192, 32, 255) 
      end 
      self.contents.fill_rect(rect1, color1) 
      self.contents.fill_rect(rect2, color2) 
    end 
    
    def draw_exp_bar(x, y, level, width) 
      rect1 = Rect.new(x, y, level*232.to_i, 3) 
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255)) 
    end 
    
    def draw_gender(x, y, gender) 
      if gender == 1 
        rect = Rect.new(0, 0, 18, 33) 
        bitmap = RPG::Cache.picture("Maleb.png") 
        self.contents.blt(x, y, bitmap, rect, 255) 
      end 
      if gender == 2 
        rect = Rect.new(0, 0, 18, 33) 
        bitmap = RPG::Cache.picture("Femaleb.png") 
        self.contents.blt(x, y, bitmap, rect, 255)        
      end 
    end 
  end 

  #------------------------------------------------------------  
  # Fenêtre de statut de l'équipe 
  #------------------------------------------------------------  
  class Pokemon_Battle_Party_Status < Window_Base 
    attr_accessor :battle_order 
    
    def initialize(party, order, enemy, z_level = 15) 
      @enemy = enemy # True / False 
      @battle_order = order 
      if @enemy 
        super(0-16,63-16,315+32,42+32) 
      else 
        super(325-16, 261-16, 315+32,42+32) 
      end 
      self.contents = Bitmap.new(width - 32, height - 32) 
      self.opacity = 0 
      self.z = z_level 
      @party = party 
      refresh 
    end 
    
    def refresh 
      self.contents.clear 
      src_rect = Rect.new(0, 0, 315, 42) 
      if @enemy 
        bitmap = RPG::Cache.picture("partystatusenemy.png") 
      else 
        bitmap = RPG::Cache.picture("partystatus.png") 
      end 
      self.contents.blt(0, 0, bitmap, src_rect, 255) 
      
      src_rect = Rect.new(0, 0, 30, 30) 
      if @enemy 
        ball_x = 173 
        coeff = -2 
        else 
        ball_x = 52 
        coeff = 2 
        end 
      
for i in [url=mailto:0..@party.size-1]0..@party.size-1[/url] 
        bitmap = RPG::Cache.picture("ballpartystatus.png") 
        if @party.actors[@battle_order[i]].dead? 
          bitmap = RPG::Cache.picture("ballpartystatusko.png") 
        end 
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255) 
      end 
    
    def reset_position 
      if @enemy 
        self.x = -16 
      else 
        self.x = 325-16 
      end 
      refresh 
    end 
  end 
  class Pokemon_Battle_Variable
    attr_accessor :weather
    attr_accessor :actor_last_used
    attr_accessor :enemy_last_used
    attr_accessor :battle_order
    attr_accessor :enemy_battle_order
    attr_accessor :in_battle
    attr_accessor :actor_last_taken_damage
    attr_accessor :enemy_last_taken_damage
    attr_accessor :have_fought #liste des pokémons ayant participé par leur index
    attr_accessor :enemy_party
    attr_accessor :action_id
    attr_accessor :window_index
    attr_accessor :result_flee
    attr_accessor :result_win
    attr_accessor :result_defeat
    attr_accessor :last_index
    attr_accessor :round
    attr_accessor :run_count
    attr_accessor :money
    
    # Weather: [ catégorie, nombre de tours ]
    # catégorie: 0: Normal, 1: Pluie, 2: Ensoleillé, 
    #            3: Tempête de Sable, 4: Grêle
    
    def initialize
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @result_flee = false
      @result_win = false
      @result_defeat = false
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
    
    def reset
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
    
    def reset_weather
      @weather = [0, 0]
    end
    
    def set_rain(duration = -1)
      @weather = [1, duration]
    end
    
    def rain?
      if @weather[0] == 1
        return true
      else
        return false
      end
    end
    
    def set_sunny(duration = -1)
      @weather = [2, duration]
    end
    
    def sunny?
      if @weather[0] == 2
        return true
      else
        return false
      end
    end
    
    def sandstorm?
      if @weather[0] == 3
        return true
      else
        return false
      end
    end
    
    def set_sandstorm(duration = -1)
      @weather = [3, duration]
    end
    
    def hail?
      if @weather[0] == 4
        return true
      else
        return false
      end
    end
    
    def set_hail(duration = -1)
      @weather = [4, duration]
    end
    
    def battle_end?
      if @result_flee or @result_win or @result_defeat
        return true
      else
        return false
      end
    end
    
    def add_money(amount)
      if @money == nil
        @money = 0
      end
      @money += amount
    end 
    
  end 
  
end 






EDIT : ENTRE BALISES SPOILER BON SANG.

Posté par Pαlвσlѕку le 17 Sep - 11:07 (2008)
Tu vois ce morceau vers la fin :

Spoiler


Code:
 for i in [url=mailto:0..@party.size-1]0..@party.size-1[/url] 
        bitmap = RPG::Cache.picture("ballpartystatus.png") 
        if @party.actors[@battle_order[i]].dead? 
          bitmap = RPG::Cache.picture("ballpartystatusko.png") 
        end 
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255) 
      end      


Tu le remplace par ça :
Spoiler
for i in 0..@party.size  
        bitmap = RPG::Cache.picture("ballpartystatus.png") 
        if @party.actors[@battle_order[i-1]].dead? 
          bitmap = RPG::Cache.picture("ballpartystatusko.png") 
        end 
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255) 
      end 

Posté par naruto66620 le 17 Sep - 11:56 (2008)
j'ai un mieux truck j'ai remplacer les image parce se qui faut et j'ai remplacer ton script par celuii que j'ai crée avec les même chose que tois sauf en réalisent ressource donc sa va plus vite Lordork chez mémé

Posté par Pαlвσlѕку le 17 Sep - 12:04 (2008)
Citation:
sauf en réalisent ressource donc sa va plus vite 

Je n'ai pas compris ce morceau de phrase ??

Posté par Aten974 le 17 Sep - 13:53 (2008)
Je n'ai rien compris du tout -_-

Quelqu'un de gentil et aimable pourrait me donner le script entier, qui marche et entre balise de code s.v.p. ? car je ne m'y retrouvez plus :?

Posté par Pαlвσlѕку le 17 Sep - 15:16 (2008)
Je ne peux pas le mettre entre balise car après il y a des trucs comme ça :


Code:
[url]Ceci un un bug[/url] 





Donc pas bon du tout.

Posté par Aten974 le 17 Sep - 15:31 (2008)
Pas trop compris là ...

Code:
Les balises de codes c'est ça ...


Je ne te prends pas pour un c** tkt ! ^^'

Posté par Pαlвσlѕку le 17 Sep - 15:58 (2008)
Tu as compris maintenant ??

Posté par Aten974 le 17 Sep - 16:30 (2008)
ben, qu'est-ce qui est désagréable ?

Posté par <€d> le 17 Sep - 19:08 (2008)
Il bug toujours :( :cry:

Posté par naruto66620 le 17 Sep - 20:59 (2008)
et bien enleve tous remet le normale tu afface femel male et tous tu fait les même avec femmelb
 et maleb

puis tu copie coller quoi facile je te dirait tous sa plus précis demain Bouche extensiblek:

Posté par Happy le 18 Sep - 01:02 (2008)
Hein?Je suis nargué moi^^.

Posté par Pαlвσlѕку le 18 Sep - 06:18 (2008)
Citation:
et bien enleve tous remet le normale tu afface femel male et tous tu fait les même avec femmelb  et maleb

puis tu copie coller quoi facile je te dirait tous sa plus précis demain Bouche extensiblek:


C'est quoi ces phrases ?? Je comprend rien du tout à ce que tu as écrit. J'ai corrigé le bug qu'avait mon script (je ne sais pas d'où il venait mais bon...) Sinon celui qui me dit qu'il marche pas... Je sais pas qu'est ce que je vais lui faire...

Posté par naruto66620 le 18 Sep - 07:39 (2008)
Voilà tous :

donc dans picture les picture battle_sprite1.png et battle_sprite2png [les ancien a remplacer contre les platine]


Aprés remplacer Female.png  et Male.pngpar


et aussi vous les enregistrer encore une fois en Femaleb.png et en Maleb.png
donc aprés encore dans picture vous changer l'ancien hpbar par celle si :
Aprés ajouter hpbar_team

encore picture changer les ancien party staue par sa
partystatus





partystatusenemy


Aprés

ballpartystatus





ballpartystatusko





ballbattlestatus





dummy1
(image facultative, à placer dans le dossier "Battlebacks")





statut_battle1




statut_battle2




statut_battle3




statut_battle4




statut_battle5


Attention les statut battle1/2/3/4/5
doivent être mis a la pace des stat1/2/3/4/5

donc pour ma part j'ai fait se systéme tous marche je les tester avec la v 0.7 2béta et avec la v psp4

Donc si vous avez un probléme n'hésiter pas a m'envoyer de mp

si la barre s'affiche pas la barre de hp et bien :

Dans le script "Pokemon_Party_Menu", remplacer à la ligne 795  :

bitmap = RPG::Cache.picture("hpbar.png")

par :

bitmap = RPG::Cache.picture("hpbar_team.png")


Donc vous fait tous sa sans oublier de changer bitmap = RPG::Cache.picture("hpbar.png")

par :

bitmap = RPG::Cache.picture("hpbar_team.png")


Important et logiquement sa devraient bien marcher 8)

Posté par Pαlвσlѕку le 18 Sep - 19:16 (2008)
Bien expliquer, mais toujours des problèmes pour l'orthographe.

PS: Le script va subir une modification dans l'avenir !!

Posté par <€d> le 18 Sep - 19:57 (2008)
Il bug toujours ... :cry: :cry: :cry: :cry: :cry: :cry:

Posté par Pαlвσlѕку le 18 Sep - 19:59 (2008)
C'est quoi ton bug ??

Posté par Happy le 18 Sep - 23:38 (2008)
Moi j'ai esseillé se que vous m'avez dis dans la page 1 et j'avais un bug dans Battle Core 1,mais bon,j'attend la miseà jour dePSP4G,vous savez pour quand elle est?

Posté par Pαlвσlѕку le 19 Sep - 06:10 (2008)
Cela ne m'aide pas beaucoup, c'est quelle ligne qui bug (et montre moi les précédentes et les suivantes)

Je ne sais pas quand est la prochaine mise à jour de PSP4G, demande à quelqu'un d'autre.

Posté par naruto66620 le 19 Sep - 07:46 (2008)
ne pas modifier le script surtout sauf

Dans le script "Pokemon_Party_Menu", remplacer à la ligne 795  :


bitmap = RPG::Cache.picture("hpbar.png")

par :

bitmap = RPG::Cache.picture("hpbar_team.png")


aprés tu ne change pu rien tu mais pas le new sript de la 1er parge surtout pas !

ceci est pour Happy et <€d>

Posté par Happy le 19 Sep - 17:54 (2008)
On utilise pas PSP07,mais bon pour faire simple on remplace tout simplement les image du jeu par celles que vous nous avez donné c'est tout^^.
Pas de bitmap = RPG::Cache.picture("hpbar.png")à la ligne 795.
MAIS je l'ai vu plus haut ou plus bas par approt à la Ligne 795 donc j'ai modifier par hpbar team comme vous avez dit,j'ai bien mis l'image HP bar team dans picture,et pour l'instant ça va,donc maintenant les autres images...

Posté par Pαlвσlѕку le 19 Sep - 17:57 (2008)
Appuye sur CTRL + F quand tu es dans le script et insére la ligne du script dans la casse de la fenêtre et alors tu le trouve.

PS : Entre les 2 versions de PSP, l'emplacement des lignes changent.

Posté par Happy le 19 Sep - 18:09 (2008)
Ok merci palbolsky,mais je crois que j'ai midif mon battle core 1,enfin peutetre quelqu'un peut me mettre en balise code pour que je le copie dans ma partit?
Merci^^
Bon,alors j'ai testé,et j'ai vu que pour les partystatut,que les pokéball ne sont pas bien dans les rond,que pour la HP Bar,que l'énergie dépace...et pour l'expérience aussi ><

Posté par Pαlвσlѕку le 19 Sep - 18:13 (2008)
Voilà le code entre balise :

script

Code:

class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(248,248,248,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(242 - width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(20, 47, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(46, 99, 1.0 - level, 232)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(268 - width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(44, 68, bitmap, src_rect, 255)
        end
      end
    end
   
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(46, 99, 1.0 - level, 232)
    end
     
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
     
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
   
    def dispose
      super
    end
   
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3)
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3)
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6)
      end
     
      if level < 0.1
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(248, 64, 16, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(232, 168, 50, 255)
      else
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(24, 192, 32, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
   
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*232.to_i, 3)
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255))
    end
   
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)       
      end
    end
  end


  #------------------------------------------------------------ 
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------ 
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
   
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
   
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
     
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
     
      for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
   
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end


Posté par Happy le 19 Sep - 18:33 (2008)
Merci palbolsky,tu es toujouslà, ce qui n'est pas mon cas,je dois aller en cour^^
Aller a+ et merci pour le code Clin d'œil foireux
Edit : Heu c'est normal qu'il soit petit comme sa le code?Comparé à se que j'ai sur ma partie Oo?

Posté par Pαlвσlѕку le 19 Sep - 18:37 (2008)
Ce n'est qu'un morceau car le vrai il fait 3000 lignes, mais celui là n'étant qu'un morceau, ne fais que 200 lignes. (voir 1er post pour savoir où il faut le placer)

PS: Tu vas en cours à 19h30 du soir, t'es pas normal toi^^

Posté par Happy le 19 Sep - 18:40 (2008)
Non où j'habite il est 13H40^^
Mais bon je ne sais pas si j'ai modifier mon script d'origine battle core 1,mais en tout cas je n'ai pas de bug à partir de la ligne 2421^^
Allé j'y vais.

Posté par Pαlвσlѕку le 19 Sep - 18:54 (2008)
Utilise la fonction rechercher. (si tu as la version v0.5, regarde vers la ligne 2350)

PS: Tu es canadien ??

Posté par Jordan le 19 Sep - 19:05 (2008)
bon, j'ai besoin de renseignements:
est ce que le script marche CORRECTEMENT?

Posté par Pαlвσlѕку le 19 Sep - 19:20 (2008)
Sur mon ordinateur, aucun problème mais sur les autres je sais pas pourquoi mais ça ne marche pas très bien.

Posté par Jordan le 19 Sep - 19:51 (2008)
bon je vais tester!

Posté par Jordan le 19 Sep - 20:15 (2008)
SUR ET CERTAINS JE L'UTILISE! d'ailleurs j'ai trouvé d'ou viens le bug et je l'ai reparé héhéhéhé!
vous voulez savoir? supliez moi!










nan c'est pas vrai je dec, le bug est à la ligne 2545, ou il y a     if @party.actors[@battle_order[i-]].dead?
remplacez le par        if @party.actors[@battle_order[i-1]].dead?
hoooo ça marche!

Posté par Aten974 le 19 Sep - 21:05 (2008)
Tu ne peux pas donner le script entier stp ?
Marche toujours pas --'

Posté par Jordan le 19 Sep - 21:08 (2008)
il marche pas ou tu veux pas chercher?


Spoiler
#==============================================================================
# ■ Pokemon_Battle_Core
# Pokemon Script Project - Krosk
# 20/07/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Système de Combat - Squelette général
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé, 8: Toxic
# @confuse (6), @flinch (7)
#-----------------------------------------------------------------------------
# 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
# 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# $battle_var.action_id
#   0 : Phase de Sélection
#   1 : Sélection Item
#   2 : Switch Pokémon
#   4 : Switch Fin de Tour
#-----------------------------------------------------------------------------

module POKEMON_S
  #------------------------------------------------------------ 
  # Pokemon_Battle_Core
  #   noyau possédant les fonctions communes aux combats sauvages/dresseurs
  #------------------------------------------------------------ 
  #------------------------------------------------------------ 
  # Fonctions à définir à l'extérieur
  #   initialize
  #   pre_battle_animation
  #   enemy_skill_decision
  #   end_battle_check
  #   actor_item_use
  #   catch_pokemon
  #   run_able?
  #   end_battle_victory
  #------------------------------------------------------------ 
  class Pokemon_Battle_Core
    attr_accessor :z_level
    attr_accessor :actor_status
    attr_accessor :actor
    attr_accessor :actor_sprite
   
    #------------------------------------------------------------ 
    # ------------------- Squelette Général ---------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # main
    #------------------------------------------------------------
    def main
      # Pré-création des Sprites
      # Fond
      if @battleback_name != ""
        @battleback_name = $game_map.battleback_name + ".png"
        @ground_name = "ground" + $game_map.battleback_name + ".png"
      else
        print("Attention, réglez le BattleBack du Tileset.")
        @battleback_name = "battle0.png"
        @ground_name = "groundbattle0.png"
      end
      @background = Sprite.new
      @background.z = @z_level
     
      # Fond du message
      @message_background = Sprite.new
      @message_background.y = 336
      @message_background.z = @z_level + 19
     
      # Sprite de flash
      @flash_sprite = Sprite.new
      @flash_sprite.bitmap = RPG::Cache.picture("black.png")
      @flash_sprite.color = Color.new(255,255,255)
      @flash_sprite.opacity = 0
      @flash_sprite.z = @z_level + 13
     
      # Fenetre de texte
      @text_window = Window_Base.new(4, 340, 632, 136)
      @text_window.opacity = 0
      @text_window.z = @z_level + 20
      @text_window.contents = Bitmap.new(600 + 32, 104 + 32)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsizebig
     
      # Fenetre d'action
      s1 = "ATTAQUE"
      s2 = "SAC"
      s3 = "POKéMON"
      s4 = "FUITE"
     
      @action_window = Window_Command.new(320, [s1, s2, s3, s4], $fontsizebig, 2, 56)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
     
      # Viewport
      battle_viewport = Viewport.new(0, 0, 640, 336)
      battle_viewport.z = @z_level + 15
     
      # Sprites acteurs # Positions par défaut des centres
      @enemy_sprite = RPG::Sprite.new(battle_viewport)
      @enemy_sprite.x = 464
      @enemy_sprite.y = 104
      @enemy_sprite.z = @z_level + 15
      @enemy_ground = RPG::Sprite.new
      @enemy_ground.x = 464
      @enemy_ground.y = 149
      @enemy_ground.z = @z_level + 11
      @actor_sprite = RPG::Sprite.new(battle_viewport)
      @actor_sprite.x = 153
      @actor_sprite.y = 336
      @actor_sprite.z = @z_level + 15
      @actor_ground = RPG::Sprite.new
      @actor_ground.x = 153
      @actor_ground.y = 386
      @actor_ground.z = @z_level + 11
     
      # Création fenêtre de statut
      @actor_status = Pokemon_Battle_Status.new(@actor, false, @z_level + 15)
      @enemy_status = Pokemon_Battle_Status.new(@enemy, true, @z_level + 15)
      @actor_status.visible = false
      @enemy_status.visible = false
      @enemy_caught = false
     
      @actor_party_status = Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10)
      @enemy_party_status = Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10)
      @actor_party_status.visible = false
      @enemy_party_status.visible = false
      # note: .active = true activera les animations liées à ces fenêtres
      @actor_party_status.active = false
      @enemy_party_status.active = false
     
      # Lancement des animations
      pre_battle_transition
      pre_battle_animation
     
      # Effets pré-premier round
      post_round_effect
     
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
     
      # Fin de scene
      Graphics.freeze
      @background.dispose
      @message_background.dispose
      @flash_sprite.dispose
      @text_window.dispose
      @action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
      end
      if @ball_sprite != nil
        @ball_sprite.dispose
      end
      @enemy_sprite.dispose
      @actor_sprite.dispose
      @actor_status.dispose
      @enemy_status.dispose
      @actor_party_status.dispose
      @enemy_party_status.dispose
    end
   
    #------------------------------------------------------------ 
    # Déroulement
    #------------------------------------------------------------
    def update
      # Animation test : séquence de test d'une animation
      if false
        if $temp == nil
          $temp = false
          @actor_sprite.register_position
          @enemy_sprite.register_position
        end
        animation = $data_animations[15] # tappez le numéro de l'anim à tester
        if not @enemy_sprite.effect? and not @actor_sprite.effect?
          if $temp
            @enemy_sprite.reset_position
            @actor_sprite.register_position
            @actor_sprite.animation(animation, true, true)
            $temp = !$temp
          else
            @actor_sprite.reset_position
            @enemy_sprite.register_position
            @enemy_sprite.animation(animation, true)
            $temp = !$temp
          end
        end
        @actor_sprite.update
        @enemy_sprite.update
        return
      end
     
      case @phase
      when 0 # Phase d'initialisation
        @phase = 1
       
        # Création fenêtre de skill
        list = []
        for skill in @actor.skills_set
          list.push(skill.name)
        end
        while list.size < 4
          list.push("  ---")
        end
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
       
        # Compétences bloquées
        for i in 0..@actor.skills_set.length-1
          skill = @actor.skills_set[i]
          if not(skill.usable?)
            @skills_window.disable_item(i)
          end
        end
       
        # Curseur sur le dernier choix
        if $battle_var.last_index == nil
          $battle_var.last_index = 0
          @skills_window.index = 0
        else
          @skills_window.index = $battle_var.last_index
        end
       
        # Création fenêtre description de skill
        @skill_descr = Window_Base.new(512, 336, 128, 144)
        @skill_descr.contents = Bitmap.new(96, 144)
        @skill_descr.contents.font.name = $fontface
        @skill_descr.contents.font.size = $fontsizebig
        @skill_descr.visible = false
        skill_descr_refresh
       
        # Activation fenêtre
        @actor_status.visible = true
        @enemy_status.visible = true
               
        # ------- ---------- --------- --------
        #    Saut de phase de sélection actor
        # ------- ---------- --------- --------
        jumped = phase_jump
       
        # Activations fenêtres
        if not(jumped)
          draw_text("Que doit faire", @actor.given_name + "?")
          @action_window.visible = true
          @action_window.active= true
          $battle_var.action_id = 0
        end
       
      when 1 # Phase d'attente d'action
        @action_window.update
        @skills_window.update
        if @skills_window.active and input
          skill_descr_refresh
        end
       
        if Input.trigger?(Input::C) and @action_window.active
          case @action_window.index
          when 0 # Selection ATTAQUE
            $game_system.se_play($data_system.decision_se)
            @action_window.active = false
            @action_window.visible = false
           
            # ------- ---------- --------- --------
            #   Reset compteur de fuite
            # ------- ---------- --------- --------
            $battle_var.run_count = 0
           
            # ------- ---------- --------- --------
            #    Saut de phase de sélection attaque
            # ------- ---------- --------- --------
            if attack_selection_jump
              @actor_action = 1
              @phase = 2
              return
            end
           
            # ------- ---------- --------- --------
            #      Vérification PP // Lutte
            # ------- ---------- --------- --------
            total = 0
            for skill in @actor.skills_set
              if skill.usable?
                total += skill.pp
              end
            end
            if total == 0
              @actor_action = 1
              @phase = 2
              @actor_skill = Skill.new(165) # Lutte
              return
            end
           
            @skills_window.active = true
            @skills_window.visible = true
            @skill_descr.visible = true
            @text_window.contents.clear
          when 1 # Selection ITEM
            $game_system.se_play($data_system.decision_se)
            scene = Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "battle")
            scene.main
            return_data = scene.return_data
            @phase = 0
            if $battle_var.action_id == 1
              @phase = 2
              @actor_action = 3
              @item_id = return_data
            end
          when 2 # Selection PKMN
            # ------- ---------- --------- --------
            #    Vérification switch permis
            # ------- ---------- --------- --------
            if not(switch_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            $game_system.se_play($data_system.decision_se)
            $battle_var.window_index = @action_window.index
            scene = Pokemon_Party_Menu.new(0, @z_level + 100)
            scene.main
            return_data = scene.return_data
            @phase = 0
            # Enregistrement données Switch de Pokémon
            if $battle_var.action_id == 2
              @phase = 2
              @actor_action = 2
              @switch_id = return_data
            end
          when 3 # sélection FUITE
            # ------- ---------- --------- --------
            #    Vérification fuite permise
            # ------- ---------- --------- --------
            @action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              draw_text("Que doit faire", @actor.given_name + "?")
              return
            end
            @action_window.visible = true
           
            @action_window.active = false
            @action_window.visible = false
            @text_window.contents.clear
            run
          end
          return
        end
       
        if Input.trigger?(Input::C) and @skills_window.active
          index = @skills_window.index
          skill = @actor.skills_set[index]
          if skill != nil and skill.usable?
            @actor_action = 1
            @phase = 2
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @actor_skill = @actor.skills_set[index]
            $battle_var.last_index = @skills_window.index
          else
            $game_system.se_play($data_system.buzzer_se)
          end
        end
       
        if Input.trigger?(Input::B) and @skills_window.active
          $game_system.se_play($data_system.decision_se)
          @skills_window.active = false
          @skills_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @phase = 0
        end
       
       
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
       
        enemy_skill_decision
       
        statistic_refresh
        turn_order
        phase2
        phase3
       
        # Phase de switch de fin de tour
        $battle_var.action_id = 4
        end_battle_check
       
        if $battle_var.battle_end?
          return
        end
       
        # Fin de tour / Post_Round effects
        post_round_effect
        @actor_status.refresh
        @enemy_status.refresh
       
        if $battle_var.battle_end?
          return
        end
       
        # Phase de switch post_round
        $battle_var.action_id = 6
        end_battle_check
        @phase = 0
       
        if $battle_var.battle_end?
          return
        end
       
        # Incrémentation nombre de tours
        $battle_var.round += 1
       
      end
      return
    end
   
    #------------------------------------------------------------ 
    # Vérifications préliminaires et ordre d'action
    #------------------------------------------------------------
    def statistic_refresh
      @actor.statistic_refresh
      @enemy.statistic_refresh
    end
   
    #Recherche de priorité
    def turn_order
      # Comparaison des priorités
      if @actor_skill == nil or @enemy_skill == nil
        @strike_first = true
        return
      end
     
      if @actor_action != 1 # Attaque
        @strike_first = false
        return
      end 
     
      if @actor_skill.priority > @enemy_skill.priority
        @strike_first = true
      elsif @actor_skill.priority < @enemy_skill.priority
        @strike_first = false
      else
       
      # En cas d'égalité
        if @enemy.spd > @actor.spd
          @strike_first = false
        elsif @enemy.spd < @actor.spd
          @strike_first = true
        else
          @strike_first = rand(2)>0 ? true : false
        end
      end
    end
   
    #------------------------------------------------------------ 
    # Rounds
    #------------------------------------------------------------           
    def phase2 # Pré_Rounds
      @action_window.visible = false
      @action_window.active = false
      @actor_status.visible = true
      @enemy_status.visible = true
      @actor_status.refresh
      @enemy_status.refresh
      draw_text("","")
     
      # Préround 1: Fuite
      if @actor_action == 4
        run
      end
      if @enemy_action == 4
        enemy_run
      end
     
      # Préround 2: Item
      if @actor_action == 3
        actor_item_use
      end
      if @enemy_action == 3
        enemy_item_use
      end
     
      # Préround 3: Switch Pokémon
      if @actor_action == 2
        actor_pokemon_switch
      end
      if @enemy_action == 2
        enemy_pokemon_switch
      end
     
      @actor_status.refresh
      @enemy_status.refresh
    end
       
    # Round: Attaques
    def phase3
      if @strike_first
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
     
      if not(@strike_first)
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
    end
   
    #------------------------------------------------------------ 
    # Fonctions auxiliaires
    #------------------------------------------------------------    
    def switch(list, id1, id2)
      if id1 <= id2
        list.insert(id1, list[id2])
        list.delete_at(id2+1)
        list.insert(id2 + 1, list[id1+1])
        list.delete_at(id1+1)
        return list
      else
        switch(list, id2, id1)
      end
    end
   
    # Fonction auxiliaire
    def input
      if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
        Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
        Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
        return true
      end
      return false
    end
   
    def draw_text(line1 = "", line2 = "")
      if line1.type == Array
        if line1[1] != nil
          draw_text(line1[0], line1[1])
        else
          draw_text(line1[0])
        end
      else
        Graphics.freeze
        @text_window.contents.clear
        @text_window.draw_text(12, 0, 460, 50, line1)
        @text_window.draw_text(12, 55, 460, 50, line2)
        Graphics.transition(5)
      end
    end
   
    def draw_text_valid(line1 = "", line2 = "")
      draw_text(line1, line2)
      loop do
        Graphics.update
        Input.update
        if Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
    def wait(frame)
      i = 0
      loop do
        i += 1
        Graphics.update
        if i >= frame
          break
        end
      end
    end
   
    def wait_hit
      loop do
        Graphics.update
        Input.update
        if input
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
   
    def update_sprite
      @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
    end
   
   
   
   
    #------------------------------------------------------------ 
    # ----------------------- Interface -------------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # Fenêtre de description
    #------------------------------------------------------------       
    def skill_descr_refresh
      @skill_descr.contents.clear
      index = @skills_window.index
      skill = @actor.skills_set[index]
      if skill != nil
        string = skill.pp.to_s + "/" + skill.ppmax.to_s
        type = skill.type
      else
        string = "---"
        type = 0
      end
      normal_color = Color.new(60,60,60)
      @skill_descr.contents.font.color = normal_color
      #@skill_descr.contents.draw_text(0,6,60,39, "PP:")
      @skill_descr.contents.draw_text(0,6,96,39, string, 1)
      #@skill_descr.contents.draw_text(0,60,140,39, "TP:")
      draw_type(0, 60, type)
    end 
     
    def draw_type(x, y, type)
      src_rect = Rect.new(0, 0, 96, 42)
      bitmap = RPG::Cache.picture("T" + type.to_s + ".png")
      @skill_descr.contents.blt(x, y, bitmap, src_rect, 255)
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ------------------ Fonctions de combat --------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------   
    # Fonctions spéciales - programmation des attaques
    #------------------------------------------------------------
    def heal(user, user_sprite, user_status, bonus)
      value = bonus.abs
      for i in 1..value
        if bonus >= 0
          user.add_hp(1)
        else
          user.remove_hp(1)
        end
        if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
          next
        end
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.hp >= user.max_hp or user.dead?
          break
        end
      end
    end
   
    def self_damage(user, user_sprite, user_status, damage)
      if damage > 0
        Audio.se_play("Audio/SE/Hit.wav", 100)
        blink(user_sprite)
      end
      for i in 1..damage
        user.remove_hp(1)
        user_status.refresh
        if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
          next
        end
        Graphics.update
        Graphics.update
        if user.dead?
          break
        end
      end
    end
   
    #------------------------------------------------------------   
    # Fonctions communes - Programmation des attaques
    #------------------------------------------------------------
    # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé
    # 6: Confus, 7: Flinch, 8: Toxic
    #------------------------------------------------------------
    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre
    #------------------------------------------------------------
   
    # Fonction à appeler en cas d'effets sur le statut
    def status_check(target, status, forcing = false)
      # Immunités
      # Poison
      if (target.type_poison? or target.type_steel?) and
          (status == 1 or status == 8)
        draw_text(target.given_name + " est insensible", "au poison!")
        wait(40)
        return
      end
      # Freeze
      if status == 5 and target.type_ice?
        draw_text(target.given_name + " est insensible", "au gel!")
        wait(40)
        return
      end
      # Burn
      if status == 3 and target.type_fire?
        draw_text(target.given_name + " est insensible", "aux brûlures!")
        wait(40)
        return
      end
      # Soleil
      if status == 5 and $battle_var.sunny?
        draw_text("Le soleil empêche " + target.given_name, "de geler!")
        wait(40)
        return
      end
      # Lumber / Echauffement (ab)
      if status == 2 and target.ability == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.")
        wait(40)
        return
      end
      # Ignifu-voile / Water Veil (ab)
      if status == 3 and target.ability == 41
        draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.")
        wait(40)
        return
      end
      # Insomnia (ab) // Vital Spirit / Esprit Vital (ab)
      if status == 4 and (target.ability == 15 or target.ability == 72)
        draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.")
        wait(40)
        return
      end
      # Vaccin / Immunity (ab)
      if [1, 8].include?(status) and target.ability == 17
        draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.")
        wait(40)
        return
      end
      # Armumagma / Magma Armor (ab)
      if target.ability == 40 and status == 5
        draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.")
        wait(40)
        return
      end
      # Tempo Perso / Own Tempo (ab)
      if status == 6 and target.ability == 20
        draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.")
        wait(40)
        return
      end
      # Attention / Inner focus (ab)
      if target.ability == 39 and status == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.")
        wait(40)
        return
      end
      # Synchronize (ab)
      if target.ability == 28 and [1, 2, 3, 8].include?(status)
        target.ability_token = status
        if status == 8
          target.ability_token = 1
        end
      end
     
      if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status))
        status_string(target, -target.status) # animation
      elsif status == 6 and target.confused? and not(forcing)
        status_string(target, -6)
      elsif target.effect_list.include?(0x7C) and
          status != 7 # Rune Protect/Safeguard
        draw_text(target.given_name + "est", "protégé des altérations!")
        wait(40)
      elsif target.effect_list.include?(0x9F) and
          status == 4 # Uproar
        draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!")
        wait(40)
      else
        case status
        when 1
          target.status_poison(forcing)
        when 2
          target.status_paralyze(forcing)
        when 3
          target.status_burn(forcing)
        when 4
          target.status_sleep(forcing)
        when 5
          target.status_frozen(forcing)
        when 6
          target.status_confuse
        when 7
          target.status_flinch
        when 8
          target.status_toxic(forcing)
        end
        status_string(target, status)
      end
    end
   
    def accuracy_stage(user, target)
      stage = user.acc_stage - target.eva_stage
      stage = stage < -6 ? -6 : stage > 6 ? 6 : stage
     
      # --------------- ---------------- --------------
      #           Programmation des attaques
      # --------------- ---------------- --------------
      # Clairvoyayance / Foresight
      if target.effect_list.include?(0x71)
        stage = user.acc_stage
      end
      # --------------- ---------------- --------------
      # --------------- ---------------- --------------
     
      case stage
      when -6
        return 33.0/100
      when -5
        return 36.0/100
      when -4
        return 43.0/100
      when -3
        return 50.0/100
      when -2
        return 60.0/100
      when -1
        return 75.0/100
      when 0
        return 1
      when 1
        return 133.0/100
      when 2
        return 166.0/100
      when 3
        return 2
      when 4
        return 250.0/100
      when 5
        return 133.0/50
      when 6
        return 3
      end
    end
   
    #------------------------------------------------------------ 
    # Post_round
    #------------------------------------------------------------        
    def post_round_effect
      # --------- -------------- --------------------
      # Fin des effets "at the end of a round"
      # --------- -------------- --------------------     
      # Suppression état appeuré (ne dure que un tour)
      @actor.flinch_check
      @enemy.flinch_check
      # Suppression état autre
      if @actor.dead?
        @actor.cure
        @actor.cure_state
      end
      if @enemy.dead?
        @enemy.cure
        @enemy.cure_state
      end
     
      # --------- -------------- --------------------
      # Programmation des attaques en Post-round
      # --------- -------------- --------------------
      #      Cycle commun 0 - Souhait et Météo
      # --------- -------------- --------------------
      post_round_cycle0
     
      # --------- -------------- --------------------
      #         Cycle individuel 1
      #      Programmation des attaques
      #           Effets du statut
      # --------- -------------- --------------------     
      if @strike_first
        post_round_cycle_1(@actor, @enemy)
        post_round_cycle_1(@enemy, @actor)
      else
        post_round_cycle_1(@enemy, @actor)
        post_round_cycle_1(@actor, @enemy)
      end
     
      # --------- -------------- --------------------
      #                Cycle 2
      #         Programmation des attaques
      #            Dommages finaux
      # --------- -------------- --------------------
      if @strike_first
        post_round_cycle_2(@actor, @enemy)
        post_round_cycle_2(@enemy, @actor)
      else
        post_round_cycle_2(@enemy, @actor)
        post_round_cycle_2(@actor, @enemy)
      end
     
      @actor.skill_effect_clean
      @enemy.skill_effect_clean
     
      faint_check
     
      # Round suivant
      if $battle_var.round == nil
        $battle_var.round = 0
      end
      $battle_var.round += 1
    end
   
   
    # --------- -------------- --------------------
    #     Cycle commun 0 - Météo et Souhait
    # --------- -------------- --------------------
    def post_round_cycle0
      if @strike_first
        list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]]
      else
        list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]]
      end
     
      # Suppression du contrôle pour un pokémon mort
      for array in list
        if array[0].dead?
          list.delete(array)
        end
      end
     
      for array in list
        actor = array[0]
        actor.skill_effect_end_turn
        for effect in actor.effect_list
          case effect
          when 0x56 # Entrave / Disable
            index = actor.effect_list.index(0x56)
            if actor.effect[index][1] == 0
              skill_id = actor.effect[index][2]
              skill = actor.skills_set[skill_id]
              skill.enable
              draw_text(skill.name + " de "+ actor.given_name, "est rétablie!")
              wait(40)
            end
          when 0x5A # Encore
            index = actor.effect_list.index(0x5A)
            if actor.skills_set[index].pp == 0
              actor.effect[index][1] = 0 # Fin de l'effet
            end
          when 0x75 # Rollout
            index = actor.effect_list.index(0x75)
            ## N'a pas fait de dégât ce tour ci >> Supprimé
            #if actor.effect[index][2] != actor.effect[index][1]
            #  actor.effect.delete_at(index)
            #end
            if actor.asleep? or actor.frozen?
              actor.effect.delete_at(index)
            end
          when 0x77 # Taillade / Fury Cutter
            index = actor.effect_list.index(0x77)
            # N'a pas fait de dégât ce tour ci >> Supprimé
            if actor.effect[index][2] != actor.effect[index][1]
              actor.effect.delete_at(index)
            end
          end
        end
      end
     
      weather = $battle_var.weather[0]
      $battle_var.weather[1] -= 1
      count = $battle_var.weather[1]
     
      # Souhait -- Programmation des attaques
      for array in list
        target = array[0]
        target_sprite = array[1]
        target_status = array[2]
        if target.effect_list.include?(0xB3)
          bonus = target.hp / 2
          draw_text("Un souhait est réalisé.")
          heal(target, target_sprite, target_status, bonus)
          wait(40)
        end
      end
     
      # Pluie
      if $battle_var.rain? and count != 0
        draw_text("La pluie continue de", "tomber.")
        animation = $data_animations[493]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.rain? and count == 0
        draw_text("La pluie s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Ensoleillé
      if $battle_var.sunny? and count != 0
        draw_text("Les rayons du soleil","tapent fort.")
        animation = $data_animations[492]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.sunny? and count == 0
        draw_text("Le soleil est parti.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Tempete de sable
      if $battle_var.sandstorm? and count != 0
        draw_text("La tempête de sable souffle.")
        animation = $data_animations[494]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégats
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ground? or target.type_rock? or target.type_steel?
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or
              target.ability == 8
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.sandstorm? and count == 0
        draw_text("La tempête de sable s'est arretée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Grêle
      if $battle_var.hail? and count > 0
        draw_text("Il grêle...")
        animation = $data_animations[495]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégâts
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ice? or
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3)
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.hail? and count == 0
        draw_text("La grêle s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
    end
   
   
   
   
    # --------- -------------- --------------------
    #              Cycle individuel 1
    # --------- -------------- --------------------
    def post_round_cycle_1(actor, enemy)
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un Pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #    Programmation des attaques et des capa
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0xB5 # Ingrain / Racines
          bonus = actor.max_hp / 16
          draw_text(actor.given_name + " puise", "de l'énergie dans la terre.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      end
     
      case actor.ability
      when 44 # Cuvette / Rain Dish (ab)
        if $battle_var.rain?
          bonus = actor.max_hp / 16
          draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      when 54 # Absentéisme / Truant (ab)
        if actor.ability_token == nil
          actor.ability_token = true
        end
        if actor.ability_token == true
          actor.ability_token = false
        elsif actor.ability_token == false
          actor.ability_token = true
        end
      when 61 # Mue / Shed skin (ab)
        if actor.status != 0 and rand(100) < 30
          actor.cure
          draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.")
          wait(40)
        end
      end
     
      for effect in enemy.effect_list
        case effect
        when 0x54 # Leech Seed / Vampigraine
          malus = actor.max_hp / 8
          draw_text("L'énergie de " + actor.given_name,"est drainée!")
          heal(actor, actor_sprite, actor_status, -malus)
          heal(enemy, enemy_sprite, enemy_status, malus)
          wait(40)
        when 0x2A # Multi_turn attack
          damage = actor.max_hp / 16
          draw_text(actor.given_name, "est piégé!")
          self_damage(actor, actor_sprite, actor_status, damage)
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #          Inspection des statuts
      # --------- -------------- --------------------
      if actor.status == 1 # Poison
        damage = actor.poison_effect
        draw_text(actor.given_name + " souffre", "du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 8 # Toxic
        damage = actor.toxic_effect
        draw_text(actor.given_name + " souffre", "gravement du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 3 #Burn
        damage = actor.burn_effect
        draw_text(actor.given_name + " souffre", "de ses brûlures.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
     
      actor.confuse_decrement
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------     
      for effect in actor.effect_list
        case effect
        when 0x6B # Nightmare / Cauchemar
          if actor.asleep?
            damage = actor.max_hp / 4
            draw_text(actor.given_name + " fait", "un chauchemar!")
            heal(actor, actor_sprite, actor_status, -damage)
            wait(20)
          else
            index = actor.effect_list.index(0x6B)
            actor.effect.delete_at(index)
          end
        when 0x6D # Curse
          damage = actor.max_hp / 4
          draw_text(actor.given_name + " est", "maudit!")
          heal(actor, actor_sprite, actor_status, -damage)
          wait(20)
        when 0x9F # Uproar / Brouhaha
          if actor.asleep?
            actor.cure
            draw_text(actor.given_name + " se réveille", "à cause du brouhaha!")
            wait(40)
          end
          if actor.frozen? #Fin de l'effet
            index = actor.effect_list.index(0x9F)
            actor.effect.delete_at(index)
          end
        when 0xAF # Taunt / Provoc
          index = actor.effect_list.index(0xAF)
          for skill in actor.skills_set
            if skill.power == 0 and actor.effect[index][1] > 0
              draw_text(skill.name + " est bloqué!")
              skill.disable
              wait(40)
            elsif actor.effect[index][1] == 0
              draw_text(skill.name + " est rétablit.")
              skill.enable
              wait(40)
            end
          end
        when 0xBB # Yawn / Baillement
          if actor.status == 0
            status_check(actor, 4)
            actor_status.refresh
          end
        end
      end
     
      if actor.dead?
        return
      end
      # --------- -------------- --------------------
      #                  Berry check
      # --------- -------------- -------------------- 
      if Item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp
        draw_text(actor.given_name + " récupère un peu", "de vie avec " + Item.name(actor.item_hold) + ".")
        bonus = actor.max_hp / 16
        if bonus == 0
          bonus = 1
        end
        heal(actor, actor_sprite, actor_status, bonus)
        wait(40)
      end
    end
     
    # --------- -------------- --------------------
    #              Cycle individuel 2
    # --------- -------------- --------------------    
    def post_round_cycle_2(actor, enemy)
      # Redéfinition
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des capacités
      # --------- -------------- --------------------
      case actor.ability
      when 2 # Crachin / Drizzle (ab)
        if not($battle_var.rain?) # Pluie
          draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.")
          wait(40)
          animation = $data_animations[493]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_rain
      when 45 # Sable Volant / Sand stream (ab)
        if not($battle_var.sandstorm?) # Tempete Sable
          draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.")
          wait(40)
          animation = $data_animations[494]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 70 # Sècheresse / Drought (ab)
        if not($battle_var.sunny?) # Soleil
          draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.")
          wait(40)
          animation = $data_animations[492]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 3 # Speed Boost (ab)
        draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.")
        actor.change_spd(+1)
        stage_animation(actor_sprite, $data_animations[482])
        wait(40)
      when 22 # Intimidate (ab)
        if not(actor.ability_active)
          actor.ability_active = true
          draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".")
          enemy.change_atk(-1)
          stage_animation(enemy_sprite, $data_animations[479])
          wait(40)
        end
      when 59 # Forecast / Meteo (ab)
        if $battle_var.sunny? and not(actor.type_fire?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en FEU!")
          actor.ability_token = 2
          actor.form = 2
          update_sprite
          wait(40)
        elsif $battle_var.rain? and not(actor.type_water?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en EAU!")
          actor.ability_token = 3
          actor.form = 3
          update_sprite
          wait(40)
        elsif $battle_var.hail? and not(actor.type_ice?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en GLACE!")
          actor.ability_token = 6
          actor.form = 6
          update_sprite
          wait(40)
        elsif not(actor.type_normal?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en NORMAL!")
          actor.ability_token = 1
          actor.form = 0
          update_sprite
          wait(40)
        end
      end
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0x72 # Requiem / Perish Song
          index = actor.effect_list.index(0x72)
          number = actor.effect[index][1]
          if number > 0
            if number > 1
              string = "#{number.to_s} tours"
            elsif number == 1
              string = "#{number.to_s} tour"
            end
            draw_text("Plus que #{string}", "pour #{actor.given_name}...")
            wait(40)
          else
            draw_text("#{actor.given_name} est", "K.O. par REQUIEM!")
            damage = actor.hp
            heal(actor, actor_sprite, actor_status, -damage)
            wait(40)
          end
        end
      end
     
      # --------- -------------- --------------------
      #      Nettoyage des compteurs d'effets
      # --------- -------------- --------------------
      for effect in actor.effect
        case effect
        when [0x10, 0] # Reflet / Reflect
          draw_text("L'effet de REFLET est", "terminé.")
          wait(40)
        when [0x23, 0] # Light Screen
          draw_text("L'effet de MUR LUMIERE est", "terminé.")
          wait(40)
        when [0x2E, 0] # Brume / Mist
          draw_text("La brume se dissipe.")
          wait(40)
        when [0x7C, 0] # Rune Protect / Safeguard
          draw_text("L'effet de RUNE PROTECT", "est terminé.")
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
    end
   
   
   
    #------------------------------------------------------------ 
    # Items
    #------------------------------------------------------------    
    def actor_item_use # items à utiliser
      # Item déjà utilisé ie remplacé par 0
      if @item_id == 0
        return
      end
    end

    #------------------------------------------------------------ 
    # Switch de pokémon
    #------------------------------------------------------------        
    def actor_pokemon_switch
      if @switch_id != -1
        if not(@actor.dead?)
          @actor_status.visible = true
        else
          @actor_status.visible = false
        end
       
        switch_effect(@actor, @enemy)
       
        if not(@actor.dead?)
          recall_pokemon
        end
       
        @battle_order = switch(@battle_order, 0, @switch_id)
        @actor = @party.actors[@battle_order[0]]
        @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
        @actor_status = Pokemon_Battle_Status.new(@actor, false)
        @actor_status.visible = false
        if not($battle_var.have_fought.include?(@actor.party_index))
          $battle_var.have_fought.push(@actor.party_index)
        end
       
        launch_pokemon
        @actor_status.visible = true
        @switch_id = -1
      end
    end
   
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy.dead?)
          @enemy_status.visible = true
        else
          @enemy_status.visible = false
        end
       
        switch_effect(@enemy, @actor)
       
        if not(@enemy.dead?)
          recall_enemy_pokemon
        end
       
        @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id)
        @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]]
        $data_pokedex[@enemy.id][0] = true
        @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
        @enemy_status = Pokemon_Battle_Status.new(@enemy, true)
        @enemy_status.visible = false
       
        launch_enemy_pokemon
        @enemy_status.visible = true
        @enemy_switch_id = -1
      end
    end
   
    #------------------------------------------------------------ 
    # Fuite
    #------------------------------------------------------------          
    def run
      if run_able?(@actor, @enemy)
        $battle_var.run_count += 1
        @action_window.active = false
        @action_window.visible = false
        end_battle_flee
      else
        $battle_var.run_count += 1
        fail_flee
        @phase = 2
        @actor_action = 0
        $battle_var.action_id = 0
      end
    end
   
    def run_able?(runner, opponent)
      x = (Integer(opponent.spd/4) % 255)
      rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count))
      if not(flee_able(runner, opponent))
        return false
      end
      if opponent.spd <= runner.spd
        return true
      elsif x == 0
        return true
      elsif rate > 255
        return true
      elsif rand(256) <= rate
        return true
      else
        return false
      end
    end
   
    def run_enemy
      if run_able?(@enemy, @actor)
        end_battle_flee_enemy
      end
    end
   
    #------------------------------------------------------------ 
    # Animations supplémentaires au combat
    #------------------------------------------------------------  
    # Défaites / KO
    #------------------------------------------------------------      
    def enemy_down
      # Si déjà vaincu
      if @enemy_sprite.zoom_y == 0
        return
      end
      # Sinon
      @enemy_sprite.oy = @enemy_sprite.bitmap.height
      @enemy_sprite.y += @enemy_sprite.bitmap.height / 2
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
     
      loop do
        @enemy_status.x -= 20
        #@enemy_sprite.zoom_y -= 0.05
        @enemy_sprite.y += 8
        @enemy_sprite.opacity -= 20
        Graphics.update
        #if @enemy_sprite.zoom_y <= 0.0
        if @enemy_sprite.y >= 348
          @enemy_sprite.zoom_y = 0
          break
        end
      end
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.y -= @enemy_sprite.bitmap.height
      draw_text(@enemy.given_name, "est K.O.!")
      wait(40)
    end
   
    def actor_down
      # Si déjà vaincu
      #if @actor_sprite.zoom_y <= 0.0
      if @actor_sprite.y >= 576
        return
      end
      # Sinon
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
      loop do
        @actor_status.x += 20
        #@actor_sprite.zoom_y -= 0.05
        @actor_sprite.y += 12
        @actor_sprite.opacity -= 20
        Graphics.update
        #if @actor_sprite.zoom_y <= 0.0
        if @actor_sprite.y >= 576
          break
        end
      end
     
      draw_text(@actor.given_name, "est K.O.!")
      wait(40)
    end
   
    #------------------------------------------------------------      
    # Attaques
    #------------------------------------------------------------
    def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite)
      if miss
        wait(40)
        draw_text("Mais cela échoue!")
        wait(40)
        return
      end
     
      if user == @enemy
        reverse = true
      else
        reverse = false
      end
     
      efficiency = info[2]
      if hit and efficiency != -2
        # Animation utilisateur
        animation_user = $data_animations[user_skill.user_anim_id]
        user_sprite.register_position
       
        if animation_user != nil
          user_sprite.animation(animation_user, true, reverse)
          until not(user_sprite.effect?)
            user_sprite.update
            Graphics.update
          end
        end
       
        user_sprite.reset_position
       
        user_sprite.update
        Graphics.update
       
        # Animation Cible
        animation_target = $data_animations[user_skill.target_anim_id]
        target_sprite.register_position
       
        if animation_target != nil
          target_sprite.animation(animation_target, true, reverse)
          until not(target_sprite.effect?)
            target_sprite.update
            Graphics.update
          end
        end
       
        target_sprite.reset_position
       
        target_sprite.update
        Graphics.update
       
        if info[0] > 0
          case efficiency
          when 0 # Normal
            Audio.se_play("Audio/SE/Hit.wav", 100)
            blink(target_sprite, 3, 3)
          when 1 # Super efficace
            Audio.se_play("Audio/SE/Hitplus.wav", 100)
            blink(target_sprite, 2, 5)
          when -1 # Peu efficace
            Audio.se_play("Audio/SE/Hitlow.wav", 100)
            blink(target_sprite, 4, 2)
          end
        end
      elsif not(hit)
        wait(40)
        draw_text(user.given_name, "rate son attaque!")
        wait(40)
      end
    end
   
    def blink(sprite, frame = 4, number = 3)
      for i in 0..number
        wait(frame)
        sprite.opacity = 0
        Graphics.update
        wait(frame)
        sprite.opacity = 255
        Graphics.update
      end
    end
   
    def post_attack(info, damage, power)
      efficiency = info[2]
      if damage == 0 and (efficiency != -2 or power == 0)
        return
      end
      critical = info[1]
      if critical  and efficiency != -2 #critical_hit
        draw_text("Coup critique!")
        wait(40)
      end
      case efficiency
      when 1
        draw_text("C'est super efficace!")
        wait(40)
      when -1
        draw_text("Ce n'est pas très efficace...")
        wait(40)
      when -2
        draw_text("Ca ne l'affecte pas...")
        wait(40)
      end
    end
   
    def faint_check(user = nil)
      if user == nil
        faint_check(@actor)
        faint_check(@enemy)
      end
      if user == @actor and user.dead?
        actor_down
      end
      if user == @enemy and user.dead?
        enemy_down
      end
    end
       
   
    #------------------------------------------------------------      
    # Statut et stats
    #------------------------------------------------------------   
    def status_animation(sprite, status)
      animation = $data_animations[469 + status]
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          break
        end
      end
    end
   
    def stage_animation(sprite, animation)
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          wait(20)
          break
        end
      end
    end

    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
    def type_string(type)
      case type
      when 0
        return "???"
      when 1
        return "NORMAL"
      when 2
        return "FEU"
      when 3
        return "EAU"
      when 4
        return "ELECTRIK"
      when 5
        return "PLANTE"
      when 6
        return "GLACE"
      when 7
        return "COMBAT"
      when 8
        return "POISON"
      when 9
        return "SOL"
      when 10
        return "VOL"
      when 11
        return "PSY"
      when 12
        return "INSECTE"
      when 13
        return "ROCHE"
      when 14
        return "SPECTRE"
      when 15
        return "DRAGON"
      when 16
        return "ACIER"
      when 17
        return "TENEBRES"
      end
    end
   
   
    # Changement (ou pas) de statut
    def status_string(actor, status)
      string = actor.given_name
      case status
      when -1
        draw_text(string + " est", "déjà empoisonné!")
        wait(40)
      when -2
        draw_text(string + " est", "déjà paralysé!")
        wait(40)
      when -3
        draw_text(string,"brûle déjà!")
        wait(40)
      when -4
        draw_text(string,"dort déjà!")
        wait(40)
      when -5
        draw_text(string, "est déjà gelé!")
        wait(40)
      when -6
        draw_text(string, "est déjà confus!")
        wait(40)
      when -8
        draw_text(string + " est", "déjà gravement empoisonné!")
        wait(40)
      when 1
        draw_text(string, "est empoisonné!")
        wait(40)
      when 2
        draw_text(string, "est paralysé!")
        wait(40)
      when 3
        draw_text(string,"brûle!")
        wait(40)
      when 4
        draw_text(string,"s'endort!")
        wait(40)
      when 5
        draw_text(string,"gèle!")
        wait(40)
      when 6
        draw_text("Cela rend " + string, "confus!")
        wait(40)
      when 7
        draw_text(string, "est appeuré!")
        wait(40)
      when 8
        draw_text(string + " est", "gravement empoisonné!")
        wait(40)
      end
    end
   
    # S'occupe du texte et de l'animation
    def raise_stat(string, actor, n = 0)
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == 1
        text = actor.given_name + " augmente!"
      elsif n > 1
        text = actor.given_name + " augmente beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[478])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[480])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[484])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[486])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[482])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[488])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[490])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    def reduce_stat(string, actor, n = true, self_inflicted = false)
      # Mist/Brume
      if actor.effect_list.include?(0x2E)
        draw_text(actor.given_name + " est", "protégé par la brume!")
        wait(40)
        return
      end
      # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab)
      if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted)
        draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!")
        wait(40)
        return
      end
      # Keen Eye / Regard Vif (ab)
      if actor.ability == 51 and string == "ACC"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!")
        wait(40)
        return
      end
      # Hyper Cutter (ab)
      if actor.ability == 52 and string == "ATK"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!")
        wait(40)
        return
      end
     
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == -1
        text = actor.given_name + " baisse!"
      elsif n < -1
        text = actor.given_name + " baisse beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[479])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[481])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[485])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[487])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[483])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[489])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[491])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    #------------------------------------------------------------      
    # Appel / Rappel de Pokémon
    #------------------------------------------------------------          
    def recall_pokemon
      draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!")
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.y = 336
      @actor_sprite.x = 153
      @actor_sprite.color = @actor.ball_color
      @actor_sprite.color.alpha = 0
     
      until @actor_sprite.color.alpha >= 255
        @flash_sprite.opacity += 25
        @actor_sprite.color.alpha += 25
        Graphics.update
      end
     
      Audio.se_play("Audio/SE/Pokeopen.wav")
      loop do
        @actor_status.x += 20
        @actor_sprite.opacity -= 25
        @actor_sprite.color.alpha += 25
        @actor_sprite.zoom_x -= 0.1
        @actor_sprite.zoom_y -= 0.1
        @flash_sprite.opacity -= 25
        Graphics.update
        if @actor_status.x >= 711
          @actor_status.visible = false
          @actor_status.x = 711
          @actor_sprite.color.alpha = 0
          @actor_sprite.opacity = 0
          Graphics.update
          break
        end
      end
    end
   
    def launch_pokemon
      @actor_sprite.x = 153
      @actor_sprite.y = 336
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.zoom_x = 0
      @actor_sprite.zoom_y = 0
     
      #if @actor_party_status.active
      #  @actor_party_status.x = 0
      #  @actor_party_status.visible = true
      #end
     
      name = @actor.given_name
      text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)]
      draw_text(text)
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = -44
      @ball_sprite.y = 324
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x += 5
        @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        #if @actor_party_status.active
        #  @actor_party_status.x -= 80
        #end
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          #if @actor_party_status.active
          #  @actor_party_status.x = 0
          #  @actor_party_status.visible = false
          #end
          break
        end
      end
      @actor_sprite.opacity = 0
      @actor_sprite.color = @actor.ball_color
     
      until @actor_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @actor_sprite.zoom_x += 0.1
        @actor_sprite.zoom_y += 0.1
        @actor_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
     
      @actor_sprite.zoom_x = 1
      @actor_sprite.zoom_y = 1
      @actor_sprite.opacity = 255
     
      @actor_status.x = 711
      @actor_status.visible = true
     
      if @actor.shiny
        animation = $data_animations[496]
        @actor_sprite.animation(animation, true)
      end
     
      until @actor_status.x == 311
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @actor_status.x -= 20
        @actor_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @actor_sprite.update
        Graphics.update
      end
     
      until not(@actor_sprite.effect?)
        @actor_sprite.update
        Graphics.update
      end
     
      @actor_status.x = 311
      @actor_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    def launch_enemy_pokemon
      @enemy_sprite.x = 464
      @enemy_sprite.y = 104
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.zoom_x = 0
      @enemy_sprite.zoom_y = 0
     
      string = Trainer_Info.type(@trainer_id) + " " + Trainer_Info.name(@trainer_id)
      draw_text(@enemy.name + " est envoyé", "par " + string + "!")
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = 663
      @ball_sprite.y = 104
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x -= 5
        @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          break
        end
      end
      @enemy_sprite.opacity = 0
      @enemy_sprite.color = @enemy.ball_color
     
      until @enemy_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @enemy_sprite.zoom_x += 0.08
        @enemy_sprite.zoom_y += 0.08
        @enemy_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      @enemy_sprite.zoom_x = 1
      @enemy_sprite.zoom_y = 1
      @enemy_sprite.opacity = 255
     
      @enemy_status.x = -377
      @enemy_status.visible = true
     
      if @enemy.shiny
        animation = $data_animations[496]
        @enemy_sprite.animation(animation, true)
      end
     
      until @enemy_status.x == 23
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @enemy_status.x += 20
        @enemy_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @enemy_sprite.update
        Graphics.update
      end
     
      until not(@enemy_sprite.effect?)
        @enemy_sprite.update
        Graphics.update
      end
     
      @enemy_sprite.x = 464
      @enemy_status.x = 23
      @enemy_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    #------------------------------------------------------------ 
    # Fin de combat
    #------------------------------------------------------------     
    def end_battle(result = 0)     
      # Reset des variables et effets
      $battle_var.reset
      @actor.skill_effect_reset
      @actor.reset_stat_stage
      @actor.cure_state
      @actor.ability_active = false
      @enemy.skill_effect_reset
      @enemy.reset_stat_stage
      @enemy.cure_state
      @enemy.ability_active = false
      # -----------------------------------
      Audio.me_stop
      wait(10)
      $game_system.bgm_play($game_temp.map_bgm)
      wait(10)
      Graphics.freeze
      # -----------------------------------
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      # Défaite
      $scene = Scene_Map.new
    end
   
    def end_battle_flee(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@actor.given_name, "est expulsé du combat!")
        loop do
          if @actor_sprite.x > -160
            @actor_sprite.x -= 20
          end
          Graphics.update
          Input.update
          if @actor_sprite.x <= -160
            wait(40)
            break
          end
        end
      else
        draw_text("Vous prenez la fuite!")
        wait(40)
      end
      end_battle(1)
    end
   
    def fail_flee
      draw_text("Vous ne pouvez pas","vous enfuir!")
      wait(40)
    end
   
    def end_battle_flee_enemy(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@enemy.given_name, "est expulsé du combat!")
      else
        draw_text(@enemy.given_name + " s'échappe!")
      end
      loop do
        if @enemy_sprite.x < 800
          @enemy_sprite.x += 20
        end
        Graphics.update
        Input.update
        if @enemy_sprite.x >= 800
          wait(40)
          break
        end
      end
      end_battle(1)
    end
   
    def end_battle_defeat
      $battle_var.result_defeat = true
      draw_text("Tous vos Pokémons", "ont été vaincus!")
      wait(40)
      $pokemon_party.money /= 2
      if not(@lose)
        if $game_variables[1] == 0
          print("Réglez votre point de retour!")
        else
          $game_map.setup($game_variables[1])
          $game_map.display_x = $game_variables[2]
          $game_map.display_y = $game_variables[3]
          $game_player.moveto($game_variables[2], $game_variables[3])
        end
        $game_temp.common_event_id = 2
      end
      $game_temp.map_bgm = $game_map.bgm
      end_battle(2)
    end
   
    def draw_choice
      @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig)
      @command.x = 517
      @command.y = 215
      loop do
        Graphics.update
        Input.update
        @command.update
        if Input.trigger?(Input::C) and @command.index == 0
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return true
        end
        if Input.trigger?(Input::C) and @command.index == 1
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return false
        end
      end
    end
  end
 
  #------------------------------------------------------------ 
  # Fenêtre de statut
  #------------------------------------------------------------ 
  class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(0,0,0,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size(@pokemon.name).width + 3
        draw_gender(15 + width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(9, 42, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(93, 99, 1.0 - level, 192)
        width_text = self.contents.text_size(@pokemon.given_name).width + 3
        draw_gender(39 + width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(42, 66, bitmap, src_rect, 255)
        end
      end
    end
   
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(93, 99, 1.0 - level, 192)
    end
     
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
     
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
   
    def dispose
      super
    end
   
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 45, y + 6, level*144.to_i, 3)
      rect2 = Rect.new(x + 45, y + 9, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 45, y + 6, level*129.to_i, 3)
        rect2 = Rect.new(x + 45, y + 9, level*129.to_i, 6)
      end
     
      if level < 0.1
        color1 = Color.new(170, 70, 70, 255)
        color2 = Color.new(250, 90, 60, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(200, 170, 0, 255)
        color2 = Color.new(250, 225, 50, 255)
      else
        color1 = Color.new(90, 210, 125, 255)
        color2 = Color.new(110, 250, 170, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
   
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*192.to_i, 6)
      self.contents.fill_rect(rect1, Color.new(160, 160, 255, 255))
    end
   
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)       
      end
    end
  end
 
 
  #------------------------------------------------------------ 
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------ 
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
   
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
   
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
     
      src_rect = Rect.new(0, 0, 21, 21)
      if @enemy
        ball_x = 231
        coeff = -1
      else
        ball_x = 63
        coeff = 1
      end
     
      for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i-1]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*30*(i-1), 3, bitmap, src_rect, 255)
      end
    end
   
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end
 
 
 
 
  class Pokemon_Battle_Variable

    attr_accessor :weather
    attr_accessor :actor_last_used
    attr_accessor :enemy_last_used
    attr_accessor :battle_order
    attr_accessor :enemy_battle_order
    attr_accessor :in_battle
    attr_accessor :actor_last_taken_damage
    attr_accessor :enemy_last_taken_damage
    attr_accessor :have_fought #liste des pokémons ayant participé par leur index
    attr_accessor :enemy_party
    attr_accessor :action_id
    attr_accessor :window_index
    attr_accessor :result_flee
    attr_accessor :result_win
    attr_accessor :result_defeat
    attr_accessor :last_index
    attr_accessor :round
    attr_accessor :run_count
    attr_accessor :money
   
    # Weather: [ catégorie, nombre de tours ]
    # catégorie: 0: Normal, 1: Pluie, 2: Ensoleillé,
    #            3: Tempête de Sable, 4: Grêle
   
    def initialize
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @result_flee = false
      @result_win = false
      @result_defeat = false
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
   
    def reset
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
   
    def reset_weather
      @weather = [0, 0]
    end
   
    def set_rain(duration = -1)
      @weather = [1, duration]
    end
   
    def rain?
      if @weather[0] == 1
        return true
      else
        return false
      end
    end
   
    def set_sunny(duration = -1)
      @weather = [2, duration]
    end
   
    def sunny?
      if @weather[0] == 2
        return true
      else
        return false
      end
    end
   
    def sandstorm?
      if @weather[0] == 3
        return true
      else
        return false
      end
    end
   
    def set_sandstorm(duration = -1)
      @weather = [3, duration]
    end
   
    def hail?
      if @weather[0] == 4
        return true
      else
        return false
      end
    end
   
    def set_hail(duration = -1)
      @weather = [4, duration]
    end
   
    def battle_end?
      if @result_flee or @result_win or @result_defeat
        return true
      else
        return false
      end
    end
   
    def add_money(amount)
      if @money == nil
        @money = 0
      end
      @money += amount
    end
   
  end
 
end
     

Posté par Aten974 le 19 Sep - 21:20 (2008)
Il ne marche pas, pour chercher j'utilise control+F

Il marche maintenant(après avoir enlever le smilies)... Mais ... Ca change rien ! ^^'

Posté par Jordan le 19 Sep - 21:34 (2008)
comment ça ça change rien?

Posté par Happy le 19 Sep - 23:18 (2008)
Palbolsky,j'utilises la version 4G^^

Posté par Pαlвσlѕку le 20 Sep - 06:23 (2008)
Aie, je ne connais pas le script de PSP4.

LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOLLLLL Pour ça change rien car c'est le script d'origine (sans la modification Clin d'œil foireux)

Voilà le morceau de script corriger si tous ce passe bien.

script

Code:

class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(248,248,248,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(242 - width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(20, 47, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(46, 99, 1.0 - level, 232)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(268 - width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(44, 68, bitmap, src_rect, 255)
        end
      end
    end
   
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(46, 99, 1.0 - level, 232)
    end
     
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
     
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
   
    def dispose
      super
    end
   
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3)
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3)
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6)
      end
     
      if level < 0.1
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(248, 64, 16, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(232, 168, 50, 255)
      else
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(24, 192, 32, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
   
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*232.to_i, 3)
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255))
    end
   
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)       
      end
    end
  end


  #------------------------------------------------------------ 
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------ 
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
   
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
   
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
     
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
     
      for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i-1]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
   
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end


Posté par Jordan le 20 Sep - 15:28 (2008)
les pokéballs ne sont pas à leurs place! tu peux corriger ça stp?

Posté par Happy le 20 Sep - 18:21 (2008)
Oui pareil pour moi,aussi l'experience n'est pas bien dans la barre,la barre d'HP n'entour estplus grande que la barre d'énergie.

Posté par Jordan le 20 Sep - 18:36 (2008)
ça y est! prend le dernier code donné par palbolsky, et ne prend surtout pas les resosurces données par ce bêta de naruto! prend celles de palb

Posté par Happy le 20 Sep - 19:30 (2008)
Oui mais on le met où le code que palbolsky à donné?

Posté par Jordan le 20 Sep - 20:10 (2008)
oui!

edit; j'avais mal lu ton post ====> palbolsky!

Posté par Pαlвσlѕку le 20 Sep - 20:25 (2008)
Regarde le 1er post.

Posté par Happy le 21 Sep - 02:25 (2008)
A non je n'ai pas de bug dans mon battle core 1,je m'en souvient avoir fait une copie.
Mais sinon,je ne vois pas qu'on dit dans le premier poste de modifier plusieurs lignes d'un scripte,j'ai bien modifier pour le hp bar team mais sinon je ne vois rien d'autre.

Posté par Pαlвσlѕку le 21 Sep - 11:13 (2008)
Je vais réexpliquer alors.

Le script (en faite un morceau) que j'ai mis un peu avant est a placé dans le script battle_core_1. Il doit remplacer ce qui se trouve de la ligne 2421 à la ligne 2621 (ligne correspondant à PSP v0.7)

Pour les personnes ne possédant pas cette version de PSP, il ne vous reste plus qu'a cherché dans le script les lignes qui se ressemble beaucoup.
Voilà quelque chose qui fonctionnera peut-être. Appuyez quand vous êtes dans le script, sur CTRL + F ce qui va ouvrir la fenêtre de recherche (très utile)
Après dedans rentrer cette ligne :
Code:
class Pokemon_Battle_Status < Window_Base

Puis après avoir appuyer sur suivant, vous devrier trouver la 1er ligne du script à remplacer (donc sous PSP v0.7, c'est la ligne 2421)

Je pense qu'avec ceci, tout devrait être plus clair.

Posté par <€d> le 22 Sep - 07:39 (2008)
Il me dit :


Pokemon_Battle_Core 1
#==============================================================================
# ■ Pokemon_Battle_Core
# Pokemon Script Project - Krosk
# 20/07/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Système de Combat - Squelette général
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé, 8: Toxic
# @confuse (6), @flinch (7)
#-----------------------------------------------------------------------------
# 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
# 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# $battle_var.action_id
#   0 : Phase de Sélection
#   1 : Sélection Item
#   2 : Switch Pokémon
#   4 : Switch Fin de Tour
#-----------------------------------------------------------------------------

module POKEMON_S
  #------------------------------------------------------------ 
  # Pokemon_Battle_Core
  #   noyau possédant les fonctions communes aux combats sauvages/dresseurs
  #------------------------------------------------------------ 
  #------------------------------------------------------------ 
  # Fonctions à définir à l'extérieur
  #   initialize
  #   pre_battle_animation
  #   enemy_skill_decision
  #   end_battle_check
  #   actor_item_use
  #   catch_pokemon
  #   run_able?
  #   end_battle_victory
  #------------------------------------------------------------ 
  class Pokemon_Battle_Core
    attr_accessor :z_level
    attr_accessor :actor_status
    attr_accessor :actor
    attr_accessor :actor_sprite
   
    #------------------------------------------------------------ 
    # ------------------- Squelette Général ---------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # main
    #------------------------------------------------------------
     def main
      # Pré-création des Sprites
      # Fond
      if @battleback_name != ""
      if $game_switches[12] == true # J pour jour
        @battleback_name = $game_map.battleback_name + ".png"
        @ground_name = "ground" + $game_map.battleback_name + ".png"
      elsif $game_switches[16] == true # N pour nuit
        @battleback_name = $game_map.battleback_name + "N" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "N" + ".png"
      elsif $game_switches[18] == true # AC pour matin
        @battleback_name = $game_map.battleback_name + "AC" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "AC" + ".png"
      elsif $game_switches[14] == true # AC pour soir
        @battleback_name = $game_map.battleback_name + "AC" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "AC" + ".png"
      end
      else
        print("Attention, réglez le BattleBack du Tileset.")
        @battleback_name = "battle0.png"
        @ground_name = "groundbattle0.png"
      end
      @background = Sprite.new
      @background.z = @z_level
     
      # Fond du message
      @message_background = Sprite.new
      @message_background.y = 336
      @message_background.z = @z_level + 19
     
      # Sprite de flash
      @flash_sprite = Sprite.new
      @flash_sprite.bitmap = RPG::Cache.picture("black.png")
      @flash_sprite.color = Color.new(255,255,255)
      @flash_sprite.opacity = 0
      @flash_sprite.z = @z_level + 13
     
      # Fenetre de texte
      @text_window = Window_Base.new(4, 340, 632, 136)
      @text_window.opacity = 0
      @text_window.z = @z_level + 20
      @text_window.contents = Bitmap.new(600 + 32, 104 + 32)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsizebig
     
      # Fenetre d'action
      s1 = "ATTAQUE"
      s2 = "SAC"
      s3 = "POKéMON"
      s4 = "FUITE"
     
      @action_window = Window_Command.new(320, [s1, s2, s3, s4], $fontsizebig, 2, 56)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
     
      # Viewport
      battle_viewport = Viewport.new(0, 0, 640, 336)
      battle_viewport.z = @z_level + 15
     
      # Sprites acteurs # Positions par défaut des centres
      @enemy_sprite = RPG::Sprite.new(battle_viewport)
      @enemy_sprite.x = 463
      @enemy_sprite.y = 108
      @enemy_sprite.z = @z_level + 15
      @enemy_ground = RPG::Sprite.new
      @enemy_ground.x = 463
      @enemy_ground.y = 163
      @enemy_ground.z = @z_level + 11
      @actor_sprite = RPG::Sprite.new(battle_viewport)
      @actor_sprite.x = 156
      @actor_sprite.y = 336
      @actor_sprite.z = @z_level + 15
      @actor_ground = RPG::Sprite.new
      @actor_ground.x = 156
      @actor_ground.y = 386
      @actor_ground.z = @z_level + 11
     
      # Création fenêtre de statut
      @actor_status = POKEMON_S::Pokemon_Battle_Status.new(@actor, false, @z_level + 15)
      @enemy_status = POKEMON_S::Pokemon_Battle_Status.new(@enemy, true, @z_level + 15)
      @actor_status.visible = false
      @enemy_status.visible = false
      @enemy_caught = false
     
      @actor_party_status = POKEMON_S::Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10)
      @enemy_party_status = POKEMON_S::Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10)
      @actor_party_status.visible = false
      @enemy_party_status.visible = false
      # note: .active = true activera les animations liées à ces fenêtres
      @actor_party_status.active = false
      @enemy_party_status.active = false
     
      # Lancement des animations
      pre_battle_transition
      pre_battle_animation
     
      # Effets pré-premier round
      post_round_effect
     
     
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
     
      # Fin de scene
      Graphics.freeze
      @background.dispose
      @message_background.dispose
      @flash_sprite.dispose
      @text_window.dispose
      @action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
      end
      if @ball_sprite != nil
        @ball_sprite.dispose
      end
      @enemy_sprite.dispose
      @actor_sprite.dispose
      @actor_status.dispose
      @enemy_status.dispose
      @actor_party_status.dispose
      @enemy_party_status.dispose
    end
   
    #------------------------------------------------------------ 
    # Déroulement
    #------------------------------------------------------------
    def update
      case @phase
      when 0 # Phase d'initialisation
        @phase = 1
       
        # Création fenêtre de skill
        list = []
        for skill in @actor.skills_set
          list.push(skill.name)
        end
        while list.size < 4
          list.push("  ---")
        end
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
       
        # Compétences bloquées
        for i in 0..@actor.skills_set.length-1
          skill = @actor.skills_set[i]
          if not(skill.usable?)
            @skills_window.disable_item(i)
          end
        end
       
        # Curseur sur le dernier choix
        if $battle_var.last_index == nil
          $battle_var.last_index = 0
          @skills_window.index = 0
        else
          @skills_window.index = $battle_var.last_index
        end
       
        # Création fenêtre description de skill
        @skill_descr = Window_Base.new(512, 336, 128, 144)
        @skill_descr.contents = Bitmap.new(96, 144)
        @skill_descr.contents.font.name = $fontface
        @skill_descr.contents.font.size = $fontsizebig
        @skill_descr.visible = false
        skill_descr_refresh
       
        # Activation fenêtre
        @actor_status.visible = true
        @enemy_status.visible = true
               
        # ------- ---------- --------- --------
        #    Saut de phase de sélection actor
        # ------- ---------- --------- --------
        jumped = phase_jump
       
        # Activations fenêtres
        if not(jumped)
          draw_text("Que doit faire", @actor.given_name + "?")
          @action_window.visible = true
          @action_window.active= true
          $battle_var.action_id = 0
        end
       
      when 1 # Phase d'attente d'action
        @action_window.update
        @skills_window.update
        if @skills_window.active and input
          skill_descr_refresh
        end
       
        if Input.trigger?(Input::C) and @action_window.active
          case @action_window.index
          when 0 # Selection ATTAQUE
            $game_system.se_play($data_system.decision_se)
            @action_window.active = false
            @action_window.visible = false
           
            # ------- ---------- --------- --------
            #   Reset compteur de fuite
            # ------- ---------- --------- --------
            $battle_var.run_count = 0
           
            # ------- ---------- --------- --------
            #    Saut de phase de sélection attaque
            # ------- ---------- --------- --------
            if attack_selection_jump
              @actor_action = 1
              @phase = 2
              return
            end
           
            # ------- ---------- --------- --------
            #      Vérification PP // Lutte
            # ------- ---------- --------- --------
            total = 0
            for skill in @actor.skills_set
              if skill.usable?
                total += skill.pp
              end
            end
            if total == 0
              @actor_action = 1
              @phase = 2
              @actor_skill = Skill.new(165) # Lutte
              return
            end
           
            @skills_window.active = true
            @skills_window.visible = true
            @skill_descr.visible = true
            @text_window.contents.clear
          when 1 # Selection ITEM
            $game_system.se_play($data_system.decision_se)
            scene = POKEMON_S::Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "battle")
            scene.main
            return_data = scene.return_data
            @phase = 0
            if $battle_var.action_id == 1
              @phase = 2
              @actor_action = 3
              @item_id = return_data
            end
          when 2 # Selection PKMN
            # ------- ---------- --------- --------
            #    Vérification switch permis
            # ------- ---------- --------- --------
            if not(switch_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            $game_system.se_play($data_system.decision_se)
            $battle_var.window_index = @action_window.index
            scene = POKEMON_S::Pokemon_Party_Menu.new(0, @z_level + 100)
            scene.main
            return_data = scene.return_data
            @phase = 0
            # Enregistrement données Switch de Pokémon
            if $battle_var.action_id == 2
              @phase = 2
              @actor_action = 2
              @switch_id = return_data
            end
          when 3 # sélection FUITE
            # ------- ---------- --------- --------
            #    Vérification fuite permise
            # ------- ---------- --------- --------
            @action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              return
            end
            @action_window.visible = true
           
            @action_window.active = false
            @action_window.visible = false
            @text_window.contents.clear
            run
          end
          return
        end
       
        if Input.trigger?(Input::C) and @skills_window.active
          index = @skills_window.index
          skill = @actor.skills_set[index]
          if skill != nil and skill.usable?
            @actor_action = 1
            @phase = 2
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @actor_skill = @actor.skills_set[index]
            $battle_var.last_index = @skills_window.index
          else
            $game_system.se_play($data_system.buzzer_se)
          end
        end
       
        if Input.trigger?(Input::B) and @skills_window.active
          $game_system.se_play($data_system.decision_se)
          @skills_window.active = false
          @skills_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @phase = 0
        end
       
       
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
       
        enemy_skill_decision
       
        statistic_refresh
        turn_order
        phase2
        phase3
       
        # Phase de switch de fin de tour
        $battle_var.action_id = 4
        end_battle_check
       
        if $battle_var.battle_end?
          return
        end
       
        # Fin de tour / Post_Round effects
        post_round_effect
        @actor_status.refresh
        @enemy_status.refresh
       
        if $battle_var.battle_end?
          return
        end
       
        # Phase de switch post_round
        $battle_var.action_id = 6
        end_battle_check
        @phase = 0
       
        if $battle_var.battle_end?
          return
        end
       
        # Incrémentation nombre de tours
        $battle_var.round += 1
       
      end
      return
    end
   
    #------------------------------------------------------------ 
    # Vérifications préliminaires et ordre d'action
    #------------------------------------------------------------
    def statistic_refresh
      @actor.statistic_refresh
      @enemy.statistic_refresh
    end
   
    #Recherche de priorité
    def turn_order
      # Comparaison des priorités
      if @actor_skill == nil or @enemy_skill == nil
        @strike_first = true
        return
      end
     
      if @actor_action != 1 # Attaque
        @strike_first = false
        return
      end 
     
      if @actor_skill.priority > @enemy_skill.priority
        @strike_first = true
      elsif @actor_skill.priority < @enemy_skill.priority
        @strike_first = false
      else
       
      # En cas d'égalité
        if @enemy.spd > @actor.spd
          @strike_first = false
        elsif @enemy.spd < @actor.spd
          @strike_first = true
        else
          @strike_first = rand(2)>0 ? true : false
        end
      end
    end
   
    #------------------------------------------------------------ 
    # Rounds
    #------------------------------------------------------------           
    def phase2 # Pré_Rounds
      @action_window.visible = false
      @action_window.active = false
      @actor_status.visible = true
      @enemy_status.visible = true
      @actor_status.refresh
      @enemy_status.refresh
      draw_text("","")
     
      # Préround 1: Fuite
      if @actor_action == 4
        run
      end
      if @enemy_action == 4
        enemy_run
      end
     
      # Préround 2: Item
      if @actor_action == 3
        actor_item_use
      end
      if @enemy_action == 3
        enemy_item_use
      end
     
      # Préround 3: Switch Pokémon
      if @actor_action == 2
        actor_pokemon_switch
      end
      if @enemy_action == 2
        enemy_pokemon_switch
      end
     
      @actor_status.refresh
      @enemy_status.refresh
    end
       
    # Round: Attaques
    def phase3
      if @strike_first
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
     
      if not(@strike_first)
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
    end
   
    #------------------------------------------------------------ 
    # Fonctions auxiliaires
    #------------------------------------------------------------    
    def switch(list, id1, id2)
      if id1 <= id2
        list.insert(id1, list[id2])
        list.delete_at(id2+1)
        list.insert(id2 + 1, list[id1+1])
        list.delete_at(id1+1)
        return list
      else
        switch(list, id2, id1)
      end
    end
   
    # Fonction auxiliaire
    def input
      if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
        Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
        Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
        return true
      end
      return false
    end
   
    def draw_text(line1 = "", line2 = "")
      if line1.type == Array
        if line1[1] != nil
          draw_text(line1[0], line1[1])
        else
          draw_text(line1[0])
        end
      else
        Graphics.freeze
        @text_window.contents.clear
        @text_window.draw_text(12, 0, 460, 50, line1)
        @text_window.draw_text(12, 55, 460, 50, line2)
        Graphics.transition(5)
      end
    end
   
    def draw_text_valid(line1 = "", line2 = "")
      draw_text(line1, line2)
      loop do
        Graphics.update
        Input.update
        if Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
    def wait(frame)
      i = 0
      loop do
        i += 1
        Graphics.update
        if i >= frame
          break
        end
      end
    end
   
    def wait_hit
      loop do
        Graphics.update
        Input.update
        if input
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ----------------------- Interface -------------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # Fenêtre de description
    #------------------------------------------------------------       
    def skill_descr_refresh
      @skill_descr.contents.clear
      index = @skills_window.index
      skill = @actor.skills_set[index]
      if skill != nil
        string = skill.pp.to_s + "/" + skill.ppmax.to_s
        type = skill.type
      else
        string = "---"
        type = 0
      end
      normal_color = Color.new(60,60,60)
      @skill_descr.contents.font.color = normal_color
      #@skill_descr.contents.draw_text(0,6,60,39, "PP:")
      @skill_descr.contents.draw_text(0,6,96,39, string, 1)
      #@skill_descr.contents.draw_text(0,60,140,39, "TP:")
      draw_type(0, 60, type)
    end 
     
    def draw_type(x, y, type)
      src_rect = Rect.new(0, 0, 96, 42)
      bitmap = RPG::Cache.picture("T" + type.to_s + ".png")
      @skill_descr.contents.blt(x, y, bitmap, src_rect, 255)
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ------------------ Fonctions de combat --------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------   
    # Fonctions spéciales - programmation des attaques
    #------------------------------------------------------------
    def heal(user, user_sprite, user_status, bonus)
      value = bonus.abs
      for i in 1..value
        if bonus >= 0
          user.add_hp(1)
        else
          user.remove_hp(1)
        end
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.hp >= user.max_hp or user.dead?
          break
        end
      end
    end
   
    def self_damage(user, user_sprite, user_status, damage)
      if damage > 0
        Audio.se_play("Audio/SE/Hit.wav", 100)
        blink(user_sprite)
      end
      for i in 1..damage
        user.remove_hp(1)
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.dead?
          break
        end
      end
    end
   
    #------------------------------------------------------------   
    # Fonctions communes - Programmation des attaques
    #------------------------------------------------------------
    # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé
    # 6: Confus, 7: Flinch, 8: Toxic
    #------------------------------------------------------------
    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre
    #------------------------------------------------------------
   
    # Fonction à appeler en cas d'effets sur le statut
    def status_check(target, status, forcing = false)
      # Immunités
      # Poison
      if (target.type_poison? or target.type_steel?) and
          (status == 1 or status == 8)
        draw_text(target.given_name + " est insensible", "au poison!")
        wait(40)
        return
      end
      # Freeze
      if status == 5 and target.type_ice?
        draw_text(target.given_name + " est insensible", "au gel!")
        wait(40)
        return
      end
      # Burn
      if status == 3 and target.type_fire?
        draw_text(target.given_name + " est insensible", "aux brûlures!")
        wait(40)
        return
      end
      # Soleil
      if status == 5 and $battle_var.sunny?
        draw_text("Le soleil empêche " + target.given_name, "de geler!")
        wait(40)
        return
      end
      # Lumber / Echauffement (ab)
      if status == 2 and target.ability == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.")
        wait(40)
        return
      end
      # Ignifu-voile / Water Veil (ab)
      if status == 3 and target.ability == 41
        draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.")
        wait(40)
        return
      end
      # Insomnia (ab) // Vital Spirit / Esprit Vital (ab)
      if status == 4 and (target.ability == 15 or target.ability == 72)
        draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.")
        wait(40)
        return
      end
      # Vaccin / Immunity (ab)
      if [1, 8].include?(status) and target.ability == 17
        draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.")
        wait(40)
        return
      end
      # Armumagma / Magma Armor (ab)
      if target.ability == 40 and status == 5
        draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.")
        wait(40)
        return
      end
      # Tempo Perso / Own Tempo (ab)
      if status == 6 and target.ability == 20
        draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.")
        wait(40)
        return
      end
      # Attention / Inner focus (ab)
      if target.ability == 39 and status == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.")
        wait(40)
        return
      end
      # Synchronize (ab)
      if target.ability == 28 and [1, 2, 3, 8].include?(status)
        target.ability_token = status
        if status == 8
          target.ability_token = 1
        end
      end
     
      if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status))
        status_string(target, -target.status) # animation
      elsif status == 6 and target.confused? and not(forcing)
        status_string(target, -6)
      elsif target.effect_list.include?(0x7C) and
          status != 7 # Rune Protect/Safeguard
        draw_text(target.given_name + "est", "protégé des altérations!")
        wait(40)
      elsif target.effect_list.include?(0x9F) and
          status == 4 # Uproar
        draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!")
        wait(40)
      else
        case status
        when 1
          target.status_poison(forcing)
        when 2
          target.status_paralyze(forcing)
        when 3
          target.status_burn(forcing)
        when 4
          target.status_sleep(forcing)
        when 5
          target.status_frozen(forcing)
        when 6
          target.status_confuse
        when 7
          target.status_flinch
        when 8
          target.status_toxic(forcing)
        end
        status_string(target, status)
      end
    end
   
    def accuracy_stage(user, target)
      stage = user.acc_stage - target.eva_stage
      stage = stage < -6 ? -6 : stage > 6 ? 6 : stage
     
      # --------------- ---------------- --------------
      #           Programmation des attaques
      # --------------- ---------------- --------------
      # Clairvoyayance / Foresight
      if target.effect_list.include?(0x71)
        stage = user.acc_stage
      end
      # --------------- ---------------- --------------
      # --------------- ---------------- --------------
     
      case stage
      when -6
        return 33.0/100
      when -5
        return 36.0/100
      when -4
        return 43.0/100
      when -3
        return 50.0/100
      when -2
        return 60.0/100
      when -1
        return 75.0/100
      when 0
        return 1
      when 1
        return 133.0/100
      when 2
        return 166.0/100
      when 3
        return 2
      when 4
        return 250.0/100
      when 5
        return 133.0/50
      when 6
        return 3
      end
    end
   
    #------------------------------------------------------------ 
    # Post_round
    #------------------------------------------------------------        
    def post_round_effect
      # --------- -------------- --------------------
      # Fin des effets "at the end of a round"
      # --------- -------------- --------------------     
      # Suppression état appeuré (ne dure que un tour)
      @actor.flinch_check
      @enemy.flinch_check
      # Suppression état autre
      if @actor.dead?
        @actor.cure
        @actor.cure_state
      end
      if @enemy.dead?
        @enemy.cure
        @enemy.cure_state
      end
     
      # --------- -------------- --------------------
      # Programmation des attaques en Post-round
      # --------- -------------- --------------------
      #      Cycle commun 0 - Souhait et Météo
      # --------- -------------- --------------------
      post_round_cycle0
     
      # --------- -------------- --------------------
      #         Cycle individuel 1
      #      Programmation des attaques
      #           Effets du statut
      # --------- -------------- --------------------     
      if @strike_first
        post_round_cycle_1(@actor, @enemy)
        post_round_cycle_1(@enemy, @actor)
      else
        post_round_cycle_1(@enemy, @actor)
        post_round_cycle_1(@actor, @enemy)
      end
     
      # --------- -------------- --------------------
      #                Cycle 2
      #         Programmation des attaques
      #            Dommages finaux
      # --------- -------------- --------------------
      if @strike_first
        post_round_cycle_2(@actor, @enemy)
        post_round_cycle_2(@enemy, @actor)
      else
        post_round_cycle_2(@enemy, @actor)
        post_round_cycle_2(@actor, @enemy)
      end
     
      @actor.skill_effect_clean
      @enemy.skill_effect_clean
     
      faint_check
     
      # Round suivant
      if $battle_var.round == nil
        $battle_var.round = 0
      end
      $battle_var.round += 1
    end
   
   
    # --------- -------------- --------------------
    #     Cycle commun 0 - Météo et Souhait
    # --------- -------------- --------------------
    def post_round_cycle0
      if @strike_first
        list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]]
      else
        list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]]
      end
     
      # Suppression du contrôle pour un pokémon mort
      for array in list
        if array[0].dead?
          list.delete(array)
        end
      end
     
      for array in list
        actor = array[0]
        actor.skill_effect_end_turn
        for effect in actor.effect_list
          case effect
          when 0x56 # Entrave / Disable
            index = actor.effect_list.index(0x56)
            if actor.effect[index][1] == 0
              skill_id = actor.effect[index][2]
              skill = actor.skills_set[skill_id]
              skill.enable
              draw_text(skill.name + " de "+ actor.given_name, "est rétablie!")
              wait(40)
            end
          when 0x5A # Encore
            index = actor.effect_list.index(0x5A)
            if actor.skills_set[index].pp == 0
              actor.effect[index][1] = 0 # Fin de l'effet
            end
          when 0x75 # Rollout
            index = actor.effect_list.index(0x75)
            ## N'a pas fait de dégât ce tour ci >> Supprimé
            #if actor.effect[index][2] != actor.effect[index][1]
            #  actor.effect.delete_at(index)
            #end
            if actor.asleep? or actor.frozen?
              actor.effect.delete_at(index)
            end
          when 0x77 # Taillade / Fury Cutter
            index = actor.effect_list.index(0x77)
            # N'a pas fait de dégât ce tour ci >> Supprimé
            if actor.effect[index][2] != actor.effect[index][1]
              actor.effect.delete_at(index)
            end
          end
        end
      end
     
      weather = $battle_var.weather[0]
      $battle_var.weather[1] -= 1
      count = $battle_var.weather[1]
     
      # Souhait -- Programmation des attaques
      for array in list
        target = array[0]
        target_sprite = array[1]
        target_status = array[2]
        if target.effect_list.include?(0xB3)
          bonus = target.hp / 2
          draw_text("Un souhait est réalisé.")
          heal(target, target_sprite, target_status, bonus)
          wait(40)
        end
      end
     
      # Pluie
      if $battle_var.rain? and count != 0
        draw_text("La pluie continue de", "tomber.")
        animation = $data_animations[379]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.rain? and count == 0
        draw_text("La pluie s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Ensoleillé
      if $battle_var.sunny? and count != 0
        draw_text("Les rayons du soleil","tapent fort.")
        animation = $data_animations[378]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.sunny? and count == 0
        draw_text("Le soleil est parti.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Tempete de sable
      if $battle_var.sandstorm? and count != 0
        draw_text("La tempête de sable souffle.")
        animation = $data_animations[380]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégats
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ground? or target.type_rock? or target.type_steel?
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or
              target.ability == 8
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.sandstorm? and count == 0
        draw_text("La tempête de sable s'est arretée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Grêle
      if $battle_var.hail? and count > 0
        draw_text("Il grêle...")
        animation = $data_animations[381]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégâts
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ice? or
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3)
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.hail? and count == 0
        draw_text("La grêle s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
    end
   
   
   
   
    # --------- -------------- --------------------
    #              Cycle individuel 1
    # --------- -------------- --------------------
    def post_round_cycle_1(actor, enemy)
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un Pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #    Programmation des attaques et des capa
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0xB5 # Ingrain / Racines
          bonus = actor.max_hp / 16
          draw_text(actor.given_name + " puise", "de l'énergie dans la terre.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      end
     
      case actor.ability
      when 44 # Cuvette / Rain Dish (ab)
        if $battle_var.rain?
          bonus = actor.max_hp / 16
          draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.")
          wait(40)
        end
      when 54 # Absentéisme / Truant (ab)
        if actor.ability_token == nil
          actor.ability_token = true
        end
        if actor.ability_token == true
          actor.ability_token = false
        elsif actor.ability_token == false
          actor.ability_token = true
        end
      when 61 # Mue / Shed skin (ab)
        if actor.status != 0 and rand(100) < 30
          actor.cure
          draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.")
          wait(40)
        end
      end
     
      for effect in enemy.effect_list
        case effect
        when 0x54 # Leech Seed / Vampigraine
          malus = actor.max_hp / 8
          draw_text("L'énergie de " + actor.given_name,"est drainée!")
          heal(actor, actor_sprite, actor_status, -malus)
          heal(enemy, enemy_sprite, enemy_status, malus)
          wait(40)
        when 0x2A # Multi_turn attack
          damage = actor.max_hp / 16
          draw_text(actor.given_name, "est piégé!")
          self_damage(actor, actor_sprite, actor_status, damage)
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #          Inspection des statuts
      # --------- -------------- --------------------
      if actor.status == 1 # Poison
        damage = actor.poison_effect
        draw_text(actor.given_name + " souffre", "du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 8 # Toxic
        damage = actor.toxic_effect
        draw_text(actor.given_name + " souffre", "gravement du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 3 #Burn
        damage = actor.burn_effect
        draw_text(actor.given_name + " souffre", "de ses brûlures.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
     
      actor.confuse_decrement
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------     
      for effect in actor.effect_list
        case effect
        when 0x6B # Nightmare / Cauchemar
          if actor.asleep?
            damage = actor.max_hp / 4
            draw_text(actor.given_name + " fait", "un chauchemar!")
            heal(actor, actor_sprite, actor_status, -damage)
            wait(20)
          else
            index = actor.effect_list.index(0x6B)
            actor.effect.delete_at(index)
          end
        when 0x6D # Curse
          damage = actor.max_hp / 4
          draw_text(actor.given_name + " est", "maudit!")
          heal(actor, actor_sprite, actor_status, -damage)
          wait(20)
        when 0x9F # Uproar / Brouhaha
          if actor.asleep?
            actor.cure
            draw_text(actor.given_name + " se réveille", "à cause du brouhaha!")
            wait(40)
          end
          if actor.frozen? #Fin de l'effet
            index = actor.effect_list.index(0x9F)
            actor.effect.delete_at(index)
          end
        when 0xAF # Taunt / Provoc
          index = actor.effect_list.index(0xAF)
          for skill in actor.skills_set
            if skill.power == 0 and actor.effect[index][1] > 0
              draw_text(skill.name + " est bloqué!")
              skill.disable
              wait(40)
            elsif actor.effect[index][1] == 0
              draw_text(skill.name + " est rétablit.")
              skill.enable
              wait(40)
            end
          end
        when 0xBB # Yawn / Baillement
          if actor.status == 0
            status_check(actor, 4)
            actor_status.refresh
          end
        end
      end
     
      if actor.dead?
        return
      end
      # --------- -------------- --------------------
      #                  Berry check
      # --------- -------------- -------------------- 
      if $item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp
        draw_text(actor.given_name + " récupère un peu", "de vie avec " + $item.name(actor.item_hold) + ".")
        bonus = actor.max_hp / 16
        if bonus == 0
          bonus = 1
        end
        heal(actor, actor_sprite, actor_status, bonus)
        wait(40)
      end
    end
     
    # --------- -------------- --------------------
    #              Cycle individuel 2
    # --------- -------------- --------------------    
    def post_round_cycle_2(actor, enemy)
      # Redéfinition
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des capacités
      # --------- -------------- --------------------
      case actor.ability
      when 2 # Crachin / Drizzle (ab)
        if not($battle_var.rain?) # Pluie
          draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.")
          wait(40)
          animation = $data_animations[379]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_rain
      when 45 # Sable Volant / Sand stream (ab)
        if not($battle_var.sandstorm?) # Tempete Sable
          draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.")
          wait(40)
          animation = $data_animations[380]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 70 # Sècheresse / Drought (ab)
        if not($battle_var.sunny?) # Soleil
          draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.")
          wait(40)
          animation = $data_animations[378]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 3 # Speed Boost (ab)
        draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.")
        actor.change_spd(+1)
        stage_animation(actor_sprite, $data_animations[368])
        wait(40)
      when 22 # Intimidate (ab)
        if not(actor.ability_active)
          actor.ability_active = true
          draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".")
          enemy.change_atk(-1)
          stage_animation(enemy_sprite, $data_animations[365])
          wait(40)
        end
      when 59 # Forecast / Meteo (ab)
        if $battle_var.sunny? and not(actor.type_fire?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en FEU!")
          actor.ability_token = 2
        elsif $battle_var.rain? and not(actor.type_water?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en EAU!")
          actor.ability_token = 3
        elsif $battle_var.hail? and not(actor.type_ice?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en GLACE!")
          actor.ability_token = 6
        elsif not(actor.type_normal?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en NORMAL!")
          actor.ability_token = 0
        end
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0x72 # Requiem / Perish Song
          index = actor.effect_list.index(0x72)
          number = actor.effect[index][1]
          if number > 0
            if number > 1
              string = number.to_s + " tours"
            elsif number == 1
              string = number.to_s + " tour"
            end
            draw_text("Plus que " + string, "pour " + actor.given_name + "...")
            wait(40)
          else
            draw_text(actor.given_name + " est", "K.O. par REQUIEM!")
            damage = actor.hp
            heal(actor, actor_sprite, actor_status, -damage)
            wait(40)
          end
        end
      end
     
      # --------- -------------- --------------------
      #      Nettoyage des compteurs d'effets
      # --------- -------------- --------------------
      for effect in actor.effect
        case effect
        when [0x10, 0] # Reflet / Reflect
          draw_text("L'effet de REFLET est", "terminé.")
          wait(40)
        when [0x23, 0] # Light Screen
          draw_text("L'effet de MUR LUMIERE est", "terminé.")
          wait(40)
        when [0x2E, 0] # Brume / Mist
          draw_text("La brume se dissipe.")
          wait(40)
        when [0x7C, 0] # Rune Protect / Safeguard
          draw_text("L'effet de RUNE PROTECT", "est terminé.")
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
    end
   
   
   
    #------------------------------------------------------------ 
    # Items
    #------------------------------------------------------------    
    def actor_item_use # items à utiliser
      # Item déjà utilisé ie remplacé par 0
      if @item_id == 0
        return
      end
    end

    #------------------------------------------------------------ 
    # Switch de pokémon
    #------------------------------------------------------------        
    def actor_pokemon_switch
      if @switch_id != -1
        if not(@actor.dead?)
          @actor_status.visible = true
        else
          @actor_status.visible = false
        end
       
        switch_effect(@actor, @enemy)
       
        if not(@actor.dead?)
          recall_pokemon
        end
       
        @battle_order = switch(@battle_order, 0, @switch_id)
        @actor = @party.actors[@battle_order[0]]
        @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
        @actor_status = POKEMON_S::Pokemon_Battle_Status.new(@actor, false)
        @actor_status.visible = false
        if not($battle_var.have_fought.include?(@actor.party_index))
          $battle_var.have_fought.push(@actor.party_index)
        end
       
        launch_pokemon
        @actor_status.visible = true
        @switch_id = -1
      end
    end
   
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy.dead?)
          @enemy_status.visible = true
        else
          @enemy_status.visible = false
        end
       
        switch_effect(@enemy, @actor)
       
        if not(@enemy.dead?)
          recall_enemy_pokemon
        end
       
        @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id)
        @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]]
        $data_pokedex[@enemy.id][0] = true
        @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
        @enemy_status = POKEMON_S::Pokemon_Battle_Status.new(@enemy, true)
        @enemy_status.visible = false
       
        launch_enemy_pokemon
        @enemy_status.visible = true
        @enemy_switch_id = -1
      end
    end
   
    #------------------------------------------------------------ 
    # Fuite
    #------------------------------------------------------------          
    def run
      if run_able?(@actor, @enemy)
        $battle_var.run_count += 1
        @action_window.active = false
        @action_window.visible = false
        end_battle_flee
      else
        $battle_var.run_count += 1
        fail_flee
        @phase = 2
        @actor_action = 0
        $battle_var.action_id = 0
      end
    end
   
    def run_able?(runner, opponent)
      x = (Integer(opponent.spd/4) % 255)
      rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count))
      if not(flee_able(runner, opponent))
        return false
      end
      if opponent.spd <= runner.spd
        return true
      elsif x == 0
        return true
      elsif rate > 255
        return true
      elsif rand(256) <= rate
        return true
      else
        return false
      end
    end
   
    def run_enemy
      if run_able?(@enemy, @actor)
        end_battle_flee_enemy
      end
    end
   
    #------------------------------------------------------------ 
    # Animations supplémentaires au combat
    #------------------------------------------------------------  
    # Défaites / KO
    #------------------------------------------------------------      
    def enemy_down
      # Si déjà vaincu
      if @enemy_sprite.zoom_y == 0
        return
      end
      # Sinon
      @enemy_sprite.oy = @enemy_sprite.bitmap.height
      @enemy_sprite.y += @enemy_sprite.bitmap.height / 2
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
     
      loop do
        @enemy_status.x -= 20
        #@enemy_sprite.zoom_y -= 0.05
        @enemy_sprite.y += 8
        @enemy_sprite.opacity -= 20
        Graphics.update
        #if @enemy_sprite.zoom_y <= 0.0
        if @enemy_sprite.y >= 348
          @enemy_sprite.zoom_y = 0
          break
        end
      end
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.y -= @enemy_sprite.bitmap.height
      draw_text(@enemy.given_name, "est K.O.!")
      wait(40)
    end
   
    def actor_down
      # Si déjà vaincu
      #if @actor_sprite.zoom_y <= 0.0
      if @actor_sprite.y >= 576
        return
      end
      # Sinon
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
      loop do
        @actor_status.x += 20
        #@actor_sprite.zoom_y -= 0.05
        @actor_sprite.y += 12
        @actor_sprite.opacity -= 20
        Graphics.update
        #if @actor_sprite.zoom_y <= 0.0
        if @actor_sprite.y >= 576
          break
        end
      end
     
      draw_text(@actor.given_name, "est K.O.!")
      wait(40)
    end
   
    #------------------------------------------------------------      
    # Attaques
    #------------------------------------------------------------
    def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite)
      if miss
        wait(40)
        draw_text("Mais cela échoue!")
        wait(40)
        return
      end
     
      if user == @enemy
        reverse = true
      else
        reverse = false
      end
     
      efficiency = info[2]
      if hit and efficiency != -2
        # Animation utilisateur
        animation_user = $data_animations[user_skill.user_anim_id]
        if animation_user != nil
          user_sprite.animation(animation_user, true, reverse)
          until not(user_sprite.effect?)
            user_sprite.update
            Graphics.update
          end
        end
       
        user_sprite.update
        Graphics.update
       
        # Animation Cible
        animation_target = $data_animations[user_skill.target_anim_id]
        if animation_target != nil
          target_sprite.animation(animation_target, true, reverse)
          until not(target_sprite.effect?)
            target_sprite.update
            Graphics.update
          end
        end
       
        target_sprite.update
        Graphics.update
       
        if info[0] > 0
          case efficiency
          when 0 # Normal
            Audio.se_play("Audio/SE/Hit.wav", 100)
            blink(target_sprite, 3, 3)
          when 1 # Super efficace
            Audio.se_play("Audio/SE/Hitplus.wav", 100)
            blink(target_sprite, 2, 5)
          when -1 # Peu efficace
            Audio.se_play("Audio/SE/Hitlow.wav", 100)
            blink(target_sprite, 4, 2)
          end
        end
      elsif not(hit)
        wait(40)
        draw_text(user.given_name, "rate son attaque!")
        wait(40)
      end
    end
   
    def blink(sprite, frame = 4, number = 3)
      for i in 0..number
        wait(frame)
        sprite.opacity = 0
        Graphics.update
        wait(frame)
        sprite.opacity = 255
        Graphics.update
      end
    end
   
    def post_attack(info, damage, power)
      efficiency = info[2]
      if damage == 0 and (efficiency != -2 or power == 0)
        return
      end
      critical = info[1]
      if critical  and efficiency != -2 #critical_hit
        draw_text("Coup critique!")
        wait(40)
      end
      case efficiency
      when 1
        draw_text("C'est super efficace!")
        wait(40)
      when -1
        draw_text("Ce n'est pas très efficace...")
        wait(40)
      when -2
        draw_text("Ca ne l'affecte pas...")
        wait(40)
      end
    end
   
    def faint_check(user = nil)
      if user == nil
        faint_check(@actor)
        faint_check(@enemy)
      end
      if user == @actor and user.dead?
        actor_down
      end
      if user == @enemy and user.dead?
        enemy_down
      end
    end
       
   
    #------------------------------------------------------------      
    # Statut et stats
    #------------------------------------------------------------   
    def status_animation(sprite, status)
      animation = $data_animations[355 + status]
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          break
        end
      end
    end
   
    def stage_animation(sprite, animation)
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          wait(20)
          break
        end
      end
    end

    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
    def type_string(type)
      case type
      when 0
        return "???"
      when 1
        return "NORMAL"
      when 2
        return "FEU"
      when 3
        return "EAU"
      when 4
        return "ELECTRIK"
      when 5
        return "PLANTE"
      when 6
        return "GLACE"
      when 7
        return "COMBAT"
      when 8
        return "POISON"
      when 9
        return "SOL"
      when 10
        return "VOL"
      when 11
        return "PSY"
      when 12
        return "INSECTE"
      when 13
        return "ROCHE"
      when 14
        return "SPECTRE"
      when 15
        return "DRAGON"
      when 16
        return "ACIER"
      when 17
        return "TENEBRES"
      end
    end
   
   
    # Changement (ou pas) de statut
    def status_string(actor, status)
      string = actor.given_name
      case status
      when -1
        draw_text(string + " est", "déjà empoisonné!")
        wait(40)
      when -2
        draw_text(string + " est", "déjà paralysé!")
        wait(40)
      when -3
        draw_text(string,"brûle déjà!")
        wait(40)
      when -4
        draw_text(string,"dort déjà!")
        wait(40)
      when -5
        draw_text(string, "est déjà gelé!")
        wait(40)
      when -6
        draw_text(string, "est déjà confus!")
        wait(40)
      when -8
        draw_text(string + " est", "déjà gravement empoisonné!")
        wait(40)
      when 1
        draw_text(string, "est empoisonné!")
        wait(40)
      when 2
        draw_text(string, "est paralysé!")
        wait(40)
      when 3
        draw_text(string,"brûle!")
        wait(40)
      when 4
        draw_text(string,"s'endort!")
        wait(40)
      when 5
        draw_text(string,"gèle!")
        wait(40)
      when 6
        draw_text("Cela rend " + string, "confus!")
        wait(40)
      when 7
        draw_text(string, "est appeuré!")
        wait(40)
      when 8
        draw_text(string + " est", "gravement empoisonné!")
        wait(40)
      end
    end
   
    # S'occupe du texte et de l'animation
    def raise_stat(string, actor, n = 0)
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == 1
        text = actor.given_name + " augmente!"
      elsif n > 1
        text = actor.given_name + " augmente beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[364])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[366])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[370])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[372])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[368])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[374])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[376])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    def reduce_stat(string, actor, n = true, self_inflicted = false)
      # Mist/Brume
      if actor.effect_list.include?(0x2E)
        draw_text(actor.given_name + " est", "protégé par la brume!")
        wait(40)
        return
      end
      # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab)
      if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted)
        draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!")
        wait(40)
        return
      end
      # Keen Eye / Regard Vif (ab)
      if actor.ability == 51 and string == "ACC"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!")
        wait(40)
        return
      end
      # Hyper Cutter (ab)
      if actor.ability == 52 and string == "ATK"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!")
        wait(40)
        return
      end
     
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == -1
        text = actor.given_name + " baisse!"
      elsif n < -1
        text = actor.given_name + " baisse beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[365])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[367])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[371])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[373])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[369])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[375])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[377])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    #------------------------------------------------------------      
    # Appel / Rappel de Pokémon
    #------------------------------------------------------------          
    def recall_pokemon
      draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!")
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.y = 336
      @actor_sprite.x = 156
      @actor_sprite.color = @actor.ball_color
      @actor_sprite.color.alpha = 0
     
      until @actor_sprite.color.alpha >= 255
        @flash_sprite.opacity += 25
        @actor_sprite.color.alpha += 25
        Graphics.update
      end
     
      Audio.se_play("Audio/SE/Pokeopen.wav")
      loop do
        @actor_status.x += 20
        @actor_sprite.opacity -= 25
        @actor_sprite.color.alpha += 25
        @actor_sprite.zoom_x -= 0.1
        @actor_sprite.zoom_y -= 0.1
        @flash_sprite.opacity -= 25
        Graphics.update
        if @actor_status.x >= 711
          @actor_status.visible = false
          @actor_status.x = 711
          @actor_sprite.color.alpha = 0
          @actor_sprite.opacity = 0
          Graphics.update
          break
        end
      end
    end
   
    def launch_pokemon
      @actor_sprite.x = 156
      @actor_sprite.y = 336
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.zoom_x = 0
      @actor_sprite.zoom_y = 0
     
      #if @actor_party_status.active
      #  @actor_party_status.x = 0
      #  @actor_party_status.visible = true
      #end
     
      name = @actor.given_name
      text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)]
      draw_text(text)
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = -44
      @ball_sprite.y = 324
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x += 5
        @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        #if @actor_party_status.active
        #  @actor_party_status.x -= 80
        #end
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          #if @actor_party_status.active
          #  @actor_party_status.x = 0
          #  @actor_party_status.visible = false
          #end
          break
        end
      end
      @actor_sprite.opacity = 0
      @actor_sprite.color = @actor.ball_color
     
      until @actor_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @actor_sprite.zoom_x += 0.1
        @actor_sprite.zoom_y += 0.1
        @actor_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
     
      @actor_sprite.zoom_x = 1
      @actor_sprite.zoom_y = 1
      @actor_sprite.opacity = 255
     
      @actor_status.x = 711
      @actor_status.visible = true
     
      if @actor.shiny
        animation = $data_animations[382]
        @actor_sprite.animation(animation, true)
      end
     
      until @actor_status.x == 311
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @actor_status.x -= 20
        @actor_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @actor_sprite.update
        Graphics.update
      end
     
      until not(@actor_sprite.effect?)
        @actor_sprite.update
        Graphics.update
      end
     
      @actor_status.x = 311
      @actor_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    def launch_enemy_pokemon
      @enemy_sprite.x = 463
      @enemy_sprite.y = 108
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.zoom_x = 0
      @enemy_sprite.zoom_y = 0
     
      string = $trainer.type(@trainer_id) + " " + $trainer.name(@trainer_id)
      draw_text(@enemy.name + " est envoyé", "par " + string + "!")
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = 663
      @ball_sprite.y = 108
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x -= 5
        @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          break
        end
      end
      @enemy_sprite.opacity = 0
      @enemy_sprite.color = @enemy.ball_color
     
      until @enemy_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @enemy_sprite.zoom_x += 0.08
        @enemy_sprite.zoom_y += 0.08
        @enemy_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      @enemy_sprite.zoom_x = 1
      @enemy_sprite.zoom_y = 1
      @enemy_sprite.opacity = 255
     
      @enemy_status.x = -377
      @enemy_status.visible = true
     
      if @enemy.shiny
        animation = $data_animations[382]
        @enemy_sprite.animation(animation, true)
      end
     
      until @enemy_status.x == 23
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @enemy_status.x += 20
        @enemy_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @enemy_sprite.update
        Graphics.update
      end
     
      until not(@enemy_sprite.effect?)
        @enemy_sprite.update
        Graphics.update
      end
     
      @enemy_sprite.x = 463
      @enemy_status.x = 23
      @enemy_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    #------------------------------------------------------------ 
    # Fin de combat
    #------------------------------------------------------------     
    def end_battle(result = 0)     
      # Reset des variables et effets
      $battle_var.reset
      @actor.skill_effect_reset
      @actor.reset_stat_stage
      @actor.cure_state
      @actor.ability_active = false
      @enemy.skill_effect_reset
      @enemy.reset_stat_stage
      @enemy.cure_state
      @enemy.ability_active = false
      # -----------------------------------
      Audio.me_stop
      wait(10)
      $game_system.bgm_play($game_temp.map_bgm)
      wait(10)
      Graphics.freeze
      # -----------------------------------
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      # Défaite
      $scene = Scene_Map.new
    end
   
    def end_battle_flee(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@actor.given_name, "est expulsé du combat!")
        loop do
          if @actor_sprite.x > -160
            @actor_sprite.x -= 20
          end
          Graphics.update
          Input.update
          if @actor_sprite.x <= -160
            wait(40)
            break
          end
        end
      else
        draw_text("Vous prenez la fuite!")
        wait(40)
      end
      end_battle(1)
    end
   
    def fail_flee
      draw_text("Vous ne pouvez pas","vous enfuir!")
      wait(40)
    end
   
    def end_battle_flee_enemy(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@enemy.given_name, "est expulsé du combat!")
      else
        draw_text(@enemy.given_name + " s'échappe!")
      end
      loop do
        if @enemy_sprite.x < 800
          @enemy_sprite.x += 20
        end
        Graphics.update
        Input.update
        if @enemy_sprite.x >= 800
          wait(40)
          break
        end
      end
      end_battle(1)
    end
   
    def end_battle_defeat
      $battle_var.result_defeat = true
      draw_text("Tous vos Pokémons", "ont été vaincus!")
      wait(40)
      $pokemon_party.money /= 2
      if not(@lose)
        if $game_variables[1] == 0
          print("Réglez votre point de retour!")
        else
          $game_map.setup($game_variables[1])
          $game_map.display_x = $game_variables[2]
          $game_map.display_y = $game_variables[3]
          $game_player.moveto($game_variables[2], $game_variables[3])
        end
        $game_temp.common_event_id = 2
      end
      $game_temp.map_bgm = $game_map.bgm
      end_battle(2)
    end
   
    def draw_choice
      @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig)
      @command.x = 517
      @command.y = 215
      loop do
        Graphics.update
        Input.update
        @command.update
        if Input.trigger?(Input::C) and @command.index == 0
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return true
        end
        if Input.trigger?(Input::C) and @command.index == 1
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return false
        end
      end
    end
  end
 
  #------------------------------------------------------------ 
  # Fenêtre de statut
  #------------------------------------------------------------ 
  class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(0,0,0,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size(@pokemon.name).width + 3
        draw_gender(15 + width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(9, 42, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)

        class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
  
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(248,248,248,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(242 - width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(20, 47, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(46, 99, 1.0 - level, 232)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(268 - width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(44, 68, bitmap, src_rect, 255)
        end
      end
    end
  
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(46, 99, 1.0 - level, 232)
    end
    
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
    
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
  
    def dispose
      super
    end
  
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3)
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3)
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6)
      end
    
      if level < 0.1
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(248, 64, 16, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(232, 168, 50, 255)
      else
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(24, 192, 32, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
  
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*232.to_i, 3)
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255))
    end
  
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)      
      end
    end
  end


  #------------------------------------------------------------
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
  
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
  
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
    
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
    
for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
  
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end
      @run_count = 0
      @money = 0
    end
   
    def reset
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = POKEMON_S::Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
   
    def reset_weather
      @weather = [0, 0]
    end
   
    def set_rain(duration = -1)
      @weather = [1, duration]
    end
   
    def rain?
      if @weather[0] == 1
        return true
      else
        return false
      end
    end
   
    def set_sunny(duration = -1)
      @weather = [2, duration]
    end
   
    def sunny?
      if @weather[0] == 2
        return true
      else
        return false
      end
    end
   
    def sandstorm?
      if @weather[0] == 3
        return true
      else
        return false
      end
    end
   
    def set_sandstorm(duration = -1)
      @weather = [3, duration]
    end
   
    def hail?
      if @weather[0] == 4
        return true
      else
        return false
      end
    end
   
    def set_hail(duration = -1)
      @weather = [4, duration]
    end
   
    def battle_end?
      if @result_flee or @result_win or @result_defeat
        return true
      else
        return false
      end
    end
   
    def add_money(amount)
      if @money == nil
        @money = 0
      end
      @money += amount
    end
   
  end
 
end


Posté par Pαlвσlѕку le 22 Sep - 08:05 (2008)
Il y a une erreur dans le script.

Une ligne de ton script contient ça :


Code:
if @party.actors[@battle_order[i]].dead?

Remplace là par ça :


Code:
if @party.actors[@battle_order[i-1]].dead?

Si ça ne marche toujours pas, indique moi la ligne qui bug car là je ne sais même si j'ai corrigé la bonne ligne.

Posté par <€d> le 22 Sep - 17:35 (2008)
Toujours le même bug:

 
Scripte
#==============================================================================
# ■ Pokemon_Battle_Core
# Pokemon Script Project - Krosk
# 20/07/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Système de Combat - Squelette général
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé, 8: Toxic
# @confuse (6), @flinch (7)
#-----------------------------------------------------------------------------
# 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
# 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# $battle_var.action_id
#   0 : Phase de Sélection
#   1 : Sélection Item
#   2 : Switch Pokémon
#   4 : Switch Fin de Tour
#-----------------------------------------------------------------------------

module POKEMON_S
  #------------------------------------------------------------ 
  # Pokemon_Battle_Core
  #   noyau possédant les fonctions communes aux combats sauvages/dresseurs
  #------------------------------------------------------------ 
  #------------------------------------------------------------ 
  # Fonctions à définir à l'extérieur
  #   initialize
  #   pre_battle_animation
  #   enemy_skill_decision
  #   end_battle_check
  #   actor_item_use
  #   catch_pokemon
  #   run_able?
  #   end_battle_victory
  #------------------------------------------------------------ 
  class Pokemon_Battle_Core
    attr_accessor :z_level
    attr_accessor :actor_status
    attr_accessor :actor
    attr_accessor :actor_sprite
   
    #------------------------------------------------------------ 
    # ------------------- Squelette Général ---------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # main
    #------------------------------------------------------------
     def main
      # Pré-création des Sprites
      # Fond
      if @battleback_name != ""
      if $game_switches[12] == true # J pour jour
        @battleback_name = $game_map.battleback_name + ".png"
        @ground_name = "ground" + $game_map.battleback_name + ".png"
      elsif $game_switches[16] == true # N pour nuit
        @battleback_name = $game_map.battleback_name + "N" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "N" + ".png"
      elsif $game_switches[18] == true # AC pour matin
        @battleback_name = $game_map.battleback_name + "AC" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "AC" + ".png"
      elsif $game_switches[14] == true # AC pour soir
        @battleback_name = $game_map.battleback_name + "AC" + ".png"
        @ground_name = "ground" + $game_map.battleback_name + "AC" + ".png"
      end
      else
        print("Attention, réglez le BattleBack du Tileset.")
        @battleback_name = "battle0.png"
        @ground_name = "groundbattle0.png"
      end
      @background = Sprite.new
      @background.z = @z_level
     
      # Fond du message
      @message_background = Sprite.new
      @message_background.y = 336
      @message_background.z = @z_level + 19
     
      # Sprite de flash
      @flash_sprite = Sprite.new
      @flash_sprite.bitmap = RPG::Cache.picture("black.png")
      @flash_sprite.color = Color.new(255,255,255)
      @flash_sprite.opacity = 0
      @flash_sprite.z = @z_level + 13
     
      # Fenetre de texte
      @text_window = Window_Base.new(4, 340, 632, 136)
      @text_window.opacity = 0
      @text_window.z = @z_level + 20
      @text_window.contents = Bitmap.new(600 + 32, 104 + 32)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsizebig
     
      # Fenetre d'action
      s1 = "ATTAQUE"
      s2 = "SAC"
      s3 = "POKéMON"
      s4 = "FUITE"
     
      @action_window = Window_Command.new(320, [s1, s2, s3, s4], $fontsizebig, 2, 56)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
     
      # Viewport
      battle_viewport = Viewport.new(0, 0, 640, 336)
      battle_viewport.z = @z_level + 15
     
      # Sprites acteurs # Positions par défaut des centres
      @enemy_sprite = RPG::Sprite.new(battle_viewport)
      @enemy_sprite.x = 463
      @enemy_sprite.y = 108
      @enemy_sprite.z = @z_level + 15
      @enemy_ground = RPG::Sprite.new
      @enemy_ground.x = 463
      @enemy_ground.y = 163
      @enemy_ground.z = @z_level + 11
      @actor_sprite = RPG::Sprite.new(battle_viewport)
      @actor_sprite.x = 156
      @actor_sprite.y = 336
      @actor_sprite.z = @z_level + 15
      @actor_ground = RPG::Sprite.new
      @actor_ground.x = 156
      @actor_ground.y = 386
      @actor_ground.z = @z_level + 11
     
      # Création fenêtre de statut
      @actor_status = POKEMON_S::Pokemon_Battle_Status.new(@actor, false, @z_level + 15)
      @enemy_status = POKEMON_S::Pokemon_Battle_Status.new(@enemy, true, @z_level + 15)
      @actor_status.visible = false
      @enemy_status.visible = false
      @enemy_caught = false
     
      @actor_party_status = POKEMON_S::Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10)
      @enemy_party_status = POKEMON_S::Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10)
      @actor_party_status.visible = false
      @enemy_party_status.visible = false
      # note: .active = true activera les animations liées à ces fenêtres
      @actor_party_status.active = false
      @enemy_party_status.active = false
     
      # Lancement des animations
      pre_battle_transition
      pre_battle_animation
     
      # Effets pré-premier round
      post_round_effect
     
     
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
     
      # Fin de scene
      Graphics.freeze
      @background.dispose
      @message_background.dispose
      @flash_sprite.dispose
      @text_window.dispose
      @action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
      end
      if @ball_sprite != nil
        @ball_sprite.dispose
      end
      @enemy_sprite.dispose
      @actor_sprite.dispose
      @actor_status.dispose
      @enemy_status.dispose
      @actor_party_status.dispose
      @enemy_party_status.dispose
    end
   
    #------------------------------------------------------------ 
    # Déroulement
    #------------------------------------------------------------
    def update
      case @phase
      when 0 # Phase d'initialisation
        @phase = 1
       
        # Création fenêtre de skill
        list = []
        for skill in @actor.skills_set
          list.push(skill.name)
        end
        while list.size < 4
          list.push("  ---")
        end
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
       
        # Compétences bloquées
        for i in 0..@actor.skills_set.length-1
          skill = @actor.skills_set[i]
          if not(skill.usable?)
            @skills_window.disable_item(i)
          end
        end
       
        # Curseur sur le dernier choix
        if $battle_var.last_index == nil
          $battle_var.last_index = 0
          @skills_window.index = 0
        else
          @skills_window.index = $battle_var.last_index
        end
       
        # Création fenêtre description de skill
        @skill_descr = Window_Base.new(512, 336, 128, 144)
        @skill_descr.contents = Bitmap.new(96, 144)
        @skill_descr.contents.font.name = $fontface
        @skill_descr.contents.font.size = $fontsizebig
        @skill_descr.visible = false
        skill_descr_refresh
       
        # Activation fenêtre
        @actor_status.visible = true
        @enemy_status.visible = true
               
        # ------- ---------- --------- --------
        #    Saut de phase de sélection actor
        # ------- ---------- --------- --------
        jumped = phase_jump
       
        # Activations fenêtres
        if not(jumped)
          draw_text("Que doit faire", @actor.given_name + "?")
          @action_window.visible = true
          @action_window.active= true
          $battle_var.action_id = 0
        end
       
      when 1 # Phase d'attente d'action
        @action_window.update
        @skills_window.update
        if @skills_window.active and input
          skill_descr_refresh
        end
       
        if Input.trigger?(Input::C) and @action_window.active
          case @action_window.index
          when 0 # Selection ATTAQUE
            $game_system.se_play($data_system.decision_se)
            @action_window.active = false
            @action_window.visible = false
           
            # ------- ---------- --------- --------
            #   Reset compteur de fuite
            # ------- ---------- --------- --------
            $battle_var.run_count = 0
           
            # ------- ---------- --------- --------
            #    Saut de phase de sélection attaque
            # ------- ---------- --------- --------
            if attack_selection_jump
              @actor_action = 1
              @phase = 2
              return
            end
           
            # ------- ---------- --------- --------
            #      Vérification PP // Lutte
            # ------- ---------- --------- --------
            total = 0
            for skill in @actor.skills_set
              if skill.usable?
                total += skill.pp
              end
            end
            if total == 0
              @actor_action = 1
              @phase = 2
              @actor_skill = Skill.new(165) # Lutte
              return
            end
           
            @skills_window.active = true
            @skills_window.visible = true
            @skill_descr.visible = true
            @text_window.contents.clear
          when 1 # Selection ITEM
            $game_system.se_play($data_system.decision_se)
            scene = POKEMON_S::Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "battle")
            scene.main
            return_data = scene.return_data
            @phase = 0
            if $battle_var.action_id == 1
              @phase = 2
              @actor_action = 3
              @item_id = return_data
            end
          when 2 # Selection PKMN
            # ------- ---------- --------- --------
            #    Vérification switch permis
            # ------- ---------- --------- --------
            if not(switch_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            $game_system.se_play($data_system.decision_se)
            $battle_var.window_index = @action_window.index
            scene = POKEMON_S::Pokemon_Party_Menu.new(0, @z_level + 100)
            scene.main
            return_data = scene.return_data
            @phase = 0
            # Enregistrement données Switch de Pokémon
            if $battle_var.action_id == 2
              @phase = 2
              @actor_action = 2
              @switch_id = return_data
            end
          when 3 # sélection FUITE
            # ------- ---------- --------- --------
            #    Vérification fuite permise
            # ------- ---------- --------- --------
            @action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              return
            end
            @action_window.visible = true
           
            @action_window.active = false
            @action_window.visible = false
            @text_window.contents.clear
            run
          end
          return
        end
       
        if Input.trigger?(Input::C) and @skills_window.active
          index = @skills_window.index
          skill = @actor.skills_set[index]
          if skill != nil and skill.usable?
            @actor_action = 1
            @phase = 2
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @actor_skill = @actor.skills_set[index]
            $battle_var.last_index = @skills_window.index
          else
            $game_system.se_play($data_system.buzzer_se)
          end
        end
       
        if Input.trigger?(Input::B) and @skills_window.active
          $game_system.se_play($data_system.decision_se)
          @skills_window.active = false
          @skills_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @phase = 0
        end
       
       
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
       
        enemy_skill_decision
       
        statistic_refresh
        turn_order
        phase2
        phase3
       
        # Phase de switch de fin de tour
        $battle_var.action_id = 4
        end_battle_check
       
        if $battle_var.battle_end?
          return
        end
       
        # Fin de tour / Post_Round effects
        post_round_effect
        @actor_status.refresh
        @enemy_status.refresh
       
        if $battle_var.battle_end?
          return
        end
       
        # Phase de switch post_round
        $battle_var.action_id = 6
        end_battle_check
        @phase = 0
       
        if $battle_var.battle_end?
          return
        end
       
        # Incrémentation nombre de tours
        $battle_var.round += 1
       
      end
      return
    end
   
    #------------------------------------------------------------ 
    # Vérifications préliminaires et ordre d'action
    #------------------------------------------------------------
    def statistic_refresh
      @actor.statistic_refresh
      @enemy.statistic_refresh
    end
   
    #Recherche de priorité
    def turn_order
      # Comparaison des priorités
      if @actor_skill == nil or @enemy_skill == nil
        @strike_first = true
        return
      end
     
      if @actor_action != 1 # Attaque
        @strike_first = false
        return
      end 
     
      if @actor_skill.priority > @enemy_skill.priority
        @strike_first = true
      elsif @actor_skill.priority < @enemy_skill.priority
        @strike_first = false
      else
       
      # En cas d'égalité
        if @enemy.spd > @actor.spd
          @strike_first = false
        elsif @enemy.spd < @actor.spd
          @strike_first = true
        else
          @strike_first = rand(2)>0 ? true : false
        end
      end
    end
   
    #------------------------------------------------------------ 
    # Rounds
    #------------------------------------------------------------           
    def phase2 # Pré_Rounds
      @action_window.visible = false
      @action_window.active = false
      @actor_status.visible = true
      @enemy_status.visible = true
      @actor_status.refresh
      @enemy_status.refresh
      draw_text("","")
     
      # Préround 1: Fuite
      if @actor_action == 4
        run
      end
      if @enemy_action == 4
        enemy_run
      end
     
      # Préround 2: Item
      if @actor_action == 3
        actor_item_use
      end
      if @enemy_action == 3
        enemy_item_use
      end
     
      # Préround 3: Switch Pokémon
      if @actor_action == 2
        actor_pokemon_switch
      end
      if @enemy_action == 2
        enemy_pokemon_switch
      end
     
      @actor_status.refresh
      @enemy_status.refresh
    end
       
    # Round: Attaques
    def phase3
      if @strike_first
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
     
      if not(@strike_first)
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
    end
   
    #------------------------------------------------------------ 
    # Fonctions auxiliaires
    #------------------------------------------------------------    
    def switch(list, id1, id2)
      if id1 <= id2
        list.insert(id1, list[id2])
        list.delete_at(id2+1)
        list.insert(id2 + 1, list[id1+1])
        list.delete_at(id1+1)
        return list
      else
        switch(list, id2, id1)
      end
    end
   
    # Fonction auxiliaire
    def input
      if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
        Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
        Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
        return true
      end
      return false
    end
   
    def draw_text(line1 = "", line2 = "")
      if line1.type == Array
        if line1[1] != nil
          draw_text(line1[0], line1[1])
        else
          draw_text(line1[0])
        end
      else
        Graphics.freeze
        @text_window.contents.clear
        @text_window.draw_text(12, 0, 460, 50, line1)
        @text_window.draw_text(12, 55, 460, 50, line2)
        Graphics.transition(5)
      end
    end
   
    def draw_text_valid(line1 = "", line2 = "")
      draw_text(line1, line2)
      loop do
        Graphics.update
        Input.update
        if Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
    def wait(frame)
      i = 0
      loop do
        i += 1
        Graphics.update
        if i >= frame
          break
        end
      end
    end
   
    def wait_hit
      loop do
        Graphics.update
        Input.update
        if input
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ----------------------- Interface -------------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # Fenêtre de description
    #------------------------------------------------------------       
    def skill_descr_refresh
      @skill_descr.contents.clear
      index = @skills_window.index
      skill = @actor.skills_set[index]
      if skill != nil
        string = skill.pp.to_s + "/" + skill.ppmax.to_s
        type = skill.type
      else
        string = "---"
        type = 0
      end
      normal_color = Color.new(60,60,60)
      @skill_descr.contents.font.color = normal_color
      #@skill_descr.contents.draw_text(0,6,60,39, "PP:")
      @skill_descr.contents.draw_text(0,6,96,39, string, 1)
      #@skill_descr.contents.draw_text(0,60,140,39, "TP:")
      draw_type(0, 60, type)
    end 
     
    def draw_type(x, y, type)
      src_rect = Rect.new(0, 0, 96, 42)
      bitmap = RPG::Cache.picture("T" + type.to_s + ".png")
      @skill_descr.contents.blt(x, y, bitmap, src_rect, 255)
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ------------------ Fonctions de combat --------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------   
    # Fonctions spéciales - programmation des attaques
    #------------------------------------------------------------
    def heal(user, user_sprite, user_status, bonus)
      value = bonus.abs
      for i in 1..value
        if bonus >= 0
          user.add_hp(1)
        else
          user.remove_hp(1)
        end
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.hp >= user.max_hp or user.dead?
          break
        end
      end
    end
   
    def self_damage(user, user_sprite, user_status, damage)
      if damage > 0
        Audio.se_play("Audio/SE/Hit.wav", 100)
        blink(user_sprite)
      end
      for i in 1..damage
        user.remove_hp(1)
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.dead?
          break
        end
      end
    end
   
    #------------------------------------------------------------   
    # Fonctions communes - Programmation des attaques
    #------------------------------------------------------------
    # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé
    # 6: Confus, 7: Flinch, 8: Toxic
    #------------------------------------------------------------
    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre
    #------------------------------------------------------------
   
    # Fonction à appeler en cas d'effets sur le statut
    def status_check(target, status, forcing = false)
      # Immunités
      # Poison
      if (target.type_poison? or target.type_steel?) and
          (status == 1 or status == 8)
        draw_text(target.given_name + " est insensible", "au poison!")
        wait(40)
        return
      end
      # Freeze
      if status == 5 and target.type_ice?
        draw_text(target.given_name + " est insensible", "au gel!")
        wait(40)
        return
      end
      # Burn
      if status == 3 and target.type_fire?
        draw_text(target.given_name + " est insensible", "aux brûlures!")
        wait(40)
        return
      end
      # Soleil
      if status == 5 and $battle_var.sunny?
        draw_text("Le soleil empêche " + target.given_name, "de geler!")
        wait(40)
        return
      end
      # Lumber / Echauffement (ab)
      if status == 2 and target.ability == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.")
        wait(40)
        return
      end
      # Ignifu-voile / Water Veil (ab)
      if status == 3 and target.ability == 41
        draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.")
        wait(40)
        return
      end
      # Insomnia (ab) // Vital Spirit / Esprit Vital (ab)
      if status == 4 and (target.ability == 15 or target.ability == 72)
        draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.")
        wait(40)
        return
      end
      # Vaccin / Immunity (ab)
      if [1, 8].include?(status) and target.ability == 17
        draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.")
        wait(40)
        return
      end
      # Armumagma / Magma Armor (ab)
      if target.ability == 40 and status == 5
        draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.")
        wait(40)
        return
      end
      # Tempo Perso / Own Tempo (ab)
      if status == 6 and target.ability == 20
        draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.")
        wait(40)
        return
      end
      # Attention / Inner focus (ab)
      if target.ability == 39 and status == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.")
        wait(40)
        return
      end
      # Synchronize (ab)
      if target.ability == 28 and [1, 2, 3, 8].include?(status)
        target.ability_token = status
        if status == 8
          target.ability_token = 1
        end
      end
     
      if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status))
        status_string(target, -target.status) # animation
      elsif status == 6 and target.confused? and not(forcing)
        status_string(target, -6)
      elsif target.effect_list.include?(0x7C) and
          status != 7 # Rune Protect/Safeguard
        draw_text(target.given_name + "est", "protégé des altérations!")
        wait(40)
      elsif target.effect_list.include?(0x9F) and
          status == 4 # Uproar
        draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!")
        wait(40)
      else
        case status
        when 1
          target.status_poison(forcing)
        when 2
          target.status_paralyze(forcing)
        when 3
          target.status_burn(forcing)
        when 4
          target.status_sleep(forcing)
        when 5
          target.status_frozen(forcing)
        when 6
          target.status_confuse
        when 7
          target.status_flinch
        when 8
          target.status_toxic(forcing)
        end
        status_string(target, status)
      end
    end
   
    def accuracy_stage(user, target)
      stage = user.acc_stage - target.eva_stage
      stage = stage < -6 ? -6 : stage > 6 ? 6 : stage
     
      # --------------- ---------------- --------------
      #           Programmation des attaques
      # --------------- ---------------- --------------
      # Clairvoyayance / Foresight
      if target.effect_list.include?(0x71)
        stage = user.acc_stage
      end
      # --------------- ---------------- --------------
      # --------------- ---------------- --------------
     
      case stage
      when -6
        return 33.0/100
      when -5
        return 36.0/100
      when -4
        return 43.0/100
      when -3
        return 50.0/100
      when -2
        return 60.0/100
      when -1
        return 75.0/100
      when 0
        return 1
      when 1
        return 133.0/100
      when 2
        return 166.0/100
      when 3
        return 2
      when 4
        return 250.0/100
      when 5
        return 133.0/50
      when 6
        return 3
      end
    end
   
    #------------------------------------------------------------ 
    # Post_round
    #------------------------------------------------------------        
    def post_round_effect
      # --------- -------------- --------------------
      # Fin des effets "at the end of a round"
      # --------- -------------- --------------------     
      # Suppression état appeuré (ne dure que un tour)
      @actor.flinch_check
      @enemy.flinch_check
      # Suppression état autre
      if @actor.dead?
        @actor.cure
        @actor.cure_state
      end
      if @enemy.dead?
        @enemy.cure
        @enemy.cure_state
      end
     
      # --------- -------------- --------------------
      # Programmation des attaques en Post-round
      # --------- -------------- --------------------
      #      Cycle commun 0 - Souhait et Météo
      # --------- -------------- --------------------
      post_round_cycle0
     
      # --------- -------------- --------------------
      #         Cycle individuel 1
      #      Programmation des attaques
      #           Effets du statut
      # --------- -------------- --------------------     
      if @strike_first
        post_round_cycle_1(@actor, @enemy)
        post_round_cycle_1(@enemy, @actor)
      else
        post_round_cycle_1(@enemy, @actor)
        post_round_cycle_1(@actor, @enemy)
      end
     
      # --------- -------------- --------------------
      #                Cycle 2
      #         Programmation des attaques
      #            Dommages finaux
      # --------- -------------- --------------------
      if @strike_first
        post_round_cycle_2(@actor, @enemy)
        post_round_cycle_2(@enemy, @actor)
      else
        post_round_cycle_2(@enemy, @actor)
        post_round_cycle_2(@actor, @enemy)
      end
     
      @actor.skill_effect_clean
      @enemy.skill_effect_clean
     
      faint_check
     
      # Round suivant
      if $battle_var.round == nil
        $battle_var.round = 0
      end
      $battle_var.round += 1
    end
   
   
    # --------- -------------- --------------------
    #     Cycle commun 0 - Météo et Souhait
    # --------- -------------- --------------------
    def post_round_cycle0
      if @strike_first
        list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]]
      else
        list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]]
      end
     
      # Suppression du contrôle pour un pokémon mort
      for array in list
        if array[0].dead?
          list.delete(array)
        end
      end
     
      for array in list
        actor = array[0]
        actor.skill_effect_end_turn
        for effect in actor.effect_list
          case effect
          when 0x56 # Entrave / Disable
            index = actor.effect_list.index(0x56)
            if actor.effect[index][1] == 0
              skill_id = actor.effect[index][2]
              skill = actor.skills_set[skill_id]
              skill.enable
              draw_text(skill.name + " de "+ actor.given_name, "est rétablie!")
              wait(40)
            end
          when 0x5A # Encore
            index = actor.effect_list.index(0x5A)
            if actor.skills_set[index].pp == 0
              actor.effect[index][1] = 0 # Fin de l'effet
            end
          when 0x75 # Rollout
            index = actor.effect_list.index(0x75)
            ## N'a pas fait de dégât ce tour ci >> Supprimé
            #if actor.effect[index][2] != actor.effect[index][1]
            #  actor.effect.delete_at(index)
            #end
            if actor.asleep? or actor.frozen?
              actor.effect.delete_at(index)
            end
          when 0x77 # Taillade / Fury Cutter
            index = actor.effect_list.index(0x77)
            # N'a pas fait de dégât ce tour ci >> Supprimé
            if actor.effect[index][2] != actor.effect[index][1]
              actor.effect.delete_at(index)
            end
          end
        end
      end
     
      weather = $battle_var.weather[0]
      $battle_var.weather[1] -= 1
      count = $battle_var.weather[1]
     
      # Souhait -- Programmation des attaques
      for array in list
        target = array[0]
        target_sprite = array[1]
        target_status = array[2]
        if target.effect_list.include?(0xB3)
          bonus = target.hp / 2
          draw_text("Un souhait est réalisé.")
          heal(target, target_sprite, target_status, bonus)
          wait(40)
        end
      end
     
      # Pluie
      if $battle_var.rain? and count != 0
        draw_text("La pluie continue de", "tomber.")
        animation = $data_animations[379]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.rain? and count == 0
        draw_text("La pluie s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Ensoleillé
      if $battle_var.sunny? and count != 0
        draw_text("Les rayons du soleil","tapent fort.")
        animation = $data_animations[378]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.sunny? and count == 0
        draw_text("Le soleil est parti.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Tempete de sable
      if $battle_var.sandstorm? and count != 0
        draw_text("La tempête de sable souffle.")
        animation = $data_animations[380]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégats
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ground? or target.type_rock? or target.type_steel?
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or
              target.ability == 8
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.sandstorm? and count == 0
        draw_text("La tempête de sable s'est arretée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Grêle
      if $battle_var.hail? and count > 0
        draw_text("Il grêle...")
        animation = $data_animations[381]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégâts
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ice? or
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3)
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.hail? and count == 0
        draw_text("La grêle s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
    end
   
   
   
   
    # --------- -------------- --------------------
    #              Cycle individuel 1
    # --------- -------------- --------------------
    def post_round_cycle_1(actor, enemy)
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un Pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #    Programmation des attaques et des capa
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0xB5 # Ingrain / Racines
          bonus = actor.max_hp / 16
          draw_text(actor.given_name + " puise", "de l'énergie dans la terre.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      end
     
      case actor.ability
      when 44 # Cuvette / Rain Dish (ab)
        if $battle_var.rain?
          bonus = actor.max_hp / 16
          draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.")
          wait(40)
        end
      when 54 # Absentéisme / Truant (ab)
        if actor.ability_token == nil
          actor.ability_token = true
        end
        if actor.ability_token == true
          actor.ability_token = false
        elsif actor.ability_token == false
          actor.ability_token = true
        end
      when 61 # Mue / Shed skin (ab)
        if actor.status != 0 and rand(100) < 30
          actor.cure
          draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.")
          wait(40)
        end
      end
     
      for effect in enemy.effect_list
        case effect
        when 0x54 # Leech Seed / Vampigraine
          malus = actor.max_hp / 8
          draw_text("L'énergie de " + actor.given_name,"est drainée!")
          heal(actor, actor_sprite, actor_status, -malus)
          heal(enemy, enemy_sprite, enemy_status, malus)
          wait(40)
        when 0x2A # Multi_turn attack
          damage = actor.max_hp / 16
          draw_text(actor.given_name, "est piégé!")
          self_damage(actor, actor_sprite, actor_status, damage)
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #          Inspection des statuts
      # --------- -------------- --------------------
      if actor.status == 1 # Poison
        damage = actor.poison_effect
        draw_text(actor.given_name + " souffre", "du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 8 # Toxic
        damage = actor.toxic_effect
        draw_text(actor.given_name + " souffre", "gravement du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 3 #Burn
        damage = actor.burn_effect
        draw_text(actor.given_name + " souffre", "de ses brûlures.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
     
      actor.confuse_decrement
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------     
      for effect in actor.effect_list
        case effect
        when 0x6B # Nightmare / Cauchemar
          if actor.asleep?
            damage = actor.max_hp / 4
            draw_text(actor.given_name + " fait", "un chauchemar!")
            heal(actor, actor_sprite, actor_status, -damage)
            wait(20)
          else
            index = actor.effect_list.index(0x6B)
            actor.effect.delete_at(index)
          end
        when 0x6D # Curse
          damage = actor.max_hp / 4
          draw_text(actor.given_name + " est", "maudit!")
          heal(actor, actor_sprite, actor_status, -damage)
          wait(20)
        when 0x9F # Uproar / Brouhaha
          if actor.asleep?
            actor.cure
            draw_text(actor.given_name + " se réveille", "à cause du brouhaha!")
            wait(40)
          end
          if actor.frozen? #Fin de l'effet
            index = actor.effect_list.index(0x9F)
            actor.effect.delete_at(index)
          end
        when 0xAF # Taunt / Provoc
          index = actor.effect_list.index(0xAF)
          for skill in actor.skills_set
            if skill.power == 0 and actor.effect[index][1] > 0
              draw_text(skill.name + " est bloqué!")
              skill.disable
              wait(40)
            elsif actor.effect[index][1] == 0
              draw_text(skill.name + " est rétablit.")
              skill.enable
              wait(40)
            end
          end
        when 0xBB # Yawn / Baillement
          if actor.status == 0
            status_check(actor, 4)
            actor_status.refresh
          end
        end
      end
     
      if actor.dead?
        return
      end
      # --------- -------------- --------------------
      #                  Berry check
      # --------- -------------- -------------------- 
      if $item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp
        draw_text(actor.given_name + " récupère un peu", "de vie avec " + $item.name(actor.item_hold) + ".")
        bonus = actor.max_hp / 16
        if bonus == 0
          bonus = 1
        end
        heal(actor, actor_sprite, actor_status, bonus)
        wait(40)
      end
    end
     
    # --------- -------------- --------------------
    #              Cycle individuel 2
    # --------- -------------- --------------------    
    def post_round_cycle_2(actor, enemy)
      # Redéfinition
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des capacités
      # --------- -------------- --------------------
      case actor.ability
      when 2 # Crachin / Drizzle (ab)
        if not($battle_var.rain?) # Pluie
          draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.")
          wait(40)
          animation = $data_animations[379]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_rain
      when 45 # Sable Volant / Sand stream (ab)
        if not($battle_var.sandstorm?) # Tempete Sable
          draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.")
          wait(40)
          animation = $data_animations[380]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 70 # Sècheresse / Drought (ab)
        if not($battle_var.sunny?) # Soleil
          draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.")
          wait(40)
          animation = $data_animations[378]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 3 # Speed Boost (ab)
        draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.")
        actor.change_spd(+1)
        stage_animation(actor_sprite, $data_animations[368])
        wait(40)
      when 22 # Intimidate (ab)
        if not(actor.ability_active)
          actor.ability_active = true
          draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".")
          enemy.change_atk(-1)
          stage_animation(enemy_sprite, $data_animations[365])
          wait(40)
        end
      when 59 # Forecast / Meteo (ab)
        if $battle_var.sunny? and not(actor.type_fire?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en FEU!")
          actor.ability_token = 2
        elsif $battle_var.rain? and not(actor.type_water?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en EAU!")
          actor.ability_token = 3
        elsif $battle_var.hail? and not(actor.type_ice?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en GLACE!")
          actor.ability_token = 6
        elsif not(actor.type_normal?)
          draw_text(actor.ability_name + " de " + actor.given_name, "change son type en NORMAL!")
          actor.ability_token = 0
        end
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0x72 # Requiem / Perish Song
          index = actor.effect_list.index(0x72)
          number = actor.effect[index][1]
          if number > 0
            if number > 1
              string = number.to_s + " tours"
            elsif number == 1
              string = number.to_s + " tour"
            end
            draw_text("Plus que " + string, "pour " + actor.given_name + "...")
            wait(40)
          else
            draw_text(actor.given_name + " est", "K.O. par REQUIEM!")
            damage = actor.hp
            heal(actor, actor_sprite, actor_status, -damage)
            wait(40)
          end
        end
      end
     
      # --------- -------------- --------------------
      #      Nettoyage des compteurs d'effets
      # --------- -------------- --------------------
      for effect in actor.effect
        case effect
        when [0x10, 0] # Reflet / Reflect
          draw_text("L'effet de REFLET est", "terminé.")
          wait(40)
        when [0x23, 0] # Light Screen
          draw_text("L'effet de MUR LUMIERE est", "terminé.")
          wait(40)
        when [0x2E, 0] # Brume / Mist
          draw_text("La brume se dissipe.")
          wait(40)
        when [0x7C, 0] # Rune Protect / Safeguard
          draw_text("L'effet de RUNE PROTECT", "est terminé.")
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
    end
   
   
   
    #------------------------------------------------------------ 
    # Items
    #------------------------------------------------------------    
    def actor_item_use # items à utiliser
      # Item déjà utilisé ie remplacé par 0
      if @item_id == 0
        return
      end
    end

    #------------------------------------------------------------ 
    # Switch de pokémon
    #------------------------------------------------------------        
    def actor_pokemon_switch
      if @switch_id != -1
        if not(@actor.dead?)
          @actor_status.visible = true
        else
          @actor_status.visible = false
        end
       
        switch_effect(@actor, @enemy)
       
        if not(@actor.dead?)
          recall_pokemon
        end
       
        @battle_order = switch(@battle_order, 0, @switch_id)
        @actor = @party.actors[@battle_order[0]]
        @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
        @actor_status = POKEMON_S::Pokemon_Battle_Status.new(@actor, false)
        @actor_status.visible = false
        if not($battle_var.have_fought.include?(@actor.party_index))
          $battle_var.have_fought.push(@actor.party_index)
        end
       
        launch_pokemon
        @actor_status.visible = true
        @switch_id = -1
      end
    end
   
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy.dead?)
          @enemy_status.visible = true
        else
          @enemy_status.visible = false
        end
       
        switch_effect(@enemy, @actor)
       
        if not(@enemy.dead?)
          recall_enemy_pokemon
        end
       
        @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id)
        @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]]
        $data_pokedex[@enemy.id][0] = true
        @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
        @enemy_status = POKEMON_S::Pokemon_Battle_Status.new(@enemy, true)
        @enemy_status.visible = false
       
        launch_enemy_pokemon
        @enemy_status.visible = true
        @enemy_switch_id = -1
      end
    end
   
    #------------------------------------------------------------ 
    # Fuite
    #------------------------------------------------------------          
    def run
      if run_able?(@actor, @enemy)
        $battle_var.run_count += 1
        @action_window.active = false
        @action_window.visible = false
        end_battle_flee
      else
        $battle_var.run_count += 1
        fail_flee
        @phase = 2
        @actor_action = 0
        $battle_var.action_id = 0
      end
    end
   
    def run_able?(runner, opponent)
      x = (Integer(opponent.spd/4) % 255)
      rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count))
      if not(flee_able(runner, opponent))
        return false
      end
      if opponent.spd <= runner.spd
        return true
      elsif x == 0
        return true
      elsif rate > 255
        return true
      elsif rand(256) <= rate
        return true
      else
        return false
      end
    end
   
    def run_enemy
      if run_able?(@enemy, @actor)
        end_battle_flee_enemy
      end
    end
   
    #------------------------------------------------------------ 
    # Animations supplémentaires au combat
    #------------------------------------------------------------  
    # Défaites / KO
    #------------------------------------------------------------      
    def enemy_down
      # Si déjà vaincu
      if @enemy_sprite.zoom_y == 0
        return
      end
      # Sinon
      @enemy_sprite.oy = @enemy_sprite.bitmap.height
      @enemy_sprite.y += @enemy_sprite.bitmap.height / 2
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
     
      loop do
        @enemy_status.x -= 20
        #@enemy_sprite.zoom_y -= 0.05
        @enemy_sprite.y += 8
        @enemy_sprite.opacity -= 20
        Graphics.update
        #if @enemy_sprite.zoom_y <= 0.0
        if @enemy_sprite.y >= 348
          @enemy_sprite.zoom_y = 0
          break
        end
      end
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.y -= @enemy_sprite.bitmap.height
      draw_text(@enemy.given_name, "est K.O.!")
      wait(40)
    end
   
    def actor_down
      # Si déjà vaincu
      #if @actor_sprite.zoom_y <= 0.0
      if @actor_sprite.y >= 576
        return
      end
      # Sinon
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
      loop do
        @actor_status.x += 20
        #@actor_sprite.zoom_y -= 0.05
        @actor_sprite.y += 12
        @actor_sprite.opacity -= 20
        Graphics.update
        #if @actor_sprite.zoom_y <= 0.0
        if @actor_sprite.y >= 576
          break
        end
      end
     
      draw_text(@actor.given_name, "est K.O.!")
      wait(40)
    end
   
    #------------------------------------------------------------      
    # Attaques
    #------------------------------------------------------------
    def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite)
      if miss
        wait(40)
        draw_text("Mais cela échoue!")
        wait(40)
        return
      end
     
      if user == @enemy
        reverse = true
      else
        reverse = false
      end
     
      efficiency = info[2]
      if hit and efficiency != -2
        # Animation utilisateur
        animation_user = $data_animations[user_skill.user_anim_id]
        if animation_user != nil
          user_sprite.animation(animation_user, true, reverse)
          until not(user_sprite.effect?)
            user_sprite.update
            Graphics.update
          end
        end
       
        user_sprite.update
        Graphics.update
       
        # Animation Cible
        animation_target = $data_animations[user_skill.target_anim_id]
        if animation_target != nil
          target_sprite.animation(animation_target, true, reverse)
          until not(target_sprite.effect?)
            target_sprite.update
            Graphics.update
          end
        end
       
        target_sprite.update
        Graphics.update
       
        if info[0] > 0
          case efficiency
          when 0 # Normal
            Audio.se_play("Audio/SE/Hit.wav", 100)
            blink(target_sprite, 3, 3)
          when 1 # Super efficace
            Audio.se_play("Audio/SE/Hitplus.wav", 100)
            blink(target_sprite, 2, 5)
          when -1 # Peu efficace
            Audio.se_play("Audio/SE/Hitlow.wav", 100)
            blink(target_sprite, 4, 2)
          end
        end
      elsif not(hit)
        wait(40)
        draw_text(user.given_name, "rate son attaque!")
        wait(40)
      end
    end
   
    def blink(sprite, frame = 4, number = 3)
      for i in 0..number
        wait(frame)
        sprite.opacity = 0
        Graphics.update
        wait(frame)
        sprite.opacity = 255
        Graphics.update
      end
    end
   
    def post_attack(info, damage, power)
      efficiency = info[2]
      if damage == 0 and (efficiency != -2 or power == 0)
        return
      end
      critical = info[1]
      if critical  and efficiency != -2 #critical_hit
        draw_text("Coup critique!")
        wait(40)
      end
      case efficiency
      when 1
        draw_text("C'est super efficace!")
        wait(40)
      when -1
        draw_text("Ce n'est pas très efficace...")
        wait(40)
      when -2
        draw_text("Ca ne l'affecte pas...")
        wait(40)
      end
    end
   
    def faint_check(user = nil)
      if user == nil
        faint_check(@actor)
        faint_check(@enemy)
      end
      if user == @actor and user.dead?
        actor_down
      end
      if user == @enemy and user.dead?
        enemy_down
      end
    end
       
   
    #------------------------------------------------------------      
    # Statut et stats
    #------------------------------------------------------------   
    def status_animation(sprite, status)
      animation = $data_animations[355 + status]
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          break
        end
      end
    end
   
    def stage_animation(sprite, animation)
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          wait(20)
          break
        end
      end
    end

    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
    def type_string(type)
      case type
      when 0
        return "???"
      when 1
        return "NORMAL"
      when 2
        return "FEU"
      when 3
        return "EAU"
      when 4
        return "ELECTRIK"
      when 5
        return "PLANTE"
      when 6
        return "GLACE"
      when 7
        return "COMBAT"
      when 8
        return "POISON"
      when 9
        return "SOL"
      when 10
        return "VOL"
      when 11
        return "PSY"
      when 12
        return "INSECTE"
      when 13
        return "ROCHE"
      when 14
        return "SPECTRE"
      when 15
        return "DRAGON"
      when 16
        return "ACIER"
      when 17
        return "TENEBRES"
      end
    end
   
   
    # Changement (ou pas) de statut
    def status_string(actor, status)
      string = actor.given_name
      case status
      when -1
        draw_text(string + " est", "déjà empoisonné!")
        wait(40)
      when -2
        draw_text(string + " est", "déjà paralysé!")
        wait(40)
      when -3
        draw_text(string,"brûle déjà!")
        wait(40)
      when -4
        draw_text(string,"dort déjà!")
        wait(40)
      when -5
        draw_text(string, "est déjà gelé!")
        wait(40)
      when -6
        draw_text(string, "est déjà confus!")
        wait(40)
      when -8
        draw_text(string + " est", "déjà gravement empoisonné!")
        wait(40)
      when 1
        draw_text(string, "est empoisonné!")
        wait(40)
      when 2
        draw_text(string, "est paralysé!")
        wait(40)
      when 3
        draw_text(string,"brûle!")
        wait(40)
      when 4
        draw_text(string,"s'endort!")
        wait(40)
      when 5
        draw_text(string,"gèle!")
        wait(40)
      when 6
        draw_text("Cela rend " + string, "confus!")
        wait(40)
      when 7
        draw_text(string, "est appeuré!")
        wait(40)
      when 8
        draw_text(string + " est", "gravement empoisonné!")
        wait(40)
      end
    end
   
    # S'occupe du texte et de l'animation
    def raise_stat(string, actor, n = 0)
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == 1
        text = actor.given_name + " augmente!"
      elsif n > 1
        text = actor.given_name + " augmente beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[364])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[366])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[370])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[372])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[368])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[374])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[376])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    def reduce_stat(string, actor, n = true, self_inflicted = false)
      # Mist/Brume
      if actor.effect_list.include?(0x2E)
        draw_text(actor.given_name + " est", "protégé par la brume!")
        wait(40)
        return
      end
      # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab)
      if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted)
        draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!")
        wait(40)
        return
      end
      # Keen Eye / Regard Vif (ab)
      if actor.ability == 51 and string == "ACC"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!")
        wait(40)
        return
      end
      # Hyper Cutter (ab)
      if actor.ability == 52 and string == "ATK"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!")
        wait(40)
        return
      end
     
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == -1
        text = actor.given_name + " baisse!"
      elsif n < -1
        text = actor.given_name + " baisse beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[365])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[367])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[371])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[373])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[369])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[375])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[377])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    #------------------------------------------------------------      
    # Appel / Rappel de Pokémon
    #------------------------------------------------------------          
    def recall_pokemon
      draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!")
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.y = 336
      @actor_sprite.x = 156
      @actor_sprite.color = @actor.ball_color
      @actor_sprite.color.alpha = 0
     
      until @actor_sprite.color.alpha >= 255
        @flash_sprite.opacity += 25
        @actor_sprite.color.alpha += 25
        Graphics.update
      end
     
      Audio.se_play("Audio/SE/Pokeopen.wav")
      loop do
        @actor_status.x += 20
        @actor_sprite.opacity -= 25
        @actor_sprite.color.alpha += 25
        @actor_sprite.zoom_x -= 0.1
        @actor_sprite.zoom_y -= 0.1
        @flash_sprite.opacity -= 25
        Graphics.update
        if @actor_status.x >= 711
          @actor_status.visible = false
          @actor_status.x = 711
          @actor_sprite.color.alpha = 0
          @actor_sprite.opacity = 0
          Graphics.update
          break
        end
      end
    end
   
    def launch_pokemon
      @actor_sprite.x = 156
      @actor_sprite.y = 336
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.zoom_x = 0
      @actor_sprite.zoom_y = 0
     
      #if @actor_party_status.active
      #  @actor_party_status.x = 0
      #  @actor_party_status.visible = true
      #end
     
      name = @actor.given_name
      text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)]
      draw_text(text)
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = -44
      @ball_sprite.y = 324
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x += 5
        @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        #if @actor_party_status.active
        #  @actor_party_status.x -= 80
        #end
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          #if @actor_party_status.active
          #  @actor_party_status.x = 0
          #  @actor_party_status.visible = false
          #end
          break
        end
      end
      @actor_sprite.opacity = 0
      @actor_sprite.color = @actor.ball_color
     
      until @actor_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @actor_sprite.zoom_x += 0.1
        @actor_sprite.zoom_y += 0.1
        @actor_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
     
      @actor_sprite.zoom_x = 1
      @actor_sprite.zoom_y = 1
      @actor_sprite.opacity = 255
     
      @actor_status.x = 711
      @actor_status.visible = true
     
      if @actor.shiny
        animation = $data_animations[382]
        @actor_sprite.animation(animation, true)
      end
     
      until @actor_status.x == 311
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @actor_status.x -= 20
        @actor_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @actor_sprite.update
        Graphics.update
      end
     
      until not(@actor_sprite.effect?)
        @actor_sprite.update
        Graphics.update
      end
     
      @actor_status.x = 311
      @actor_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    def launch_enemy_pokemon
      @enemy_sprite.x = 463
      @enemy_sprite.y = 108
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.zoom_x = 0
      @enemy_sprite.zoom_y = 0
     
      string = $trainer.type(@trainer_id) + " " + $trainer.name(@trainer_id)
      draw_text(@enemy.name + " est envoyé", "par " + string + "!")
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = 663
      @ball_sprite.y = 108
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x -= 5
        @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          break
        end
      end
      @enemy_sprite.opacity = 0
      @enemy_sprite.color = @enemy.ball_color
     
      until @enemy_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @enemy_sprite.zoom_x += 0.08
        @enemy_sprite.zoom_y += 0.08
        @enemy_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      @enemy_sprite.zoom_x = 1
      @enemy_sprite.zoom_y = 1
      @enemy_sprite.opacity = 255
     
      @enemy_status.x = -377
      @enemy_status.visible = true
     
      if @enemy.shiny
        animation = $data_animations[382]
        @enemy_sprite.animation(animation, true)
      end
     
      until @enemy_status.x == 23
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @enemy_status.x += 20
        @enemy_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @enemy_sprite.update
        Graphics.update
      end
     
      until not(@enemy_sprite.effect?)
        @enemy_sprite.update
        Graphics.update
      end
     
      @enemy_sprite.x = 463
      @enemy_status.x = 23
      @enemy_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    #------------------------------------------------------------ 
    # Fin de combat
    #------------------------------------------------------------     
    def end_battle(result = 0)     
      # Reset des variables et effets
      $battle_var.reset
      @actor.skill_effect_reset
      @actor.reset_stat_stage
      @actor.cure_state
      @actor.ability_active = false
      @enemy.skill_effect_reset
      @enemy.reset_stat_stage
      @enemy.cure_state
      @enemy.ability_active = false
      # -----------------------------------
      Audio.me_stop
      wait(10)
      $game_system.bgm_play($game_temp.map_bgm)
      wait(10)
      Graphics.freeze
      # -----------------------------------
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      # Défaite
      $scene = Scene_Map.new
    end
   
    def end_battle_flee(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@actor.given_name, "est expulsé du combat!")
        loop do
          if @actor_sprite.x > -160
            @actor_sprite.x -= 20
          end
          Graphics.update
          Input.update
          if @actor_sprite.x <= -160
            wait(40)
            break
          end
        end
      else
        draw_text("Vous prenez la fuite!")
        wait(40)
      end
      end_battle(1)
    end
   
    def fail_flee
      draw_text("Vous ne pouvez pas","vous enfuir!")
      wait(40)
    end
   
    def end_battle_flee_enemy(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@enemy.given_name, "est expulsé du combat!")
      else
        draw_text(@enemy.given_name + " s'échappe!")
      end
      loop do
        if @enemy_sprite.x < 800
          @enemy_sprite.x += 20
        end
        Graphics.update
        Input.update
        if @enemy_sprite.x >= 800
          wait(40)
          break
        end
      end
      end_battle(1)
    end
   
    def end_battle_defeat
      $battle_var.result_defeat = true
      draw_text("Tous vos Pokémons", "ont été vaincus!")
      wait(40)
      $pokemon_party.money /= 2
      if not(@lose)
        if $game_variables[1] == 0
          print("Réglez votre point de retour!")
        else
          $game_map.setup($game_variables[1])
          $game_map.display_x = $game_variables[2]
          $game_map.display_y = $game_variables[3]
          $game_player.moveto($game_variables[2], $game_variables[3])
        end
        $game_temp.common_event_id = 2
      end
      $game_temp.map_bgm = $game_map.bgm
      end_battle(2)
    end
   
    def draw_choice
      @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig)
      @command.x = 517
      @command.y = 215
      loop do
        Graphics.update
        Input.update
        @command.update
        if Input.trigger?(Input::C) and @command.index == 0
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return true
        end
        if Input.trigger?(Input::C) and @command.index == 1
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return false
        end
      end
    end
  end
 
  #------------------------------------------------------------ 
  # Fenêtre de statut
  #------------------------------------------------------------ 
  class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(0,0,0,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size(@pokemon.name).width + 3
        draw_gender(15 + width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(9, 42, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)

        class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
  
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(248,248,248,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(242 - width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(20, 47, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(46, 99, 1.0 - level, 232)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(268 - width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(44, 68, bitmap, src_rect, 255)
        end
      end
    end
  
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(46, 99, 1.0 - level, 232)
    end
    
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
    
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
  
    def dispose
      super
    end
  
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3)
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3)
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6)
      end
    
      if level < 0.1
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(248, 64, 16, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(232, 168, 50, 255)
      else
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(24, 192, 32, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
  
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*232.to_i, 3)
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255))
    end
  
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)      
      end
    end
  end


  #------------------------------------------------------------
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
  
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
  
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
    
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
    
for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i-1]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
  
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end
      @run_count = 0
      @money = 0
    end
   
    def reset
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = POKEMON_S::Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
   
    def reset_weather
      @weather = [0, 0]
    end
   
    def set_rain(duration = -1)
      @weather = [1, duration]
    end
   
    def rain?
      if @weather[0] == 1
        return true
      else
        return false
      end
    end
   
    def set_sunny(duration = -1)
      @weather = [2, duration]
    end
   
    def sunny?
      if @weather[0] == 2
        return true
      else
        return false
      end
    end
   
    def sandstorm?
      if @weather[0] == 3
        return true
      else
        return false
      end
    end
   
    def set_sandstorm(duration = -1)
      @weather = [3, duration]
    end
   
    def hail?
      if @weather[0] == 4
        return true
      else
        return false
      end
    end
   
    def set_hail(duration = -1)
      @weather = [4, duration]
    end
   
    def battle_end?
      if @result_flee or @result_win or @result_defeat
        return true
      else
        return false
      end
    end
   
    def add_money(amount)
      if @money == nil
        @money = 0
      end
      @money += amount
    end
   
  end
 
end

Posté par Pαlвσlѕку le 22 Sep - 19:48 (2008)
Remplace tout le contenu du script battle_core_1 par ça :

script

#==============================================================================
# ■ Pokemon_Battle_Core
# Pokemon Script Project - Krosk
# 20/07/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Système de Combat - Squelette général
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé, 8: Toxic
# @confuse (6), @flinch (7)
#-----------------------------------------------------------------------------
# 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
# 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# $battle_var.action_id
#   0 : Phase de Sélection
#   1 : Sélection Item
#   2 : Switch Pokémon
#   4 : Switch Fin de Tour
#-----------------------------------------------------------------------------

module POKEMON_S
  #------------------------------------------------------------ 
  # Pokemon_Battle_Core
  #   noyau possédant les fonctions communes aux combats sauvages/dresseurs
  #------------------------------------------------------------ 
  #------------------------------------------------------------ 
  # Fonctions à définir à l'extérieur
  #   initialize
  #   pre_battle_animation
  #   enemy_skill_decision
  #   end_battle_check
  #   actor_item_use
  #   catch_pokemon
  #   run_able?
  #   end_battle_victory
  #------------------------------------------------------------ 
  class Pokemon_Battle_Core
    attr_accessor :z_level
    attr_accessor :actor_status
    attr_accessor :actor
    attr_accessor :actor_sprite
   
    #------------------------------------------------------------ 
    # ------------------- Squelette Général ---------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # main
    #------------------------------------------------------------
    def main
      # Pré-création des Sprites
      # Fond
      if @battleback_name != ""
        @battleback_name = $game_map.battleback_name + ".png"
        @ground_name = "ground" + $game_map.battleback_name + ".png"
      else
        print("Attention, réglez le BattleBack du Tileset.")
        @battleback_name = "battle0.png"
        @ground_name = "groundbattle0.png"
      end
      @background = Sprite.new
      @background.z = @z_level
     
      # Fond du message
      @message_background = Sprite.new
      @message_background.y = 336
      @message_background.z = @z_level + 19
     
      # Sprite de flash
      @flash_sprite = Sprite.new
      @flash_sprite.bitmap = RPG::Cache.picture("black.png")
      @flash_sprite.color = Color.new(255,255,255)
      @flash_sprite.opacity = 0
      @flash_sprite.z = @z_level + 13
     
      # Fenetre de texte
      @text_window = Window_Base.new(4, 340, 632, 136)
      @text_window.opacity = 0
      @text_window.z = @z_level + 20
      @text_window.contents = Bitmap.new(600 + 32, 104 + 32)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsizebig
     
      # Fenetre d'action
      s1 = "ATTAQUE"
      s2 = "SAC"
      s3 = "POKéMON"
      s4 = "FUITE"
     
      @action_window = Window_Command.new(320, [s1,s2,s3,s4], $fontsizebig, 2, 56)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
     
      # Viewport
      battle_viewport = Viewport.new(0, 0, 640, 336)
      battle_viewport.z = @z_level + 15
     
      # Sprites acteurs # Positions par défaut des centres
      @enemy_sprite = RPG::Sprite.new(battle_viewport)
      @enemy_sprite.x = 464
      @enemy_sprite.y = 104
      @enemy_sprite.z = @z_level + 15
      @enemy_ground = RPG::Sprite.new
      @enemy_ground.x = 464
      @enemy_ground.y = 149
      @enemy_ground.z = @z_level + 11
      @actor_sprite = RPG::Sprite.new(battle_viewport)
      @actor_sprite.x = 153
      @actor_sprite.y = 336
      @actor_sprite.z = @z_level + 15
      @actor_ground = RPG::Sprite.new
      @actor_ground.x = 153
      @actor_ground.y = 386
      @actor_ground.z = @z_level + 11
     
      # Création fenêtre de statut
      @actor_status = Pokemon_Battle_Status.new(@actor, false, @z_level + 15)
      @enemy_status = Pokemon_Battle_Status.new(@enemy, true, @z_level + 15)
      @actor_status.visible = false
      @enemy_status.visible = false
      @enemy_caught = false
     
      @actor_party_status = Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10)
      @enemy_party_status = Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10)
      @actor_party_status.visible = false
      @enemy_party_status.visible = false
      # note: .active = true activera les animations liées à ces fenêtres
      @actor_party_status.active = false
      @enemy_party_status.active = false
     
      # Lancement des animations
      pre_battle_transition
      pre_battle_animation
     
      # Effets pré-premier round
      post_round_effect
     
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
     
      # Fin de scene
      Graphics.freeze
      @background.dispose
      @message_background.dispose
      @flash_sprite.dispose
      @text_window.dispose
      @action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
      end
      if @ball_sprite != nil
        @ball_sprite.dispose
      end
      @enemy_sprite.dispose
      @actor_sprite.dispose
      @actor_status.dispose
      @enemy_status.dispose
      @actor_party_status.dispose
      @enemy_party_status.dispose
    end
   
    #------------------------------------------------------------ 
    # Déroulement
    #------------------------------------------------------------
    def update
      # Animation test : séquence de test d'une animation
      if false
        if $temp == nil
          $temp = false
          @actor_sprite.register_position
          @enemy_sprite.register_position
        end
        animation = $data_animations[15] # tappez le numéro de l'anim à tester
        if not @enemy_sprite.effect? and not @actor_sprite.effect?
          if $temp
            @enemy_sprite.reset_position
            @actor_sprite.register_position
            @actor_sprite.animation(animation, true, true)
            $temp = !$temp
          else
            @actor_sprite.reset_position
            @enemy_sprite.register_position
            @enemy_sprite.animation(animation, true)
            $temp = !$temp
          end
        end
        @actor_sprite.update
        @enemy_sprite.update
        return
      end
     
      case @phase
      when 0 # Phase d'initialisation
        @phase = 1
       
        # Création fenêtre de skill
        list = []
        for skill in @actor.skills_set
          list.push(skill.name)
        end
        while list.size < 4
          list.push("  ---")
        end
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
       
        # Compétences bloquées
        for i in 0..@actor.skills_set.length-1
          skill = @actor.skills_set
          if not(skill.usable?)
            @skills_window.disable_item(i)
          end
        end
       
        # Curseur sur le dernier choix
        if $battle_var.last_index == nil
          $battle_var.last_index = 0
          @skills_window.index = 0
        else
          @skills_window.index = $battle_var.last_index
        end
       
        # Création fenêtre description de skill
        @skill_descr = Window_Base.new(512, 336, 128, 144)
        @skill_descr.contents = Bitmap.new(96, 144)
        @skill_descr.contents.font.name = $fontface
        @skill_descr.contents.font.size = $fontsizebig
        @skill_descr.visible = false
        skill_descr_refresh
       
        # Activation fenêtre
        @actor_status.visible = true
        @enemy_status.visible = true
               
        # ------- ---------- --------- --------
        #    Saut de phase de sélection actor
        # ------- ---------- --------- --------
        jumped = phase_jump
       
        # Activations fenêtres
        if not(jumped)
          draw_text("Que doit faire", @actor.given_name + "?")
          @action_window.visible = true
          @action_window.active= true
          $battle_var.action_id = 0
        end
       
      when 1 # Phase d'attente d'action
        @action_window.update
        @skills_window.update
        if @skills_window.active and input
          skill_descr_refresh
        end
       
        if Input.trigger?(Input::C) and @action_window.active
          case @action_window.index
          when 0 # Selection ATTAQUE
            $game_system.se_play($data_system.decision_se)
            @action_window.active = false
            @action_window.visible = false
           
            # ------- ---------- --------- --------
            #   Reset compteur de fuite
            # ------- ---------- --------- --------
            $battle_var.run_count = 0
           
            # ------- ---------- --------- --------
            #    Saut de phase de sélection attaque
            # ------- ---------- --------- --------
            if attack_selection_jump
              @actor_action = 1
              @phase = 2
              return
            end
           
            # ------- ---------- --------- --------
            #      Vérification PP // Lutte
            # ------- ---------- --------- --------
            total = 0
            for skill in @actor.skills_set
              if skill.usable?
                total += skill.pp
              end
            end
            if total == 0
              @actor_action = 1
              @phase = 2
              @actor_skill = Skill.new(165) # Lutte
              return
            end
           
            @skills_window.active = true
            @skills_window.visible = true
            @skill_descr.visible = true
            @text_window.contents.clear
          when 1 # Selection ITEM
            $game_system.se_play($data_system.decision_se)
            scene = Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "battle")
            scene.main
            return_data = scene.return_data
            @phase = 0
            if $battle_var.action_id == 1
              @phase = 2
              @actor_action = 3
              @item_id = return_data
            end
          when 2 # Selection PKMN
            # ------- ---------- --------- --------
            #    Vérification switch permis
            # ------- ---------- --------- --------
            if not(switch_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            $game_system.se_play($data_system.decision_se)
            $battle_var.window_index = @action_window.index
            scene = Pokemon_Party_Menu.new(0, @z_level + 100)
            scene.main
            return_data = scene.return_data
            @phase = 0
            # Enregistrement données Switch de Pokémon
            if $battle_var.action_id == 2
              @phase = 2
              @actor_action = 2
              @switch_id = return_data
            end
          when 3 # sélection FUITE
            # ------- ---------- --------- --------
            #    Vérification fuite permise
            # ------- ---------- --------- --------
            @action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              draw_text("Que doit faire", @actor.given_name + "?")
              return
            end
            @action_window.visible = true
           
            @action_window.active = false
            @action_window.visible = false
            @text_window.contents.clear
            run
          end
          return
        end
       
        if Input.trigger?(Input::C) and @skills_window.active
          index = @skills_window.index
          skill = @actor.skills_set[index]
          if skill != nil and skill.usable?
            @actor_action = 1
            @phase = 2
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @actor_skill = @actor.skills_set[index]
            $battle_var.last_index = @skills_window.index
          else
            $game_system.se_play($data_system.buzzer_se)
          end
        end
       
        if Input.trigger?(Input::B) and @skills_window.active
          $game_system.se_play($data_system.decision_se)
          @skills_window.active = false
          @skills_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @phase = 0
        end
       
       
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
       
        enemy_skill_decision
       
        statistic_refresh
        turn_order
        phase2
        phase3
       
        # Phase de switch de fin de tour
        $battle_var.action_id = 4
        end_battle_check
       
        if $battle_var.battle_end?
          return
        end
       
        # Fin de tour / Post_Round effects
        post_round_effect
        @actor_status.refresh
        @enemy_status.refresh
       
        if $battle_var.battle_end?
          return
        end
       
        # Phase de switch post_round
        $battle_var.action_id = 6
        end_battle_check
        @phase = 0
       
        if $battle_var.battle_end?
          return
        end
       
        # Incrémentation nombre de tours
        $battle_var.round += 1
       
      end
      return
    end
   
    #------------------------------------------------------------ 
    # Vérifications préliminaires et ordre d'action
    #------------------------------------------------------------
    def statistic_refresh
      @actor.statistic_refresh
      @enemy.statistic_refresh
    end
   
    #Recherche de priorité
    def turn_order
      # Comparaison des priorités
      if @actor_skill == nil or @enemy_skill == nil
        @strike_first = true
        return
      end
     
      if @actor_action != 1 # Attaque
        @strike_first = false
        return
      end 
     
      if @actor_skill.priority > @enemy_skill.priority
        @strike_first = true
      elsif @actor_skill.priority < @enemy_skill.priority
        @strike_first = false
      else
       
      # En cas d'égalité
        if @enemy.spd > @actor.spd
          @strike_first = false
        elsif @enemy.spd < @actor.spd
          @strike_first = true
        else
          @strike_first = rand(2)>0 ? true : false
        end
      end
    end
   
    #------------------------------------------------------------ 
    # Rounds
    #------------------------------------------------------------           
    def phase2 # Pré_Rounds
      @action_window.visible = false
      @action_window.active = false
      @actor_status.visible = true
      @enemy_status.visible = true
      @actor_status.refresh
      @enemy_status.refresh
      draw_text("","")
     
      # Préround 1: Fuite
      if @actor_action == 4
        run
      end
      if @enemy_action == 4
        enemy_run
      end
     
      # Préround 2: Item
      if @actor_action == 3
        actor_item_use
      end
      if @enemy_action == 3
        enemy_item_use
      end
     
      # Préround 3: Switch Pokémon
      if @actor_action == 2
        actor_pokemon_switch
      end
      if @enemy_action == 2
        enemy_pokemon_switch
      end
     
      @actor_status.refresh
      @enemy_status.refresh
    end
       
    # Round: Attaques
    def phase3
      if @strike_first
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
     
      if not(@strike_first)
        if @actor_action == 1 and not(@actor.dead?)
          attack_action(@actor, @actor_skill, @enemy)
        end
      else
        if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
          attack_action(@enemy, @enemy_skill, @actor)
        end
      end
     
      faint_check
     
      if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
        return
      end
    end
   
    #------------------------------------------------------------ 
    # Fonctions auxiliaires
    #------------------------------------------------------------    
    def switch(list, id1, id2)
      if id1 <= id2
        list.insert(id1, list[id2])
        list.delete_at(id2+1)
        list.insert(id2 + 1, list[id1+1])
        list.delete_at(id1+1)
        return list
      else
        switch(list, id2, id1)
      end
    end
   
    # Fonction auxiliaire
    def input
      if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
        Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
        Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
        return true
      end
      return false
    end
   
    def draw_text(line1 = "", line2 = "")
      if line1.type == Array
        if line1[1] != nil
          draw_text(line1[0], line1[1])
        else
          draw_text(line1[0])
        end
      else
        Graphics.freeze
        @text_window.contents.clear
        @text_window.draw_text(12, 0, 460, 50, line1)
        @text_window.draw_text(12, 55, 460, 50, line2)
        Graphics.transition(5)
      end
    end
   
    def draw_text_valid(line1 = "", line2 = "")
      draw_text(line1, line2)
      loop do
        Graphics.update
        Input.update
        if Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
    def wait(frame)
      i = 0
      loop do
        i += 1
        Graphics.update
        if i >= frame
          break
        end
      end
    end
   
    def wait_hit
      loop do
        Graphics.update
        Input.update
        if input
          $game_system.se_play($data_system.decision_se)
          break
        end
      end
    end
   
   
    def update_sprite
      @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
    end
   
   
   
   
    #------------------------------------------------------------ 
    # ----------------------- Interface -------------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------ 
    # Fenêtre de description
    #------------------------------------------------------------       
    def skill_descr_refresh
      @skill_descr.contents.clear
      index = @skills_window.index
      skill = @actor.skills_set[index]
      if skill != nil
        string = skill.pp.to_s + "/" + skill.ppmax.to_s
        type = skill.type
      else
        string = "---"
        type = 0
      end
      normal_color = Color.new(60,60,60)
      @skill_descr.contents.font.color = normal_color
      #@skill_descr.contents.draw_text(0,6,60,39, "PP:")
      @skill_descr.contents.draw_text(0,6,96,39, string, 1)
      #@skill_descr.contents.draw_text(0,60,140,39, "TP:")
      draw_type(0, 60, type)
    end 
     
    def draw_type(x, y, type)
      src_rect = Rect.new(0, 0, 96, 42)
      bitmap = RPG::Cache.picture("T" + type.to_s + ".png")
      @skill_descr.contents.blt(x, y, bitmap, src_rect, 255)
    end
   
   
   
   
   
   
   
    #------------------------------------------------------------ 
    # ------------------ Fonctions de combat --------------------
    #------------------------------------------------------------
   
    #------------------------------------------------------------   
    # Fonctions spéciales - programmation des attaques
    #------------------------------------------------------------
    def heal(user, user_sprite, user_status, bonus)
      value = bonus.abs
      for i in 1..value
        if bonus >= 0
          user.add_hp(1)
        else
          user.remove_hp(1)
        end
        if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
          next
        end
        user_status.refresh
        Graphics.update
        Graphics.update
        if user.hp >= user.max_hp or user.dead?
          break
        end
      end
    end
   
    def self_damage(user, user_sprite, user_status, damage)
      if damage > 0
        Audio.se_play("Audio/SE/Hit.wav", 100)
        blink(user_sprite)
      end
      for i in 1..damage
        user.remove_hp(1)
        user_status.refresh
        if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
          next
        end
        Graphics.update
        Graphics.update
        if user.dead?
          break
        end
      end
    end
   
    #------------------------------------------------------------   
    # Fonctions communes - Programmation des attaques
    #------------------------------------------------------------
    # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé
    # 6: Confus, 7: Flinch, 8: Toxic
    #------------------------------------------------------------
    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre
    #------------------------------------------------------------
   
    # Fonction à appeler en cas d'effets sur le statut
    def status_check(target, status, forcing = false)
      # Immunités
      # Poison
      if (target.type_poison? or target.type_steel?) and
          (status == 1 or status == 8)
        draw_text(target.given_name + " est insensible", "au poison!")
        wait(40)
        return
      end
      # Freeze
      if status == 5 and target.type_ice?
        draw_text(target.given_name + " est insensible", "au gel!")
        wait(40)
        return
      end
      # Burn
      if status == 3 and target.type_fire?
        draw_text(target.given_name + " est insensible", "aux brûlures!")
        wait(40)
        return
      end
      # Soleil
      if status == 5 and $battle_var.sunny?
        draw_text("Le soleil empêche " + target.given_name, "de geler!")
        wait(40)
        return
      end
      # Lumber / Echauffement (ab)
      if status == 2 and target.ability == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.")
        wait(40)
        return
      end
      # Ignifu-voile / Water Veil (ab)
      if status == 3 and target.ability == 41
        draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.")
        wait(40)
        return
      end
      # Insomnia (ab) // Vital Spirit / Esprit Vital (ab)
      if status == 4 and (target.ability == 15 or target.ability == 72)
        draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.")
        wait(40)
        return
      end
      # Vaccin / Immunity (ab)
      if [1, 8].include?(status) and target.ability == 17
        draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.")
        wait(40)
        return
      end
      # Armumagma / Magma Armor (ab)
      if target.ability == 40 and status == 5
        draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.")
        wait(40)
        return
      end
      # Tempo Perso / Own Tempo (ab)
      if status == 6 and target.ability == 20
        draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.")
        wait(40)
        return
      end
      # Attention / Inner focus (ab)
      if target.ability == 39 and status == 7
        draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.")
        wait(40)
        return
      end
      # Synchronize (ab)
      if target.ability == 28 and [1, 2, 3, 8].include?(status)
        target.ability_token = status
        if status == 8
          target.ability_token = 1
        end
      end
     
      if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status))
        status_string(target, -target.status) # animation
      elsif status == 6 and target.confused? and not(forcing)
        status_string(target, -6)
      elsif target.effect_list.include?(0x7C) and
          status != 7 # Rune Protect/Safeguard
        draw_text(target.given_name + "est", "protégé des altérations!")
        wait(40)
      elsif target.effect_list.include?(0x9F) and
          status == 4 # Uproar
        draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!")
        wait(40)
      else
        case status
        when 1
          target.status_poison(forcing)
        when 2
          target.status_paralyze(forcing)
        when 3
          target.status_burn(forcing)
        when 4
          target.status_sleep(forcing)
        when 5
          target.status_frozen(forcing)
        when 6
          target.status_confuse
        when 7
          target.status_flinch
        when 8
          target.status_toxic(forcing)
        end
        status_string(target, status)
      end
    end
   
    def accuracy_stage(user, target)
      stage = user.acc_stage - target.eva_stage
      stage = stage < -6 ? -6 : stage > 6 ? 6 : stage
     
      # --------------- ---------------- --------------
      #           Programmation des attaques
      # --------------- ---------------- --------------
      # Clairvoyayance / Foresight
      if target.effect_list.include?(0x71)
        stage = user.acc_stage
      end
      # --------------- ---------------- --------------
      # --------------- ---------------- --------------
     
      case stage
      when -6
        return 33.0/100
      when -5
        return 36.0/100
      when -4
        return 43.0/100
      when -3
        return 50.0/100
      when -2
        return 60.0/100
      when -1
        return 75.0/100
      when 0
        return 1
      when 1
        return 133.0/100
      when 2
        return 166.0/100
      when 3
        return 2
      when 4
        return 250.0/100
      when 5
        return 133.0/50
      when 6
        return 3
      end
    end
   
    #------------------------------------------------------------ 
    # Post_round
    #------------------------------------------------------------        
    def post_round_effect
      # --------- -------------- --------------------
      # Fin des effets "at the end of a round"
      # --------- -------------- --------------------     
      # Suppression état appeuré (ne dure que un tour)
      @actor.flinch_check
      @enemy.flinch_check
      # Suppression état autre
      if @actor.dead?
        @actor.cure
        @actor.cure_state
      end
      if @enemy.dead?
        @enemy.cure
        @enemy.cure_state
      end
     
      # --------- -------------- --------------------
      # Programmation des attaques en Post-round
      # --------- -------------- --------------------
      #      Cycle commun 0 - Souhait et Météo
      # --------- -------------- --------------------
      post_round_cycle0
     
      # --------- -------------- --------------------
      #         Cycle individuel 1
      #      Programmation des attaques
      #           Effets du statut
      # --------- -------------- --------------------     
      if @strike_first
        post_round_cycle_1(@actor, @enemy)
        post_round_cycle_1(@enemy, @actor)
      else
        post_round_cycle_1(@enemy, @actor)
        post_round_cycle_1(@actor, @enemy)
      end
     
      # --------- -------------- --------------------
      #                Cycle 2
      #         Programmation des attaques
      #            Dommages finaux
      # --------- -------------- --------------------
      if @strike_first
        post_round_cycle_2(@actor, @enemy)
        post_round_cycle_2(@enemy, @actor)
      else
        post_round_cycle_2(@enemy, @actor)
        post_round_cycle_2(@actor, @enemy)
      end
     
      @actor.skill_effect_clean
      @enemy.skill_effect_clean
     
      faint_check
     
      # Round suivant
      if $battle_var.round == nil
        $battle_var.round = 0
      end
      $battle_var.round += 1
    end
   
   
    # --------- -------------- --------------------
    #     Cycle commun 0 - Météo et Souhait
    # --------- -------------- --------------------
    def post_round_cycle0
      if @strike_first
        list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]]
      else
        list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]]
      end
     
      # Suppression du contrôle pour un pokémon mort
      for array in list
        if array[0].dead?
          list.delete(array)
        end
      end
     
      for array in list
        actor = array[0]
        actor.skill_effect_end_turn
        for effect in actor.effect_list
          case effect
          when 0x56 # Entrave / Disable
            index = actor.effect_list.index(0x56)
            if actor.effect[index][1] == 0
              skill_id = actor.effect[index][2]
              skill = actor.skills_set[skill_id]
              skill.enable
              draw_text(skill.name + " de "+ actor.given_name, "est rétablie!")
              wait(40)
            end
          when 0x5A # Encore
            index = actor.effect_list.index(0x5A)
            if actor.skills_set[index].pp == 0
              actor.effect[index][1] = 0 # Fin de l'effet
            end
          when 0x75 # Rollout
            index = actor.effect_list.index(0x75)
            ## N'a pas fait de dégât ce tour ci >> Supprimé
            #if actor.effect[index][2] != actor.effect[index][1]
            #  actor.effect.delete_at(index)
            #end
            if actor.asleep? or actor.frozen?
              actor.effect.delete_at(index)
            end
          when 0x77 # Taillade / Fury Cutter
            index = actor.effect_list.index(0x77)
            # N'a pas fait de dégât ce tour ci >> Supprimé
            if actor.effect[index][2] != actor.effect[index][1]
              actor.effect.delete_at(index)
            end
          end
        end
      end
     
      weather = $battle_var.weather[0]
      $battle_var.weather[1] -= 1
      count = $battle_var.weather[1]
     
      # Souhait -- Programmation des attaques
      for array in list
        target = array[0]
        target_sprite = array[1]
        target_status = array[2]
        if target.effect_list.include?(0xB3)
          bonus = target.hp / 2
          draw_text("Un souhait est réalisé.")
          heal(target, target_sprite, target_status, bonus)
          wait(40)
        end
      end
     
      # Pluie
      if $battle_var.rain? and count != 0
        draw_text("La pluie continue de", "tomber.")
        animation = $data_animations[493]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.rain? and count == 0
        draw_text("La pluie s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Ensoleillé
      if $battle_var.sunny? and count != 0
        draw_text("Les rayons du soleil","tapent fort.")
        animation = $data_animations[492]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
        wait(20)
      elsif $battle_var.sunny? and count == 0
        draw_text("Le soleil est parti.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Tempete de sable
      if $battle_var.sandstorm? and count != 0
        draw_text("La tempête de sable souffle.")
        animation = $data_animations[494]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégats
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ground? or target.type_rock? or target.type_steel?
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or
              target.ability == 8
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.sandstorm? and count == 0
        draw_text("La tempête de sable s'est arretée.")
        wait(40)
        $battle_var.reset_weather
      end
     
      # Grêle
      if $battle_var.hail? and count > 0
        draw_text("Il grêle...")
        animation = $data_animations[495]
        @actor_sprite.animation(animation, true)
        loop do
          @actor_sprite.update
          Graphics.update
          Input.update
          if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
            break
          end
        end
       
        # Dégâts
        for array in list
          target = array[0]
          target_sprite = array[1]
          target_status = array[2]
          if target.type_ice? or
              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3)
            next
          end
          damage = target.max_hp / 16
          heal(target, target_sprite, target_status, -damage)
        end
      elsif $battle_var.hail? and count == 0
        draw_text("La grêle s'est arrêtée.")
        wait(40)
        $battle_var.reset_weather
      end
     
    end
   
   
   
   
    # --------- -------------- --------------------
    #              Cycle individuel 1
    # --------- -------------- --------------------
    def post_round_cycle_1(actor, enemy)
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un Pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #    Programmation des attaques et des capa
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0xB5 # Ingrain / Racines
          bonus = actor.max_hp / 16
          draw_text(actor.given_name + " puise", "de l'énergie dans la terre.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      end
     
      case actor.ability
      when 44 # Cuvette / Rain Dish (ab)
        if $battle_var.rain?
          bonus = actor.max_hp / 16
          draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.")
          heal(actor, actor_sprite, actor_status, bonus)
          wait(40)
        end
      when 54 # Absentéisme / Truant (ab)
        if actor.ability_token == nil
          actor.ability_token = true
        end
        if actor.ability_token == true
          actor.ability_token = false
        elsif actor.ability_token == false
          actor.ability_token = true
        end
      when 61 # Mue / Shed skin (ab)
        if actor.status != 0 and rand(100) < 30
          actor.cure
          draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.")
          wait(40)
        end
      end
     
      for effect in enemy.effect_list
        case effect
        when 0x54 # Leech Seed / Vampigraine
          malus = actor.max_hp / 8
          draw_text("L'énergie de " + actor.given_name,"est drainée!")
          heal(actor, actor_sprite, actor_status, -malus)
          heal(enemy, enemy_sprite, enemy_status, malus)
          wait(40)
        when 0x2A # Multi_turn attack
          damage = actor.max_hp / 16
          draw_text(actor.given_name, "est piégé!")
          self_damage(actor, actor_sprite, actor_status, damage)
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #          Inspection des statuts
      # --------- -------------- --------------------
      if actor.status == 1 # Poison
        damage = actor.poison_effect
        draw_text(actor.given_name + " souffre", "du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 8 # Toxic
        damage = actor.toxic_effect
        draw_text(actor.given_name + " souffre", "gravement du poison.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
      if actor.status == 3 #Burn
        damage = actor.burn_effect
        draw_text(actor.given_name + " souffre", "de ses brûlures.")
        status_animation(actor_sprite, actor.status)
        heal(actor, actor_sprite, actor_status, -damage)
        wait(20)
      end
     
      actor.confuse_decrement
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------     
      for effect in actor.effect_list
        case effect
        when 0x6B # Nightmare / Cauchemar
          if actor.asleep?
            damage = actor.max_hp / 4
            draw_text(actor.given_name + " fait", "un chauchemar!")
            heal(actor, actor_sprite, actor_status, -damage)
            wait(20)
          else
            index = actor.effect_list.index(0x6B)
            actor.effect.delete_at(index)
          end
        when 0x6D # Curse
          damage = actor.max_hp / 4
          draw_text(actor.given_name + " est", "maudit!")
          heal(actor, actor_sprite, actor_status, -damage)
          wait(20)
        when 0x9F # Uproar / Brouhaha
          if actor.asleep?
            actor.cure
            draw_text(actor.given_name + " se réveille", "à cause du brouhaha!")
            wait(40)
          end
          if actor.frozen? #Fin de l'effet
            index = actor.effect_list.index(0x9F)
            actor.effect.delete_at(index)
          end
        when 0xAF # Taunt / Provoc
          index = actor.effect_list.index(0xAF)
          for skill in actor.skills_set
            if skill.power == 0 and actor.effect[index][1] > 0
              draw_text(skill.name + " est bloqué!")
              skill.disable
              wait(40)
            elsif actor.effect[index][1] == 0
              draw_text(skill.name + " est rétablit.")
              skill.enable
              wait(40)
            end
          end
        when 0xBB # Yawn / Baillement
          if actor.status == 0
            status_check(actor, 4)
            actor_status.refresh
          end
        end
      end
     
      if actor.dead?
        return
      end
      # --------- -------------- --------------------
      #                  Berry check
      # --------- -------------- -------------------- 
      if Item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp
        draw_text(actor.given_name + " récupère un peu", "de vie avec " + Item.name(actor.item_hold) + ".")
        bonus = actor.max_hp / 16
        if bonus == 0
          bonus = 1
        end
        heal(actor, actor_sprite, actor_status, bonus)
        wait(40)
      end
    end
     
    # --------- -------------- --------------------
    #              Cycle individuel 2
    # --------- -------------- --------------------    
    def post_round_cycle_2(actor, enemy)
      # Redéfinition
      if actor == @actor
        actor_status = @actor_status
        actor_sprite = @actor_sprite
        enemy_status = @enemy_status
        enemy_sprite = @enemy_sprite
      elsif actor == @enemy
        actor_status = @enemy_status
        actor_sprite = @enemy_sprite
        enemy_status = @actor_status
        enemy_sprite = @actor_sprite
      end
     
      # Suppression du contrôle pour un pokémon mort
      if actor.dead?
        return
      end
     
      # --------- -------------- --------------------
      #         Programmation des capacités
      # --------- -------------- --------------------
      case actor.ability
      when 2 # Crachin / Drizzle (ab)
        if not($battle_var.rain?) # Pluie
          draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.")
          wait(40)
          animation = $data_animations[493]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_rain
      when 45 # Sable Volant / Sand stream (ab)
        if not($battle_var.sandstorm?) # Tempete Sable
          draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.")
          wait(40)
          animation = $data_animations[494]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 70 # Sècheresse / Drought (ab)
        if not($battle_var.sunny?) # Soleil
          draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.")
          wait(40)
          animation = $data_animations[492]
          @actor_sprite.animation(animation, true)
          loop do
            @actor_sprite.update
            Graphics.update
            Input.update
            if not(@actor_sprite.effect?)
              break
            end
          end
        end
        $battle_var.set_sandstorm
      when 3 # Speed Boost (ab)
        draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.")
        actor.change_spd(+1)
        stage_animation(actor_sprite, $data_animations[482])
        wait(40)
      when 22 # Intimidate (ab)
        if not(actor.ability_active)
          actor.ability_active = true
          draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".")
          enemy.change_atk(-1)
          stage_animation(enemy_sprite, $data_animations[479])
          wait(40)
        end
      when 59 # Forecast / Meteo (ab)
        if $battle_var.sunny? and not(actor.type_fire?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en FEU!")
          actor.ability_token = 2
          actor.form = 2
          update_sprite
          wait(40)
        elsif $battle_var.rain? and not(actor.type_water?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en EAU!")
          actor.ability_token = 3
          actor.form = 3
          update_sprite
          wait(40)
        elsif $battle_var.hail? and not(actor.type_ice?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en GLACE!")
          actor.ability_token = 6
          actor.form = 6
          update_sprite
          wait(40)
        elsif not(actor.type_normal?)
          draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en NORMAL!")
          actor.ability_token = 1
          actor.form = 0
          update_sprite
          wait(40)
        end
      end
      # --------- -------------- --------------------
      #         Programmation des attaques
      # --------- -------------- --------------------
      for effect in actor.effect_list
        case effect
        when 0x72 # Requiem / Perish Song
          index = actor.effect_list.index(0x72)
          number = actor.effect[index][1]
          if number > 0
            if number > 1
              string = "#{number.to_s} tours"
            elsif number == 1
              string = "#{number.to_s} tour"
            end
            draw_text("Plus que #{string}", "pour #{actor.given_name}...")
            wait(40)
          else
            draw_text("#{actor.given_name} est", "K.O. par REQUIEM!")
            damage = actor.hp
            heal(actor, actor_sprite, actor_status, -damage)
            wait(40)
          end
        end
      end
     
      # --------- -------------- --------------------
      #      Nettoyage des compteurs d'effets
      # --------- -------------- --------------------
      for effect in actor.effect
        case effect
        when [0x10, 0] # Reflet / Reflect
          draw_text("L'effet de REFLET est", "terminé.")
          wait(40)
        when [0x23, 0] # Light Screen
          draw_text("L'effet de MUR LUMIERE est", "terminé.")
          wait(40)
        when [0x2E, 0] # Brume / Mist
          draw_text("La brume se dissipe.")
          wait(40)
        when [0x7C, 0] # Rune Protect / Safeguard
          draw_text("L'effet de RUNE PROTECT", "est terminé.")
          wait(40)
        end
      end
     
      if actor.dead?
        return
      end
    end
   
   
   
    #------------------------------------------------------------ 
    # Items
    #------------------------------------------------------------    
    def actor_item_use # items à utiliser
      # Item déjà utilisé ie remplacé par 0
      if @item_id == 0
        return
      end
    end

    #------------------------------------------------------------ 
    # Switch de pokémon
    #------------------------------------------------------------        
    def actor_pokemon_switch
      if @switch_id != -1
        if not(@actor.dead?)
          @actor_status.visible = true
        else
          @actor_status.visible = false
        end
       
        switch_effect(@actor, @enemy)
       
        if not(@actor.dead?)
          recall_pokemon
        end
       
        @battle_order = switch(@battle_order, 0, @switch_id)
        @actor = @party.actors[@battle_order[0]]
        @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
        @actor_status = Pokemon_Battle_Status.new(@actor, false)
        @actor_status.visible = false
        if not($battle_var.have_fought.include?(@actor.party_index))
          $battle_var.have_fought.push(@actor.party_index)
        end
       
        launch_pokemon
        @actor_status.visible = true
        @switch_id = -1
      end
    end
   
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy.dead?)
          @enemy_status.visible = true
        else
          @enemy_status.visible = false
        end
       
        switch_effect(@enemy, @actor)
       
        if not(@enemy.dead?)
          recall_enemy_pokemon
        end
       
        @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id)
        @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]]
        $data_pokedex[@enemy.id][0] = true
        @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
        @enemy_status = Pokemon_Battle_Status.new(@enemy, true)
        @enemy_status.visible = false
       
        launch_enemy_pokemon
        @enemy_status.visible = true
        @enemy_switch_id = -1
      end
    end
   
    #------------------------------------------------------------ 
    # Fuite
    #------------------------------------------------------------          
    def run
      if run_able?(@actor, @enemy)
        $battle_var.run_count += 1
        @action_window.active = false
        @action_window.visible = false
        end_battle_flee
      else
        $battle_var.run_count += 1
        fail_flee
        @phase = 2
        @actor_action = 0
        $battle_var.action_id = 0
      end
    end
   
    def run_able?(runner, opponent)
      x = (Integer(opponent.spd/4) % 255)
      rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count))
      if not(flee_able(runner, opponent))
        return false
      end
      if opponent.spd <= runner.spd
        return true
      elsif x == 0
        return true
      elsif rate > 255
        return true
      elsif rand(256) <= rate
        return true
      else
        return false
      end
    end
   
    def run_enemy
      if run_able?(@enemy, @actor)
        end_battle_flee_enemy
      end
    end
   
    #------------------------------------------------------------ 
    # Animations supplémentaires au combat
    #------------------------------------------------------------  
    # Défaites / KO
    #------------------------------------------------------------      
    def enemy_down
      # Si déjà vaincu
      if @enemy_sprite.zoom_y == 0
        return
      end
      # Sinon
      @enemy_sprite.oy = @enemy_sprite.bitmap.height
      @enemy_sprite.y += @enemy_sprite.bitmap.height / 2
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
     
      loop do
        @enemy_status.x -= 20
        #@enemy_sprite.zoom_y -= 0.05
        @enemy_sprite.y += 8
        @enemy_sprite.opacity -= 20
        Graphics.update
        #if @enemy_sprite.zoom_y <= 0.0
        if @enemy_sprite.y >= 348
          @enemy_sprite.zoom_y = 0
          break
        end
      end
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.y -= @enemy_sprite.bitmap.height
      draw_text(@enemy.given_name, "est K.O.!")
      wait(40)
    end
   
    def actor_down
      # Si déjà vaincu
      #if @actor_sprite.zoom_y <= 0.0
      if @actor_sprite.y >= 576
        return
      end
      # Sinon
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
      wait(50)
      Audio.se_play("Audio/SE/Down.wav")
      loop do
        @actor_status.x += 20
        #@actor_sprite.zoom_y -= 0.05
        @actor_sprite.y += 12
        @actor_sprite.opacity -= 20
        Graphics.update
        #if @actor_sprite.zoom_y <= 0.0
        if @actor_sprite.y >= 576
          break
        end
      end
     
      draw_text(@actor.given_name, "est K.O.!")
      wait(40)
    end
   
    #------------------------------------------------------------      
    # Attaques
    #------------------------------------------------------------
    def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite)
      if miss
        wait(40)
        draw_text("Mais cela échoue!")
        wait(40)
        return
      end
     
      if user == @enemy
        reverse = true
      else
        reverse = false
      end
     
      efficiency = info[2]
      if hit and efficiency != -2
        # Animation utilisateur
        animation_user = $data_animations[user_skill.user_anim_id]
        user_sprite.register_position
       
        if animation_user != nil
          user_sprite.animation(animation_user, true, reverse)
          until not(user_sprite.effect?)
            user_sprite.update
            Graphics.update
          end
        end
       
        user_sprite.reset_position
       
        user_sprite.update
        Graphics.update
       
        # Animation Cible
        animation_target = $data_animations[user_skill.target_anim_id]
        target_sprite.register_position
       
        if animation_target != nil
          target_sprite.animation(animation_target, true, reverse)
          until not(target_sprite.effect?)
            target_sprite.update
            Graphics.update
          end
        end
       
        target_sprite.reset_position
       
        target_sprite.update
        Graphics.update
       
        if info[0] > 0
          case efficiency
          when 0 # Normal
            Audio.se_play("Audio/SE/Hit.wav", 100)
            blink(target_sprite, 3, 3)
          when 1 # Super efficace
            Audio.se_play("Audio/SE/Hitplus.wav", 100)
            blink(target_sprite, 2, 5)
          when -1 # Peu efficace
            Audio.se_play("Audio/SE/Hitlow.wav", 100)
            blink(target_sprite, 4, 2)
          end
        end
      elsif not(hit)
        wait(40)
        draw_text(user.given_name, "rate son attaque!")
        wait(40)
      end
    end
   
    def blink(sprite, frame = 4, number = 3)
      for i in 0..number
        wait(frame)
        sprite.opacity = 0
        Graphics.update
        wait(frame)
        sprite.opacity = 255
        Graphics.update
      end
    end
   
    def post_attack(info, damage, power)
      efficiency = info[2]
      if damage == 0 and (efficiency != -2 or power == 0)
        return
      end
      critical = info[1]
      if critical  and efficiency != -2 #critical_hit
        draw_text("Coup critique!")
        wait(40)
      end
      case efficiency
      when 1
        draw_text("C'est super efficace!")
        wait(40)
      when -1
        draw_text("Ce n'est pas très efficace...")
        wait(40)
      when -2
        draw_text("Ca ne l'affecte pas...")
        wait(40)
      end
    end
   
    def faint_check(user = nil)
      if user == nil
        faint_check(@actor)
        faint_check(@enemy)
      end
      if user == @actor and user.dead?
        actor_down
      end
      if user == @enemy and user.dead?
        enemy_down
      end
    end
       
   
    #------------------------------------------------------------      
    # Statut et stats
    #------------------------------------------------------------   
    def status_animation(sprite, status)
      animation = $data_animations[469 + status]
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          break
        end
      end
    end
   
    def stage_animation(sprite, animation)
      sprite.animation(animation, true)
      loop do
        sprite.update
        Graphics.update
        Input.update
        if not(sprite.effect?)
          wait(20)
          break
        end
      end
    end

    # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
    # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
    def type_string(type)
      case type
      when 0
        return "???"
      when 1
        return "NORMAL"
      when 2
        return "FEU"
      when 3
        return "EAU"
      when 4
        return "ELECTRIK"
      when 5
        return "PLANTE"
      when 6
        return "GLACE"
      when 7
        return "COMBAT"
      when 8
        return "POISON"
      when 9
        return "SOL"
      when 10
        return "VOL"
      when 11
        return "PSY"
      when 12
        return "INSECTE"
      when 13
        return "ROCHE"
      when 14
        return "SPECTRE"
      when 15
        return "DRAGON"
      when 16
        return "ACIER"
      when 17
        return "TENEBRES"
      end
    end
   
   
    # Changement (ou pas) de statut
    def status_string(actor, status)
      string = actor.given_name
      case status
      when -1
        draw_text(string + " est", "déjà empoisonné!")
        wait(40)
      when -2
        draw_text(string + " est", "déjà paralysé!")
        wait(40)
      when -3
        draw_text(string,"brûle déjà!")
        wait(40)
      when -4
        draw_text(string,"dort déjà!")
        wait(40)
      when -5
        draw_text(string, "est déjà gelé!")
        wait(40)
      when -6
        draw_text(string, "est déjà confus!")
        wait(40)
      when -8
        draw_text(string + " est", "déjà gravement empoisonné!")
        wait(40)
      when 1
        draw_text(string, "est empoisonné!")
        wait(40)
      when 2
        draw_text(string, "est paralysé!")
        wait(40)
      when 3
        draw_text(string,"brûle!")
        wait(40)
      when 4
        draw_text(string,"s'endort!")
        wait(40)
      when 5
        draw_text(string,"gèle!")
        wait(40)
      when 6
        draw_text("Cela rend " + string, "confus!")
        wait(40)
      when 7
        draw_text(string, "est appeuré!")
        wait(40)
      when 8
        draw_text(string + " est", "gravement empoisonné!")
        wait(40)
      end
    end
   
    # S'occupe du texte et de l'animation
    def raise_stat(string, actor, n = 0)
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == 1
        text = actor.given_name + " augmente!"
      elsif n > 1
        text = actor.given_name + " augmente beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[478])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[480])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[484])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[486])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[482])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[488])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[490])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    def reduce_stat(string, actor, n = true, self_inflicted = false)
      # Mist/Brume
      if actor.effect_list.include?(0x2E)
        draw_text(actor.given_name + " est", "protégé par la brume!")
        wait(40)
        return
      end
      # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab)
      if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted)
        draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!")
        wait(40)
        return
      end
      # Keen Eye / Regard Vif (ab)
      if actor.ability == 51 and string == "ACC"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!")
        wait(40)
        return
      end
      # Hyper Cutter (ab)
      if actor.ability == 52 and string == "ATK"
        draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!")
        wait(40)
        return
      end
     
      if actor == @actor
        actor_sprite = @actor_sprite
      elsif actor == @enemy
        actor_sprite = @enemy_sprite
      end
     
      if n == -1
        text = actor.given_name + " baisse!"
      elsif n < -1
        text = actor.given_name + " baisse beaucoup!"
      end
     
      if n != 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",text)
          stage_animation(actor_sprite, $data_animations[479])
        when "DFE"
          draw_text("Ah, Défense de",text)
          stage_animation(actor_sprite, $data_animations[481])
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[485])
        when "DFS"
          draw_text("Ah, Défense Spéciale de",text)
          stage_animation(actor_sprite, $data_animations[487])
        when "SPD"
          draw_text("Ah, Vitesse de",text)
          stage_animation(actor_sprite, $data_animations[483])
        when "EVA"
          draw_text("Ah, Esquive de",text)       
          stage_animation(actor_sprite, $data_animations[489])
        when "ACC"
          draw_text("Ah, Précision de",text)
          stage_animation(actor_sprite, $data_animations[491])
        end
      elsif n == 0
        case string
        when "ATK"
          draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFE"
          draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "ATS"
          draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "DFS"
          draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "SPD"
          draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when "EVA"
          draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!")       
          wait(40)
        when "ACC"
          draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!")
          wait(40)
        when 0
          draw_text("Les effets positifs sont supprimés!")
          wait(40)
        end
      end
    end
   
    #------------------------------------------------------------      
    # Appel / Rappel de Pokémon
    #------------------------------------------------------------          
    def recall_pokemon
      draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!")
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.y = 336
      @actor_sprite.x = 153
      @actor_sprite.color = @actor.ball_color
      @actor_sprite.color.alpha = 0
     
      until @actor_sprite.color.alpha >= 255
        @flash_sprite.opacity += 25
        @actor_sprite.color.alpha += 25
        Graphics.update
      end
     
      Audio.se_play("Audio/SE/Pokeopen.wav")
      loop do
        @actor_status.x += 20
        @actor_sprite.opacity -= 25
        @actor_sprite.color.alpha += 25
        @actor_sprite.zoom_x -= 0.1
        @actor_sprite.zoom_y -= 0.1
        @flash_sprite.opacity -= 25
        Graphics.update
        if @actor_status.x >= 711
          @actor_status.visible = false
          @actor_status.x = 711
          @actor_sprite.color.alpha = 0
          @actor_sprite.opacity = 0
          Graphics.update
          break
        end
      end
    end
   
    def launch_pokemon
      @actor_sprite.x = 153
      @actor_sprite.y = 336
      @actor_sprite.ox = @actor_sprite.bitmap.width / 2
      @actor_sprite.oy = @actor_sprite.bitmap.height
      @actor_sprite.zoom_x = 0
      @actor_sprite.zoom_y = 0
     
      #if @actor_party_status.active
      #  @actor_party_status.x = 0
      #  @actor_party_status.visible = true
      #end
     
      name = @actor.given_name
      text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)]
      draw_text(text)
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = -44
      @ball_sprite.y = 324
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x += 5
        @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        #if @actor_party_status.active
        #  @actor_party_status.x -= 80
        #end
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          #if @actor_party_status.active
          #  @actor_party_status.x = 0
          #  @actor_party_status.visible = false
          #end
          break
        end
      end
      @actor_sprite.opacity = 0
      @actor_sprite.color = @actor.ball_color
     
      until @actor_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @actor_sprite.zoom_x += 0.1
        @actor_sprite.zoom_y += 0.1
        @actor_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@actor.cry)
        Audio.se_play(@actor.cry)
      end
     
      @actor_sprite.zoom_x = 1
      @actor_sprite.zoom_y = 1
      @actor_sprite.opacity = 255
     
      @actor_status.x = 711
      @actor_status.visible = true
     
      if @actor.shiny
        animation = $data_animations[496]
        @actor_sprite.animation(animation, true)
      end
     
      until @actor_status.x == 311
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @actor_status.x -= 20
        @actor_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @actor_sprite.update
        Graphics.update
      end
     
      until not(@actor_sprite.effect?)
        @actor_sprite.update
        Graphics.update
      end
     
      @actor_status.x = 311
      @actor_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    def launch_enemy_pokemon
      @enemy_sprite.x = 464
      @enemy_sprite.y = 104
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.zoom_x = 0
      @enemy_sprite.zoom_y = 0
     
      string = Trainer_Info.type(@trainer_id) + " " + Trainer_Info.name(@trainer_id)
      draw_text(@enemy.name + " est envoyé", "par " + string + "!")
     
      @ball_sprite = Sprite.new
      @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite)
      @ball_sprite.ox = @ball_sprite.bitmap.width / 2
      @ball_sprite.oy = @ball_sprite.bitmap.height / 2
      @ball_sprite.x = 663
      @ball_sprite.y = 104
      @ball_sprite.z = @z_level + 14
     
      t = 0
      pi = 3.14
     
      loop do
        t += 1
        @ball_sprite.x -= 5
        @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi)
        @ball_sprite.angle = - t*63
        Graphics.update
        if t == 40
          @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite)
          Audio.se_play("Audio/SE/Pokeopen.wav")
          break
        end
      end
      @enemy_sprite.opacity = 0
      @enemy_sprite.color = @enemy.ball_color
     
      until @enemy_sprite.zoom_x >= 0.9
        @flash_sprite.opacity += 25
        @ball_sprite.opacity -= 25
        @enemy_sprite.zoom_x += 0.08
        @enemy_sprite.zoom_y += 0.08
        @enemy_sprite.opacity += 25
        Graphics.update
      end
     
      if FileTest.exist?(@enemy.cry)
        Audio.se_play(@enemy.cry)
      end
     
      @enemy_sprite.zoom_x = 1
      @enemy_sprite.zoom_y = 1
      @enemy_sprite.opacity = 255
     
      @enemy_status.x = -377
      @enemy_status.visible = true
     
      if @enemy.shiny
        animation = $data_animations[496]
        @enemy_sprite.animation(animation, true)
      end
     
      until @enemy_status.x == 23
        @background.update
        @actor_ground.update
        @enemy_ground.update
        @enemy_status.x += 20
        @enemy_sprite.color.alpha -= 25
        @flash_sprite.opacity -= 25
        @enemy_sprite.update
        Graphics.update
      end
     
      until not(@enemy_sprite.effect?)
        @enemy_sprite.update
        Graphics.update
      end
     
      @enemy_sprite.x = 464
      @enemy_status.x = 23
      @enemy_sprite.color.alpha = 0
      @flash_sprite.opacity = 0
      @ball_sprite.dispose
      Graphics.update
    end
   
    #------------------------------------------------------------ 
    # Fin de combat
    #------------------------------------------------------------     
    def end_battle(result = 0)     
      # Reset des variables et effets
      $battle_var.reset
      @actor.skill_effect_reset
      @actor.reset_stat_stage
      @actor.cure_state
      @actor.ability_active = false
      @enemy.skill_effect_reset
      @enemy.reset_stat_stage
      @enemy.cure_state
      @enemy.ability_active = false
      # -----------------------------------
      Audio.me_stop
      wait(10)
      $game_system.bgm_play($game_temp.map_bgm)
      wait(10)
      Graphics.freeze
      # -----------------------------------
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      # Défaite
      $scene = Scene_Map.new
    end
   
    def end_battle_flee(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@actor.given_name, "est expulsé du combat!")
        loop do
          if @actor_sprite.x > -160
            @actor_sprite.x -= 20
          end
          Graphics.update
          Input.update
          if @actor_sprite.x <= -160
            wait(40)
            break
          end
        end
      else
        draw_text("Vous prenez la fuite!")
        wait(40)
      end
      end_battle(1)
    end
   
    def fail_flee
      draw_text("Vous ne pouvez pas","vous enfuir!")
      wait(40)
    end
   
    def end_battle_flee_enemy(expulsion = false)
      $battle_var.result_flee = true
      $game_system.se_play($data_system.escape_se)
      if expulsion
        draw_text(@enemy.given_name, "est expulsé du combat!")
      else
        draw_text(@enemy.given_name + " s'échappe!")
      end
      loop do
        if @enemy_sprite.x < 800
          @enemy_sprite.x += 20
        end
        Graphics.update
        Input.update
        if @enemy_sprite.x >= 800
          wait(40)
          break
        end
      end
      end_battle(1)
    end
   
    def end_battle_defeat
      $battle_var.result_defeat = true
      draw_text("Tous vos Pokémons", "ont été vaincus!")
      wait(40)
      $pokemon_party.money /= 2
      if not(@lose)
        if $game_variables[1] == 0
          print("Réglez votre point de retour!")
        else
          $game_map.setup($game_variables[1])
          $game_map.display_x = $game_variables[2]
          $game_map.display_y = $game_variables[3]
          $game_player.moveto($game_variables[2], $game_variables[3])
        end
        $game_temp.common_event_id = 2
      end
      $game_temp.map_bgm = $game_map.bgm
      end_battle(2)
    end
   
    def draw_choice
      @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig)
      @command.x = 517
      @command.y = 215
      loop do
        Graphics.update
        Input.update
        @command.update
        if Input.trigger?(Input::C) and @command.index == 0
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return true
        end
        if Input.trigger?(Input::C) and @command.index == 1
          $game_system.se_play($data_system.decision_se)
          @command.dispose
          @command = nil
          Input.update
          return false
        end
      end
    end
  end

  #------------------------------------------------------------ 
  # Fenêtre de statut
  # Modifier par Palbolsky
  # Apparence combat POKéMON Platine
  #------------------------------------------------------------ 
  class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(248,248,248,255)
      if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(242 - width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(20, 47, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(46, 99, 1.0 - level, 232)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(268 - width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(44, 68, bitmap, src_rect, 255)
        end
      end
    end
   
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(46, 99, 1.0 - level, 232)
    end
     
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
     
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
   
    def dispose
      super
    end
   
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3)
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3)
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6)
      end
     
      if level < 0.1
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(248, 64, 16, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(232, 168, 50, 255)
      else
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(24, 192, 32, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
   
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*232.to_i, 3)
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255))
    end
   
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)       
      end
    end
  end


  #------------------------------------------------------------ 
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------ 
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
   
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
   
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
     
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
     
      for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i][/i]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
   
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end 



  class Pokemon_Battle_Variable

    attr_accessor :weather
    attr_accessor :actor_last_used
    attr_accessor :enemy_last_used
    attr_accessor :battle_order
    attr_accessor :enemy_battle_order
    attr_accessor :in_battle
    attr_accessor :actor_last_taken_damage
    attr_accessor :enemy_last_taken_damage
    attr_accessor :have_fought #liste des pokémons ayant participé par leur index
    attr_accessor :enemy_party
    attr_accessor :action_id
    attr_accessor :window_index
    attr_accessor :result_flee
    attr_accessor :result_win
    attr_accessor :result_defeat
    attr_accessor :last_index
    attr_accessor :round
    attr_accessor :run_count
    attr_accessor :money
   
    # Weather: [ catégorie, nombre de tours ]
    # catégorie: 0: Normal, 1: Pluie, 2: Ensoleillé,
    #            3: Tempête de Sable, 4: Grêle
   
    def initialize
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @result_flee = false
      @result_win = false
      @result_defeat = false
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
   
    def reset
      @weather = [0, 0]
      @actor_last_used = nil
      @enemy_last_used = nil
      @battle_order = (0..5).to_a
      @enemy_battle_order = (0..5).to_a
      @in_battle = false
      @actor_last_taken_damage = 0
      @enemy_last_taken_damage = 0
      @have_fought = []
      @enemy_party = Pokemon_Party.new
      @action_id = 0
      @window_index = 0
      @last_index = 0
      @round = 0
      @run_count = 0
      @money = 0
    end
   
    def reset_weather
      @weather = [0, 0]
    end
   
    def set_rain(duration = -1)
      @weather = [1, duration]
    end
   
    def rain?
      if @weather[0] == 1
        return true
      else
        return false
      end
    end
   
    def set_sunny(duration = -1)
      @weather = [2, duration]
    end
   
    def sunny?
      if @weather[0] == 2
        return true
      else
        return false
      end
    end
   
    def sandstorm?
      if @weather[0] == 3
        return true
      else
        return false
      end
    end
   
    def set_sandstorm(duration = -1)
      @weather = [3, duration]
    end
   
    def hail?
      if @weather[0] == 4
        return true
      else
        return false
      end
    end
   
    def set_hail(duration = -1)
      @weather = [4, duration]
    end
   
    def battle_end?
      if @result_flee or @result_win or @result_defeat
        return true
      else
        return false
      end
    end
   
    def add_money(amount)
      if @money == nil
        @money = 0
      end
      @money += amount
    end
   
  end

end


Dis moi si ça bug encore.

Posté par <€d> le 23 Sep - 07:21 (2008)
comme toujours:


      # Fenetre d'action
      s1 = "ATTAQUE"
      s2 = "SAC"
      s3 = "POKéMON"
      s4 = "FUITE"
    
      @action_window = Window_Command.new(320, , $fontsizebig, 2, 56)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
    
      # Viewport

Posté par Drakhaine le 23 Sep - 09:22 (2008)
bah remplace
Code:
 @action_window = Window_Command.new(320, , $fontsizebig, 2, 56)
par
Code:
 @action_window = Window_Command.new(320, [s1,s2,s3,s4], $fontsizebig, 2, 56)


Faut quand même avoir des notions en Ruby pour utiliser les scripts.. Sache donc que après un ???.new (création d'un objet de classe ???), tu auras souvent une parenthèse pleine d'arguments (des chiffres ou des variables) séparés par des virgules. L'erreur vient du fait que tu as deux virgules juxtaposées !!

En recherchant dans les scripts
Code:
class Window_Command
, puis
Code:
def initialize
, tu peux voir les arguments attendus :
Code:
def initialize(width, commands, size = $fontsize, column = 1, height = nil)

Ici, on attends la largeur de la fenêtre, un tableau contenant les commandes, la taille de la police, le nombre de colonnes et la hauteur (des cellules j'imagine, j'me suis pas penché sur le code plus que ça)

Posté par Happy le 23 Sep - 22:52 (2008)
Et ED,ça fonctionne je vais mettre le systme de palbolsky après moi aussi^^

Posté par Pαlвσlѕку le 24 Sep - 09:28 (2008)
Merci d'avoir cette erreur Drakhaine car je ne l'avais pas vu.
J'ai donc naturellement corrigé le script présent plus haut. Il ne devrait plus porter d'erreur maintenant (je l'espère...)

Posté par Jordan le 24 Sep - 11:48 (2008)
Palbolsky a écrit:
Merci d'avoir cette erreur Drakhaine car je ne l'avais pas vu.
J'ai donc naturellement corrigé le script présent plus haut. Il ne devrait plus porter d'erreur maintenant (je l'espère...)

PS : Sachez que jordan a intégré mon système de combat dans son jeu (POKéMON ANTIQUITE)


quelle pub! XD je ne pense pas que savoir que je l'ai mis va les faire changer d'avis en ce qui conserne ton beau systéme ^^

Posté par Pαlвσlѕку le 24 Sep - 19:47 (2008)
Tu disais Jordan ??

Vous avez encore des problèmes avec mon script (celui de krosk aussi^^) sinon ??

Posté par bibiantonio le 27 Sep - 16:41 (2008)
héhé ça marche ^^ !
c'est trés bien fait ^^

Posté par Pαlвσlѕку le 27 Sep - 16:42 (2008)
Merci pour ce compliment, ça me fait plaisir. Au moins j'aurais fait quelque chose d'utile^^

Posté par bibiantonio le 27 Sep - 16:43 (2008)
^^
moi je trouve ça trés jolie alors je le prends :p

Posté par Pαlвσlѕку le 27 Sep - 16:48 (2008)
Le script aura une petite modification ce soir (ou demain). Vous ne serez pas obliger d'appliquer le nouveau morceau que je mettrais dedans. Cette modification a pour but de modifier la couleur de l'ombre des lettres (et ça rend très bien).

Voilà j'ai terminé avec ce post, ce qui me fait maintenant 500 messages, en 42 jours.

Posté par Happy le 27 Sep - 22:31 (2008)
Je n'ai pas pu essseiller vraiment ton script palbolsky,,siltplai tu peux me faire un recapitulatife de se qu'il faut faire?

Posté par Aten974 le 28 Sep - 06:16 (2008)
essseiller ?!oO Tu parles bien la france toi ! :lol:

tout est au début :

./1777.html

si c'est ça que tu cherches ...

Posté par Pαlвσlѕку le 28 Sep - 15:28 (2008)
Salut membre fidèle de ce topic^^
J'ai terminé la modification, vous rajoutez donc :

Code:
def draw_text(x, y, w, h, string, align = 0, color = normal_color)
    self.contents.font.color = Color.new(40,48,40,255)
    self.contents.draw_text(x + 2, y + 2, w, h, string, align)
    self.contents.font.color = color
    self.contents.draw_text(x, y, w, h, string, align)
  end

Au-dessus de :
Code:
if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")


Si vous avez des questions n'hésitait pas.

PS : Vous n'êtes pas obliger de rajouter ce morceau.

Posté par Aten974 le 28 Sep - 15:34 (2008)
As-tu mis à jour ton 1er post ?(quand les spoilers remarcheront je te dirai si je prends ce script et si je l'aime bien !)

Posté par Pαlвσlѕку le 28 Sep - 15:36 (2008)
Je viens de le mettre à jour. Tu veux que je t'envoie le tout par MP ??

Voilà ce que ça donne après avoir appliquer mon tuto :
#40/1/3/5/exemple_combat_platine-…

Posté par Aten974 le 28 Sep - 15:40 (2008)
Euh oui stp ! ^^

Posté par Pαlвσlѕку le 28 Sep - 17:46 (2008)
Si vous avez des problèmes avec la mise à jour, dites le moi.

Posté par Aten974 le 28 Sep - 18:13 (2008)
Super script ! Merci !

Posté par <€d> le 28 Sep - 18:34 (2008)
Il bug quand je commence un combat:

        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
    
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
    
      for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
  
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end

Posté par Happy le 29 Sep - 11:44 (2008)
Le code à la page 4 fonctionne,vite je suis en retard pour les cours^^
A+!!!

Posté par Pαlвσlѕку le 29 Sep - 17:42 (2008)
<€d> remplace :



Code:
if @party.actors[@battle_order[i]].dead?

par :
Code:
if @party.actors[@battle_order[i-1]].dead?





PS : Le script de la page 4 n'a pas subit la modification.

Posté par Demos Kerrigan le 29 Sep - 18:01 (2008)
Trop fort ce script mais avant que je l'utilise, je voudrais savoir s'il est fonctionnel avec le PSP 0.7 beta sans erreur car je compte l'utiliser et mettre le nom de Palbolsky dans les crédits.

Posté par Ram' le 29 Sep - 18:06 (2008)
>>Oui d'après ce que j'ai pu lire dans le reste du topic<<

Posté par Aten974 le 29 Sep - 18:09 (2008)
Oui il marche sur PSP v0.7 je l'utilise pour ma version ! Bouche extensiblek:

Posté par Demos Kerrigan le 29 Sep - 18:10 (2008)
J'espère qu'au moins il a modifié le dummy à la bonne taille ^^

Posté par Aten974 le 29 Sep - 18:32 (2008)
ça je l'ignore j'ai customiser le mien ...

Posté par Demos Kerrigan le 29 Sep - 19:11 (2008)
il marche pas mal finalement ^^ fallait juste que j'aille lire dans les bonnes places XD

Je met vos noms dans la liste des crédits.

Posté par Pαlвσlѕку le 30 Sep - 06:24 (2008)
A ce que je vois, je n'ai pas eu besoin d'intervenir (c'est bien rare). Le dummy est bien réglé (merci Krosk de me l'avoir signaler tout au début)
D'ici quelques jours, je mettrais le script en téléchargement pour éviter les problèmes de caractères du forum.

Si vous avez des sugestions pour amélirorer le script, n'hésitez pas à m'en proposer.

Posté par <€d> le 30 Sep - 07:44 (2008)
j'ai un autre problème :  dès que je commence un combat les deux dresseur arrive chacun de leur côté et reparte de l'autre.

Posté par Pαlвσlѕку le 30 Sep - 18:00 (2008)
Je ne sais pas d'où ça peut venir car ma modification ne porte pas dessus. Le script fonctionnant correctement chez moi, je ferais une copie que je mettrais dans un fichier, qui sera téléchargable sur le forum.

Rappel : Compatible PSP v 0.7 et v 0.5.
Sachez que pour la version 0.5 de PSP, les lignes ne sont pas au même endroit. Donc fouiller dans le script dont vous devez mettre ma modification.

Posté par Aten974 le 8 Oct - 13:34 (2008)
désolé du up mais vous en pensez quoi ? :


http://www.dailymotion.com/sparco974/video/11765524

Posté par Pαlвσlѕку le 8 Oct - 15:46 (2008)
La barre des deux pokémons est trop clair. A moins que tu ne changes la couleur du texte, ça fait pas très bien.
Sinon, ça me fait plaisir que vous utilisez mon système de combat.

BONNE JOURNEE LES GENS :mrgreen:

Posté par <€d> le 26 Oct - 09:46 (2008)
Tu peux l'adapter sur PSP4G

Posté par Pαlвσlѕку le 4 Jan - 20:16 (2009)
Bien que ça fait 2 mois, je vais voir ce que je peux faire (je travaille pas sous PSP4G et donc les scripts sont un mystère pour moi)

Comme promis, voilà le lien pour le script, ainsi que les images qui vont avec :
http://dl.free.fr/tFnggM44i

Posté par Jordan le 5 Jan - 07:44 (2009)
tu as enfin fais une demo pour le script c'est ça si j'ai bien compris?
Et bien tant mieux par ce que c'était le foutoir ^^

Posté par Masharu-Law le 14 Jan - 18:07 (2009)
Hello ^^.

J'ai voulu essayer d'intégrer le script mais au final j'ai cette erreur :

????? Scene_Intro' ? 69 ??? NameError ???????
Uninitialized constant POKEMON_S::Pokemon_Battle_Variable

Dois-je tout refaire (car incompatible) ou existe-t-il une solution ? Merci Imbécile heureux.

Posté par Aten974 le 15 Jan - 19:40 (2009)
Si tu utilises psp0.7 oui, réinstalle, si tu utilises une autre version, c'est incompatible !

Posté par Masharu-Law le 16 Jan - 00:05 (2009)
Merci d'avoir répondu Clin d'œil foireux.
Aten974 a écrit:
Si tu utilises psp0.7 oui, réinstalle, si tu utilises une autre version, c'est incompatible !

Dois je comprendre que, quelque soit le cas, c'est imcompatible XD ? J'ai voulu dire par refaire, remettre en ordre (supprimé toutes les ajouts de ce tuto quoi, parce que voilà je replace les anciens scripts par ceux de ce tuto, et puisque le jeu bloque je suis obligé de tout refaire s'il n'ya pas de solution Clin d'œil foireux).

Pourtant j'utilise le mod PSP0.7 (couplé avec le projet PSPG4).

Donc solution à ce problème ou j'abandonne (= je remets mon projet comme avant d'avoir essayer ce tuto Clin d'œil foireux) ?

Posté par Angi-MK le 16 Jan - 00:10 (2009)
ouais, ne supprime pas ton projet... Remet juste les scripts en état Clin d'œil foireux

Posté par Masharu-Law le 16 Jan - 00:18 (2009)
Mais bien sur que non que je vais pas le sup je ne l'ai pas dit dans ce sens XD...J'"abandonne" à prendre dans le sens où j'abandonne ce tuto qui était ma fois très intéressant.

Posté par Angi-MK le 16 Jan - 00:57 (2009)
Ouais alors abandonne le tuto lol :mrgreen:

Posté par Aten974 le 16 Jan - 11:07 (2009)
Avec la version 0.7 c'est compatible mais pas avec les autres !

Posté par Sphinx le 16 Jan - 19:34 (2009)
Clin d'œil foireux apparemment, tu utilises PSP4G (antérieure à PSP0.7) donc tu peux essayer de transférer ton projet sur 0.7 pour utiliser ce script =)

Posté par Pαlвσlѕку le 16 Jan - 20:14 (2009)
Compatible PSPv0.7 et PSP4G !!

http://dl.free.fr/jjmpmbbU3

Posté par Sphinx le 16 Jan - 20:34 (2009)
Aten974 a écrit:
Avec la version 0.7 c'est compatible mais pas avec les autres !


^_^ jconnais pas vraiment le tuto (simplement parce que je ne l'ai jamais installé Clin d'œil foireux) donc je me fiais surtout aux posts précédents qui tendent à dire que ca ne serait pas compatible ac autre chose que PSP0.7 ^_^

Posté par Pαlвσlѕку le 16 Jan - 20:41 (2009)
J'ai juste modifier des points de vues graphiques. La seule chose qui est différent pour chaque version, c'est l'emplacement des lignes de scripts.
Il m'a fallut 5 minutes pour installer mon tuto sur PSP4G, et ça fonctionne très bien.

Posté par Sphinx le 16 Jan - 21:38 (2009)
Petit saligaud mal élevé Alors ne pas tenir compte de mes messages précédents lol


^_^" désolé, je sors

Posté par Masharu-Law le 17 Jan - 16:40 (2009)
Palbolsky a écrit:
Compatible PSPv0.7 et PSP4G !!
http://dl.free.fr/jjmpmbbU3


Merci Palbolsky Clin d'œil foireux , j'essaie ça demain dès que je peux et je vous tiens au courant.

Update :
Vraiment navré mais chez moi ça ne marche pas, et je ne comprend pas pourquoi (simple recopiage du tuto + les img sont dans le dos Picture). Soit j'ai l'erreur "error syntaxe" à la dernière ligne du script soit en manipulant un peu (je rajoute juste un "end" ^^") je me retrouve avec la même erreur qu'avant.

Posté par PiVa le 17 Jan - 17:51 (2009)
Tu as du faire une erreur... sa marche chez Palboskyil n'y a pas de raison que ca bug chez toi.
Palbosky tu pourrais lui postés les scripts modifier en entier ?

Posté par Masharu-Law le 17 Jan - 19:32 (2009)
Je résume de tête :
- 1er étape : changer une ligne  dans menu_pokémon_party.
- 2e étape : changer toute la fin du script battle_core 1 par le script modifié.
- Et après ne pas oublier de mettre les images dans le dos Picture.

Si j'ai fait une erreur, c'est seulement si j'ai raté une étape.

Posté par Pαlвσlѕку le 17 Jan - 19:43 (2009)
Citation:
- 2e étape : changer toute la fin du script battle_core 1 par le script modifié.

Pas jusqu'à la fin !! (j'ai écrit la ligne où ça s'arrêtait)

Colle ton script Pokemon_Battle_Core 1 sur le forum, a partir de la 2000ième ligne. Je pourrais l'examiner comme ça.

PS : Je ne peux pas mettre le script en entier car les forums au tendance à modifier les scripts, et donc vos scripts seraient remplis de fautes ! (et donc ne fonctionne pas)

Posté par PiVa le 17 Jan - 20:42 (2009)
bah dans un petit fichier bloc note uploadé ?

Posté par Pαlвσlѕку le 17 Jan - 21:00 (2009)
Voilà ^^

http://dl.free.fr/qIg5qvgLI

Posté par Masharu-Law le 17 Jan - 21:12 (2009)
Ayé ça marche ^^ ! J'avais en effet remplacé toute la fin par le script du tuto ^^", enlevant ainsi une bonne partie de code, ce qui faisait bugger le jeu. Comme j'ai une sauvegarde de mon projetn j'ai pu vérifié ça assez facilement. Ça marche vraiment ^^.

Merci et merci infiniment pour votre aide Clin d'œil foireux .

Posté par Pαlвσlѕку le 17 Jan - 21:34 (2009)
Tu avais supprimé la fenêtre de statut de l'équipe. Je comprends pourquoi le script buguait^^
Si vous avez des problèmes, ou que vous voulez modifiez quelques choses, postez !!

Posté par DarkAngel le 5 Fév - 21:15 (2009)
Bonjour j'ai la dernière version de PSP et j'arrive pas a mettre le script u_u

Posté par Pαlвσlѕку le 5 Fév - 22:25 (2009)
Tu pourrais être plus précis :
Version de PSP : PSP v0.7 C6 ?? (C6 = correctif 6)
J'arrive pas à le mettre : Comment ça ?

Posté par Aten974 le 6 Fév - 10:26 (2009)
Aufait, il y a un décalage pour la barre de vie comparé à la Hp_bar Clin d'œil foireux

Posté par Pαlвσlѕку le 6 Fév - 19:25 (2009)
Un petit sreen SVP.
Normalement, il ne peut pas y avoir de décalage, mais bon...

Posté par Aten974 le 6 Fév - 19:52 (2009)
Le premier post est à jour ? ^^"

Car j'ai supprimé involontairement le script ^^"

Posté par Pαlвσlѕку le 6 Fév - 20:13 (2009)
Le script est là : http://dl.free.fr/qIg5qvgLI

Posté par Aten974 le 6 Fév - 20:30 (2009)
compatible psp v0.7 Correctif 6 ?

Posté par Ace Attorney Man le 6 Fév - 20:32 (2009)
Normalement oui , je l'avait avant et ça marchait avec le correctif 6 ^_^(mais le premier post est pas à jour)

Posté par Pαlвσlѕку le 6 Fév - 20:50 (2009)
Maintenant c'est bon. Premier Post à jour !

Compatible avec PSP v0.7 C6 (je possède cette version et ça marche nickel)

Posté par DarkAngel le 6 Fév - 21:30 (2009)
Ah ouki le probleme que j'avais c'est que les lignes ne correspondais pas, J'ai un probleme après avoir mit le scripte dans Pokemon_Battle_Wild  ligne 136

Posté par Pαlвσlѕку le 6 Fév - 23:08 (2009)
Log + le morceau où ça bug (10 lignes avant-après, signale la ligne qui bug)
Je pourrais mieux t'aider de cette façon.

Posté par Aten974 le 7 Fév - 07:18 (2009)
marche nickel maintenant, merci !

Posté par Pαlвσlѕку le 7 Fév - 07:28 (2009)
De rien, c'est normal ^^

Posté par DarkAngel le 7 Fév - 11:47 (2009)
La parti qui bug et celle-la la lige ou il y a le @background.bitmap = RPG::Cache.battleback(@battleback_name) :
Code

     # Dessin
      Graphics.freeze
 /!\@background.bitmap = RPG::Cache.battleback(@battleback_name)
/!\
      @message_background.bitmap = RPG::Cache.battleback(BATTLE_MSG)
      @enemy_sprite.bitmap = RPG::Cache.battler(@start_enemy_battler, 0)
      ###@enemy_sprite.bitmap = RPG::Cache.battler("ENEMY.png", 0)
      @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
      @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
      @enemy_sprite.x -= 782

Posté par Ace Attorney Man le 7 Fév - 11:51 (2009)
t'as réglé le battleback du tiles toi ? -_-"

Posté par Heiwka le 7 Fév - 19:41 (2009)
Dans le téléchargement je ne vois que le document texte Oo
tu peut me donner les images comme ça, là ?

Posté par DarkAngel le 8 Fév - 17:03 (2009)
u_u non j'ai juste mit ce que a dit Palbolsky u_u c'est tout TT

Posté par Sphinx le 8 Fév - 17:09 (2009)
xD C'est connu que quand on règle pas le battlerback, ca bug au début de tout combat (dresseur ou sauvage) Clin d'œil foireux Ca c'est un bug presque aussi vieux que PSP Clin d'œil foireux

Posté par DarkAngel le 8 Fév - 20:53 (2009)
On fait comment pour le régler u_u 

Posté par Sphinx le 8 Fév - 21:09 (2009)
BDD... Quand tu règles le tileset, tu règles aussi le battleback...

Base de RMXP tt ca...

Posté par Pαlвσlѕку le 8 Fév - 21:27 (2009)
Moi ça m'arrive trop souvent de l'oublier xD.

Poké-coco, je crois que ça vient de moi, j'ai pas dû mettre le bon lien dans mon premier post xD.

Sphinx, +1

Premier post corrigé

Posté par DarkAngel le 8 Fév - 21:44 (2009)
U_u Et l'autre Scripte on le met ou xD

Posté par Pαlвσlѕку le 8 Fév - 22:18 (2009)
Quel autre script ??

Posté par DarkAngel le 9 Fév - 18:32 (2009)
Celui ci :
Script

Class Pokemon_Battle_Status < Window_Base
    def initialize(pokemon, enemy, z_level = 15)
      @enemy = enemy # True / False
      if @enemy
        super(23,0,332,116)
      else
        super(311,203,341,140)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontsmall
      self.contents.font.size = $fontsmallsize
      # self.contents.font.bold = true
      self.opacity = 0
      self.z = z_level
      @pokemon = pokemon
      refresh
    end
   
    def refresh
      self.contents.clear
      level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
      normal_color = Color.new(248,248,248,255)
     
def draw_text(x, y, w, h, string, align = 0, color = normal_color)
    self.contents.font.color = Color.new(40,48,40,255)
    self.contents.draw_text(x + 2, y + 2, w, h, string, align)
    self.contents.font.color = color
    self.contents.draw_text(x, y, w, h, string, align)
  end

if @enemy
        src_rect = Rect.new(0, 0, 300, 84)
        bitmap = RPG::Cache.picture("battle_sprite1.png")
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(69,45, level)
        draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(242 - width_text, 15, @pokemon.gender)
        if $data_pokedex[@pokemon.id][1]
          src_rect = Rect.new(0, 0, 21, 21)
          bitmap = RPG::Cache.picture("ballbattlestatus.png")
          self.contents.blt(27, 45, bitmap, src_rect, 255)
        end
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(20, 47, bitmap, src_rect, 255)
        end
      else
        src_rect = Rect.new(0, 0, 309, 108)
        bitmap = RPG::Cache.picture("battle_sprite2.png") #barre du pokémon de l'équipe
        self.contents.blt(0, 0, bitmap, src_rect, 255)
        draw_hp_bar(93,45, level)
        draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 58, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
        if @pokemon.level < 100
          level = @pokemon.next_exp.to_f /
            (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
        else
          level = 0
        end
        draw_exp_bar(46, 99, 1.0 - level, 232)
        width_text = self.contents.text_size("N." + @pokemon.level.to_s).width - 3
        draw_gender(268 - width_text, 15, @pokemon.gender)
        if @pokemon.status != 0
          string = "stat_battle" + @pokemon.status.to_s + ".png"
          src_rect = Rect.new(0, 0, 60, 24)
          bitmap = RPG::Cache.picture(string)
          self.contents.blt(44, 68, bitmap, src_rect, 255)
        end
      end
    end
   
    def exp_refresh
      level = @pokemon.next_exp.to_f /
        (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
      draw_exp_bar(46, 99, 1.0 - level, 232)
    end
     
    def damage_refresh(info)
      damage = info[0]
      if damage == 0
        return
      end
     
      for i in 1..damage
        @pokemon.remove_hp(1)
        Graphics.update
        Graphics.update
        if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
          break
        end
      end
    end
   
    def dispose
      super
    end
   
    def draw_hp_bar(x, y, level, small = false)
      src_rect = Rect.new(0, 0, 198, 24)
      bitmap = RPG::Cache.picture("hpbar.png")
      if small
        bitmap = RPG::Cache.picture("hpbarsmall.png")
      end
      self.contents.blt(x, y, bitmap, src_rect, 255)
      rect1 = Rect.new(x + 42, y + 4, level*144.to_i, 3)
      rect2 = Rect.new(x + 42, y + 7, level*144.to_i, 6)
      if small
        rect1 = Rect.new(x + 42, y + 4, level*129.to_i, 3)
        rect2 = Rect.new(x + 42, y + 7, level*129.to_i, 6)
      end
     
      if level < 0.1
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(248, 64, 16, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(232, 168, 50, 255)
      else
        color1 = Color.new(248, 248, 248, 255)
        color2 = Color.new(24, 192, 32, 255)
      end
      self.contents.fill_rect(rect1, color1)
      self.contents.fill_rect(rect2, color2)
    end
   
    def draw_exp_bar(x, y, level, width)
      rect1 = Rect.new(x, y, level*232.to_i, 3)
      self.contents.fill_rect(rect1, Color.new(64, 144, 224, 255))
    end
   
    def draw_gender(x, y, gender)
      if gender == 1
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Maleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb.png")
        self.contents.blt(x, y, bitmap, rect, 255)       
      end
    end
  end
 
 
  #------------------------------------------------------------ 
  # Fenêtre de statut de l'équipe
  #------------------------------------------------------------ 
  class Pokemon_Battle_Party_Status < Window_Base
    attr_accessor :battle_order
   
    def initialize(party, order, enemy, z_level = 15)
      @enemy = enemy # True / False
      @battle_order = order
      if @enemy
        super(0-16,63-16,315+32,42+32)
      else
        super(325-16, 261-16, 315+32,42+32)
      end
      self.contents = Bitmap.new(width - 32, height - 32)
      self.opacity = 0
      self.z = z_level
      @party = party
      refresh
    end
   
    def refresh
      self.contents.clear
      src_rect = Rect.new(0, 0, 315, 42)
      if @enemy
        bitmap = RPG::Cache.picture("partystatusenemy.png")
      else
        bitmap = RPG::Cache.picture("partystatus.png")
      end
      self.contents.blt(0, 0, bitmap, src_rect, 255)
     
      src_rect = Rect.new(0, 0, 30, 30)
      if @enemy
        ball_x = 173
        coeff = -2
        else
        ball_x = 52
        coeff = 2
        end
     
      for i in 1..@party.size
        bitmap = RPG::Cache.picture("ballpartystatus.png")
        if @party.actors[@battle_order[i][/i]].dead?
          bitmap = RPG::Cache.picture("ballpartystatusko.png")
        end
        self.contents.blt(ball_x + coeff*16*(i-1), 2, bitmap, src_rect, 255)
      end
    end
   
    def reset_position
      if @enemy
        self.x = -16
      else
        self.x = 325-16
      end
      refresh
    end
  end

Posté par Drag le 16 Mai - 18:22 (2009)
Bonjour j'ai un bug avec le script Pokemon_Party_Menu depuis que j'ai ajouté les combats platine. Ca m'affiche Syntax Error (les 10 lignes d'après n'y sont pas car c'est la dernière qui bug)
Code:
        bitmap = RPG::Cache.picture("Maleb_equipe.png")
        self.contents.blt(x, y, bitmap, rect, 255)
      end
      if gender == 2
        rect = Rect.new(0, 0, 18, 33)
        bitmap = RPG::Cache.picture("Femaleb_equipe.png")
        self.contents.blt(x, y, bitmap, rect, 255)          
        end
    end
  end
end

Que faire s'il vous plait?

Posté par PiVa le 16 Mai - 18:42 (2009)
Essaie de rajouter un end tous à la fin.

Posté par Drag le 16 Mai - 18:47 (2009)
J'ai essayé mais ça m'affiche toujours le meme bug.

Posté par Lén le 16 Mai - 18:52 (2009)
non surtout pas tu va mettre trop de temps a régler le pb ! ... tu supprime tout et tu le recolle.

Posté par Mini' le 16 Mai - 19:01 (2009)
Regarde si dans ton dossier Pictures tu as les deux images sous les noms de "Maleb.png" et "Femaleb.png".
Sinon, renomme-les (les images qui se trouvent dans Pictures) en Maleb.png  ou bien Femaleb.png.

Good luck !

Posté par Drag le 16 Mai - 19:08 (2009)
Miniyas ils y sont et supprimer collez j'ai essayer ça marche pas.

Posté par Lén le 16 Mai - 20:48 (2009)
Drag a écrit:

Miniyas ils y sont et supprimer collez j'ai essayer ça marche pas.

J'ai relu ton premier post,, et pourtant je ne vois ni le log, ni ce que ça dis quand ça bug ...

Posté par bibiantonio le 17 Mai - 10:16 (2009)
pourquoi NT à édité ce topic ? :( je le recherchais et j'était content de le retrouver et là je suis déçu, ça marchait bien avant,pourquoi ça été changé ? je comprends pas

Posté par PiVa le 17 Mai - 13:17 (2009)
Il n'y a plus rien ! Malédiction !

Posté par Raiden le 17 Mai - 13:29 (2009)
Il y a plus rien de quoi moi j'ai tout.

Posté par PiVa le 17 Mai - 14:15 (2009)
Ça remarche, le forum bugger je pense, désolé  Lordork chez mémé