Advertisement
Guest User

Pokemon_Battle_Core 1

a guest
Jan 8th, 2016
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 91.98 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Pokemon_Battle_Core
  3. # Pokemon Script Project - Krosk
  4. # 20/07/07
  5. #-----------------------------------------------------------------------------
  6. # Corrigé par RhenaudTheLukark
  7. #-----------------------------------------------------------------------------
  8. # Scène à ne pas modifier de préférence
  9. #-----------------------------------------------------------------------------
  10. # Système de Combat - Squelette général
  11. #-----------------------------------------------------------------------------
  12.  
  13. #-----------------------------------------------------------------------------
  14. # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé, 8: Toxic
  15. # @confuse (6), @flinch (7)
  16. #-----------------------------------------------------------------------------
  17. # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
  18. # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
  19. #-----------------------------------------------------------------------------
  20.  
  21. #-----------------------------------------------------------------------------
  22. # $battle_var.action_id
  23. #   0 : Phase de Sélection
  24. #   1 : Sélection Item
  25. #   2 : Switch Pokémon
  26. #   4 : Switch Fin de Tour
  27. #-----------------------------------------------------------------------------
  28.  
  29. module POKEMON_S
  30.   #------------------------------------------------------------  
  31.   # Pokemon_Battle_Core
  32.   #   noyau possédant les fonctions communes aux combats sauvages/dresseurs
  33.   #------------------------------------------------------------  
  34.   #------------------------------------------------------------  
  35.   # Fonctions à définir à l'extérieur
  36.   #   initialize
  37.   #   pre_battle_animation
  38.   #   enemy_skill_decision
  39.   #   end_battle_check
  40.   #   actor_item_use
  41.   #   catch_pokemon
  42.   #   run_able?
  43.   #   end_battle_victory
  44.   #------------------------------------------------------------  
  45.   class Pokemon_Battle_Core
  46.     attr_accessor :z_level
  47.     attr_accessor :actor_status
  48.     attr_accessor :actor
  49.     attr_accessor :actor_sprite
  50.    
  51.     #------------------------------------------------------------  
  52.     # ------------------- Squelette Général ---------------------
  53.     #------------------------------------------------------------
  54.    
  55.     #------------------------------------------------------------  
  56.     # main
  57.     #------------------------------------------------------------
  58.     def main
  59.       # Pré-création des Sprites
  60.       # Fond
  61.       if @battleback_name != ""
  62.         @battleback_name = $game_map.battleback_name + ".png"
  63.         @ground_name = "ground" + $game_map.battleback_name + ".png"
  64.       else
  65.         print("Attention, réglez le BattleBack du Tileset.")
  66.         @battleback_name = "battle0.png"
  67.         @ground_name = "groundbattle0.png"
  68.       end
  69.       @background = Sprite.new
  70.       @background.z = @z_level
  71.      
  72.       # Fond du message
  73.       @message_background = Sprite.new
  74.       @message_background.y = 336
  75.       @message_background.z = @z_level + 19
  76.      
  77.       # Sprite de flash
  78.       @flash_sprite = Sprite.new
  79.       @flash_sprite.bitmap = RPG::Cache.picture("black.png")
  80.       @flash_sprite.color = Color.new(255,255,255)
  81.       @flash_sprite.opacity = 0
  82.       @flash_sprite.z = @z_level + 13
  83.      
  84.       # Fenetre de texte
  85.       @text_window = Window_Base.new(4, 340, 632, 136)
  86.       @text_window.opacity = 0
  87.       @text_window.z = @z_level + 20
  88.       @text_window.contents = Bitmap.new(600 + 32, 104 + 32)
  89.       @text_window.contents.font.name = $fontface
  90.       @text_window.contents.font.size = $fontsizebig
  91.      
  92.       # Fenetre d'action
  93.       s1 = "ATTAQUE"
  94.       s2 = "SAC"
  95.       s3 = "POKéMON"
  96.       s4 = "FUITE"
  97.      
  98.       @action_window = Window_Command.new(320, [s1, s2, s3, s4], $fontsizebig, 2, 56)
  99.       @action_window.x = 320
  100.       @action_window.y = 336
  101.       @action_window.z = @z_level + 21
  102.       @action_window.height = 144
  103.       @action_window.active = false
  104.       @action_window.visible = false
  105.       @action_window.index = 0
  106.      
  107.       # Viewport
  108.       battle_viewport = Viewport.new(0, 0, 640, 336)
  109.       battle_viewport.z = @z_level + 15
  110.      
  111.       # Sprites acteurs # Positions par défaut des centres
  112.       @enemy_sprite = RPG::Sprite.new(battle_viewport)
  113.       @enemy_sprite.x = 464
  114.       @enemy_sprite.y = 134
  115.       @enemy_sprite.z = @z_level + 15
  116.       @enemy_ground = RPG::Sprite.new
  117.       @enemy_ground.x = 464
  118.       @enemy_ground.y = 174
  119.       @enemy_ground.z = @z_level + 11
  120.       @actor_sprite = RPG::Sprite.new(battle_viewport)
  121.       @actor_sprite.x = 153
  122.       @actor_sprite.y = 336
  123.       @actor_sprite.z = @z_level + 15
  124.       @actor_ground = RPG::Sprite.new
  125.       @actor_ground.x = 153
  126.       @actor_ground.y = 386
  127.       @actor_ground.z = @z_level + 11
  128.      
  129.       # Création fenêtre de statut
  130.       @actor_status = Pokemon_Battle_Status.new(@actor, false, @z_level + 15)
  131.       @enemy_status = Pokemon_Battle_Status.new(@enemy, true, @z_level + 15)
  132.       @actor_status.visible = false
  133.       @enemy_status.visible = false
  134.       @enemy_caught = false
  135.      
  136.       @actor_party_status = Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10)
  137.       @enemy_party_status = Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10)
  138.       @actor_party_status.visible = false
  139.       @enemy_party_status.visible = false
  140.       # note: .active = true activera les animations liées à ces fenêtres
  141.       @actor_party_status.active = false
  142.       @enemy_party_status.active = false
  143.      
  144.       # Lancement des animations
  145.       pre_battle_transition
  146.       pre_battle_animation
  147.      
  148.       # Effets pré-premier round
  149.       post_round_effect
  150.      
  151.       Graphics.transition
  152.       loop do
  153.         Graphics.update
  154.         Input.update
  155.         update
  156.         if $scene != self
  157.           break
  158.         end
  159.       end
  160.      
  161.       # Fin de scene
  162.       Graphics.freeze
  163.       @background.dispose
  164.       @message_background.dispose
  165.       @flash_sprite.dispose
  166.       @text_window.dispose
  167.       @action_window.dispose
  168.       @enemy_ground.dispose
  169.       @actor_ground.dispose
  170.       if @skill_window != nil
  171.         @skills_window.dispose
  172.       end
  173.       if @ball_sprite != nil
  174.         @ball_sprite.dispose
  175.       end
  176.       @enemy_sprite.dispose
  177.       @actor_sprite.dispose
  178.       @actor_status.dispose
  179.       @enemy_status.dispose
  180.       @actor_party_status.dispose
  181.       @enemy_party_status.dispose
  182.     end
  183.    
  184.     #------------------------------------------------------------  
  185.     # Déroulement
  186.     #------------------------------------------------------------
  187.     def update
  188.       # Animation test : séquence de test d'une animation
  189.       if false
  190.         if $temp == nil
  191.           $temp = false
  192.           @actor_sprite.register_position
  193.           @enemy_sprite.register_position
  194.         end
  195.         animation = $data_animations[15] # tappez le numéro de l'anim à tester
  196.         if not @enemy_sprite.effect? and not @actor_sprite.effect?
  197.           if $temp
  198.             @enemy_sprite.reset_position
  199.             @actor_sprite.register_position
  200.             @actor_sprite.animation(animation, true, true)
  201.             $temp = !$temp
  202.           else
  203.             @actor_sprite.reset_position
  204.             @enemy_sprite.register_position
  205.             @enemy_sprite.animation(animation, true)
  206.             $temp = !$temp
  207.           end
  208.         end
  209.         @actor_sprite.update
  210.         @enemy_sprite.update
  211.         return
  212.       end
  213.      
  214.       case @phase
  215.       when 0 # Phase d'initialisation
  216.         @phase = 1
  217.        
  218.         # Création fenêtre de skill
  219.         list = []
  220.         for skill in @actor.skills_set
  221.           #if skill.id > 500
  222.           #  list.push("\C[2]" + skill.name + "\C[0]")
  223.           #end
  224.           list.push(skill.name)
  225.         end
  226.         while list.size < 4
  227.           list.push("  ---")
  228.         end
  229.         @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56)
  230.         @skills_window.x = 0
  231.         @skills_window.y = 336
  232.         @skills_window.height = 144
  233.         @skills_window.visible = false
  234.         @skills_window.active = false
  235.        
  236.         # Compétences bloquées
  237.         for i in 0..@actor.skills_set.length-1
  238.           skill = @actor.skills_set[i]
  239.           if not(skill.usable?)
  240.             @skills_window.disable_item(i)
  241.           end
  242.         end
  243.        
  244.         # Curseur sur le dernier choix
  245.         if $battle_var.last_index == nil
  246.           $battle_var.last_index = 0
  247.           @skills_window.index = 0
  248.         else
  249.           @skills_window.index = $battle_var.last_index
  250.         end
  251.        
  252.         # Création fenêtre description de skill
  253.         @skill_descr = Window_Base.new(512, 336, 128, 144)
  254.         @skill_descr.contents = Bitmap.new(96, 144)
  255.         @skill_descr.contents.font.name = $fontface
  256.         @skill_descr.contents.font.size = $fontsizebig
  257.         @skill_descr.visible = false
  258.         skill_descr_refresh
  259.        
  260.         # Activation fenêtre
  261.         @actor_status.visible = true
  262.         @enemy_status.visible = true
  263.                
  264.         # ------- ---------- --------- --------
  265.         #    Saut de phase de sélection actor
  266.         # ------- ---------- --------- --------
  267.         jumped = phase_jump
  268.        
  269.         # Activations fenêtres
  270.         if not(jumped)
  271.           draw_text("Que doit faire ", @actor.given_name + "?")
  272.           @action_window.visible = true
  273.           @action_window.active= true
  274.           $battle_var.action_id = 0
  275.         end
  276.        
  277.       when 1 # Phase d'attente d'action
  278.        
  279.         @action_window.update
  280.         @skills_window.update
  281.         if @skills_window.active and input
  282.           skill_descr_refresh
  283.         end
  284.        
  285.         if Input.trigger?(Input::C) and @action_window.active
  286.           case @action_window.index
  287.           when 0 # Selection ATTAQUE
  288.             $game_system.se_play($data_system.decision_se)
  289.             @action_window.active = false
  290.             @action_window.visible = false
  291.            
  292.             # ------- ---------- --------- --------
  293.             #   Reset compteur de fuite
  294.             # ------- ---------- --------- --------
  295.             $battle_var.run_count = 0
  296.            
  297.             # ------- ---------- --------- --------
  298.             #    Saut de phase de sélection attaque
  299.             # ------- ---------- --------- --------
  300.             if attack_selection_jump
  301.               @actor_action = 1
  302.               @phase = 2
  303.               return
  304.             end
  305.            
  306.             # ------- ---------- --------- --------
  307.             #      Vérification PP // Lutte
  308.             # ------- ---------- --------- --------
  309.             total = 0
  310.             for skill in @actor.skills_set
  311.               if skill.usable?
  312.                 total += skill.pp
  313.               end
  314.             end
  315.             if total == 0
  316.               @actor_action = 1
  317.               @phase = 2
  318.               @actor_skill = Skill.new(165) # Lutte
  319.               return
  320.             end
  321.            
  322.             @skills_window.active = true
  323.             @skills_window.visible = true
  324.             @skill_descr.visible = true
  325.             @text_window.contents.clear
  326.           when 1 # Selection ITEM
  327.             if @actor.effect_list.include?(0xE8)
  328.               $game_system.se_play($data_system.buzzer_se)
  329.               @action_window.visible = false  
  330.               draw_text("Embargo empêche l'utilisation","des objets!")
  331.               wait(40)
  332.               draw_text("Que doit faire ", @actor.given_name + "?")
  333.               @action_window.visible = true
  334.             else
  335.               $game_system.se_play($data_system.decision_se)
  336.               scene = Pokemon_Item_Bag.new($pokemon_party.bag_index, @z_level + 100, "battle")
  337.               scene.main
  338.               return_data = scene.return_data
  339.               @phase = 0
  340.               if $battle_var.action_id == 1
  341.                 @phase = 2
  342.                 @actor_action = 3
  343.                 @item_id = return_data
  344.               end
  345.             end
  346.           when 2 # Selection PKMN
  347.             # ------- ---------- --------- --------
  348.             #    Vérification switch permis
  349.             # ------- ---------- --------- --------
  350.             if not(switch_able(@actor, @enemy))
  351.               $game_system.se_play($data_system.buzzer_se)
  352.               return
  353.             end
  354.             $game_system.se_play($data_system.decision_se)
  355.             $battle_var.window_index = @action_window.index
  356.             scene = Pokemon_Party_Menu.new(0, @z_level + 100)
  357.             scene.main
  358.             return_data = scene.return_data
  359.             @phase = 0
  360.             # Enregistrement données Switch de Pokémon
  361.             if $battle_var.action_id == 2
  362.               @phase = 2
  363.               @actor_action = 2
  364.               @switch_id = return_data
  365.             end
  366.           when 3 # sélection FUITE
  367.             # ------- ---------- --------- --------
  368.             #    Vérification fuite permise
  369.             # ------- ---------- --------- --------
  370.             @action_window.visible = false
  371.             if not(flee_able(@actor, @enemy))
  372.               $game_system.se_play($data_system.buzzer_se)
  373.               @action_window.visible = true
  374.               draw_text("Que doit faire", @actor.given_name + "?")
  375.               return
  376.             end
  377.             @action_window.visible = true
  378.            
  379.             @action_window.active = false
  380.             @action_window.visible = false
  381.             @text_window.contents.clear
  382.             run
  383.           end
  384.           return
  385.         end
  386.        
  387.         if Input.trigger?(Input::C) and @skills_window.active
  388.           index = @skills_window.index
  389.           skill = @actor.skills_set[index]
  390.           if skill != nil and skill.usable?
  391.             @actor_action = 1
  392.             @phase = 2
  393.             @skills_window.active = false
  394.             @skills_window.visible = false
  395.             @skill_descr.visible = false
  396.             @action_window.active = false
  397.             @action_window.visible= false
  398.             @actor_skill = @actor.skills_set[index]
  399.             $battle_var.last_index = @skills_window.index
  400.           else
  401.             $game_system.se_play($data_system.buzzer_se)
  402.           end
  403.         end
  404.        
  405.         if Input.trigger?(Input::B) and @skills_window.active
  406.           $game_system.se_play($data_system.decision_se)
  407.           @skills_window.active = false
  408.           @skills_window.visible = false
  409.           @skill_descr.visible = false
  410.           @action_window.active = true
  411.           @phase = 0
  412.         end
  413.        
  414.        
  415.       when 2 # Phase d'action automatisée
  416.         @action_window.visible = false
  417.         @action_window.active = false
  418.        
  419.         enemy_skill_decision
  420.        
  421.         statistic_refresh_modif
  422.         turn_order
  423.         phase2
  424.         phase3
  425.        
  426.         # Phase de switch de fin de tour
  427.         $battle_var.action_id = 4
  428.         end_battle_check
  429.        
  430.         if $battle_var.battle_end?
  431.           return
  432.         end
  433.        
  434.         # Fin de tour / Post_Round effects
  435.         post_round_effect
  436.         @actor_status.refresh
  437.         @enemy_status.refresh
  438.        
  439.         if $battle_var.battle_end?
  440.           return
  441.         end
  442.        
  443.         # Phase de switch post_round
  444.         $battle_var.action_id = 6
  445.         end_battle_check
  446.         @phase = 0
  447.        
  448.         if $battle_var.battle_end?
  449.           return
  450.         end
  451.        
  452.         # Incrémentation nombre de tours
  453.         $battle_var.round += 1
  454.        
  455.       end
  456.       return
  457.     end
  458.    
  459.     #------------------------------------------------------------  
  460.     # Vérifications préliminaires et ordre d'action
  461.     #------------------------------------------------------------
  462.     def statistic_refresh
  463.       @actor.statistic_refresh
  464.       @enemy.statistic_refresh
  465.     end
  466.    
  467.     def statistic_refresh_modif
  468.       @actor.statistic_refresh_modif
  469.       @enemy.statistic_refresh_modif
  470.     end
  471.    
  472.     #Recherche de priorité
  473.     def turn_order
  474.       # Comparaison des priorités
  475.       if @actor_skill == nil or @enemy_skill == nil
  476.         @strike_first = true
  477.         return
  478.       end
  479.      
  480.       if @actor_action != 1 # Attaque
  481.         @strike_first = false
  482.         return
  483.       end  
  484.      
  485.       if @actor_skill.priority > @enemy_skill.priority
  486.         @strike_first = true
  487.       elsif @actor_skill.priority < @enemy_skill.priority
  488.         @strike_first = false
  489.       else
  490.         # En cas d'égalité de priorité
  491.         if @actor.effect_list.include?(0xE1) and not @enemy.effect_list.include?(0xE1)
  492.           if @enemy.spd > @actor.spd*2
  493.             @strike_first = false
  494.           elsif @enemy.spd < @actor.spd*2
  495.             @strike_first = true
  496.           else
  497.             @strike_first = rand(2)>0 ? true : false
  498.           end
  499.         elsif @enemy.effect_list.include?(0xE1) and not @actor.effect_list.include?(0xE1)
  500.           if @enemy.spd*2 > @actor.spd
  501.             @strike_first = false
  502.           elsif @enemy.spd*2 < @actor.spd
  503.             @strike_first = true
  504.           else
  505.             @strike_first = rand(2)>0 ? true : false
  506.           end
  507.         else
  508.           if @enemy.spd > @actor.spd
  509.             @strike_first = false
  510.           elsif @enemy.spd < @actor.spd
  511.             @strike_first = true
  512.           else
  513.             @strike_first = rand(2)>0 ? true : false
  514.           end
  515.         end
  516.         if @actor.effect_list.include?(0x102) # Distorsion
  517.           @strike_first = !@strike_first
  518.         end
  519.       end
  520.     end
  521.    
  522.     #------------------------------------------------------------  
  523.     # Rounds
  524.     #------------------------------------------------------------            
  525.     def phase2 # Pré_Rounds
  526.       @action_window.visible = false
  527.       @action_window.active = false
  528.       @actor_status.visible = true
  529.       @enemy_status.visible = true
  530.       @actor_status.refresh
  531.       @enemy_status.refresh
  532.       draw_text("","")
  533.      
  534.       # Préround 1: Fuite
  535.       if @actor_action == 4
  536.         run
  537.       end
  538.       if @enemy_action == 4
  539.         enemy_run
  540.       end
  541.      
  542.       # Préround 2: Item
  543.       if @actor_action == 3
  544.         actor_item_use
  545.       end
  546.       if @enemy_action == 3
  547.         enemy_item_use
  548.       end
  549.      
  550.       # Préround 3: Switch Pokémon
  551.       if @actor_action == 2
  552.         actor_pokemon_switch
  553.       end
  554.       if @enemy_action == 2
  555.         enemy_pokemon_switch
  556.       end
  557.      
  558.       @actor_status.refresh
  559.       @enemy_status.refresh
  560.     end
  561.        
  562.     # Round: Attaques
  563.     def phase3
  564.       if @strike_first
  565.         if @actor_action == 1 and not(@actor.dead?)
  566.           attack_action(@actor, @actor_skill, @enemy)
  567.         end
  568.       else
  569.         if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
  570.           attack_action(@enemy, @enemy_skill, @actor)
  571.         end
  572.       end
  573.      
  574.       faint_check
  575.      
  576.       if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
  577.         return
  578.       end
  579.      
  580.       if not(@strike_first)
  581.         if @actor_action == 1 and not(@actor.dead?)
  582.           attack_action(@actor, @actor_skill, @enemy)
  583.         end
  584.       else
  585.         if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?)
  586.           attack_action(@enemy, @enemy_skill, @actor)
  587.         end
  588.       end
  589.      
  590.       faint_check
  591.      
  592.       if @actor.dead? or @enemy.dead? or $battle_var.battle_end?
  593.         return
  594.       end
  595.     end
  596.    
  597.     #------------------------------------------------------------  
  598.     # Fonctions auxiliaires
  599.     #------------------------------------------------------------    
  600.     def switch(list, id1, id2)
  601.       if id1 <= id2
  602.         list.insert(id1, list[id2])
  603.         list.delete_at(id2+1)
  604.         list.insert(id2 + 1, list[id1+1])
  605.         list.delete_at(id1+1)
  606.         return list
  607.       else
  608.         switch(list, id2, id1)
  609.       end
  610.     end
  611.    
  612.     # Fonction auxiliaire
  613.     def input
  614.       if Input.trigger?(Input::C) or Input.trigger?(Input::B) or
  615.         Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
  616.         Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
  617.         return true
  618.       end
  619.       return false
  620.     end
  621.    
  622.     def draw_text(line1 = "", line2 = "")
  623.       if line1.type == Array
  624.         if line1[1] != nil
  625.           draw_text(line1[0], line1[1])
  626.         else
  627.           draw_text(line1[0])
  628.         end
  629.       else
  630.         Graphics.freeze
  631.         @text_window.contents.clear
  632.         @text_window.draw_text(12, 0, 460, 50, line1)
  633.         @text_window.draw_text(12, 55, 460, 50, line2)
  634.         Graphics.transition(5)
  635.       end
  636.     end
  637.    
  638.     def draw_text_valid(line1 = "", line2 = "")
  639.       draw_text(line1, line2)
  640.       loop do
  641.         Graphics.update
  642.         Input.update
  643.         if Input.trigger?(Input::C)
  644.           $game_system.se_play($data_system.decision_se)
  645.           break
  646.         end
  647.       end
  648.     end
  649.    
  650.     def wait(frame)
  651.       i = 0
  652.       loop do
  653.         i += 1
  654.         Graphics.update
  655.         if i >= frame
  656.           break
  657.         end
  658.       end
  659.     end
  660.    
  661.     def wait_hit
  662.       loop do
  663.         Graphics.update
  664.         Input.update
  665.         if input
  666.           $game_system.se_play($data_system.decision_se)
  667.           break
  668.         end
  669.       end
  670.     end
  671.    
  672.    
  673.     def update_sprite
  674.       @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
  675.       @actor_sprite.ox = @actor_sprite.bitmap.width / 2
  676.       @actor_sprite.oy = @actor_sprite.bitmap.height
  677.       @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
  678.       @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
  679.       @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
  680.     end
  681.    
  682.    
  683.    
  684.    
  685.     #------------------------------------------------------------  
  686.     # ----------------------- Interface -------------------------
  687.     #------------------------------------------------------------
  688.    
  689.     #------------------------------------------------------------  
  690.     # Fenêtre de description
  691.     #------------------------------------------------------------        
  692.     def skill_descr_refresh
  693.       @skill_descr.contents.clear
  694.       index = @skills_window.index
  695.       skill = @actor.skills_set[index]
  696.       if skill != nil
  697.         string = skill.pp.to_s + "/" + skill.ppmax.to_s
  698.         type = skill.type
  699.       else
  700.         string = "---"
  701.         type = 0
  702.       end
  703.       normal_color = Color.new(60,60,60)
  704.       @skill_descr.contents.font.color = normal_color
  705.       #@skill_descr.contents.draw_text(0,6,60,39, "PP:")
  706.       @skill_descr.contents.draw_text(0,6,96,39, string, 1)
  707.       #@skill_descr.contents.draw_text(0,60,140,39, "TP:")
  708.       draw_type(0, 60, type)
  709.     end  
  710.      
  711.     def draw_type(x, y, type)
  712.       src_rect = Rect.new(0, 0, 96, 42)
  713.       bitmap = RPG::Cache.picture("T" + type.to_s + ".png")
  714.       @skill_descr.contents.blt(x, y, bitmap, src_rect, 255)
  715.     end
  716.    
  717.    
  718.    
  719.    
  720.    
  721.    
  722.    
  723.     #------------------------------------------------------------  
  724.     # ------------------ Fonctions de combat --------------------
  725.     #------------------------------------------------------------
  726.    
  727.     #------------------------------------------------------------    
  728.     # Fonctions spéciales - programmation des attaques
  729.     #------------------------------------------------------------
  730.     def heal(user, user_sprite, user_status, bonus)
  731.       value = bonus.abs
  732.       if user.effect_list.include?(0xEC) # Anti-Soin
  733.         draw_text("ANTI-SOIN empêche","la régénération de PV!")
  734.       else
  735.         for i in 1..value
  736.           if bonus >= 0
  737.             user.add_hp(1)
  738.           else
  739.             user.remove_hp(1)
  740.           end
  741.           if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
  742.             next
  743.           end
  744.           user_status.refresh
  745.           Graphics.update
  746.           Graphics.update
  747.           if user.hp >= user.max_hp or user.dead?
  748.             break
  749.           end
  750.         end
  751.       end
  752.     end
  753.    
  754.     def self_damage(user, user_sprite, user_status, damage)
  755.       if damage > 0
  756.         Audio.se_play("Audio/SE/Hit.wav", 100)
  757.         blink(user_sprite)
  758.       end
  759.       for i in 1..damage
  760.         user.remove_hp(1)
  761.         user_status.refresh
  762.         if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0
  763.           next
  764.         end
  765.         Graphics.update
  766.         Graphics.update
  767.         if user.dead?
  768.           break
  769.         end
  770.       end
  771.     end
  772.    
  773.     #------------------------------------------------------------    
  774.     # Fonctions communes - Programmation des attaques
  775.     #------------------------------------------------------------
  776.     # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé
  777.     # 6: Confus, 7: Flinch, 8: Toxic
  778.     #------------------------------------------------------------
  779.     # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
  780.     # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre
  781.     #------------------------------------------------------------
  782.    
  783.     # Fonction à appeler en cas d'effets sur le statut
  784.     def status_check(target, status, forcing = false)
  785.       # Immunités
  786.       # Poison
  787.       if (target.type_poison? or target.type_steel?) and
  788.           (status == 1 or status == 8)
  789.         draw_text(target.given_name + " est insensible", "au poison!")
  790.         wait(40)
  791.         return
  792.       end
  793.       # Freeze
  794.       if status == 5 and target.type_ice?
  795.         draw_text(target.given_name + " est insensible", "au gel!")
  796.         wait(40)
  797.         return
  798.       end
  799.       # Burn
  800.       if status == 3 and target.type_fire?
  801.         draw_text(target.given_name + " est insensible", "aux brûlures!")
  802.         wait(40)
  803.         return
  804.       end
  805.       # Soleil
  806.       if status == 5 and $battle_var.sunny?
  807.         draw_text("Le soleil empêche " + target.given_name, "de geler!")
  808.         wait(40)
  809.         return
  810.       end
  811.       unless target.effect_list.include?(0xEF) or target.effect_list.include?(0xF7)
  812.         # Lumber / Echauffement (ab)
  813.         if status == 2 and target.ability == 7
  814.           draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.")
  815.           wait(40)
  816.           return
  817.         end
  818.         # Ignifu-voile / Water Veil (ab)
  819.         if status == 3 and target.ability == 41
  820.           draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.")
  821.           wait(40)
  822.           return
  823.         end
  824.         # Insomnia (ab) // Vital Spirit / Esprit Vital (ab) + cas de Soucigraine
  825.         if status == 4 and (target.ability == 15 or target.ability == 72 or target.effect_list.include?(0xF7))
  826.           draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.")
  827.           wait(40)
  828.           return
  829.         end
  830.         # Vaccin / Immunity (ab)
  831.         if [1, 8].include?(status) and target.ability == 17
  832.           draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.")
  833.           wait(40)
  834.           return
  835.         end
  836.         # Armumagma / Magma Armor (ab)
  837.         if target.ability == 40 and status == 5
  838.           draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.")
  839.           wait(40)
  840.           return
  841.         end
  842.         # Tempo Perso / Own Tempo (ab)
  843.         if status == 6 and target.ability == 20
  844.           draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.")
  845.           wait(40)
  846.           return
  847.         end
  848.         # Attention / Inner focus (ab)
  849.         if target.ability == 39 and status == 7
  850.           draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.")
  851.           wait(40)
  852.           return
  853.         end
  854.         # Synchronize (ab)
  855.         if target.ability == 28 and [1, 2, 3, 8].include?(status)
  856.           target.ability_token = status
  857.           if status == 8
  858.             target.ability_token = 1
  859.           end
  860.         end
  861.       end
  862.      
  863.       if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status))
  864.         status_string(target, -target.status) # animation
  865.       elsif status == 6 and target.confused? and not(forcing)
  866.         status_string(target, -6)
  867.       elsif target.effect_list.include?(0x7C) and
  868.         status != 7 # Rune Protect/Safeguard
  869.         draw_text(target.given_name + "est", "protégé des altérations!")
  870.         wait(40)
  871.       elsif target.effect_list.include?(0x9F) and
  872.         status == 4 # Uproar
  873.         draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!")
  874.         wait(40)
  875.       else
  876.         case status
  877.         when 1
  878.           target.status_poison(forcing)
  879.         when 2
  880.           target.status_paralyze(forcing)
  881.         when 3
  882.           target.status_burn(forcing)
  883.         when 4
  884.           target.status_sleep(forcing)
  885.         when 5
  886.           target.status_frozen(forcing)
  887.         when 6
  888.           target.status_confuse
  889.         when 7
  890.           target.status_flinch
  891.         when 8
  892.           target.status_toxic(forcing)
  893.         end
  894.         status_string(target, status)
  895.       end
  896.     end
  897.    
  898.     def accuracy_stage(user, target)
  899.       stage = user.acc_stage - target.eva_stage
  900.       stage = stage < -6 ? -6 : stage > 6 ? 6 : stage
  901.      
  902.       # --------------- ---------------- --------------
  903.       #           Programmation des attaques
  904.       # --------------- ---------------- --------------
  905.       # Clairvoyayance / Foresight
  906.       if target.effect_list.include?(0x71)
  907.         stage = user.acc_stage
  908.       end
  909.       # --------------- ---------------- --------------
  910.       # --------------- ---------------- --------------
  911.      
  912.       case stage
  913.       when -6
  914.         return 33.0/100
  915.       when -5
  916.         return 36.0/100
  917.       when -4
  918.         return 43.0/100
  919.       when -3
  920.         return 50.0/100
  921.       when -2
  922.         return 60.0/100
  923.       when -1
  924.         return 75.0/100
  925.       when 0
  926.         return 1
  927.       when 1
  928.         return 133.0/100
  929.       when 2
  930.         return 166.0/100
  931.       when 3
  932.         return 2
  933.       when 4
  934.         return 250.0/100
  935.       when 5
  936.         return 133.0/50
  937.       when 6
  938.         return 3
  939.       end
  940.     end
  941.    
  942.     #------------------------------------------------------------  
  943.     # Post_round
  944.     #------------------------------------------------------------        
  945.     def post_round_effect
  946.       # --------- -------------- --------------------
  947.       # Fin des effets "at the end of a round"
  948.       # --------- -------------- --------------------      
  949.       # Suppression état apeuré (ne dure que un tour)
  950.       @actor.flinch_check
  951.       @enemy.flinch_check
  952.       # Suppression état autre
  953.       if @actor.dead?
  954.         @actor.cure
  955.         @actor.cure_state
  956.       end
  957.       if @enemy.dead?
  958.         @enemy.cure
  959.         @enemy.cure_state
  960.       end
  961.      
  962.       # --------- -------------- --------------------
  963.       # Programmation des attaques en Post-round
  964.       # --------- -------------- --------------------
  965.       #      Cycle commun 0 - Souhait et Météo
  966.       # --------- -------------- --------------------
  967.       post_round_cycle0
  968.      
  969.       # --------- -------------- --------------------
  970.       #         Cycle individuel 1
  971.       #      Programmation des attaques
  972.       #           Effets du statut
  973.       # --------- -------------- --------------------      
  974.       if @strike_first
  975.         post_round_cycle_1(@actor, @enemy)
  976.         post_round_cycle_1(@enemy, @actor)
  977.       else
  978.         post_round_cycle_1(@enemy, @actor)
  979.         post_round_cycle_1(@actor, @enemy)
  980.       end
  981.      
  982.       # --------- -------------- --------------------
  983.       #                Cycle 2
  984.       #         Programmation des attaques
  985.       #            Dommages finaux
  986.       # --------- -------------- --------------------
  987.       if @strike_first
  988.         post_round_cycle_2(@actor, @enemy)
  989.         post_round_cycle_2(@enemy, @actor)
  990.       else
  991.         post_round_cycle_2(@enemy, @actor)
  992.         post_round_cycle_2(@actor, @enemy)
  993.       end
  994.      
  995.       @actor.skill_effect_clean  
  996.       @enemy.skill_effect_clean
  997.      
  998.       faint_check
  999.      
  1000.       # Round suivant
  1001.       if $battle_var.round == nil
  1002.         $battle_var.round = 0
  1003.       end
  1004.       $battle_var.round += 1
  1005.     end
  1006.    
  1007.    
  1008.     # --------- -------------- --------------------
  1009.     #     Cycle commun 0 - Météo et Souhait
  1010.     # --------- -------------- --------------------
  1011.     def post_round_cycle0
  1012.       if @strike_first
  1013.         list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]]
  1014.       else
  1015.         list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]]
  1016.       end
  1017.      
  1018.       # Suppression du contrôle pour un pokémon mort
  1019.       for array in list
  1020.         if array[0].dead?
  1021.           list.delete(array)
  1022.         end
  1023.       end
  1024.      
  1025.       for array in list
  1026.         actor = array[0]
  1027.         actor.skill_effect_end_turn
  1028.         for effect in actor.effect_list
  1029.          
  1030.           case effect
  1031.           when 0x56 # Entrave / Disable
  1032.             index = actor.effect_list.index(0x56)
  1033.             if actor.effect[index][1] == 0
  1034.               skill_id = actor.effect[index][2]
  1035.               skill = actor.skills_set[skill_id]
  1036.               skill.enable
  1037.               draw_text(skill.name + " de "+ actor.given_name, "est rétablie!")
  1038.               wait(40)
  1039.             end
  1040.           when 0x5A # Encore
  1041.             index = actor.effect_list.index(0x5A)
  1042.             if actor.skills_set[index].pp == 0
  1043.               actor.effect[index][1] = 0 # Fin de l'effet
  1044.             end
  1045.           when 0x75 # Rollout
  1046.             index = actor.effect_list.index(0x75)
  1047.             ## N'a pas fait de dégât ce tour ci >> Supprimé
  1048.             #if actor.effect[index][2] != actor.effect[index][1]
  1049.             #  actor.effect.delete_at(index)
  1050.             #end
  1051.             if actor.asleep? or actor.frozen?
  1052.               actor.effect.delete_at(index)
  1053.             end
  1054.           when 0x77 # Taillade / Fury Cutter
  1055.             index = actor.effect_list.index(0x77)
  1056.             # N'a pas fait de dégât ce tour ci >> Supprimé
  1057.             if actor.effect[index][2] != actor.effect[index][1]
  1058.               actor.effect.delete_at(index)
  1059.             end
  1060.           end
  1061.         end
  1062.       end
  1063.      
  1064.       weather = $battle_var.weather[0]
  1065.       $battle_var.weather[1] -= 1
  1066.       count = $battle_var.weather[1]
  1067.      
  1068.       # Souhait -- Programmation des attaques
  1069.       for array in list
  1070.         target = array[0]
  1071.         target_sprite = array[1]
  1072.         target_status = array[2]
  1073.         if target.effect_list.include?(0xB3)
  1074.           bonus = target.hp / 2
  1075.           draw_text("Un souhait est réalisé.")
  1076.           heal(target, target_sprite, target_status, bonus)
  1077.           wait(40)
  1078.         end
  1079.       end
  1080.      
  1081.       # Pluie
  1082.       if $battle_var.rain? and count != 0
  1083.         draw_text("La pluie continue de", "tomber.")
  1084.         animation = $data_animations[493]
  1085.         @actor_sprite.animation(animation, true)
  1086.         loop do
  1087.           @actor_sprite.update
  1088.           Graphics.update
  1089.           Input.update
  1090.           if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
  1091.             break
  1092.           end
  1093.         end
  1094.         wait(20)
  1095.       elsif $battle_var.rain? and count == 0
  1096.         draw_text("La pluie s'est arrêtée.")
  1097.         wait(40)
  1098.         $battle_var.reset_weather
  1099.       end
  1100.      
  1101.       # Ensoleillé
  1102.       if $battle_var.sunny? and count != 0
  1103.         draw_text("Les rayons du soleil","tapent fort.")
  1104.         animation = $data_animations[492]
  1105.         @actor_sprite.animation(animation, true)
  1106.         loop do
  1107.           @actor_sprite.update
  1108.           Graphics.update
  1109.           Input.update
  1110.           if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
  1111.             break
  1112.           end
  1113.         end
  1114.         wait(20)
  1115.       elsif $battle_var.sunny? and count == 0
  1116.         draw_text("Le soleil est parti.")
  1117.         wait(40)
  1118.         $battle_var.reset_weather
  1119.       end
  1120.      
  1121.       # Tempete de sable
  1122.       if $battle_var.sandstorm? and count != 0
  1123.         draw_text("La tempête de sable souffle.")
  1124.         animation = $data_animations[494]
  1125.         @actor_sprite.animation(animation, true)
  1126.         loop do
  1127.           @actor_sprite.update
  1128.           Graphics.update
  1129.           Input.update
  1130.           if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
  1131.             break
  1132.           end
  1133.         end
  1134.        
  1135.         # Dégats
  1136.         for array in list
  1137.           target = array[0]
  1138.           target_sprite = array[1]
  1139.           target_status = array[2]
  1140.           if target.type_ground? or target.type_rock? or target.type_steel? or
  1141.              target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or
  1142.             (target.ability == 8 and !target.effect_list.include?(0xEF) or
  1143.              !target.effect_list.include?(0xF7))
  1144.             next
  1145.           end
  1146.           damage = target.max_hp / 16
  1147.           heal(target, target_sprite, target_status, -damage)
  1148.         end
  1149.       elsif $battle_var.sandstorm? and count == 0
  1150.         draw_text("La tempête de sable s'est arretée.")
  1151.         wait(40)
  1152.         $battle_var.reset_weather
  1153.       end
  1154.      
  1155.       # Grêle
  1156.       if $battle_var.hail? and count > 0
  1157.         draw_text("Il grêle...")
  1158.         animation = $data_animations[495]
  1159.         @actor_sprite.animation(animation, true)
  1160.         loop do
  1161.           @actor_sprite.update
  1162.           Graphics.update
  1163.           Input.update
  1164.           if not(@actor_sprite.effect?) #and Input.trigger?(Input::C)
  1165.             break
  1166.           end
  1167.         end
  1168.        
  1169.         # Dégâts
  1170.         for array in list
  1171.           target = array[0]
  1172.           target_sprite = array[1]
  1173.           target_status = array[2]
  1174.           if target.type_ice? or
  1175.               target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3)
  1176.             next
  1177.           end
  1178.           damage = target.max_hp / 16
  1179.           heal(target, target_sprite, target_status, -damage)
  1180.         end
  1181.       elsif $battle_var.hail? and count == 0
  1182.         draw_text("La grêle s'est arrêtée.")
  1183.         wait(40)
  1184.         $battle_var.reset_weather
  1185.       end
  1186.      
  1187.     end
  1188.    
  1189.    
  1190.    
  1191.    
  1192.     # --------- -------------- --------------------
  1193.     #              Cycle individuel 1
  1194.     # --------- -------------- --------------------
  1195.     def post_round_cycle_1(actor, enemy)
  1196.       if actor == @actor
  1197.         actor_status = @actor_status
  1198.         actor_sprite = @actor_sprite
  1199.         enemy_status = @enemy_status
  1200.         enemy_sprite = @enemy_sprite
  1201.       elsif actor == @enemy
  1202.         actor_status = @enemy_status
  1203.         actor_sprite = @enemy_sprite
  1204.         enemy_status = @actor_status
  1205.         enemy_sprite = @actor_sprite
  1206.       end
  1207.      
  1208.       # Suppression du contrôle pour un Pokémon mort
  1209.       if actor.dead?
  1210.         return
  1211.       end
  1212.      
  1213.       # --------- -------------- --------------------
  1214.       #    Programmation des attaques et des capa
  1215.       # --------- -------------- --------------------
  1216.       for effect in actor.effect_list
  1217.         case effect
  1218.         when 0xB5 # Ingrain / Racines
  1219.           bonus = actor.max_hp / 16
  1220.           draw_text(actor.given_name + " puise", "de l'énergie dans la terre.")
  1221.           heal(actor, actor_sprite, actor_status, bonus)
  1222.           wait(40)
  1223.         when 0xFB # Anneau Hydro
  1224.           bonus = actor.max_hp / 16
  1225.           draw_text(actor.given_name + " se soigne", "grâce à ANNEAU HYDRO!")
  1226.           heal(actor, actor_sprite, actor_status, bonus)
  1227.           wait(40)
  1228.         end
  1229.       end
  1230.      
  1231.       unless actor.effect_list.include?(0xEF) or actor.effect_list.include?(0xF7)
  1232.         case actor.ability
  1233.         when 44 # Cuvette / Rain Dish (ab)
  1234.           if $battle_var.rain?
  1235.             bonus = actor.max_hp / 16
  1236.             draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.")
  1237.             heal(actor, actor_sprite, actor_status, bonus)
  1238.             wait(40)
  1239.           end
  1240.         when 54 # Absentéisme / Truant (ab)
  1241.           if actor.ability_token == nil
  1242.             actor.ability_token = true
  1243.           end
  1244.           if actor.ability_token == true
  1245.             actor.ability_token = false
  1246.           elsif actor.ability_token == false
  1247.             actor.ability_token = true
  1248.           end
  1249.         when 61 # Mue / Shed skin (ab)
  1250.           if actor.status != 0 and rand(100) < 30
  1251.             actor.cure
  1252.             draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.")
  1253.             wait(40)
  1254.           end
  1255.         end
  1256.       end
  1257.      
  1258.       for effect in enemy.effect_list
  1259.         case effect
  1260.         when 0x54 # Leech Seed / Vampigraine
  1261.           malus = actor.max_hp / 8
  1262.           draw_text("L'énergie de #{actor.given_name}","est drainée!")
  1263.           heal(actor, actor_sprite, actor_status, -malus)
  1264.           heal(enemy, enemy_sprite, enemy_status, malus)
  1265.           wait(40)
  1266.         when 0x2A # Multi_turn attack
  1267.           damage = actor.max_hp / 16
  1268.           draw_text(actor.given_name, "est piégé!")
  1269.           self_damage(actor, actor_sprite, actor_status, damage)
  1270.           wait(40)
  1271.         end
  1272.       end
  1273.      
  1274.       if actor.dead?
  1275.         return
  1276.       end
  1277.      
  1278.       # --------- -------------- --------------------
  1279.       #          Inspection des statuts
  1280.       # --------- -------------- --------------------
  1281.       if actor.status == 1 # Poison
  1282.         damage = actor.poison_effect
  1283.         draw_text(actor.given_name + " souffre", "du poison.")
  1284.         status_animation(actor_sprite, actor.status)
  1285.         heal(actor, actor_sprite, actor_status, -damage)
  1286.         wait(20)
  1287.       end
  1288.       if actor.status == 8 # Toxic
  1289.         damage = actor.toxic_effect
  1290.         draw_text(actor.given_name + " souffre", "gravement du poison.")
  1291.         status_animation(actor_sprite, actor.status)
  1292.         heal(actor, actor_sprite, actor_status, -damage)
  1293.         wait(20)
  1294.       end
  1295.       if actor.status == 3 #Burn
  1296.         damage = actor.burn_effect
  1297.         draw_text(actor.given_name + " souffre", "de ses brûlures.")
  1298.         status_animation(actor_sprite, actor.status)
  1299.         heal(actor, actor_sprite, actor_status, -damage)
  1300.         wait(20)
  1301.       end
  1302.      
  1303.       actor.confuse_decrement
  1304.       if actor.dead?
  1305.         return
  1306.       end
  1307.      
  1308.       # --------- -------------- --------------------
  1309.       #         Programmation des attaques
  1310.       # --------- -------------- --------------------      
  1311.       for effect in actor.effect_list
  1312.         case effect
  1313.         when 0x6B # Nightmare / Cauchemar
  1314.           if actor.asleep?
  1315.             damage = actor.max_hp / 4
  1316.             draw_text(actor.given_name + " fait", "un chauchemar!")
  1317.             heal(actor, actor_sprite, actor_status, -damage)
  1318.             wait(20)
  1319.           else
  1320.             index = actor.effect_list.index(0x6B)
  1321.             actor.effect.delete_at(index)
  1322.           end
  1323.         when 0x6D # Curse
  1324.           damage = actor.max_hp / 4
  1325.           draw_text(actor.given_name + " est", "maudit!")
  1326.           heal(actor, actor_sprite, actor_status, -damage)
  1327.           wait(20)
  1328.         when 0x9F # Uproar / Brouhaha
  1329.           if actor.asleep?
  1330.             actor.cure
  1331.             draw_text(actor.given_name + " se réveille", "à cause du brouhaha!")
  1332.             wait(40)
  1333.           end
  1334.           if actor.frozen? # Fin de l'effet
  1335.             index = actor.effect_list.index(0x9F)
  1336.             actor.effect.delete_at(index)
  1337.           end
  1338.         when 0xAF # Taunt / Provoc
  1339.           index = actor.effect_list.index(0xAF)
  1340.           for skill in actor.skills_set
  1341.             if skill.power == 0 and actor.effect[index][1] > 0
  1342.               draw_text(skill.name + " est bloqué!")
  1343.               skill.disable
  1344.               wait(40)
  1345.             elsif actor.effect[index][1] == 0
  1346.               draw_text(skill.name + " est rétablit.")
  1347.               skill.enable
  1348.               wait(40)
  1349.             end
  1350.           end
  1351.         when 0xBB # Yawn / Baillement
  1352.           if actor.status == 0
  1353.             status_check(actor, 4)
  1354.             actor_status.refresh
  1355.           end
  1356.         end
  1357.       end
  1358.      
  1359.       if actor.dead?
  1360.         return
  1361.       end
  1362.       # --------- -------------- --------------------
  1363.       #                  Berry check
  1364.       # --------- -------------- --------------------  
  1365.       if Item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp
  1366.         draw_text(actor.given_name + " récupère un peu", "de vie avec " + Item.name(actor.item_hold) + ".")
  1367.         bonus = actor.max_hp / 16
  1368.         if bonus == 0
  1369.           bonus = 1
  1370.         end
  1371.         heal(actor, actor_sprite, actor_status, bonus)
  1372.         wait(40)
  1373.       end
  1374.     end
  1375.      
  1376.     # --------- -------------- --------------------
  1377.     #              Cycle individuel 2
  1378.     # --------- -------------- --------------------    
  1379.     def post_round_cycle_2(actor, enemy)
  1380.       # Redéfinition
  1381.       if actor == @actor
  1382.         actor_status = @actor_status
  1383.         actor_sprite = @actor_sprite
  1384.         enemy_status = @enemy_status
  1385.         enemy_sprite = @enemy_sprite
  1386.       elsif actor == @enemy
  1387.         actor_status = @enemy_status
  1388.         actor_sprite = @enemy_sprite
  1389.         enemy_status = @actor_status
  1390.         enemy_sprite = @actor_sprite
  1391.       end
  1392.      
  1393.       # Suppression du contrôle pour un pokémon mort
  1394.       if actor.dead?
  1395.         return
  1396.       end
  1397.      
  1398.       # --------- -------------- --------------------
  1399.       #         Programmation des capacités
  1400.       # --------- -------------- --------------------
  1401.       unless actor.effect_list.include?(0xEF) or actor.effect_list.include?(0xF7)
  1402.         case actor.ability
  1403.         when 2 # Crachin / Drizzle (ab)
  1404.           if not($battle_var.rain?) # Pluie
  1405.             draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.")
  1406.             wait(40)
  1407.             animation = $data_animations[493]
  1408.             @actor_sprite.animation(animation, true)
  1409.             loop do
  1410.               @actor_sprite.update
  1411.               Graphics.update
  1412.               Input.update
  1413.               if not(@actor_sprite.effect?)
  1414.                 break
  1415.               end
  1416.             end
  1417.           end
  1418.           $battle_var.set_rain
  1419.         when 45 # Sable Volant / Sand stream (ab)
  1420.           if not($battle_var.sandstorm?) # Tempete Sable
  1421.             draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.")
  1422.             wait(40)
  1423.             animation = $data_animations[494]
  1424.             @actor_sprite.animation(animation, true)
  1425.             loop do
  1426.               @actor_sprite.update
  1427.               Graphics.update
  1428.               Input.update
  1429.               if not(@actor_sprite.effect?)
  1430.                 break
  1431.               end
  1432.             end
  1433.           end
  1434.           $battle_var.set_sandstorm
  1435.         when 70 # Sècheresse / Drought (ab)
  1436.           if not($battle_var.sunny?) # Soleil
  1437.             draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.")
  1438.             wait(40)
  1439.             animation = $data_animations[492]
  1440.             @actor_sprite.animation(animation, true)
  1441.             loop do
  1442.               @actor_sprite.update
  1443.               Graphics.update
  1444.               Input.update
  1445.               if not(@actor_sprite.effect?)
  1446.                 break
  1447.               end
  1448.             end
  1449.           end
  1450.           $battle_var.set_sandstorm
  1451.         when 3 # Speed Boost (ab)
  1452.           draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.")
  1453.           actor.change_spd(+1)
  1454.           stage_animation(actor_sprite, $data_animations[482])
  1455.           wait(40)
  1456.         when 22 # Intimidate (ab)
  1457.           if not(actor.ability_active)
  1458.             actor.ability_active = true
  1459.             draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".")
  1460.             enemy.change_atk(-1)
  1461.             stage_animation(enemy_sprite, $data_animations[479])
  1462.             wait(40)
  1463.           end
  1464.         when 59 # Forecast / Meteo (ab)
  1465.           if $battle_var.sunny? and not(actor.type_fire?)
  1466.             draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en FEU!")
  1467.             actor.ability_token = 2
  1468.             actor.form = 2
  1469.             update_sprite
  1470.             wait(40)
  1471.           elsif $battle_var.rain? and not(actor.type_water?)
  1472.             draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en EAU!")
  1473.             actor.ability_token = 3
  1474.             actor.form = 3
  1475.             update_sprite
  1476.             wait(40)
  1477.           elsif $battle_var.hail? and not(actor.type_ice?)
  1478.             draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en GLACE!")
  1479.             actor.ability_token = 6
  1480.             actor.form = 6
  1481.             update_sprite
  1482.             wait(40)
  1483.           elsif not(actor.type_normal?)
  1484.             draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en NORMAL!")
  1485.             actor.ability_token = 1
  1486.             actor.form = 0
  1487.             update_sprite
  1488.             wait(40)
  1489.           end
  1490.         end
  1491.       end
  1492.       # --------- -------------- --------------------
  1493.       #         Programmation des attaques
  1494.       # --------- -------------- --------------------
  1495.       for effect in actor.effect_list
  1496.         case effect
  1497.         when 0x72 # Requiem / Perish Song
  1498.           index = actor.effect_list.index(0x72)
  1499.           number = actor.effect[index][1]
  1500.           if number > 0
  1501.             if number > 1
  1502.               string = "#{number.to_s} tours"
  1503.             elsif number == 1
  1504.               string = "#{number.to_s} tour"
  1505.             end
  1506.             draw_text("Plus que #{string}", "pour #{actor.given_name}...")
  1507.             wait(40)
  1508.           else
  1509.             draw_text("#{actor.given_name} est", "K.O. par REQUIEM!")
  1510.             damage = actor.hp
  1511.             heal(actor, actor_sprite, actor_status, -damage)
  1512.             wait(40)
  1513.           end
  1514.         end
  1515.       end
  1516.      
  1517.       # --------- -------------- --------------------
  1518.       #      Nettoyage des compteurs d'effets
  1519.       # --------- -------------- --------------------
  1520.       for effect in actor.effect     #EDIT_MSG_FIN_EFFET
  1521.         if effect[1] == 0
  1522.           case effect[0]
  1523.           when 0x41 # Protection / ???
  1524.             draw_text("L'effet de PROTECTION", "prend fin.")
  1525.             wait(40)
  1526.           when 0x23 # Light Screen
  1527.             draw_text("L'effet de MUR LUMIERE", "prend fin.")
  1528.             wait(40)
  1529.           when 0x2E # Brume / Mist
  1530.             draw_text("La brume se dissipe.")
  1531.             wait(40)
  1532.           when 0x7C # Rune Protect / Safeguard
  1533.             draw_text("L'effet de RUNE PROTECT", "prend fin.")
  1534.             wait(40)
  1535.           when 0xE8 # Embargo
  1536.             draw_text("L'effet d'EMBARGO","prend fin.")
  1537.             wait(40)
  1538.           when 0xEC # Anti-Soin
  1539.             draw_text("L'effet d'ANTI-SOIN","prend fin.")
  1540.             wait(40)
  1541.           when 0xF0 # Air Veinard
  1542.             draw_text("L'effet d'AIR VEINARD","prend fin.")
  1543.             wait(40)
  1544.           end
  1545.         end
  1546.       end
  1547.      
  1548.       if actor.dead?
  1549.         return
  1550.       end
  1551.     end
  1552.    
  1553.    
  1554.     #------------------------------------------------------------  
  1555.     # Items
  1556.     #------------------------------------------------------------    
  1557.     def actor_item_use # items à utiliser
  1558.       # Item déjà utilisé ie remplacé par 0
  1559.       if @item_id == 0
  1560.         return
  1561.       end
  1562.     end
  1563.  
  1564.     #------------------------------------------------------------  
  1565.     # Switch de pokémon
  1566.     #------------------------------------------------------------        
  1567.     def actor_pokemon_switch
  1568.       if @switch_id != -1
  1569.         if not(@actor.dead?)
  1570.           @actor_status.visible = true
  1571.         else
  1572.           @actor_status.visible = false
  1573.         end
  1574.        
  1575.         switch_effect(@actor, @enemy)
  1576.        
  1577.         if not(@actor.dead?)
  1578.           recall_pokemon
  1579.         end
  1580.        
  1581.         @battle_order = switch(@battle_order, 0, @switch_id)
  1582.         @actor = @party.actors[@battle_order[0]]
  1583.         @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0)
  1584.         @actor_status = Pokemon_Battle_Status.new(@actor, false)
  1585.         @actor_status.visible = false
  1586.         if not($battle_var.have_fought.include?(@actor.party_index))
  1587.           $battle_var.have_fought.push(@actor.party_index)
  1588.         end
  1589.        
  1590.         launch_pokemon
  1591.         @actor_status.visible = true
  1592.         @switch_id = -1
  1593.        
  1594.         # Cas de Voeu Soin / Danse Lune
  1595.         if @actor.effect_list.include?(0xE1)
  1596.           heal(@actor, @actor_sprite, @actor_status, @actor.max_hp)
  1597.           draw_text("#{@actor.given_name} a été","soigné par VOEU SOIN!")
  1598.           @actor.effect.delete(0xE1)
  1599.           wait(40)
  1600.         end
  1601.        
  1602.         # Picots et Pics Toxic
  1603.         if @actor.effect_list.include?(0x70)
  1604.           index = @actor.effect_list.index(0x70)
  1605.           picots_actor = @actor.effect[index][2]
  1606.           if picots_actor != 0
  1607.             damage = 0
  1608.             case picots_actor
  1609.             when 1
  1610.               damage = 12.5 / 100
  1611.             when 2
  1612.               damage = 18.75 / 100
  1613.             when 3
  1614.               damage = 25 / 100
  1615.             end
  1616.             damage *= @actor.max_hp
  1617.             self_damage(@actor, @actor_sprite, @actor_status, damage)
  1618.             draw_text("Les picots blessent","#{@actor.given_name}!")
  1619.             wait(40)
  1620.           end
  1621.         end
  1622.         if @actor.effect_list.include?(0xF9)
  1623.           index = @actor.effect_list.index(0xF9)
  1624.           picots_toxic_actor = @actor.effect[index][2]
  1625.           if picots_toxic_actor != 0
  1626.             effect_temp = 0
  1627.             case picots_toxic_actor
  1628.             when 1
  1629.               effect_temp = 1
  1630.             when 2
  1631.               effect_temp = 8
  1632.             end
  1633.             status_check(@actor, effect_temp, true)
  1634.             draw_text("Les picots empoisonnent","#{@actor.given_name}!")
  1635.             wait(40)
  1636.           end
  1637.         end
  1638.       end
  1639.     end
  1640.    
  1641.     def enemy_pokemon_switch
  1642.       if @enemy_switch_id != -1
  1643.         if not(@enemy.dead?)
  1644.           @enemy_status.visible = true
  1645.         else
  1646.           @enemy_status.visible = false
  1647.         end
  1648.        
  1649.         switch_effect(@enemy, @actor)
  1650.        
  1651.         if not(@enemy.dead?)
  1652.           recall_enemy_pokemon
  1653.         end
  1654.        
  1655.         @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id)
  1656.         @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]]
  1657.         $data_pokedex[@enemy.id][0] = true
  1658.         @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
  1659.         @enemy_status = Pokemon_Battle_Status.new(@enemy, true)
  1660.         @enemy_status.visible = false
  1661.        
  1662.         launch_enemy_pokemon
  1663.         @enemy_status.visible = true
  1664.         @enemy_switch_id = -1
  1665.        
  1666.         # Cas de Voeu Soin
  1667.         if @enemy.effect_list.include?(0xE1)
  1668.           heal(@enemy, @enemy_sprite, @enemy_status, @enemy.max_hp)
  1669.           draw_text("#{@enemy.given_name} a été","soigné par VOEU SOIN!")
  1670.           @enemy.effect.delete(0xE1)
  1671.           wait(40)
  1672.         end
  1673.        
  1674.         # Picots et Pics Toxic
  1675.         if @enemy.effect_list.include?(0x70)
  1676.           index = @enemy.effect_list.index(0x70)
  1677.           picots_enemy = @enemy.effect[index][2]
  1678.           if picots_enemy != 0
  1679.             damage = 0
  1680.             case picots_enemy
  1681.             when 1
  1682.               damage = 12.5 / 100
  1683.             when 2
  1684.               damage = 18.75 / 100
  1685.             when 3
  1686.               damage = 25 / 100
  1687.             end
  1688.             damage *= @enemy.max_hp
  1689.             self_damage(@enemy, @enemy_sprite, @enemy_status, damage)
  1690.             draw_text("Les picots blessent","#{@enemy.given_name}!")
  1691.             wait(40)
  1692.           end
  1693.         end
  1694.         if @enemy.effect_list.include?(0xF9)
  1695.           index = @enemy.effect_list.index(0xF9)
  1696.           picots_toxic_enemy = @enemy.effect[index][2]
  1697.           if picots_toxic_enemy != 0
  1698.             effect_temp = 0
  1699.             case picots_toxic_enemy
  1700.             when 1
  1701.               effect_temp = 1
  1702.             when 2
  1703.               effect_temp = 8
  1704.             end
  1705.             status_check(@enemy, effect_temp, true)
  1706.             draw_text("Les picots empoisonnent","#{@enemy.given_name}!")
  1707.             wait(40)
  1708.           end
  1709.         end
  1710.        
  1711.         # Piège de Roc
  1712.         if @enemy.effect_list.include?(0x104)
  1713.           efficiency = element_rate(@enemy.type1, @enemy.type1, 9, 0, @enemy.effect_list)
  1714.           damage *= @enemy.max_hp/8 * efficiency
  1715.           self_damage(@enemy, @enemy_sprite, @enemy_status, damage)
  1716.           draw_text("Des rochers transpercent","#{@enemy.given_name}!")
  1717.           wait(40)
  1718.          
  1719.         end
  1720.       end
  1721.     end
  1722.    
  1723.     #------------------------------------------------------------  
  1724.     # Fuite
  1725.     #------------------------------------------------------------          
  1726.     def run
  1727.       if run_able?(@actor, @enemy)
  1728.         $battle_var.run_count += 1
  1729.         @action_window.active = false
  1730.         @action_window.visible = false
  1731.         end_battle_flee
  1732.       else
  1733.         $battle_var.run_count += 1
  1734.         fail_flee
  1735.         @phase = 2
  1736.         @actor_action = 0
  1737.         $battle_var.action_id = 0
  1738.       end
  1739.     end
  1740.    
  1741.     def run_able?(runner, opponent)
  1742.       x = (Integer(opponent.spd/4) % 255)
  1743.       rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count))
  1744.       if not(flee_able(runner, opponent))
  1745.         return false
  1746.       end
  1747.       if opponent.spd <= runner.spd
  1748.         return true
  1749.       elsif x == 0
  1750.         return true
  1751.       elsif rate > 255
  1752.         return true
  1753.       elsif rand(256) <= rate
  1754.         return true
  1755.       else
  1756.         return false
  1757.       end
  1758.     end
  1759.    
  1760.     def run_enemy
  1761.       if run_able?(@enemy, @actor)
  1762.         end_battle_flee_enemy
  1763.       end
  1764.     end
  1765.    
  1766.     #------------------------------------------------------------  
  1767.     # Animations supplémentaires au combat
  1768.     #------------------------------------------------------------  
  1769.     # Défaites / KO
  1770.     #------------------------------------------------------------      
  1771.     def enemy_down
  1772.       # Si déjà vaincu
  1773.       if @enemy_sprite.zoom_y == 0
  1774.         return
  1775.       end
  1776.       # Sinon
  1777.       @enemy_sprite.oy = @enemy_sprite.bitmap.height
  1778.       @enemy_sprite.y += @enemy_sprite.bitmap.height / 2
  1779.       if FileTest.exist?(@enemy.cry)
  1780.         Audio.se_play(@enemy.cry, 100, 85)
  1781.       end
  1782.      
  1783.       wait(50)
  1784.       Audio.se_play("Audio/SE/Down.wav")
  1785.      
  1786.       loop do
  1787.         @enemy_status.x -= 20
  1788.         #@enemy_sprite.zoom_y -= 0.05
  1789.         @enemy_sprite.y += 8
  1790.         @enemy_sprite.opacity -= 20
  1791.         Graphics.update
  1792.         #if @enemy_sprite.zoom_y <= 0.0
  1793.         if @enemy_sprite.y >= 348
  1794.           @enemy_sprite.zoom_y = 0
  1795.           break
  1796.         end
  1797.       end
  1798.       @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
  1799.       @enemy_sprite.y -= @enemy_sprite.bitmap.height
  1800.       draw_text(@enemy.given_name, "est K.O.!")
  1801.       wait(40)
  1802.     end
  1803.    
  1804.     def actor_down
  1805.       # Si déjà vaincu
  1806.       #if @actor_sprite.zoom_y <= 0.0
  1807.       if @actor_sprite.y >= 576
  1808.         return
  1809.       end
  1810.       # Sinon
  1811.       if FileTest.exist?(@actor.cry)
  1812.         Audio.se_play(@actor.cry, 100, 85)
  1813.       end
  1814.       wait(50)
  1815.       Audio.se_play("Audio/SE/Down.wav")
  1816.       loop do
  1817.         @actor_status.x += 20
  1818.         #@actor_sprite.zoom_y -= 0.05
  1819.         @actor_sprite.y += 12
  1820.         @actor_sprite.opacity -= 20
  1821.         Graphics.update
  1822.         #if @actor_sprite.zoom_y <= 0.0
  1823.         if @actor_sprite.y >= 576
  1824.           break
  1825.         end
  1826.       end
  1827.      
  1828.       draw_text(@actor.given_name, "est K.O.!")
  1829.       wait(40)
  1830.     end
  1831.    
  1832.     #------------------------------------------------------------      
  1833.     # Attaques
  1834.     #------------------------------------------------------------
  1835.     def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite)
  1836.       if miss
  1837.         wait(40)
  1838.         draw_text("Mais cela échoue!")
  1839.         wait(40)
  1840.         return
  1841.       end
  1842.      
  1843.       if user == @enemy
  1844.         reverse = true
  1845.       else
  1846.         reverse = false
  1847.       end
  1848.      
  1849.       efficiency = info[2]
  1850.       if hit and efficiency != -2
  1851.         # Animation utilisateur
  1852.         animation_user = $data_animations[user_skill.user_anim_id]
  1853.         user_sprite.register_position
  1854.        
  1855.         if animation_user != nil
  1856.           user_sprite.animation(animation_user, true, reverse)
  1857.           until not(user_sprite.effect?)
  1858.             user_sprite.update
  1859.             Graphics.update
  1860.           end
  1861.         end
  1862.        
  1863.         user_sprite.reset_position
  1864.        
  1865.         user_sprite.update
  1866.         Graphics.update
  1867.        
  1868.         # Animation Cible
  1869.         animation_target = $data_animations[user_skill.target_anim_id]
  1870.         target_sprite.register_position
  1871.        
  1872.         if animation_target != nil
  1873.           target_sprite.animation(animation_target, true, reverse)
  1874.           until not(target_sprite.effect?)
  1875.             target_sprite.update
  1876.             Graphics.update
  1877.           end
  1878.         end
  1879.        
  1880.         target_sprite.reset_position
  1881.        
  1882.         target_sprite.update
  1883.         Graphics.update
  1884.        
  1885.         if info[0] > 0
  1886.           case efficiency
  1887.           when 0 # Normal
  1888.             Audio.se_play("Audio/SE/Hit.wav", 100)
  1889.             blink(target_sprite, 3, 3)
  1890.           when 1 # Super efficace
  1891.             Audio.se_play("Audio/SE/Hitplus.wav", 100)
  1892.             blink(target_sprite, 2, 5)
  1893.           when -1 # Peu efficace
  1894.             Audio.se_play("Audio/SE/Hitlow.wav", 100)
  1895.             blink(target_sprite, 4, 2)
  1896.           end
  1897.         end
  1898.       elsif not(hit)
  1899.         wait(40)
  1900.         draw_text(user.given_name, "rate son attaque!")
  1901.         wait(40)
  1902.       end
  1903.     end
  1904.    
  1905.     def blink(sprite, frame = 4, number = 3)
  1906.       for i in 0..number
  1907.         wait(frame)
  1908.         sprite.opacity = 0
  1909.         Graphics.update
  1910.         wait(frame)
  1911.         sprite.opacity = 255
  1912.         Graphics.update
  1913.       end
  1914.     end
  1915.    
  1916.     def post_attack(info, damage, power)
  1917.       efficiency = info[2]
  1918.       if damage == 0 and (efficiency != -2 or power == 0)
  1919.         return
  1920.       end
  1921.       critical = info[1]
  1922.       if critical  and efficiency != -2 #critical_hit
  1923.         draw_text("Coup critique!")
  1924.         wait(40)
  1925.       end
  1926.       case efficiency
  1927.       when 1
  1928.         draw_text("C'est super efficace!")
  1929.         wait(40)
  1930.       when -1
  1931.         draw_text("Ce n'est pas très efficace...")
  1932.         wait(40)
  1933.       when -2
  1934.         draw_text("Ca ne l'affecte pas...")
  1935.         wait(40)
  1936.       end
  1937.     end
  1938.    
  1939.     def faint_check(user = nil)
  1940.       if user == nil
  1941.         faint_check(@actor)
  1942.         faint_check(@enemy)
  1943.       end
  1944.       if user == @actor and user.dead?
  1945.         actor_down
  1946.       end
  1947.       if user == @enemy and user.dead?
  1948.         enemy_down
  1949.       end
  1950.     end
  1951.        
  1952.    
  1953.     #------------------------------------------------------------      
  1954.     # Statut et stats
  1955.     #------------------------------------------------------------    
  1956.     def status_animation(sprite, status)
  1957.       animation = $data_animations[469 + status]
  1958.       sprite.animation(animation, true)
  1959.       loop do
  1960.         sprite.update
  1961.         Graphics.update
  1962.         Input.update
  1963.         if not(sprite.effect?)
  1964.           break
  1965.         end
  1966.       end
  1967.     end
  1968.    
  1969.     def stage_animation(sprite, animation)
  1970.       sprite.animation(animation, true)
  1971.       loop do
  1972.         sprite.update
  1973.         Graphics.update
  1974.         Input.update
  1975.         if not(sprite.effect?)
  1976.           wait(20)
  1977.           break
  1978.         end
  1979.       end
  1980.     end
  1981.  
  1982.     # 1 Normal  2 Feu  3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol
  1983.     # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres
  1984.     def type_string(type)
  1985.       case type
  1986.       when 0
  1987.         return "???"
  1988.       when 1
  1989.         return "NORMAL"
  1990.       when 2
  1991.         return "FEU"
  1992.       when 3
  1993.         return "EAU"
  1994.       when 4
  1995.         return "ELECTRIK"
  1996.       when 5
  1997.         return "PLANTE"
  1998.       when 6
  1999.         return "GLACE"
  2000.       when 7
  2001.         return "COMBAT"
  2002.       when 8
  2003.         return "POISON"
  2004.       when 9
  2005.         return "SOL"
  2006.       when 10
  2007.         return "VOL"
  2008.       when 11
  2009.         return "PSY"
  2010.       when 12
  2011.         return "INSECTE"
  2012.       when 13
  2013.         return "ROCHE"
  2014.       when 14
  2015.         return "SPECTRE"
  2016.       when 15
  2017.         return "DRAGON"
  2018.       when 16
  2019.         return "ACIER"
  2020.       when 17
  2021.         return "TENEBRES"
  2022.       end
  2023.     end
  2024.    
  2025.    
  2026.     # Changement (ou pas) de statut
  2027.     def status_string(actor, status)
  2028.       string = actor.given_name
  2029.       case status
  2030.       when -1
  2031.         draw_text(string + " est", "déjà empoisonné!")
  2032.         wait(40)
  2033.       when -2
  2034.         draw_text(string + " est", "déjà paralysé!")
  2035.         wait(40)
  2036.       when -3
  2037.         draw_text(string, "brûle déjà!")
  2038.         wait(40)
  2039.       when -4
  2040.         draw_text(string, "dort déjà!")
  2041.         wait(40)
  2042.       when -5
  2043.         draw_text(string, "est déjà gelé!")
  2044.         wait(40)
  2045.       when -6
  2046.         draw_text(string, "est déjà confus!")
  2047.         wait(40)
  2048.       when -8
  2049.         draw_text(string + " est", "déjà gravement empoisonné!")
  2050.         wait(40)
  2051.       when 1
  2052.         draw_text(string, "est empoisonné!")
  2053.         wait(40)
  2054.       when 2
  2055.         draw_text(string, "est paralysé!")
  2056.         wait(40)
  2057.       when 3
  2058.         draw_text(string, "brûle!")
  2059.         wait(40)
  2060.       when 4
  2061.         draw_text(string, "s'endort!")
  2062.         wait(40)
  2063.       when 5
  2064.         draw_text(string, "gèle!")
  2065.         wait(40)
  2066.       when 6
  2067.         draw_text("Cela rend " + string, "confus!")
  2068.         wait(40)
  2069.       when 7
  2070.         draw_text(string, "est apeuré!")
  2071.         wait(40)
  2072.       when 8
  2073.         draw_text(string + " est", "gravement empoisonné!")
  2074.         wait(40)
  2075.       end
  2076.     end
  2077.    
  2078.     # S'occupe du texte et de l'animation
  2079.     def raise_stat(string, actor, n = 0)
  2080.       if actor == @actor
  2081.         actor_sprite = @actor_sprite
  2082.       elsif actor == @enemy
  2083.         actor_sprite = @enemy_sprite
  2084.       end
  2085.      
  2086.       if n == 1
  2087.         text = actor.given_name + " augmente!"
  2088.       elsif n > 1
  2089.         text = actor.given_name + " augmente beaucoup!"
  2090.       end
  2091.      
  2092.       if n != 0
  2093.         case string
  2094.         when "ATK"
  2095.           draw_text("Ah, Attaque de",text)
  2096.           stage_animation(actor_sprite, $data_animations[478])
  2097.         when "DFE"
  2098.           draw_text("Ah, Défense de",text)
  2099.           stage_animation(actor_sprite, $data_animations[480])
  2100.         when "ATS"
  2101.           draw_text("Ah, Attaque Spéciale de",text)
  2102.           stage_animation(actor_sprite, $data_animations[484])
  2103.         when "DFS"
  2104.           draw_text("Ah, Défense Spéciale de",text)
  2105.           stage_animation(actor_sprite, $data_animations[486])
  2106.         when "SPD"
  2107.           draw_text("Ah, Vitesse de",text)
  2108.           stage_animation(actor_sprite, $data_animations[482])
  2109.         when "EVA"
  2110.           draw_text("Ah, Esquive de",text)        
  2111.           stage_animation(actor_sprite, $data_animations[488])
  2112.         when "ACC"
  2113.           draw_text("Ah, Précision de",text)
  2114.           stage_animation(actor_sprite, $data_animations[490])
  2115.         end
  2116.       elsif n == 0
  2117.         case string
  2118.         when "ATK"
  2119.           draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!")
  2120.           wait(40)
  2121.         when "DFE"
  2122.           draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!")
  2123.           wait(40)
  2124.         when "ATS"
  2125.           draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!")
  2126.           wait(40)
  2127.         when "DFS"
  2128.           draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!")
  2129.           wait(40)
  2130.         when "SPD"
  2131.           draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!")
  2132.           wait(40)
  2133.         when "EVA"
  2134.           draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!")        
  2135.           wait(40)
  2136.         when "ACC"
  2137.           draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!")
  2138.           wait(40)
  2139.         when 0
  2140.           draw_text("Les effets positifs sont supprimés!")
  2141.           wait(40)
  2142.         end
  2143.       end
  2144.     end
  2145.    
  2146.     def reduce_stat(string, actor, n = true, self_inflicted = false)
  2147.       # Mist/Brume
  2148.       if actor.effect_list.include?(0x2E)
  2149.         draw_text(actor.given_name + " est", "protégé par la brume!")
  2150.         wait(40)
  2151.         return
  2152.       end
  2153.      
  2154.       unless actor.effect_list.include?(0xEF) or actor.effect_list.include?(0xF7)
  2155.         # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab)
  2156.         if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted)
  2157.           draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!")
  2158.           wait(40)
  2159.           return
  2160.         end
  2161.         # Keen Eye / Regard Vif (ab)
  2162.         if actor.ability == 51 and string == "ACC"
  2163.           draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!")
  2164.           wait(40)
  2165.           return
  2166.         end
  2167.         # Hyper Cutter (ab)
  2168.         if actor.ability == 52 and string == "ATK"
  2169.           draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!")
  2170.           wait(40)
  2171.           return
  2172.         end
  2173.       end
  2174.      
  2175.       if actor == @actor
  2176.         actor_sprite = @actor_sprite
  2177.       elsif actor == @enemy
  2178.         actor_sprite = @enemy_sprite
  2179.       end
  2180.      
  2181.       if n == -1
  2182.         text = actor.given_name + " baisse!"
  2183.       elsif n < -1
  2184.         text = actor.given_name + " baisse beaucoup!"
  2185.       end
  2186.      
  2187.       if n != 0
  2188.         case string
  2189.         when "ATK"
  2190.           draw_text("Ah, Attaque de",text)
  2191.           stage_animation(actor_sprite, $data_animations[479])
  2192.         when "DFE"
  2193.           draw_text("Ah, Défense de",text)
  2194.           stage_animation(actor_sprite, $data_animations[481])
  2195.         when "ATS"
  2196.           draw_text("Ah, Attaque Spéciale de",text)
  2197.           stage_animation(actor_sprite, $data_animations[485])
  2198.         when "DFS"
  2199.           draw_text("Ah, Défense Spéciale de",text)
  2200.           stage_animation(actor_sprite, $data_animations[487])
  2201.         when "SPD"
  2202.           draw_text("Ah, Vitesse de",text)
  2203.           stage_animation(actor_sprite, $data_animations[483])
  2204.         when "EVA"
  2205.           draw_text("Ah, Esquive de",text)        
  2206.           stage_animation(actor_sprite, $data_animations[489])
  2207.         when "ACC"
  2208.           draw_text("Ah, Précision de",text)
  2209.           stage_animation(actor_sprite, $data_animations[491])
  2210.         end
  2211.       elsif n == 0
  2212.         case string
  2213.         when "ATK"
  2214.           draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!")
  2215.           wait(40)
  2216.         when "DFE"
  2217.           draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!")
  2218.           wait(40)
  2219.         when "ATS"
  2220.           draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!")
  2221.           wait(40)
  2222.         when "DFS"
  2223.           draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!")
  2224.           wait(40)
  2225.         when "SPD"
  2226.           draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!")
  2227.           wait(40)
  2228.         when "EVA"
  2229.           draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!")        
  2230.           wait(40)
  2231.         when "ACC"
  2232.           draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!")
  2233.           wait(40)
  2234.         when 0
  2235.           draw_text("Les effets positifs sont supprimés!")
  2236.           wait(40)
  2237.         end
  2238.       end
  2239.     end
  2240.    
  2241.     #------------------------------------------------------------      
  2242.     # Appel / Rappel de Pokémon
  2243.     #------------------------------------------------------------          
  2244.     def recall_pokemon
  2245.       draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!")
  2246.      
  2247.       @actor_sprite.ox = @actor_sprite.bitmap.width / 2
  2248.       @actor_sprite.oy = @actor_sprite.bitmap.height
  2249.       @actor_sprite.y = 336
  2250.       @actor_sprite.x = 153
  2251.       @actor_sprite.color = @actor.ball_color
  2252.       @actor_sprite.color.alpha = 0
  2253.      
  2254.       until @actor_sprite.color.alpha >= 255
  2255.         @flash_sprite.opacity += 25
  2256.         @actor_sprite.color.alpha += 25
  2257.         Graphics.update
  2258.       end
  2259.      
  2260.       Audio.se_play("Audio/SE/Pokeopen.wav")
  2261.       loop do
  2262.         @actor_status.x += 20
  2263.         @actor_sprite.opacity -= 25
  2264.         @actor_sprite.color.alpha += 25
  2265.         @actor_sprite.zoom_x -= 0.1
  2266.         @actor_sprite.zoom_y -= 0.1
  2267.         @flash_sprite.opacity -= 25
  2268.         Graphics.update
  2269.         if @actor_status.x >= 711
  2270.           @actor_status.visible = false
  2271.           @actor_status.x = 711
  2272.           @actor_sprite.color.alpha = 0
  2273.           @actor_sprite.opacity = 0
  2274.           Graphics.update
  2275.           break
  2276.         end
  2277.       end
  2278.     end
  2279.    
  2280.     def launch_pokemon
  2281.       @actor_sprite.x = 153
  2282.       @actor_sprite.y = 336
  2283.       @actor_sprite.ox = @actor_sprite.bitmap.width / 2
  2284.       @actor_sprite.oy = @actor_sprite.bitmap.height
  2285.       @actor_sprite.zoom_x = 0
  2286.       @actor_sprite.zoom_y = 0
  2287.      
  2288.       #if @actor_party_status.active
  2289.       #  @actor_party_status.x = 0
  2290.       #  @actor_party_status.visible = true
  2291.       #end
  2292.      
  2293.       name = @actor.given_name
  2294.       text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)]
  2295.       draw_text(text)
  2296.      
  2297.       @ball_sprite = Sprite.new
  2298.       @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite)
  2299.       @ball_sprite.ox = @ball_sprite.bitmap.width / 2
  2300.       @ball_sprite.oy = @ball_sprite.bitmap.height / 2
  2301.       @ball_sprite.x = -44
  2302.       @ball_sprite.y = 324
  2303.       @ball_sprite.z = @z_level + 14
  2304.      
  2305.       t = 0
  2306.       pi = 3.14
  2307.      
  2308.       loop do
  2309.         t += 1
  2310.         @ball_sprite.x += 5
  2311.         @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi)
  2312.         @ball_sprite.angle = - t*63
  2313.         #if @actor_party_status.active
  2314.         #  @actor_party_status.x -= 80
  2315.         #end
  2316.         Graphics.update
  2317.         if t == 40
  2318.           @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite)
  2319.           Audio.se_play("Audio/SE/Pokeopen.wav")
  2320.           #if @actor_party_status.active
  2321.           #  @actor_party_status.x = 0
  2322.           #  @actor_party_status.visible = false
  2323.           #end
  2324.           break
  2325.         end
  2326.       end
  2327.      
  2328.       if FileTest.exist?(@actor.cry)
  2329.         Audio.se_play(@actor.cry)
  2330.       end
  2331.      
  2332.       @actor_sprite.opacity = 0
  2333.       @actor_sprite.color = @actor.ball_color
  2334.       until @actor_sprite.zoom_x >= 0.9
  2335.         @flash_sprite.opacity += 25
  2336.         @ball_sprite.opacity -= 25
  2337.         @actor_sprite.zoom_x += 0.1
  2338.         @actor_sprite.zoom_y += 0.1
  2339.         @actor_sprite.opacity += 25
  2340.         Graphics.update
  2341.       end
  2342.      
  2343.       @actor_sprite.zoom_x = 1
  2344.       @actor_sprite.zoom_y = 1
  2345.       @actor_sprite.opacity = 255
  2346.      
  2347.       @actor_status.x = 711
  2348.       @actor_status.visible = true
  2349.      
  2350.       if @actor.shiny
  2351.         animation = $data_animations[496]
  2352.         @actor_sprite.animation(animation, true)
  2353.       end
  2354.      
  2355.       until @actor_status.x == 311
  2356.         @background.update
  2357.         @actor_ground.update
  2358.         @enemy_ground.update
  2359.         @actor_status.x -= 20
  2360.         @actor_sprite.color.alpha -= 25
  2361.         @flash_sprite.opacity -= 25
  2362.         @actor_sprite.update
  2363.         Graphics.update
  2364.       end
  2365.      
  2366.       until not(@actor_sprite.effect?)
  2367.         @actor_sprite.update
  2368.         Graphics.update
  2369.       end
  2370.      
  2371.       @actor_status.x = 311
  2372.       @actor_sprite.color.alpha = 0
  2373.       @flash_sprite.opacity = 0
  2374.       @ball_sprite.dispose
  2375.       Graphics.update
  2376.     end
  2377.    
  2378.     def launch_enemy_pokemon
  2379.       @enemy_sprite.x = 464
  2380.       @enemy_sprite.y = 104
  2381.       @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2
  2382.       @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2
  2383.       @enemy_sprite.zoom_x = 0
  2384.       @enemy_sprite.zoom_y = 0
  2385.      
  2386.       string = Trainer_Info.type(@trainer_id) + " " + Trainer_Info.name(@trainer_id)
  2387.       draw_text(@enemy.name + " est envoyé", "par " + string + "!")
  2388.      
  2389.       @ball_sprite = Sprite.new
  2390.       @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite)
  2391.       @ball_sprite.ox = @ball_sprite.bitmap.width / 2
  2392.       @ball_sprite.oy = @ball_sprite.bitmap.height / 2
  2393.       @ball_sprite.x = 663
  2394.       @ball_sprite.y = 104
  2395.       @ball_sprite.z = @z_level + 14
  2396.      
  2397.       t = 0
  2398.       pi = 3.14
  2399.      
  2400.       loop do
  2401.         t += 1
  2402.         @ball_sprite.x -= 5
  2403.         @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi)
  2404.         @ball_sprite.angle = - t*63
  2405.         Graphics.update
  2406.         if t == 40
  2407.           @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite)
  2408.           Audio.se_play("Audio/SE/Pokeopen.wav")
  2409.           break
  2410.         end
  2411.       end
  2412.       @enemy_sprite.opacity = 0
  2413.       @enemy_sprite.color = @enemy.ball_color
  2414.      
  2415.       if @enemy.id < 494 then @enemy_sprite.y = 134 end
  2416.      
  2417.       until @enemy_sprite.zoom_x >= 0.9
  2418.         @flash_sprite.opacity += 25
  2419.         @ball_sprite.opacity -= 25
  2420.         @enemy_sprite.zoom_x += 0.08
  2421.         @enemy_sprite.zoom_y += 0.08
  2422.         @enemy_sprite.opacity += 25
  2423.         Graphics.update
  2424.       end
  2425.      
  2426.       if FileTest.exist?(@enemy.cry)
  2427.         Audio.se_play(@enemy.cry)
  2428.       end
  2429.      
  2430.       @enemy_sprite.zoom_x = 1
  2431.       @enemy_sprite.zoom_y = 1
  2432.       @enemy_sprite.opacity = 255
  2433.      
  2434.       @enemy_status.x = -377
  2435.       @enemy_status.visible = true
  2436.      
  2437.       if @enemy.shiny
  2438.         animation = $data_animations[496]
  2439.         @enemy_sprite.animation(animation, true)
  2440.       end
  2441.      
  2442.       until @enemy_status.x == 23
  2443.         @background.update
  2444.         @actor_ground.update
  2445.         @enemy_ground.update
  2446.         @enemy_status.x += 20
  2447.         @enemy_sprite.color.alpha -= 25
  2448.         @flash_sprite.opacity -= 25
  2449.         @enemy_sprite.update
  2450.         Graphics.update
  2451.       end
  2452.      
  2453.       until not(@enemy_sprite.effect?)
  2454.         @enemy_sprite.update
  2455.         Graphics.update
  2456.       end
  2457.      
  2458.       @enemy_sprite.x = 464
  2459.       @enemy_status.x = 23
  2460.       @enemy_sprite.color.alpha = 0
  2461.       @flash_sprite.opacity = 0
  2462.       @ball_sprite.dispose
  2463.       Graphics.update
  2464.     end
  2465.    
  2466.     #------------------------------------------------------------  
  2467.     # Fin de combat
  2468.     #------------------------------------------------------------      
  2469.     def end_battle(result = 0)      
  2470.       # Reset des variables et effets
  2471.       $battle_var.reset
  2472.       @actor.skill_effect_reset
  2473.       @actor.reset_stat_stage
  2474.       @actor.cure_state
  2475.       @actor.ability_active = false
  2476.       @enemy.skill_effect_reset
  2477.       @enemy.reset_stat_stage
  2478.       @enemy.cure_state
  2479.       @enemy.ability_active = false
  2480.       # -----------------------------------
  2481.       Audio.me_stop
  2482.       wait(10)
  2483.       $game_system.bgm_play($game_temp.map_bgm)
  2484.       wait(10)
  2485.       Graphics.freeze
  2486.       # -----------------------------------
  2487.       if $game_temp.battle_proc != nil
  2488.         $game_temp.battle_proc.call(result)
  2489.         $game_temp.battle_proc = nil
  2490.       end
  2491.       # Défaite
  2492.       $scene = Scene_Map.new
  2493.     end
  2494.    
  2495.     def end_battle_flee(expulsion = false)
  2496.       $battle_var.result_flee = true
  2497.       $game_system.se_play($data_system.escape_se)
  2498.       if expulsion
  2499.         draw_text(@actor.given_name, "est expulsé du combat!")
  2500.         loop do
  2501.           if @actor_sprite.x > -160
  2502.             @actor_sprite.x -= 20
  2503.           end
  2504.           Graphics.update
  2505.           Input.update
  2506.           if @actor_sprite.x <= -160
  2507.             wait(40)
  2508.             break
  2509.           end
  2510.         end
  2511.       else
  2512.         draw_text("Vous prenez la fuite!")
  2513.         wait(40)
  2514.       end
  2515.       end_battle(1)
  2516.     end
  2517.    
  2518.     def fail_flee
  2519.       draw_text("Vous ne pouvez pas","vous enfuir!")
  2520.       wait(40)
  2521.     end
  2522.    
  2523.     def end_battle_flee_enemy(expulsion = false)
  2524.       $battle_var.result_flee = true
  2525.       $game_system.se_play($data_system.escape_se)
  2526.       if expulsion
  2527.         draw_text(@enemy.given_name, "est expulsé du combat!")
  2528.       else
  2529.         draw_text(@enemy.given_name + " s'échappe!")
  2530.       end
  2531.       loop do
  2532.         if @enemy_sprite.x < 800
  2533.           @enemy_sprite.x += 20
  2534.         end
  2535.         Graphics.update
  2536.         Input.update
  2537.         if @enemy_sprite.x >= 800
  2538.           wait(40)
  2539.           break
  2540.         end
  2541.       end
  2542.       end_battle(1)
  2543.     end
  2544.    
  2545.     def end_battle_defeat
  2546.       $battle_var.result_defeat = true
  2547.       draw_text("Tous vos Pokémons", "ont été vaincus!")
  2548.       wait(40)
  2549.       $pokemon_party.money /= 2
  2550.       if not(@lose)
  2551.         if $game_variables[1] == 0
  2552.           print("Réglez votre point de retour!")
  2553.         else
  2554.           $game_map.setup($game_variables[1])
  2555.           $game_map.display_x = $game_variables[2]
  2556.           $game_map.display_y = $game_variables[3]
  2557.           $game_player.moveto($game_variables[2], $game_variables[3])
  2558.         end
  2559.         $game_temp.common_event_id = 2
  2560.       end
  2561.       $game_temp.map_bgm = $game_map.bgm
  2562.       end_battle(2)
  2563.     end
  2564.    
  2565.     def draw_choice
  2566.       @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig)
  2567.       @command.x = 517
  2568.       @command.y = 215
  2569.       loop do
  2570.         Graphics.update
  2571.         Input.update
  2572.         @command.update
  2573.         if Input.trigger?(Input::C) and @command.index == 0
  2574.           $game_system.se_play($data_system.decision_se)
  2575.           @command.dispose
  2576.           @command = nil
  2577.           Input.update
  2578.           return true
  2579.         end
  2580.         if Input.trigger?(Input::C) and @command.index == 1
  2581.           $game_system.se_play($data_system.decision_se)
  2582.           @command.dispose
  2583.           @command = nil
  2584.           Input.update
  2585.           return false
  2586.         end
  2587.       end
  2588.     end
  2589.   end
  2590.  
  2591.   #------------------------------------------------------------  
  2592.   # Fenêtre de statut
  2593.   #------------------------------------------------------------  
  2594.   class Pokemon_Battle_Status < Window_Base
  2595.     def initialize(pokemon, enemy, z_level = 15)
  2596.       @enemy = enemy # True / False
  2597.       if @enemy
  2598.         super(23,0,332,116)
  2599.       else
  2600.         super(311,203,341,140)
  2601.       end
  2602.       self.contents = Bitmap.new(width - 32, height - 32)
  2603.       self.contents.font.name = $fontsmall
  2604.       self.contents.font.size = $fontsmallsize
  2605.       # self.contents.font.bold = true
  2606.       self.opacity = 0
  2607.       self.z = z_level
  2608.       @pokemon = pokemon
  2609.       refresh
  2610.     end
  2611.    
  2612.     def refresh
  2613.       self.contents.clear
  2614.       level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f
  2615.       normal_color = Color.new(0,0,0,255)
  2616.       if @enemy
  2617.         src_rect = Rect.new(0, 0, 300, 84)
  2618.         bitmap = RPG::Cache.picture("battle_sprite1.png")
  2619.         self.contents.blt(0, 0, bitmap, src_rect, 255)
  2620.         draw_hp_bar(69,45, level)
  2621.         draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color)
  2622.         draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
  2623.         width_text = self.contents.text_size(@pokemon.name).width + 3
  2624.         draw_gender(15 + width_text, 15, @pokemon.gender, @pokemon.id)
  2625.         if $data_pokedex[@pokemon.id][1]
  2626.           src_rect = Rect.new(0, 0, 21, 21)
  2627.           bitmap = RPG::Cache.picture("ballbattlestatus.png")
  2628.           self.contents.blt(27, 45, bitmap, src_rect, 255)
  2629.         end
  2630.         if @pokemon.status != 0
  2631.           string = "stat" + @pokemon.status.to_s + ".png"
  2632.           src_rect = Rect.new(0, 0, 60, 24)
  2633.           bitmap = RPG::Cache.picture(string)
  2634.           self.contents.blt(9, 42, bitmap, src_rect, 255)
  2635.         end
  2636.       else
  2637.         src_rect = Rect.new(0, 0, 309, 108)
  2638.         bitmap = RPG::Cache.picture("battle_sprite2.png")
  2639.         self.contents.blt(0, 0, bitmap, src_rect, 255)
  2640.         draw_hp_bar(93,45, level)
  2641.         draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color)
  2642.         draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color)
  2643.         string = @pokemon.hp < 0 ? 0 : @pokemon.hp
  2644.         draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color)
  2645.         if @pokemon.level < 100
  2646.           level = @pokemon.next_exp.to_f /
  2647.             (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
  2648.         else
  2649.           level = 0
  2650.         end
  2651.         draw_exp_bar(93, 99, 1.0 - level, 192)
  2652.         width_text = self.contents.text_size(@pokemon.given_name).width + 3
  2653.         draw_gender(39 + width_text, 15, @pokemon.gender, @pokemon.id)
  2654.         if @pokemon.status != 0
  2655.           string = "stat" + @pokemon.status.to_s + ".png"
  2656.           src_rect = Rect.new(0, 0, 60, 24)
  2657.           bitmap = RPG::Cache.picture(string)
  2658.           self.contents.blt(42, 66, bitmap, src_rect, 255)
  2659.         end
  2660.       end
  2661.     end
  2662.    
  2663.     def exp_refresh
  2664.       level = @pokemon.next_exp.to_f /
  2665.         (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f
  2666.       draw_exp_bar(93, 99, 1.0 - level, 192)
  2667.     end
  2668.      
  2669.     def damage_refresh(info)
  2670.       damage = info[0]
  2671.       if damage == 0
  2672.         return
  2673.       end
  2674.      
  2675.       for i in 1..damage
  2676.         @pokemon.remove_hp(1)
  2677.         Graphics.update
  2678.         Graphics.update
  2679.         if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead?
  2680.           break
  2681.         end
  2682.       end
  2683.     end
  2684.    
  2685.     def dispose
  2686.       super
  2687.     end
  2688.    
  2689.     def draw_hp_bar(x, y, level, small = false)
  2690.       src_rect = Rect.new(0, 0, 198, 24)
  2691.       bitmap = RPG::Cache.picture("hpbar.png")
  2692.       if small
  2693.         bitmap = RPG::Cache.picture("hpbarsmall.png")
  2694.       end
  2695.       self.contents.blt(x, y, bitmap, src_rect, 255)
  2696.       rect1 = Rect.new(x + 45, y + 6, level*144.to_i, 3)
  2697.       rect2 = Rect.new(x + 45, y + 9, level*144.to_i, 6)
  2698.       if small
  2699.         rect1 = Rect.new(x + 45, y + 6, level*129.to_i, 3)
  2700.         rect2 = Rect.new(x + 45, y + 9, level*129.to_i, 6)
  2701.       end
  2702.      
  2703.       if level < 0.1
  2704.         color1 = Color.new(170, 70, 70, 255)
  2705.         color2 = Color.new(250, 90, 60, 255)
  2706.       elsif level >= 0.1 and level < 0.5
  2707.         color1 = Color.new(200, 170, 0, 255)
  2708.         color2 = Color.new(250, 225, 50, 255)
  2709.       else
  2710.         color1 = Color.new(90, 210, 125, 255)
  2711.         color2 = Color.new(110, 250, 170, 255)
  2712.       end
  2713.       self.contents.fill_rect(rect1, color1)
  2714.       self.contents.fill_rect(rect2, color2)
  2715.     end
  2716.    
  2717.     def draw_exp_bar(x, y, level, width)
  2718.       rect1 = Rect.new(x, y, level*192.to_i, 6)
  2719.       self.contents.fill_rect(rect1, Color.new(160, 160, 255, 255))
  2720.     end
  2721.    
  2722.     def draw_gender(x, y, gender, id)
  2723.       if id == 502
  2724.         rect = Rect.new(0, 0, 42, 33)
  2725.         bitmap = RPG::Cache.picture("Femalesb.png")
  2726.         self.contents.blt(x, y, bitmap, rect, 255)        
  2727.       else
  2728.         if gender == 1
  2729.           rect = Rect.new(0, 0, 18, 33)
  2730.           bitmap = RPG::Cache.picture("Maleb.png")
  2731.           self.contents.blt(x, y, bitmap, rect, 255)
  2732.         end
  2733.         if gender == 2
  2734.           rect = Rect.new(0, 0, 18, 33)
  2735.           bitmap = RPG::Cache.picture("Femaleb.png")
  2736.           self.contents.blt(x, y, bitmap, rect, 255)        
  2737.         end
  2738.       end
  2739.     end
  2740.   end
  2741.  
  2742.  
  2743.   #------------------------------------------------------------  
  2744.   # Fenêtre de statut de l'équipe
  2745.   #------------------------------------------------------------  
  2746.   class Pokemon_Battle_Party_Status < Window_Base
  2747.     attr_accessor :battle_order
  2748.    
  2749.     def initialize(party, order, enemy, z_level = 15)
  2750.       @enemy = enemy # True / False
  2751.       @battle_order = order
  2752.       if @enemy
  2753.         super(0-16,63-16,315+32,42+32)
  2754.       else
  2755.         super(325-16, 261-16, 315+32,42+32)
  2756.       end
  2757.       self.contents = Bitmap.new(width - 32, height - 32)
  2758.       self.opacity = 0
  2759.       self.z = z_level
  2760.       @party = party
  2761.       refresh
  2762.     end
  2763.    
  2764.     def refresh
  2765.       self.contents.clear
  2766.       src_rect = Rect.new(0, 0, 315, 42)
  2767.       if @enemy
  2768.         bitmap = RPG::Cache.picture("partystatusenemy.png")
  2769.       else
  2770.         bitmap = RPG::Cache.picture("partystatus.png")
  2771.       end
  2772.       self.contents.blt(0, 0, bitmap, src_rect, 255)
  2773.      
  2774.       src_rect = Rect.new(0, 0, 21, 21)
  2775.       if @enemy
  2776.         ball_x = 231
  2777.         coeff = -1
  2778.       else
  2779.         ball_x = 63
  2780.         coeff = 1
  2781.       end
  2782.      
  2783.       for i in 1..@party.size
  2784.         bitmap = RPG::Cache.picture("ballpartystatus.png")
  2785.         if @party.actors[@battle_order[i-1]].dead?
  2786.           bitmap = RPG::Cache.picture("ballpartystatusko.png")
  2787.         end
  2788.         self.contents.blt(ball_x + coeff*30*(i-1), 3, bitmap, src_rect, 255)
  2789.       end
  2790.     end
  2791.    
  2792.     def reset_position
  2793.       if @enemy
  2794.         self.x = -16
  2795.       else
  2796.         self.x = 325-16
  2797.       end
  2798.       refresh
  2799.     end
  2800.   end
  2801.  
  2802.  
  2803.  
  2804.  
  2805.   class Pokemon_Battle_Variable
  2806.  
  2807.     attr_accessor :weather
  2808.     attr_accessor :last_used
  2809.     attr_accessor :actor_last_used
  2810.     attr_accessor :enemy_last_used
  2811.     attr_accessor :battle_order
  2812.     attr_accessor :enemy_battle_order
  2813.     attr_accessor :in_battle
  2814.     attr_accessor :actor_last_taken_damage
  2815.     attr_accessor :enemy_last_taken_damage
  2816.     attr_accessor :have_fought #liste des pokémons ayant participé par leur index
  2817.     attr_accessor :enemy_party
  2818.     attr_accessor :action_id
  2819.     attr_accessor :window_index
  2820.     attr_accessor :result_flee
  2821.     attr_accessor :result_win
  2822.     attr_accessor :result_defeat
  2823.     attr_accessor :last_index
  2824.     attr_accessor :round
  2825.     attr_accessor :run_count
  2826.     attr_accessor :money
  2827.     attr_accessor :money_payday
  2828.    
  2829.     # Weather: [ catégorie, nombre de tours ]
  2830.     # catégorie: 0: Normal, 1: Pluie, 2: Ensoleillé,
  2831.     #            3: Tempête de Sable, 4: Grêle
  2832.    
  2833.     def initialize
  2834.       @weather = [0, 0]
  2835.       @last_used = nil
  2836.       @actor_last_used = nil
  2837.       @enemy_last_used = nil
  2838.       @battle_order = (0..5).to_a
  2839.       @enemy_battle_order = (0..5).to_a
  2840.       @in_battle = false
  2841.       @actor_last_taken_damage = 0
  2842.       @enemy_last_taken_damage = 0
  2843.       @have_fought = []
  2844.       @enemy_party = Pokemon_Party.new
  2845.       @action_id = 0
  2846.       @window_index = 0
  2847.       @result_flee = false
  2848.       @result_win = false
  2849.       @result_defeat = false
  2850.       @last_index = 0
  2851.       @round = 0
  2852.       @run_count = 0
  2853.       @money = 0
  2854.       @money_payday = 0
  2855.     end
  2856.    
  2857.     def reset
  2858.       @weather = [0, 0]
  2859.       @last_used = nil
  2860.       @actor_last_used = nil
  2861.       @enemy_last_used = nil
  2862.       @battle_order = (0..5).to_a
  2863.       @enemy_battle_order = (0..5).to_a
  2864.       @in_battle = false
  2865.       @actor_last_taken_damage = 0
  2866.       @enemy_last_taken_damage = 0
  2867.       @have_fought = []
  2868.       @enemy_party = Pokemon_Party.new
  2869.       @action_id = 0
  2870.       @window_index = 0
  2871.       @last_index = 0
  2872.       @round = 0
  2873.       @run_count = 0
  2874.       @money = 0
  2875.       @money_payday = 0
  2876.     end
  2877.    
  2878.     def reset_weather
  2879.       @weather = [0, 0]
  2880.     end
  2881.    
  2882.     def set_rain(duration = -1)
  2883.       @weather = [1, duration]
  2884.     end
  2885.    
  2886.     def rain?
  2887.       if @weather[0] == 1
  2888.         return true
  2889.       else
  2890.         return false
  2891.       end
  2892.     end
  2893.    
  2894.     def set_sunny(duration = -1)
  2895.       @weather = [2, duration]
  2896.     end
  2897.    
  2898.     def sunny?
  2899.       if @weather[0] == 2
  2900.         return true
  2901.       else
  2902.         return false
  2903.       end
  2904.     end
  2905.    
  2906.     def sandstorm?
  2907.       if @weather[0] == 3
  2908.         return true
  2909.       else
  2910.         return false
  2911.       end
  2912.     end
  2913.    
  2914.     def set_sandstorm(duration = -1)
  2915.       @weather = [3, duration]
  2916.     end
  2917.    
  2918.     def hail?
  2919.       if @weather[0] == 4
  2920.         return true
  2921.       else
  2922.         return false
  2923.       end
  2924.     end
  2925.    
  2926.     def set_hail(duration = -1)
  2927.       @weather = [4, duration]
  2928.     end
  2929.    
  2930.     def battle_end?
  2931.       if @result_flee or @result_win or @result_defeat
  2932.         return true
  2933.       else
  2934.         return false
  2935.       end
  2936.     end
  2937.    
  2938.     def add_money(amount)
  2939.       if @money == nil
  2940.         @money = 0
  2941.       end
  2942.       @money += amount
  2943.     end
  2944.      
  2945.   end
  2946.  
  2947. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement