Sujet n°4631
Posté par Slash le 27 Juil - 22:46 (2009)
Titre : Combat style pokémon Platine
Bon, tout est dans le titre. Ce petit script vous permettra d'avoir une interface de combat a la pokémon  platine

dans un premier temps , telecharger ce petit pack d'image et installer le dans votre projet .

http://www.sendspace.com/file/4lh688

ensuite, remplacer le script Pokemon_Battle_Core 1 par celui ci si vous avez PSP0.7:

 
Pokemon_Battle_Core 1 PSP0.7

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.contents.font.color = Color.new(255,255,255)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.opacity = 0
      @action_window.z = @z_level + 22
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
      @sprite_action_window = Sprite.new
      @sprite_action_window.bitmap = RPG::Cache.picture("battle_dummy.PNG")
      @sprite_action_window.x = 320
      @sprite_action_window.y = 336
      @sprite_action_window.z = @z_level + 21
      @sprite_action_window.visible = false
      
      # 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
      @sprite_action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @sprite_skill_window.dispose
        @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
        @sprite_skill_window = Sprite.new
        @sprite_skill_window.bitmap = RPG::Cache.picture("attack_dummy.PNG")
        @sprite_skill_window.x = 0
        @sprite_skill_window.y = 336
        @sprite_skill_window.z = @z_level + 21
        @sprite_skill_window.visible = false
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.opacity = 0
        @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.opacity = 0
        @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 + "?")
          @sprite_action_window.visible = true
          @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
            @sprite_action_window.visible = 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
            
            @sprite_skill_window.visible = true
            @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)
              @sprite_action_window.visible = true
              @action_window.visible = true
              draw_text("Que doit faire", @actor.given_name + "?")
              return
            end
            @sprite_action_window.visible = true
            @action_window.visible = true
            
            @action_window.active = false
            @sprite_action_window.visible = 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
            @sprite_skill_window.visible = false
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @sprite_action_window.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)
          @sprite_skill_window.visible = false
          @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
        @sprite_action_window.visible = false
        @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
      @sprite_action_window.visible = false
      @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,  Color.new(255, 255, 255, 255))
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2,  Color.new(255, 255, 255, 255))
        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,  Color.new(255, 255, 255, 255))
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2,  Color.new(255, 255, 255, 255))
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2,  Color.new(255, 255, 255, 255))
        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, 9)
      #rect2 = Rect.new(x + 45, y + 9, level*144.to_i, 6)
      rect2 = Rect.new(x + 45, y + 6, level*144.to_i, 9)
      if small
        rect1 = Rect.new(x + 45, y + 6, level*129.to_i, 9)
        #rect2 = Rect.new(x + 45, y + 9, level*129.to_i, 6)
        rect2 = Rect.new(x + 45, y + 6, level*129.to_i, 9)
      end
      
      if level < 0.1
        color1 = Color.new(200 ,92, 84, 255)
        color2 = Color.new(200 ,92, 84, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(204, 156, 104, 255)
        color2 = Color.new(204, 156, 104, 255)
      else
        color1 = Color.new(100, 160, 104, 255)
        color2 = Color.new(100, 160, 104, 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(96, 160, 200, 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







ou par celui ci si vous avez PSP4G+

Pokemon_Battle_Core 1 PSP4G+


 
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
      unless $game_variables[5000]["compteurs"] == [] or
          $game_variables[5000]["compteurs"][0].tourne
        bool = $game_variables[5000]["compteurs"][1]
        $game_variables[5000]["compteurs"][0].arreter
        $game_variables[5000]["compteurs"][1] = bool
      end
      # 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.opacity = 0
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
      @sprite_action_window = Sprite.new
      @sprite_action_window.bitmap = RPG::Cache.picture("battle_dummy.PNG")
      @sprite_action_window.x = 320
      @sprite_action_window.y = 336
      @sprite_action_window.z = @z_level + 21
      @sprite_action_window.visible = false
      
      # 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_sprite.tone = @actor.ton
      @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
      @enemy_sprite.tone = @actor.ton
      @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
      @sprite_action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
        @sprite_skill_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.opacity = 0
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.z = @z_level + 30
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
        @sprite_skill_window = Sprite.new
        @sprite_skill_window.bitmap = RPG::Cache.picture("attack_dummy.PNG")
        @sprite_skill_window.x = 0
        @sprite_skill_window.y = 336
        @sprite_skill_window.z = @z_level + 21
        @sprite_skill_window.visible = 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.z = @z_level + 30
        @skill_descr.opacity = 0
        @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
          @sprite_action_window.visible = 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
            @sprite_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
            @sprite_skill_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
            @sprite_action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              @sprite_action_window.visible = true
              draw_text("Que doit faire", @actor.given_name + "?")
              return
            end
            @action_window.visible = true
            @sprite_action_window.visible = true
            @action_window.active = false
            @action_window.visible = false
            @sprite_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
            @sprite_skill_window.visible = false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @sprite_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
          @sprite_skill_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @sprite_action_window.visible = true
          @phase = 0
        end
        
        
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
        @sprite_action_window.visible = 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
      @sprite_action_window.visible = 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.z = @z_level + 15
        @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 voler_enemy
      draw_text("Vous avez volé " + @enemy.name,"de " + Trainer_Info.string(@trainer_id) + " !")
      wait(40)
      index = $battle_var.enemy_party.actors.index(@enemy)
      @enemy_status.dispose
      @enemy.given_name = @enemy.name
      @enemy.loyalty = @enemy.loyalty > 140 ? 0 : 140 - @enemy.loyalty
      if $pokemon_party.size < 6
        $pokemon_party.actors.push(@enemy)
        $battle_var.battle_order.push($battle_var.battle_order.size)
      else
        int = Interpreter.new
        int.ajouter_stocker_pokemon_cree(@enemy)
      end
      $battle_var.enemy_party.remove(@enemy)
      if index < $battle_var.enemy_party.size
        for i in 0...$battle_var.enemy_party.actors.size
          if $battle_var.enemy_party.actors[i].hp > 0
            enemy_temp = $battle_var.enemy_party.actors[i]
            break
          end
        end
        @enemy_switch_id = i
      end
      @enemy_caught = true
      $pokemon_party.aug_lvl(1)
      enemy_pokemon_switch
      draw_text("Venge moi, " + enemy_temp.name + " !","A l'attaque !")
      wait(40)
    end
    
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy_status.disposed?)
          if not(@enemy.dead?)
            @enemy_status.visible = true
          else
            @enemy_status.visible = false
          end
        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.z = @z_level + 15
        @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 $pokemon_capturer == true
        int = Interpreter.new
        draw_text(@enemy.given_name, "à été volé !")
        @enemy.given_name = @enemy.name
        if $pokemon_party.size < 6
          $pokemon_party.actors.push(@enemy)
          $battle_var.battle_order.push($battle_var.battle_order.size)
        else
          int.ajouter_stocker_pokemon_cree(@enemy)
        end
      else
        if FileTest.exist?(@enemy.cry)
          Audio.se_play(@enemy.cry)
        end
        draw_text(@enemy.given_name, "est K.O.!")
        wait(50)
        Audio.se_play("Audio/SE/Down.wav")
      end
        
      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
      @enemy.hp = 0
      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)      
      $alea = false
      # 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)
      $pokemon_party.incr_nb_matchs
      for actor in $pokemon_party.actors
        if $battle_var.have_fought.include?(actor.party_index)
          actor.fight[0] += 1
          if actor.dead? and not(actor.vaudou)
            actor.vaudou = actor.medaille == nil ? false : $data_medaille[actor.medaille][4]
            if actor.vaudou
              draw_text(actor.name + " subit la","malédiction !")
              wait(40)
              wait_hit
            end
          end
        end
      end
      $battle_var.result_flee = expulsion ? false : true
      $battle_var.result_flee_enemy = expulsion
      $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)
      $pokemon_party.incr_nb_matchs
      for actor in $pokemon_party.actors
        if $battle_var.have_fought.include?(actor.party_index)
          actor.fight[0] += 1
          if actor.dead? and not(actor.vaudou)
            actor.vaudou = $data_medaille[actor.medaille][4]
            if actor.vaudou
              draw_text(actor.name + " subit la","malédiction !")
              wait(40)
              wait_hit
            end
          end
        end
      end
      $battle_var.result_flee_enemy = expulsion ? false : true
      $battle_var.result_flee = expulsion
      $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
      $pokemon_party.incr_nb_matchs
      for actor in $pokemon_party.actors
        if $battle_var.have_fought.include?(actor.party_index)
          actor.fight[0] += 1
          if actor.dead? and not(actor.vaudou)
            actor.vaudou = actor.medaille > 0 ? $data_medaille[actor.medaille][4] : false
            if actor.vaudou
              draw_text(actor.name + " subit la","malédiction !")
              wait(40)
              wait_hit
            end
          end
        end
      end
      if not($sauvage)
        @enemy_sprite.opacity = 255
        @enemy_sprite.zoom_x = 1
        @enemy_sprite.zoom_y = 1
        @enemy_sprite.visible = true
        @start_enemy_battler = $alea ? "trainer" + $no_alea : Trainer_Info.battler(@trainer_id)
        @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
        @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
        @enemy_sprite.x = 723
        @enemy_sprite.y = (@enemy_sprite.bitmap.height * 2 / 3) - 10
        @enemy_sprite.bitmap = RPG::Cache.battler(@start_enemy_battler, 0)
        loop do
          @enemy_sprite.x -= 10
          Graphics.update
          if @enemy_sprite.x <= 464
            break
          end
        end
        
        list_string = Trainer_Info.string_defeat(@trainer_id)
        draw_text(list_string)
        wait(40)
        wait_hit
      end
      $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 = $game_variables[5000]["menu_dp"] ? RPG::Cache.battleback("sp1_" + $game_map.battleback_name + ".png") : 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 = $game_variables[5000]["menu_dp"] ? RPG::Cache.battleback("sp2_" + $game_map.battleback_name + ".png") : 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_flee_enemy
    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_flee_enemy = 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_flee_enemy 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




Maintenant, vous n'avez plus qu'a admirer le résultat :

Apercu du Résultat




Voila, vous pouvez Modifier les images a votre Guise afin d'amélioré votre systeme de combat.

Posté par Yondaime59 le 27 Juil - 22:52 (2009)
Waaaaooouuuwww Super!!
Mais Palbolsky en a déjà fait un :?

Posté par Slash le 27 Juil - 22:57 (2009)
ah je l'avait pas vu enfin bon si cela peut servir a certain, notament le changement d'interface dans les boite de dialogues alors ce sera utile

Posté par Pαlвσlѕку le 27 Juil - 22:58 (2009)
Le mien date de quelques mois déjà.

./1777.html

Je le trouve très réussi Slash. Bouche extensiblek:

Posté par Slash le 27 Juil - 23:02 (2009)
Merci Pal mais le tiens est pas mal non plus

Posté par Aten974 le 28 Juil - 07:56 (2009)
Slash, tu peux nous donner ce que tu as modifié stp, comme ça on peut l'additionner à celui de Pal' Imbécile heureux

Du bon boulot comme toujours en tout cas Imbécile heureux

EDIT : J'ai réussi(vous allez me dire que c'est pas sorcier :gloups: ) à modifier le script de Pal' pour qu'il y ait les images "attack/batlle_dummy"

Posté par Yoh le 28 Juil - 10:49 (2009)
C'est quoi ces images aten? 

Posté par nathan818 le 28 Juil - 11:01 (2009)
Tu pourait mettre en code??
parce que y a du texte qui c'est transformer en emoticone...

Posté par Masharu-Law le 28 Juil - 14:54 (2009)
Je n'ai aucune idée de l'mpacte que ça pourrait avoir en installant tête baissée cette interface de combat. J'utilise le Menu Pokémon (façon Platine) de Palbolsky, je voulais savoir si en installant ce script je risquerais soit d'avoir un bug soit de perdre l'ancien menu PKMN (ou soit rien de spécial xD). Je précise aussi que j'use l'interface de combat Platine de Palbolsky.

Ou alors Aten ce serait intéressant de savoir comment tu as fait pour modifier le script de Palbolsky pour que ça ressemble à celui de Slash Imbécile heureux.

Posté par Aten974 le 28 Juil - 15:06 (2009)
Maskash, pour garder le script de pal ne mets pas les images de l'interface du menu ^^'

Moi j'ai juste repris les codes pour avoir les images au lieux des fenêtres Imbécile heureux

Posté par BlueRayquaza le 28 Juil - 15:57 (2009)
Bonjour, j'ai installé toutes les images demandées, j'ai remplacé Pokémon_Battle_Core 1 par le script de Slash.
J'ai aussi rajouté 8 et la parenthèse à la place de 8), car il n'y avait rien à la place de 8), et que je suppose que normalement il y avait écrit ça ( dites le moi si j'ai fait une erreur ) puisque il faut écrire ça pour mettre 8).

Mais j'ai eu un problème ! Suis-je la seule à avoir des problèmes comme ça :( ?
Enfin, bref, je me retrouve avec un bug sans Log.txt, le voici :

????? 'Pokemon_Battle_Core 1' ? 96 ??? SyntaxError ????????

Voici la ligne 96 et son entourage :

90 # Fenetre d'action
91 s1 = "ATTAQUE"
92 s2 = "SAC"
93 s3 = "POKéMON"
94 s4 = "FUITE"
95
96 @action_window = Window_Command.new(320, , $fontsizebig, 2, 56)
97 @action_window.contents.font.color = Color.new(255,255,255)
98 @action_window.x = 320
99 @action_window.y = 336
100 @action_window.opacity = 0
101 @action_window.z = @z_level + 22

Je ne comprends vraiment pas, sourtout que niveau script je suis bof Lordork chez mémé , et en plus j'ai fait tout ce qui est demandé...

Merci d'avance Clin d'œil foireux

Posté par Masharu-Law le 28 Juil - 15:59 (2009)
Aten974 a écrit:
Maskash, pour garder le script de pal ne mets pas les images de l'interface du menu ^^'

Ce n'est pas ce que je demande.

Je veux remplacer le script "Combat Platine" de Pal par celui de Slash qui est beaucoup plus complet puisqu'il comprend l'interface des attaques qui m'intéresse vraiment (le reste je m'en fou Aten xD, mais ce que je craint avec ce nouveau script c'est que le menu Platine que j'ai change avec un auter script de Pal ne redevienne un menu R/S/E -__- (en phase de combat ou de façon permanent, si ça ne bug pas de plus et évidement).

Mais bon je vais l'essayer hein, brute comme ça à l'arrache enfin bref XD, et si ça bug NINJA POWA !...

Posté par Newtiteuf le 28 Juil - 16:21 (2009)
BlueRayquaza

ligne 96 je crois qu'il y a une virgule en trop:
@action_window = Window_Command.new(320, , $fontsizebig, 2, 56)

dis moi si ca bug toujours après l'avoir enlevée !

Posté par BlueRayquaza le 28 Juil - 16:33 (2009)
Cela provoque un autre bug, toujours sans log.txt, cette fois à la ligne 2637.
La voici :

if @party.actors[@battle_order[i][/i]].dead?

Posté par Masharu-Law le 28 Juil - 16:38 (2009)
Bon je vais voir pour comme tu as dis Aten, tout réinstaller et pour que ça bug ça ne me tente pas xD.

Posté par Newtiteuf le 28 Juil - 16:44 (2009)
Met ca a la place

if @party.actors[@battle_order].dead?

Posté par BlueRayquaza le 28 Juil - 16:50 (2009)
Désolée Lordork chez mémé , mais ça change rien ! J'ai enlevé le crochet en trop, il me met toujours le même bug ligne 2637...
Et puis, pourquoi tu as color= et /color entre crochets ? Moi j'ai i et /i !

Posté par Newtiteuf le 28 Juil - 16:54 (2009)
Non regarde j'ai édité mon post , il faut que tu remplace la ligne par ca:

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

Posté par BlueRayquaza le 28 Juil - 16:58 (2009)
Il faudrait savoir ! Bon, j'ai bien remplacé par

if @party.actors[@battle_order].dead?

mais quand je vais dans les herbes et qu'un combat démarre, il me met : Window_Command, ligne 44, ArgumentError, bad value for size

Ligne 44 : self.contents.font.size = size

Ensuite, le rapport Log.txt :

---------- Erreur de script : Window_Command ----------
----- Type
ArgumentError

----- Message
bad value for size

----- Position dans Window_Command
Ligne 44

----- Backtrace
Script : Window_Command | Ligne : 44 | Méthode : in `size='
Script : Window_Command | Ligne : 44 | Méthode : in `initialize'
Script : Pokemon_Battle_Core 1 | Ligne : 96 | Méthode : in `new'
Script : Pokemon_Battle_Core 1 | Ligne : 96 | Méthode : in `main'
Script : Main | Ligne : 57

Voilà... J'èspère que tu vas trouver Clin d'œil foireux

Posté par Newtiteuf le 28 Juil - 17:04 (2009)
montre moi les 10 lignes avant et apres la ligne 44 de "Window_Command"
et fais de même pour le 10 avant et après la ligne 96 de "Battle_core 1"
et de même avec la ligne 57 de "main"

Posté par BlueRayquaza le 28 Juil - 17:14 (2009)
10 avant/après ligne 44 Windows_Command ( ligne 44 dedans ) :

@height = height
else
@height = @heightsize
end
super(0, 0, width, commands.size * @height + 32, @height)
@item_max = commands.size
@commands = commands
@column_max = column
self.contents = Bitmap.new(width, @item_max * @height)
self.contents.font.name = $fontface
self.contents.font.size = size
refresh
self.index = 0
end

def draw_item(index, color = normal_color)
self.contents.font.color = color
# Modification pour le tracé du texte
rect = Rect.new(4 + 8 + (index % @column_max) * (width/@column_max),
@height * (index/@column_max) + (@height-@heightsize)/2, self.contents.width/@column_max, @heightsize)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

10 avant/après ligne 96 Battle_Core 1 ( ligne 96 dedans ) :

@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, $fontsizebig, 2, 56)
@action_window.contents.font.color = Color.new(255,255,255)
@action_window.x = 320
@action_window.y = 336
@action_window.opacity = 0
@action_window.z = @z_level + 22
@action_window.height = 144
@action_window.active = false
@action_window.visible = false
@action_window.index = 0
@sprite_action_window = Sprite.new

10 avant/après ligne 57 Main ( 57 dedans ) :

$fontnarrowsize = 47
$fn = 42

# トランジション準備
splash.dispose
Graphics.transition(5)
Graphics.freeze
# シーンオブジェクト (タイトル画面) を作成
$scene = Scene_Title.new
# $scene が有効な限り main メソッドを呼び出す
while $scene != nil
$scene.main
end
# フェードアウト
Graphics.transition(20)
rescue Exception => exception
EXC::error_handler(exception)
rescue Errno::ENOENT
# 例外 Errno::ENOENT を補足
# ファイルがオープンできなかった場合、メッセージを表示して終了する
filename = $!.message.sub("Ne trouve pas le fichier ou le répertoire - ", "")
print("Le ficher #{filename} n'a pas été trouvé.")
end

Voilà... :gloups:

Posté par Newtiteuf le 28 Juil - 17:34 (2009)
essaye ca juste pour voir :

Ligne 44 : self.contents.font.size = 28

Posté par BlueRayquaza le 30 Juil - 12:08 (2009)
Windows_Command : Erreur ligne 55 : self.contents.draw_text(rect, @commands[index])

Posté par Newtiteuf le 30 Juil - 12:15 (2009)
remet ca:

Ligne 44 : self.contents.font.size = size

et ne touche plus a rien, et réinstalle les scripts ok ?

Posté par BlueRayquaza le 30 Juil - 12:25 (2009)
Ok...
EDIT : Tiens ? Mais ça marche :D !
C'est bizarre, pourtant j'ai fait exactement pareil que la première fois... Ou alors Slash a édité son script...
Enfin, le tout c'est que ça marche ! Merci beaucoup :^^:

Posté par Newtiteuf le 30 Juil - 14:26 (2009)
et ben tout vas bien alors !

Je suis heureux d'avoir pu t'aider Bouche extensiblek:

Posté par Slash le 31 Juil - 16:37 (2009)
j'ai réditer le script blue rayquaza car y'avé des merdouilles avec la fonction code du fofo

Posté par Dark Palkia le 2 Aoû - 23:41 (2009)
moi j'ai un bug a la ligne 165 de pokemon battle trainer

Posté par Bilkev le 3 Aoû - 12:06 (2009)
Moi sa bug à ces lignes:
$battle_var.result_flee_enemy = false

Posté par Neptis le 13 Aoû - 21:06 (2009)
Un autre super script mais y'a un danger de bug, je vais attendre.

Super Travail !

Posté par Slash le 6 Sep - 10:24 (2009)
bon je vien de voir ce ki n'allais pas donc je vous propose ceci en modification

pour les utilisateur de PSP0.7, remplacedr le script pokemon_battle_core1 par celui ci

Script


 
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.contents.font.color = Color.new(255,255,255)
      @action_window.x = 320
      @action_window.y = 336
      @action_window.opacity = 0
      @action_window.z = @z_level + 22
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
      @sprite_action_window = Sprite.new
      @sprite_action_window.bitmap = RPG::Cache.picture("battle_dummy.PNG")
      @sprite_action_window.x = 320
      @sprite_action_window.y = 336
      @sprite_action_window.z = @z_level + 21
      @sprite_action_window.visible = false
      
      # 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
      @sprite_action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @sprite_skill_window.dispose
        @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
        @sprite_skill_window = Sprite.new
        @sprite_skill_window.bitmap = RPG::Cache.picture("attack_dummy.PNG")
        @sprite_skill_window.x = 0
        @sprite_skill_window.y = 336
        @sprite_skill_window.z = @z_level + 21
        @sprite_skill_window.visible = false
        @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.opacity = 0
        @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.opacity = 0
        @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 + "?")
          @sprite_action_window.visible = true
          @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
            @sprite_action_window.visible = 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
            
            @sprite_skill_window.visible = true
            @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)
              @sprite_action_window.visible = true
              @action_window.visible = true
              draw_text("Que doit faire", @actor.given_name + "?")
              return
            end
            @sprite_action_window.visible = true
            @action_window.visible = true
            
            @action_window.active = false
            @sprite_action_window.visible = 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
            @sprite_skill_window.visible = false
            @skills_window.active = false
            @skills_window.visible= false
            @skill_descr.visible = false
            @sprite_action_window.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)
          @sprite_skill_window.visible = false
          @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
        @sprite_action_window.visible = false
        @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
      @sprite_action_window.visible = false
      @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,  Color.new(255, 255, 255, 255))
        draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2,  Color.new(255, 255, 255, 255))
        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,  Color.new(255, 255, 255, 255))
        draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2,  Color.new(255, 255, 255, 255))
        string = @pokemon.hp < 0 ? 0 : @pokemon.hp
        draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2,  Color.new(255, 255, 255, 255))
        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, 9)
      #rect2 = Rect.new(x + 45, y + 9, level*144.to_i, 6)
      rect2 = Rect.new(x + 45, y + 6, level*144.to_i, 9)
      if small
        rect1 = Rect.new(x + 45, y + 6, level*129.to_i, 9)
        #rect2 = Rect.new(x + 45, y + 9, level*129.to_i, 6)
        rect2 = Rect.new(x + 45, y + 6, level*129.to_i, 9)
      end
      
      if level < 0.1
        color1 = Color.new(200 ,92, 84, 255)
        color2 = Color.new(200 ,92, 84, 255)
      elsif level >= 0.1 and level < 0.5
        color1 = Color.new(204, 156, 104, 255)
        color2 = Color.new(204, 156, 104, 255)
      else
        color1 = Color.new(100, 160, 104, 255)
        color2 = Color.new(100, 160, 104, 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(96, 160, 200, 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



pour les utilisateur de PSP4G+ , remplacer le script pokemon_battle_core1 par celui ci

Script


 
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
      unless $game_variables[5000]["compteurs"] == [] or
          $game_variables[5000]["compteurs"][0].tourne
        bool = $game_variables[5000]["compteurs"][1]
        $game_variables[5000]["compteurs"][0].arreter
        $game_variables[5000]["compteurs"][1] = bool
      end
      # 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.opacity = 0
      @action_window.z = @z_level + 21
      @action_window.height = 144
      @action_window.active = false
      @action_window.visible = false
      @action_window.index = 0
      @sprite_action_window = Sprite.new
      @sprite_action_window.bitmap = RPG::Cache.picture("battle_dummy.PNG")
      @sprite_action_window.x = 320
      @sprite_action_window.y = 336
      @sprite_action_window.z = @z_level + 21
      @sprite_action_window.visible = false
      
      # 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_sprite.tone = @actor.ton
      @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
      @enemy_sprite.tone = @actor.ton
      @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
      @sprite_action_window.dispose
      @enemy_ground.dispose
      @actor_ground.dispose
      if @skill_window != nil
        @skills_window.dispose
        @sprite_skill_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.opacity = 0
        @skills_window.x = 0
        @skills_window.y = 336
        @skills_window.z = @z_level + 30
        @skills_window.height = 144
        @skills_window.visible = false
        @skills_window.active = false
        @sprite_skill_window = Sprite.new
        @sprite_skill_window.bitmap = RPG::Cache.picture("attack_dummy.PNG")
        @sprite_skill_window.x = 0
        @sprite_skill_window.y = 336
        @sprite_skill_window.z = @z_level + 21
        @sprite_skill_window.visible = 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.z = @z_level + 30
        @skill_descr.opacity = 0
        @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
          @sprite_action_window.visible = 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
            @sprite_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
            @sprite_skill_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
            @sprite_action_window.visible = false
            if not(flee_able(@actor, @enemy))
              $game_system.se_play($data_system.buzzer_se)
              @action_window.visible = true
              @sprite_action_window.visible = true
              draw_text("Que doit faire", @actor.given_name + "?")
              return
            end
            @action_window.visible = true
            @sprite_action_window.visible = true
            @action_window.active = false
            @action_window.visible = false
            @sprite_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
            @sprite_skill_window.visible = false
            @skill_descr.visible = false
            @action_window.active = false
            @action_window.visible= false
            @sprite_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
          @sprite_skill_window.visible = false
          @skill_descr.visible = false
          @action_window.active = true
          @sprite_action_window.visible = true
          @phase = 0
        end
        
        
      when 2 # Phase d'action automatisée
        @action_window.visible = false
        @action_window.active = false
        @sprite_action_window.visible = 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
      @sprite_action_window.visible = 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.z = @z_level + 15
        @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 voler_enemy
      draw_text("Vous avez volé " + @enemy.name,"de " + Trainer_Info.string(@trainer_id) + " !")
      wait(40)
      index = $battle_var.enemy_party.actors.index(@enemy)
      @enemy_status.dispose
      @enemy.given_name = @enemy.name
      @enemy.loyalty = @enemy.loyalty > 140 ? 0 : 140 - @enemy.loyalty
      if $pokemon_party.size < 6
        $pokemon_party.actors.push(@enemy)
        $battle_var.battle_order.push($battle_var.battle_order.size)
      else
        int = Interpreter.new
        int.ajouter_stocker_pokemon_cree(@enemy)
      end
      $battle_var.enemy_party.remove(@enemy)
      if index < $battle_var.enemy_party.size
        for i in 0...$battle_var.enemy_party.actors.size
          if $battle_var.enemy_party.actors[i].hp > 0
            enemy_temp = $battle_var.enemy_party.actors[i]
            break
          end
        end
        @enemy_switch_id = i
      end
      @enemy_caught = true
      $pokemon_party.aug_lvl(1)
      enemy_pokemon_switch
      draw_text("Venge moi, " + enemy_temp.name + " !","A l'attaque !")
      wait(40)
    end
    
    def enemy_pokemon_switch
      if @enemy_switch_id != -1
        if not(@enemy_status.disposed?)
          if not(@enemy.dead?)
            @enemy_status.visible = true
          else
            @enemy_status.visible = false
          end
        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.z = @z_level + 15
        @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 $pokemon_capturer == true
        int = Interpreter.new
        draw_text(@enemy.given_name, "à été volé !")
        @enemy.given_name = @enemy.name
        if $pokemon_party.size < 6
          $pokemon_party.actors.push(@enemy)
          $battle_var.battle_order.push($battle_var.battle_order.size)
        else
          int.ajouter_stocker_pokemon_cree(@enemy)
        end
      else
        if FileTest.exist?(@enemy.cry)
          Audio.se_play(@enemy.cry)
        end
        draw_text(@enemy.given_name, "est K.O.!")
        wait(50)
        Audio.se_play("Audio/SE/Down.wav")
      end
        
      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
      @enemy.hp = 0
      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)      
      $alea = false
      # 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)
      $pokemon_party.incr_nb_matchs
      for actor in $pokemon_party.actors
        if $battle_var.have_fought.include?(actor.party_index)
          actor.fight[0] += 1
          if actor.dead? and not(actor.vaudou)
            actor.vaudou = actor.medaille == nil ? false : $data_medaille[actor.medaille][4]
            if actor.vaudou
              draw_text(actor.name + " subit la","malédiction !")
              wait(40)
              wait_hit
            end
          end
        end
      end
      $battle_var.result_flee = expulsion ? false : true
      $battle_var.result_flee_enemy = expulsion
      $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)
      $pokemon_party.incr_nb_matchs
      for actor in $pokemon_party.actors
        if $battle_var.have_fought.include?(actor.party_index)
          actor.fight[0] += 1
          if actor.dead? and not(actor.vaudou)
            actor.vaudou = $data_medaille[actor.medaille][4]
            if actor.vaudou
              draw_text(actor.name + " subit la","malédiction !")
              wait(40)
              wait_hit
            end
          end
        end
      end
      $battle_var.result_flee_enemy = expulsion ? false : true
      $battle_var.result_flee = expulsion
      $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
      $pokemon_party.incr_nb_matchs
      for actor in $pokemon_party.actors
        if $battle_var.have_fought.include?(actor.party_index)
          actor.fight[0] += 1
          if actor.dead? and not(actor.vaudou)
            actor.vaudou = actor.medaille > 0 ? $data_medaille[actor.medaille][4] : false
            if actor.vaudou
              draw_text(actor.name + " subit la","malédiction !")
              wait(40)
              wait_hit
            end
          end
        end
      end
      if not($sauvage)
        @enemy_sprite.opacity = 255
        @enemy_sprite.zoom_x = 1
        @enemy_sprite.zoom_y = 1
        @enemy_sprite.visible = true
        @start_enemy_battler = $alea ? "trainer" + $no_alea : Trainer_Info.battler(@trainer_id)
        @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
        @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
        @enemy_sprite.x = 723
        @enemy_sprite.y = (@enemy_sprite.bitmap.height * 2 / 3) - 10
        @enemy_sprite.bitmap = RPG::Cache.battler(@start_enemy_battler, 0)
        loop do
          @enemy_sprite.x -= 10
          Graphics.update
          if @enemy_sprite.x <= 464
            break
          end
        end
        
        list_string = Trainer_Info.string_defeat(@trainer_id)
        draw_text(list_string)
        wait(40)
        wait_hit
      end
      $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 = $game_variables[5000]["menu_dp"] ? RPG::Cache.battleback("sp1_" + $game_map.battleback_name + ".png") : 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 = $game_variables[5000]["menu_dp"] ? RPG::Cache.battleback("sp2_" + $game_map.battleback_name + ".png") : 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_flee_enemy
    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_flee_enemy = 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_flee_enemy 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



et voila tout devrai rentré dans l'ordre
bon je nmet aussi a jour le premier post pour ceux qui voudrai suivre la procedure de puis le debut

Posté par Bilkev le 6 Sep - 13:00 (2009)
Tu as enfin tenu compte de mon MP ^^.

Posté par Slash le 6 Sep - 19:31 (2009)
oui bilkev il m'en a fallu du temps mais j'ai decider de refaire le meme travail avec 4G+ pour evité tout bug

Posté par PiVa le 7 Sep - 20:46 (2009)
Du très bon travail !

Miniyas, tu pourrais mettre un screen du mixte des systèmes à Pal' ET Slash ? J'ai envie de voir le rendu, merchi d'avance ^^.

Posté par Mini' le 7 Sep - 21:27 (2009)
Pichou a écrit:
Du très bon travail ! Miniyas, tu pourrais mettre un screen du mixte des systèmes à Pal' ET Slash ? J'ai envie de voir le rendu, merchi d'avance ^^.




Moi ? Ooo

Posté par pascal_bouchard le 23 Oct - 05:21 (2009)
moi aussi j'ai un bogue j'ai mit les image battleback dans le dossier battle back et pictures dans le dossier pictures et j'ai mit le tag terrain a 1 car j'ai garder les rencontres de la démo de shinx et la transition du combat commence et après sa affiche une erreur comme celle ci:




---------- Erreur de script : Loading ----------
----- Type
Errno::ENOENT

----- Message
No such file or directory - Graphics/Battlebacks/.png

----- Position dans Loading
Ligne 1

----- Backtrace
Script : Loading | Ligne : 1 | Méthode : in `initialize'
Script : Loading | Ligne : 1 | Méthode : in `new'
Script : Loading | Ligne : 1 | Méthode : in `load_bitmap'
Script : Loading | Ligne : 1 | Méthode : in `battleback'
Script : Pokemon_Battle_Wild | Ligne : 140 | Méthode : in `pre_battle_transition'
Script : Pokemon_Battle_Core 1 | Ligne : 158 | Méthode : in `main'
Script : Main | Ligne : 49



je suis tanner que sa bogue J'ai transmit les image plusieurs fois et recopier le scripts et sa fait toujours sa.

Posté par Warp' le 23 Oct - 11:30 (2009)
Tu n'as pis un fond de bataille à ton tileset...

Posté par bibiantonio le 22 Nov - 11:38 (2009)
Bravo Slash =)

Posté par Ace Attorney Man le 22 Nov - 11:59 (2009)
Je n'avais pas vu ce script, et effectivement c'est beau, bravo Slash =)

Posté par bibiantonio le 22 Nov - 19:49 (2009)
il y a un gros problème, je sais pas si c'est ce script ou celui du Pokédex en COAA mais ça fait un message d'erreur quand je capture un Pokémon et ça me dit ça :

---------- Erreur de script : Pokemon_Battle_Wild ----------
----- Type
ArgumentError
----- Message
wrong number of arguments(5 for 3)
----- Position dans Pokemon_Battle_Wild
Ligne 643
----- Backtrace
Script : Pokemon_Battle_Wild | Ligne : 643 | Méthode : in `initialize'
Script : Pokemon_Battle_Wild | Ligne : 643 | Méthode : in `new'
Script : Pokemon_Battle_Wild | Ligne : 643 | Méthode : in `qu_catch_pokemon'
Script : Fonctions quêtes | Ligne : 47 | Méthode : in `catch_pokemon'
Script : Pokemon_Battle_Wild | Ligne : 369 | Méthode : in `actor_item_use'
Script : Pokemon_Battle_Core 1 | Ligne : 541 | Méthode : in `phase2'
Script : Pokemon_Battle_Core 1 | Ligne : 444 | Méthode : in `update'
Script : Pokemon_Battle_Core 1 | Ligne : 167 | Méthode : in `main'
Script : Pokemon_Battle_Core 1 | Ligne : 164 | Méthode : in `loop'
Script : Pokemon_Battle_Core 1 | Ligne : 171 | Méthode : in `main'
Script : Main | Ligne : 49


Si quelqu'un pouvait m'aider ça serait génial.

Posté par Ace Attorney Man le 22 Nov - 21:36 (2009)
>>Je pense que c'est un mélange du combat platine et du POKéDEX, demande à Sphinx.

Posté par Sphinx le 22 Nov - 21:41 (2009)
^^" me demander pour 2 systèmes que je ne connais que de noms...


^^" La seule chose que je puisse faire (mis à part passer des journées entières à tester le cumul des 2 pour voir où ca coince & pour voir comment se gèrent les appels, journées entières qui sont déjà grandement prises par tout le reste ^^") c'est réunir : bibiantonio (parce que c'est lui qui a ce bug), slash (créateur du script combat à la platine) & le créateur du dex utilisé par bibi & essayer de voir à 4 pk ca coince.

Mais déjà, voici une piste : la ligne qui bugge est bête un appel de fonction, appel qui comprend 5 arguments alors que la définition de la fonction n'en prévoit que 3. Bibi, qu'as tu, ligne 643 du Battle_Wild ?

Posté par Ace Attorney Man le 22 Nov - 21:43 (2009)
Le dex est aussi fait par Slash.

Posté par Sphinx le 22 Nov - 22:02 (2009)
:p bon ben à 3 lol

Posté par bibiantonio le 23 Nov - 13:42 (2009)
A la ligne 643 j'ai ça :           scene = POKEMON_S::Pokemon_Detail.new(@enemy.id, false, 0, "combat", 9999)

Posté par Sphinx le 23 Nov - 13:46 (2009)
Alors faut chercher dans ton script Pokemon_Pokedex ceci :

Code:
class Pokemon_Details
  def initialize(...)


et voir si la définition comprend bien 5 arguments

Posté par bibiantonio le 23 Nov - 16:06 (2009)
J'ai résolu le problème !
J'ai téléchargé psp v0.7 et j'ai pris les script battle_core et battle_trainer et je les ai mis à la place de ceux de 4G+ ^^ ça marche maintenant =)

Posté par Ace Attorney Man le 23 Nov - 16:51 (2009)
Ca buguera pas au niveau des quêtes ?

Posté par bibiantonio le 24 Nov - 18:02 (2009)
je m'en sert pas des quetes =)

Posté par Slash le 24 Nov - 19:14 (2009)
Bonne question Ace a vrai dire je n'est pas essayer cette option mais a priori non vu que je me sert de la base du systerme de combat de PSP et PSP4G+

Posté par Ace Attorney Man le 24 Nov - 19:22 (2009)
Ok, j'ai rien dit ^_^.
Bonne journée.

Posté par pascal_bouchard le 10 Déc - 03:06 (2009)
Moi aussi j'ai le même problème que bibi pour la capture de Pokémon. J'ai fait un post et j'en suis dsl, d'avoir poster sans avoir vérifié comme il le faut si quelqu'un avait eu ce problème. Je recommencerai plus et en passant sphinx voici ce que j'ai dans le script pokédex dans la ligne que tas écrit.


class Pokemon_Detail
def initialize(id, show, mode = 0)




J'aimerais savoir le moyen de régler ce problème sans faire comme bibi, qui a mis les scripts de psp0.7, car ce problème est gênant. Merci à vous de m'aider et je précise que mon log est semblable a bibi sauf qu'il y a pas la ligne de quête, car j'ai supprimé ce script.
Bonne fin de journée


Posté par FinalArt le 14 Jan - 10:29 (2010)
Salut, j'ai un bug, mais pas sur Core_1, mais sur Pokémon_Battle_Trainer, ligne 218 :

      @enemy_ground.bitmap = RPG::Cache.battleback(@ground_name)

Le rapport Log. :

---------- Erreur de script : Loading ----------
----- Type
Errno::ENOENT

----- Message
No such file or directory - Graphics/Battlebacks/groundherbe_campagne mill.png

----- Position dans Loading
Ligne 1

----- Backtrace
Script : Loading | Ligne : 1 | Méthode : in `initialize'
Script : Loading | Ligne : 1 | Méthode : in `new'
Script : Loading | Ligne : 1 | Méthode : in `load_bitmap'
Script : Loading | Ligne : 1 | Méthode : in `battleback'
Script : Pokemon_Battle_Trainer | Ligne : 218 | Méthode : in `pre_battle_transition'
Script : Pokemon_Battle_Core 1 | Ligne : 158 | Méthode : in `main'
Script : Main | Ligne : 50


Et le message d'erreur :


Posté par Solfay1 le 14 Jan - 13:00 (2010)
No such file or directory - Graphics/Battlebacks/groundherbe_campagne mill.png


... dans le dossier battlebacks il manque l'image groundherbe_campagne mill.png

Posté par FinalArt le 14 Jan - 13:21 (2010)
#25/6/c/e/sans-titre-999-178b092.…

... Je crois pas

Posté par Sphinx le 14 Jan - 13:38 (2010)
Solfay a écrit:
... dans le dossier battlebacks il manque l'image groundherbe_campagne mill.png


Tu as besoin du battleback mais aussi du ground associé. Cf le manuel.

Posté par FinalArt le 14 Jan - 13:43 (2010)
Merci Sphinx, je look,

Posté par dialga_prime le 15 Jan - 18:30 (2010)
moi j'ai pris le pokedex CO/AA slash et quand je capture un pokemon et qui doivent montré ses
donnée sa bug au script Pokemon_Battle_Wild ligne 643

Posté par Pαlвσlѕку le 15 Jan - 18:39 (2010)
Tu peux nous passer le log SVP ?

Posté par deleted_30062014_2002 le 21 Avr - 17:20 (2010)
Il n'yen a pas 1 pour pspds

Posté par Warp' le 21 Avr - 20:12 (2010)
Je traduit :
Est-ce que ce script est disponible sur PSP DS?

La réponse : Palb' en avait fait un(si je me rappele bien, il y avait des screens de ça sur Pokémon Echoes).
Il faudrait lui demander.

Posté par deleted_30062014_2002 le 21 Avr - 20:18 (2010)
c'est ou?

Posté par Warp' le 22 Avr - 00:18 (2010)
Tu envois un MP à Palbolsky et tu lui demandes...

Posté par ourari le 9 Mai - 12:09 (2010)
excusez moi mais a quoi servent les codes

Posté par deleted_30062014_2002 le 9 Mai - 12:14 (2010)
euh connais tu les bases de RMXP?

Posté par ourari le 10 Mai - 14:17 (2010)
bon on faite j'ai rien dit  :gloups: :gloups: :gloups: :gloups: :gloups: :gloups:

Posté par Chompy le 12 Jan - 12:35 (2011)
Le lien est mort pour mon plus grand malheur... Si quelqu'un pouvait remettre un lien à jour, je le remercierais chaleureusement !

Posté par Malwolf le 2 Fév - 13:37 (2014)
[Nécropost]

Si quelqu'un pourrait retrouver les images liés à ce script, ce serait très intéressant.
Le lien, du pack et mort depuis une bonne décennie l'espoir et vide..

Cordialement, Malwolf.

Posté par Schneitizel le 2 Fév - 13:41 (2014)
Malwolf a écrit:
[Nécropost]

Si quelqu'un pourrait retrouver les images liés à ce script, ce serait très intéressant.
Le lien, du pack et mort depuis une bonne décennie l'espoir et vide..

Cordialement, Malwolf.


Tout ce que j'ai pu trouver : http://www.spriters-resource.com/ds/pkmnplatinum/sheet/20099/

Posté par Malwolf le 2 Fév - 13:51 (2014)
Bonjour,

Je pense que pour les adapters à PSP4G+ sa va prendre un petit time.
Mais merci tout de même.

Cordialement, Malwolf.

Posté par Girakoth le 2 Fév - 21:40 (2014)
Tu dois pouvoir être capable de récupérer certaines ressources à l'aide des aperçus disponibles à la fin du premier post.

Posté par Kr0mos le 20 Oct - 00:08 (2014)
Lien mort, quelqu'un ayant le pack pourrait re-poster un lien svp?

Posté par Girakoth le 20 Oct - 06:21 (2014)
Faudrait qu'un jour, je m'amuse à choper tous les packs de ressources histoire de pouvoir les ré-uploader au besoin en fait.

Posté par Solfay le 20 Oct - 10:43 (2014)
Je me demande si quelqu'un a encore ce pack d'ailleurs °°.

Posté par Pαlвσlѕку le 20 Oct - 10:47 (2014)
Je l'ai peut-être encore mais je ne pourrais vérifier que ce soir.
Par contre ça sera la version de mon script mais c'est sensiblement la même chose.

Posté par Kr0mos le 22 Oct - 21:07 (2014)
D'acc c'est sympa quand même palbosky merci ^^ Mais perso je pense que quand j'aurais le temps je créerai un script photoshop pour automatiser l'ajout d'ombre sur chaque overworld. En attendant si quelqu'un là ça serait vraiment sympa de sa part de le partager ^^

Posté par Pαlвσlѕку le 22 Oct - 21:44 (2014)
Je ne retrouve pas la clé usb où j'aurais pu sauvegarder les images et le script.
Si je la retrouve j'essaierais d'y penser.

C'est une habitude très fréquente chez moi de perdre mes clés usb, mais je les retrouve tôt ou tard. Sauf que je ne sais jamais quand. xD