Code: |
$scene = POKEMON_S::Pokemon_Battle_Wild.new($pokemon_party, pokemon) |
Code: |
if $game_variables[39] == 0 $scene = POKEMON_S::Pokemon_Battle_Wild.new($pokemon_party, pokemon) else $scene = POKEMON_S::Pokemon_Battle_Safari.new($pokemon_party, pokemon) end |
Code: |
#============================================================================== # ■ Pokemon_Battle_Core # Pokemon Script Project - Krosk # 20/07/07 # Pokemon_Battle_Core_Safari # Therand - 01/2015 #----------------------------------------------------------------------------- # Scène à ne pas modifier de préférence #----------------------------------------------------------------------------- # Système de Combat - Safari #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Cette scene définit les actions propres au parc safari, vous pouvez modifier # les choix d'actions (BALL, APPAT, CAILLOU et FUITE) et leur effets direct # (initialisation de compteurs, tour à effectuer, action préliminaire,...) #----------------------------------------------------------------------------- module POKEMON_S #------------------------------------------------------------ # Pokemon_Battle_Core_Safari # noyau possédant les fonctions propres au parc safari #------------------------------------------------------------ #------------------------------------------------------------ # Fonctions à définir à l'extérieur # initialize # pre_battle_animation # enemy_skill_decision # end_battle_check # actor_item_use # catch_pokemon # run_able? # end_battle_victory #------------------------------------------------------------ class Pokemon_Battle_Core_Safari attr_accessor :z_level attr_accessor :actor_status attr_accessor :actor attr_accessor :actor_sprite #------------------------------------------------------------ # main #------------------------------------------------------------ def main # Pré-création des Sprites # Fond if @battleback_name != "" @battleback_name = $game_map.battleback_name + ".png" @ground_name = "ground" + $game_map.battleback_name + ".png" else print("Attention, réglez le BattleBack du Tileset.") @battleback_name = "battle0.png" @ground_name = "groundbattle0.png" end @background = Sprite.new @background.z = @z_level # Fond du message @message_background = Sprite.new @message_background.y = 336 @message_background.z = @z_level + 19 # Sprite de flash @flash_sprite = Sprite.new @flash_sprite.bitmap = RPG::Cache.picture("black.png") @flash_sprite.color = Color.new(255,255,255) @flash_sprite.opacity = 0 @flash_sprite.z = @z_level + 13 # Fenetre de texte @text_window = Window_Base.new(4, 340, 632, 136) @text_window.opacity = 0 @text_window.z = @z_level + 20 @text_window.contents = Bitmap.new(600 + 32, 104 + 32) @text_window.contents.font.name = $fontface @text_window.contents.font.size = $fontsizebig # Fenetre d'action s1 = "BALL" s2 = "CAILLOU" s3 = "APPAT" s4 = "FUITE" @action_window = Window_Command.new(320, [s1, s3, s2, s4], $fontsizebig, 2, 56) @action_window.x = 320 @action_window.y = 336 @action_window.z = @z_level + 21 @action_window.height = 144 @action_window.active = false @action_window.visible = false @action_window.index = 0 # Viewport battle_viewport = Viewport.new(0, 0, 640, 336) battle_viewport.z = @z_level + 15 # Sprites acteurs # Positions par défaut des centres @enemy_sprite = RPG::Sprite.new(battle_viewport) @enemy_sprite.x = 464 @enemy_sprite.y = 104 @enemy_sprite.z = @z_level + 15 @enemy_ground = RPG::Sprite.new @enemy_ground.x = 464 @enemy_ground.y = 149 @enemy_ground.z = @z_level + 11 @actor_sprite = RPG::Sprite.new(battle_viewport) @actor_sprite.x = 153 @actor_sprite.y = 336 @actor_sprite.z = @z_level + 15 @actor_ground = RPG::Sprite.new @actor_ground.x = 153 @actor_ground.y = 386 @actor_ground.z = @z_level + 11 # Création fenêtre de statut @actor_status = Pokemon_Battle_Status.new(@actor, false, @z_level + 15) @enemy_status = Pokemon_Battle_Status.new(@enemy, true, @z_level + 15) @actor_status.visible = false @enemy_status.visible = false @enemy_caught = false @actor_party_status = Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10) @enemy_party_status = Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10) @actor_party_status.visible = false @enemy_party_status.visible = false # note: .active = true activera les animations liées à ces fenêtres @actor_party_status.active = false @enemy_party_status.active = false # Lancement des animations pre_battle_transition pre_battle_animation # Effets pré-premier round post_round_effect Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end # Fin de scene Graphics.freeze @background.dispose @message_background.dispose @flash_sprite.dispose @text_window.dispose @action_window.dispose @enemy_ground.dispose @actor_ground.dispose if @skill_window != nil @skills_window.dispose end if @ball_sprite != nil @ball_sprite.dispose end @enemy_sprite.dispose @actor_sprite.dispose @actor_status.dispose @enemy_status.dispose @actor_party_status.dispose @enemy_party_status.dispose end #------------------------------------------------------------ # Déroulement #------------------------------------------------------------ def update # Animation test : séquence de test d'une animation if false if $temp == nil $temp = false @actor_sprite.register_position @enemy_sprite.register_position end animation = $data_animations[15] # tappez le numéro de l'anim à tester if not @enemy_sprite.effect? and not @actor_sprite.effect? if $temp @enemy_sprite.reset_position @actor_sprite.register_position @actor_sprite.animation(animation, true, true) $temp = !$temp else @actor_sprite.reset_position @enemy_sprite.register_position @enemy_sprite.animation(animation, true) $temp = !$temp end end @actor_sprite.update @enemy_sprite.update return end case @phase when 0 # Phase d'initialisation @phase = 1 # Création fenêtre de skill list = [] for skill in @actor.skills_set list.push(skill.name) end while list.size < 4 list.push(" ---") end @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56) @skills_window.x = 0 @skills_window.y = 336 @skills_window.height = 144 @skills_window.visible = false @skills_window.active = false # Compétences bloquées for i in 0..@actor.skills_set.length-1 skill = @actor.skills_set[i] if not(skill.usable?) @skills_window.disable_item(i) end end # Curseur sur le dernier choix if $battle_var.last_index == nil $battle_var.last_index = 0 @skills_window.index = 0 else @skills_window.index = $battle_var.last_index end # Création fenêtre description de skill @skill_descr = Window_Base.new(512, 336, 128, 144) @skill_descr.contents = Bitmap.new(96, 144) @skill_descr.contents.font.name = $fontface @skill_descr.contents.font.size = $fontsizebig @skill_descr.visible = false skill_descr_refresh # Activation fenêtre @actor_status.visible = true @enemy_status.visible = true # ------- ---------- --------- -------- # Saut de phase de sélection actor # ------- ---------- --------- -------- jumped = phase_jump # Activations fenêtres if not(jumped) draw_text("Que doit faire", "" + Player.name + " ?") @action_window.visible = true @action_window.active= true $battle_var.action_id = 0 end when 1 # Phase d'attente d'action @action_window.update @skills_window.update if @skills_window.active and input skill_descr_refresh end if Input.trigger?(Input::C) and @action_window.active case @action_window.index when 0 # Selection BALL $game_system.se_play($data_system.decision_se) @action_window.active = false @action_window.visible = false # Si le nombre de ball == 0, le joueur n'a plus de BALL if $pokemon_party.item_number(12) == 0 draw_text("Vous n'avez plus de SAFARI BALL!") wait(40) #On revient à la phase d'attente du joueur. @phase = 0 @ball = 0 else # Sinon on continue l'action # en retirant une SAFARI BALL $pokemon_party.add_item(12, -1) $battle_var.action_id = 1 #Ceci renvoit à la méthode de capture incluse dans Battle_Safari catch_pokemon(12) end # Si la ball ne capture pas le pokemon, on continue l'action if $battle_var.action_id == 1 @phase = 0 # @ball = 1 sert à indiquer au Battle_Core 4 que le joueur à lancé une BALL @ball = 1 #ce sera donc à l'enemy scene = enemy_skill_decision end # Si la capture réussi if $battle_var.action_id == 2 #on donne les bonnes variables pour la ball utilisée dans le pokédex @item_id = 12 $data_ball = 12 # On ajoute le pokémon à l'équipe, avec les donné de la ball (fake) ball_data = Item.data(@item_id)["ball"] @enemy.given_name = @enemy.name @enemy.ball_data = ball_data # Changement de surnom string1 = "Voulez-vous changer le" string2 = "surnom de " + @enemy.given_name + "?" draw_text(string1, string2) if draw_choice draw_text("") scene = POKEMON_S::Pokemon_Name.new(@enemy, @z_level + 50) scene.main end # Intégration au PC if $pokemon_party.size < 6 $pokemon_party.add(@enemy) else $pokemon_party.store_captured(@enemy) string1 = @enemy.given_name string2 = "est envoyé au PC." draw_text(string1, string2) wait(40) end #On fini le combat $battle_var.result_win = true end_battle end when 1 # Selection APPAT $game_system.se_play($data_system.decision_se) @action_window.active = false @action_window.visible = false # On initialise/calcul les compteurs de faim, colère @ball = 0 @angry = 0 @eating += 1 + rand(6) #@chance_safari est incluse dans le calcul de capture #vous le trouverez dans Pokemon_Safari @chance_safari /= 2 #Si @chance_safari == 0 alors l'augmenter de un, #tout simplement pour éviter d'avoir une erreur/un drop rate incorrecte #si le joueur utilise plusieurs appat de suite (le @chance_safari doit #toujours valoir 1 OU un multiple de 2) if@chance_safari == 0 @chance_safari += 1 end # Le lancement de l'appat @actor_action = 1 @phase = 2 @actor_skill = Skill.new(562) # APPAT when 2 # Selection CAILLOU $game_system.se_play($data_system.decision_se) @action_window.active = false @action_window.visible = false # On initialise/calcul les compteurs de faim, colère et doublage du rate @ball = 0 @angry += 1 + rand(6) @eating = 0 @chance_safari *= 2 #juste au cas ou... if@chance_safari == 0 @chance_safari += 1 end # Le lancement du caillou @actor_action = 1 @phase = 2 @actor_skill = Skill.new(563) # CAILLOU return when 3 # sélection FUITE # ------- ---------- --------- -------- # Vérification fuite permise # ------- ---------- --------- -------- @action_window.visible = false if not(flee_able(@actor, @enemy)) $game_system.se_play($data_system.buzzer_se) @action_window.visible = true draw_text("Que doit faire", "" + Player.name + " ?") return end @action_window.visible = true @action_window.active = false @action_window.visible = false @text_window.contents.clear run end return end if Input.trigger?(Input::C) and @skills_window.active index = @skills_window.index skill = @actor.skills_set[index] if skill != nil and skill.usable? @actor_action = 1 @phase = 2 @skills_window.active = false @skills_window.visible= false @skill_descr.visible = false @action_window.active = false @action_window.visible= false @actor_skill = @actor.skills_set[index] $battle_var.last_index = @skills_window.index else $game_system.se_play($data_system.buzzer_se) end end if Input.trigger?(Input::B) and @skills_window.active $game_system.se_play($data_system.decision_se) @skills_window.active = false @skills_window.visible = false @skill_descr.visible = false @action_window.active = true @phase = 0 end when 2 # Phase d'action automatisée @action_window.visible = false @action_window.active = false enemy_skill_decision statistic_refresh turn_order phase2 phase3 # Phase de switch de fin de tour $battle_var.action_id = 4 end_battle_check if $battle_var.battle_end? return end # Fin de tour / Post_Round effects post_round_effect @actor_status.refresh @enemy_status.refresh if $battle_var.battle_end? return end # Phase de switch post_round $battle_var.action_id = 6 end_battle_check @phase = 0 if $battle_var.battle_end? return end # Incrémentation nombre de tours $battle_var.round += 1 end return end #------------------------------------------------------------ # Vérifications préliminaires et ordre d'action #------------------------------------------------------------ def statistic_refresh @actor.statistic_refresh @enemy.statistic_refresh end #Recherche de priorité def turn_order # Comparaison des priorités if @actor_skill == nil or @enemy_skill == nil @strike_first = true return end if @actor_action != 1 # Attaque @strike_first = false return end if @actor_skill.priority > @enemy_skill.priority @strike_first = true elsif @actor_skill.priority < @enemy_skill.priority @strike_first = false else # En cas d'égalité if @enemy.spd > @actor.spd @strike_first = false elsif @enemy.spd < @actor.spd @strike_first = true else @strike_first = rand(2)>0 ? true : false end end end #------------------------------------------------------------ # Rounds #------------------------------------------------------------ def phase2 # Pré_Rounds @action_window.visible = false @action_window.active = false @actor_status.visible = true @enemy_status.visible = true @actor_status.refresh @enemy_status.refresh draw_text("","") # Préround 1: Fuite if @actor_action == 4 run end if @enemy_action == 4 enemy_run end # Préround 2: Item if @actor_action == 3 actor_item_use end if @enemy_action == 3 enemy_item_use end # Préround 3: Switch Pokémon if @actor_action == 2 actor_pokemon_switch end if @enemy_action == 2 enemy_pokemon_switch end @actor_status.refresh @enemy_status.refresh end # Round: Attaques def phase3 if @strike_first if @actor_action == 1 and not(@actor.dead?) attack_action(@actor, @actor_skill, @enemy) end else if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?) attack_action(@enemy, @enemy_skill, @actor) end end faint_check if @actor.dead? or @enemy.dead? or $battle_var.battle_end? return end if not(@strike_first) if @actor_action == 1 and not(@actor.dead?) attack_action(@actor, @actor_skill, @enemy) end else if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?) attack_action(@enemy, @enemy_skill, @actor) end end faint_check if @actor.dead? or @enemy.dead? or $battle_var.battle_end? return end end #------------------------------------------------------------ # Fonctions auxiliaires #------------------------------------------------------------ def switch(list, id1, id2) if id1 <= id2 list.insert(id1, list[id2]) list.delete_at(id2+1) list.insert(id2 + 1, list[id1+1]) list.delete_at(id1+1) return list else switch(list, id2, id1) end end # Fonction auxiliaire def input if Input.trigger?(Input::C) or Input.trigger?(Input::B) or Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT) return true end return false end def draw_text(line1 = "", line2 = "") if line1.type == Array if line1[1] != nil draw_text(line1[0], line1[1]) else draw_text(line1[0]) end else Graphics.freeze @text_window.contents.clear @text_window.draw_text(12, 0, 460, 50, line1) @text_window.draw_text(12, 55, 460, 50, line2) Graphics.transition(5) end end def draw_text_valid(line1 = "", line2 = "") draw_text(line1, line2) loop do Graphics.update Input.update if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) break end end end def wait(frame) i = 0 loop do i += 1 Graphics.update if i >= frame break end end end def wait_hit loop do Graphics.update Input.update if input $game_system.se_play($data_system.decision_se) break end end end def update_sprite @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0) @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0) @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2 @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 end #------------------------------------------------------------ # ----------------------- Interface ------------------------- #------------------------------------------------------------ #------------------------------------------------------------ # Fenêtre de description #------------------------------------------------------------ def skill_descr_refresh @skill_descr.contents.clear index = @skills_window.index skill = @actor.skills_set[index] if skill != nil string = skill.pp.to_s + "/" + skill.ppmax.to_s type = skill.type else string = "---" type = 0 end normal_color = Color.new(60,60,60) @skill_descr.contents.font.color = normal_color #@skill_descr.contents.draw_text(0,6,60,39, "PP:") @skill_descr.contents.draw_text(0,6,96,39, string, 1) #@skill_descr.contents.draw_text(0,60,140,39, "TP:") draw_type(0, 60, type) end def draw_type(x, y, type) src_rect = Rect.new(0, 0, 96, 42) bitmap = RPG::Cache.picture("T" + type.to_s + ".png") @skill_descr.contents.blt(x, y, bitmap, src_rect, 255) end #------------------------------------------------------------ # ------------------ Fonctions de combat -------------------- #------------------------------------------------------------ #------------------------------------------------------------ # Fonctions spéciales - programmation des attaques #------------------------------------------------------------ def heal(user, user_sprite, user_status, bonus) value = bonus.abs for i in 1..value if bonus >= 0 user.add_hp(1) else user.remove_hp(1) end if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0 next end user_status.refresh Graphics.update Graphics.update if user.hp >= user.max_hp or user.dead? break end end end def self_damage(user, user_sprite, user_status, damage) if damage > 0 Audio.se_play("Audio/SE/Hit.wav", 100) blink(user_sprite) end for i in 1..damage user.remove_hp(1) user_status.refresh if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0 next end Graphics.update Graphics.update if user.dead? break end end end #------------------------------------------------------------ # Fonctions communes - Programmation des attaques #------------------------------------------------------------ # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé # 6: Confus, 7: Flinch, 8: Toxic #------------------------------------------------------------ # 1 Normal 2 Feu 3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre #------------------------------------------------------------ # Fonction à appeler en cas d'effets sur le statut def status_check(target, status, forcing = false) # Immunités # Poison if (target.type_poison? or target.type_steel?) and (status == 1 or status == 8) draw_text(target.given_name + " est insensible", "au poison!") wait(40) return end # Freeze if status == 5 and target.type_ice? draw_text(target.given_name + " est insensible", "au gel!") wait(40) return end # Burn if status == 3 and target.type_fire? draw_text(target.given_name + " est insensible", "aux brûlures!") wait(40) return end # Soleil if status == 5 and $battle_var.sunny? draw_text("Le soleil empêche " + target.given_name, "de geler!") wait(40) return end # Lumber / Echauffement (ab) if status == 2 and target.ability == 7 draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.") wait(40) return end # Ignifu-voile / Water Veil (ab) if status == 3 and target.ability == 41 draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.") wait(40) return end # Insomnia (ab) // Vital Spirit / Esprit Vital (ab) if status == 4 and (target.ability == 15 or target.ability == 72) draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.") wait(40) return end # Vaccin / Immunity (ab) if [1, 8].include?(status) and target.ability == 17 draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.") wait(40) return end # Armumagma / Magma Armor (ab) if target.ability == 40 and status == 5 draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.") wait(40) return end # Tempo Perso / Own Tempo (ab) if status == 6 and target.ability == 20 draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.") wait(40) return end # Attention / Inner focus (ab) if target.ability == 39 and status == 7 draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.") wait(40) return end # Synchronize (ab) if target.ability == 28 and [1, 2, 3, 8].include?(status) target.ability_token = status if status == 8 target.ability_token = 1 end end if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status)) status_string(target, -target.status) # animation elsif status == 6 and target.confused? and not(forcing) status_string(target, -6) elsif target.effect_list.include?(0x7C) and status != 7 # Rune Protect/Safeguard draw_text(target.given_name + "est", "protégé des altérations!") wait(40) elsif target.effect_list.include?(0x9F) and status == 4 # Uproar draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!") wait(40) else case status when 1 target.status_poison(forcing) when 2 target.status_paralyze(forcing) when 3 target.status_burn(forcing) when 4 target.status_sleep(forcing) when 5 target.status_frozen(forcing) when 6 target.status_confuse when 7 target.status_flinch when 8 target.status_toxic(forcing) end status_string(target, status) end end def accuracy_stage(user, target) stage = user.acc_stage - target.eva_stage stage = stage < -6 ? -6 : stage > 6 ? 6 : stage # --------------- ---------------- -------------- # Programmation des attaques # --------------- ---------------- -------------- # Clairvoyayance / Foresight if target.effect_list.include?(0x71) stage = user.acc_stage end # --------------- ---------------- -------------- # --------------- ---------------- -------------- case stage when -6 return 33.0/100 when -5 return 36.0/100 when -4 return 43.0/100 when -3 return 50.0/100 when -2 return 60.0/100 when -1 return 75.0/100 when 0 return 1 when 1 return 133.0/100 when 2 return 166.0/100 when 3 return 2 when 4 return 250.0/100 when 5 return 133.0/50 when 6 return 3 end end #------------------------------------------------------------ # Post_round #------------------------------------------------------------ def post_round_effect # --------- -------------- -------------------- # Fin des effets "at the end of a round" # --------- -------------- -------------------- # Suppression état appeuré (ne dure que un tour) @actor.flinch_check @enemy.flinch_check # Suppression état autre if @actor.dead? @actor.cure @actor.cure_state end if @enemy.dead? @enemy.cure @enemy.cure_state end # --------- -------------- -------------------- # Programmation des attaques en Post-round # --------- -------------- -------------------- # Cycle commun 0 - Souhait et Météo # --------- -------------- -------------------- post_round_cycle0 # --------- -------------- -------------------- # Cycle individuel 1 # Programmation des attaques # Effets du statut # --------- -------------- -------------------- if @strike_first post_round_cycle_1(@actor, @enemy) post_round_cycle_1(@enemy, @actor) else post_round_cycle_1(@enemy, @actor) post_round_cycle_1(@actor, @enemy) end # --------- -------------- -------------------- # Cycle 2 # Programmation des attaques # Dommages finaux # --------- -------------- -------------------- if @strike_first post_round_cycle_2(@actor, @enemy) post_round_cycle_2(@enemy, @actor) else post_round_cycle_2(@enemy, @actor) post_round_cycle_2(@actor, @enemy) end @actor.skill_effect_clean @enemy.skill_effect_clean faint_check # Round suivant if $battle_var.round == nil $battle_var.round = 0 end $battle_var.round += 1 end # --------- -------------- -------------------- # Cycle commun 0 - Météo et Souhait # --------- -------------- -------------------- def post_round_cycle0 if @strike_first list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]] else list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]] end # Suppression du contrôle pour un pokémon mort for array in list if array[0].dead? list.delete(array) end end for array in list actor = array[0] actor.skill_effect_end_turn for effect in actor.effect_list case effect when 0x56 # Entrave / Disable index = actor.effect_list.index(0x56) if actor.effect[index][1] == 0 skill_id = actor.effect[index][2] skill = actor.skills_set[skill_id] skill.enable draw_text(skill.name + " de "+ actor.given_name, "est rétablie!") wait(40) end when 0x5A # Encore index = actor.effect_list.index(0x5A) if actor.skills_set[index].pp == 0 actor.effect[index][1] = 0 # Fin de l'effet end when 0x75 # Rollout index = actor.effect_list.index(0x75) ## N'a pas fait de dégât ce tour ci >> Supprimé #if actor.effect[index][2] != actor.effect[index][1] # actor.effect.delete_at(index) #end if actor.asleep? or actor.frozen? actor.effect.delete_at(index) end when 0x77 # Taillade / Fury Cutter index = actor.effect_list.index(0x77) # N'a pas fait de dégât ce tour ci >> Supprimé if actor.effect[index][2] != actor.effect[index][1] actor.effect.delete_at(index) end end end end weather = $battle_var.weather[0] $battle_var.weather[1] -= 1 count = $battle_var.weather[1] # Souhait -- Programmation des attaques for array in list target = array[0] target_sprite = array[1] target_status = array[2] if target.effect_list.include?(0xB3) bonus = target.hp / 2 draw_text("Un souhait est réalisé.") heal(target, target_sprite, target_status, bonus) wait(40) end end # Pluie if $battle_var.rain? and count != 0 draw_text("La pluie continue de", "tomber.") animation = $data_animations[493] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end wait(20) elsif $battle_var.rain? and count == 0 draw_text("La pluie s'est arrêtée.") wait(40) $battle_var.reset_weather end # Ensoleillé if $battle_var.sunny? and count != 0 draw_text("Les rayons du soleil","tapent fort.") animation = $data_animations[492] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end wait(20) elsif $battle_var.sunny? and count == 0 draw_text("Le soleil est parti.") wait(40) $battle_var.reset_weather end # Tempete de sable if $battle_var.sandstorm? and count != 0 draw_text("La tempête de sable souffle.") animation = $data_animations[494] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end # Dégats for array in list target = array[0] target_sprite = array[1] target_status = array[2] if target.type_ground? or target.type_rock? or target.type_steel? target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or target.ability == 8 next end damage = target.max_hp / 16 heal(target, target_sprite, target_status, -damage) end elsif $battle_var.sandstorm? and count == 0 draw_text("La tempête de sable s'est arretée.") wait(40) $battle_var.reset_weather end # Grêle if $battle_var.hail? and count > 0 draw_text("Il grêle...") animation = $data_animations[495] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end # Dégâts for array in list target = array[0] target_sprite = array[1] target_status = array[2] if target.type_ice? or target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) next end damage = target.max_hp / 16 heal(target, target_sprite, target_status, -damage) end elsif $battle_var.hail? and count == 0 draw_text("La grêle s'est arrêtée.") wait(40) $battle_var.reset_weather end end # --------- -------------- -------------------- # Cycle individuel 1 # --------- -------------- -------------------- def post_round_cycle_1(actor, enemy) if actor == @actor actor_status = @actor_status actor_sprite = @actor_sprite enemy_status = @enemy_status enemy_sprite = @enemy_sprite elsif actor == @enemy actor_status = @enemy_status actor_sprite = @enemy_sprite enemy_status = @actor_status enemy_sprite = @actor_sprite end # Suppression du contrôle pour un Pokémon mort if actor.dead? return end # --------- -------------- -------------------- # Programmation des attaques et des capa # --------- -------------- -------------------- for effect in actor.effect_list case effect when 0xB5 # Ingrain / Racines bonus = actor.max_hp / 16 draw_text(actor.given_name + " puise", "de l'énergie dans la terre.") heal(actor, actor_sprite, actor_status, bonus) wait(40) end end case actor.ability when 44 # Cuvette / Rain Dish (ab) if $battle_var.rain? bonus = actor.max_hp / 16 draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.") heal(actor, actor_sprite, actor_status, bonus) wait(40) end when 54 # Absentéisme / Truant (ab) if actor.ability_token == nil actor.ability_token = true end if actor.ability_token == true actor.ability_token = false elsif actor.ability_token == false actor.ability_token = true end when 61 # Mue / Shed skin (ab) if actor.status != 0 and rand(100) < 30 actor.cure draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.") wait(40) end end for effect in enemy.effect_list case effect when 0x54 # Leech Seed / Vampigraine malus = actor.max_hp / 8 draw_text("L'énergie de " + actor.given_name,"est drainée!") heal(actor, actor_sprite, actor_status, -malus) heal(enemy, enemy_sprite, enemy_status, malus) wait(40) when 0x2A # Multi_turn attack damage = actor.max_hp / 16 draw_text(actor.given_name, "est piégé!") self_damage(actor, actor_sprite, actor_status, damage) wait(40) end end if actor.dead? return end # --------- -------------- -------------------- # Inspection des statuts # --------- -------------- -------------------- if actor.status == 1 # Poison damage = actor.poison_effect draw_text(actor.given_name + " souffre", "du poison.") status_animation(actor_sprite, actor.status) heal(actor, actor_sprite, actor_status, -damage) wait(20) end if actor.status == 8 # Toxic damage = actor.toxic_effect draw_text(actor.given_name + " souffre", "gravement du poison.") status_animation(actor_sprite, actor.status) heal(actor, actor_sprite, actor_status, -damage) wait(20) end if actor.status == 3 #Burn damage = actor.burn_effect draw_text(actor.given_name + " souffre", "de ses brûlures.") status_animation(actor_sprite, actor.status) heal(actor, actor_sprite, actor_status, -damage) wait(20) end actor.confuse_decrement if actor.dead? return end # --------- -------------- -------------------- # Programmation des attaques # --------- -------------- -------------------- for effect in actor.effect_list case effect when 0x6B # Nightmare / Cauchemar if actor.asleep? damage = actor.max_hp / 4 draw_text(actor.given_name + " fait", "un chauchemar!") heal(actor, actor_sprite, actor_status, -damage) wait(20) else index = actor.effect_list.index(0x6B) actor.effect.delete_at(index) end when 0x6D # Curse damage = actor.max_hp / 4 draw_text(actor.given_name + " est", "maudit!") heal(actor, actor_sprite, actor_status, -damage) wait(20) when 0x9F # Uproar / Brouhaha if actor.asleep? actor.cure draw_text(actor.given_name + " se réveille", "à cause du brouhaha!") wait(40) end if actor.frozen? #Fin de l'effet index = actor.effect_list.index(0x9F) actor.effect.delete_at(index) end when 0xAF # Taunt / Provoc index = actor.effect_list.index(0xAF) for skill in actor.skills_set if skill.power == 0 and actor.effect[index][1] > 0 draw_text(skill.name + " est bloqué!") skill.disable wait(40) elsif actor.effect[index][1] == 0 draw_text(skill.name + " est rétablit.") skill.enable wait(40) end end when 0xBB # Yawn / Baillement if actor.status == 0 status_check(actor, 4) actor_status.refresh end end end if actor.dead? return end # --------- -------------- -------------------- # Berry check # --------- -------------- -------------------- if Item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp draw_text(actor.given_name + " récupère un peu", "de vie avec " + Item.name(actor.item_hold) + ".") bonus = actor.max_hp / 16 if bonus == 0 bonus = 1 end heal(actor, actor_sprite, actor_status, bonus) wait(40) end end # --------- -------------- -------------------- # Cycle individuel 2 # --------- -------------- -------------------- def post_round_cycle_2(actor, enemy) # Redéfinition if actor == @actor actor_status = @actor_status actor_sprite = @actor_sprite enemy_status = @enemy_status enemy_sprite = @enemy_sprite elsif actor == @enemy actor_status = @enemy_status actor_sprite = @enemy_sprite enemy_status = @actor_status enemy_sprite = @actor_sprite end # Suppression du contrôle pour un pokémon mort if actor.dead? return end # --------- -------------- -------------------- # Programmation des capacités # --------- -------------- -------------------- case actor.ability when 2 # Crachin / Drizzle (ab) if not($battle_var.rain?) # Pluie draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.") wait(40) animation = $data_animations[493] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end end $battle_var.set_rain when 45 # Sable Volant / Sand stream (ab) if not($battle_var.sandstorm?) # Tempete Sable draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.") wait(40) animation = $data_animations[494] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end end $battle_var.set_sandstorm when 70 # Sècheresse / Drought (ab) if not($battle_var.sunny?) # Soleil draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.") wait(40) animation = $data_animations[492] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end end $battle_var.set_sandstorm when 3 # Speed Boost (ab) draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.") actor.change_spd(+1) stage_animation(actor_sprite, $data_animations[482]) wait(40) when 22 # Intimidate (ab) if not(actor.ability_active) actor.ability_active = true draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".") enemy.change_atk(-1) stage_animation(enemy_sprite, $data_animations[479]) wait(40) end when 59 # Forecast / Meteo (ab) if $battle_var.sunny? and not(actor.type_fire?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en FEU!") actor.ability_token = 2 actor.form = 2 update_sprite wait(40) elsif $battle_var.rain? and not(actor.type_water?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en EAU!") actor.ability_token = 3 actor.form = 3 update_sprite wait(40) elsif $battle_var.hail? and not(actor.type_ice?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en GLACE!") actor.ability_token = 6 actor.form = 6 update_sprite wait(40) elsif not(actor.type_normal?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en NORMAL!") actor.ability_token = 1 actor.form = 0 update_sprite wait(40) end end # --------- -------------- -------------------- # Programmation des attaques # --------- -------------- -------------------- for effect in actor.effect_list case effect when 0x72 # Requiem / Perish Song index = actor.effect_list.index(0x72) number = actor.effect[index][1] if number > 0 if number > 1 string = "#{number.to_s} tours" elsif number == 1 string = "#{number.to_s} tour" end draw_text("Plus que #{string}", "pour #{actor.given_name}...") wait(40) else draw_text("#{actor.given_name} est", "K.O. par REQUIEM!") damage = actor.hp heal(actor, actor_sprite, actor_status, -damage) wait(40) end end end # --------- -------------- -------------------- # Nettoyage des compteurs d'effets # --------- -------------- -------------------- for effect in actor.effect case effect when [0x10, 0] # Reflet / Reflect draw_text("L'effet de REFLET est", "terminé.") wait(40) when [0x23, 0] # Light Screen draw_text("L'effet de MUR LUMIERE est", "terminé.") wait(40) when [0x2E, 0] # Brume / Mist draw_text("La brume se dissipe.") wait(40) when [0x7C, 0] # Rune Protect / Safeguard draw_text("L'effet de RUNE PROTECT", "est terminé.") wait(40) end end if actor.dead? return end end #------------------------------------------------------------ # Items #------------------------------------------------------------ def actor_item_use # items à utiliser # Item déjà utilisé ie remplacé par 0 if @item_id == 0 return end end #------------------------------------------------------------ # Switch de pokémon #------------------------------------------------------------ def actor_pokemon_switch if @switch_id != -1 if not(@actor.dead?) @actor_status.visible = true else @actor_status.visible = false end switch_effect(@actor, @enemy) if not(@actor.dead?) recall_pokemon end @battle_order = switch(@battle_order, 0, @switch_id) @actor = @party.actors[@battle_order[0]] @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0) @actor_status = Pokemon_Battle_Status.new(@actor, false) @actor_status.visible = false if not($battle_var.have_fought.include?(@actor.party_index)) $battle_var.have_fought.push(@actor.party_index) end launch_pokemon @actor_status.visible = true @switch_id = -1 end end def enemy_pokemon_switch if @enemy_switch_id != -1 if not(@enemy.dead?) @enemy_status.visible = true else @enemy_status.visible = false end switch_effect(@enemy, @actor) if not(@enemy.dead?) recall_enemy_pokemon end @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id) @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]] $data_pokedex[@enemy.id][0] = true @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0) @enemy_status = Pokemon_Battle_Status.new(@enemy, true) @enemy_status.visible = false launch_enemy_pokemon @enemy_status.visible = true @enemy_switch_id = -1 end end #------------------------------------------------------------ # Fuite #------------------------------------------------------------ def run if run_able?(@actor, @enemy) $battle_var.run_count += 1 @action_window.active = false @action_window.visible = false end_battle_flee else $battle_var.run_count += 1 fail_flee @phase = 2 @actor_action = 0 $battle_var.action_id = 0 end end def run_able?(runner, opponent) x = (Integer(opponent.spd/4) % 255) rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count)) if not(flee_able(runner, opponent)) return false end if opponent.spd <= runner.spd return true elsif x == 0 return true elsif rate > 255 return true elsif rand(256) <= rate return true else return false end end def run_enemy if run_able?(@enemy, @actor) end_battle_flee_enemy end end #------------------------------------------------------------ # Animations supplémentaires au combat #------------------------------------------------------------ # Défaites / KO #------------------------------------------------------------ def enemy_down # Si déjà vaincu if @enemy_sprite.zoom_y == 0 return end # Sinon @enemy_sprite.oy = @enemy_sprite.bitmap.height @enemy_sprite.y += @enemy_sprite.bitmap.height / 2 if FileTest.exist?(@enemy.cry) Audio.se_play(@enemy.cry) end wait(50) Audio.se_play("Audio/SE/Down.wav") loop do @enemy_status.x -= 20 #@enemy_sprite.zoom_y -= 0.05 @enemy_sprite.y += 8 @enemy_sprite.opacity -= 20 Graphics.update #if @enemy_sprite.zoom_y <= 0.0 if @enemy_sprite.y >= 348 @enemy_sprite.zoom_y = 0 break end end @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 @enemy_sprite.y -= @enemy_sprite.bitmap.height draw_text(@enemy.given_name, "est K.O.!") wait(40) end def actor_down # Si déjà vaincu #if @actor_sprite.zoom_y <= 0.0 if @actor_sprite.y >= 576 return end # Sinon if FileTest.exist?(@actor.cry) Audio.se_play(@actor.cry) end wait(50) Audio.se_play("Audio/SE/Down.wav") loop do @actor_status.x += 20 #@actor_sprite.zoom_y -= 0.05 @actor_sprite.y += 12 @actor_sprite.opacity -= 20 Graphics.update #if @actor_sprite.zoom_y <= 0.0 if @actor_sprite.y >= 576 break end end draw_text(@actor.given_name, "est K.O.!") wait(40) end #------------------------------------------------------------ # Attaques #------------------------------------------------------------ def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite) if miss wait(40) draw_text("Mais cela échoue!") wait(40) return end if user == @enemy reverse = true else reverse = false end efficiency = info[2] if hit and efficiency != -2 # Animation utilisateur animation_user = $data_animations[user_skill.user_anim_id] user_sprite.register_position if animation_user != nil user_sprite.animation(animation_user, true, reverse) until not(user_sprite.effect?) user_sprite.update Graphics.update end end user_sprite.reset_position user_sprite.update Graphics.update # Animation Cible animation_target = $data_animations[user_skill.target_anim_id] target_sprite.register_position if animation_target != nil target_sprite.animation(animation_target, true, reverse) until not(target_sprite.effect?) target_sprite.update Graphics.update end end target_sprite.reset_position target_sprite.update Graphics.update if info[0] > 0 case efficiency when 0 # Normal Audio.se_play("Audio/SE/Hit.wav", 100) blink(target_sprite, 3, 3) when 1 # Super efficace Audio.se_play("Audio/SE/Hitplus.wav", 100) blink(target_sprite, 2, 5) when -1 # Peu efficace Audio.se_play("Audio/SE/Hitlow.wav", 100) blink(target_sprite, 4, 2) end end elsif not(hit) wait(40) draw_text(user.given_name, "rate son attaque!") wait(40) end end def blink(sprite, frame = 4, number = 3) for i in 0..number wait(frame) sprite.opacity = 0 Graphics.update wait(frame) sprite.opacity = 255 Graphics.update end end def post_attack(info, damage, power) efficiency = info[2] if damage == 0 and (efficiency != -2 or power == 0) return end critical = info[1] if critical and efficiency != -2 #critical_hit draw_text("Coup critique!") wait(40) end case efficiency when 1 draw_text("C'est super efficace!") wait(40) when -1 draw_text("Ce n'est pas très efficace...") wait(40) when -2 draw_text("Ca ne l'affecte pas...") wait(40) end end def faint_check(user = nil) if user == nil faint_check(@actor) faint_check(@enemy) end if user == @actor and user.dead? actor_down end if user == @enemy and user.dead? enemy_down end end #------------------------------------------------------------ # Statut et stats #------------------------------------------------------------ def status_animation(sprite, status) animation = $data_animations[469 + status] sprite.animation(animation, true) loop do sprite.update Graphics.update Input.update if not(sprite.effect?) break end end end def stage_animation(sprite, animation) sprite.animation(animation, true) loop do sprite.update Graphics.update Input.update if not(sprite.effect?) wait(20) break end end end # 1 Normal 2 Feu 3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres def type_string(type) case type when 0 return "???" when 1 return "NORMAL" when 2 return "FEU" when 3 return "EAU" when 4 return "ELECTRIK" when 5 return "PLANTE" when 6 return "GLACE" when 7 return "COMBAT" when 8 return "POISON" when 9 return "SOL" when 10 return "VOL" when 11 return "PSY" when 12 return "INSECTE" when 13 return "ROCHE" when 14 return "SPECTRE" when 15 return "DRAGON" when 16 return "ACIER" when 17 return "TENEBRES" end end # Changement (ou pas) de statut def status_string(actor, status) string = actor.given_name case status when -1 draw_text(string + " est", "déjà empoisonné!") wait(40) when -2 draw_text(string + " est", "déjà paralysé!") wait(40) when -3 draw_text(string,"brûle déjà!") wait(40) when -4 draw_text(string,"dort déjà!") wait(40) when -5 draw_text(string, "est déjà gelé!") wait(40) when -6 draw_text(string, "est déjà confus!") wait(40) when -8 draw_text(string + " est", "déjà gravement empoisonné!") wait(40) when 1 draw_text(string, "est empoisonné!") wait(40) when 2 draw_text(string, "est paralysé!") wait(40) when 3 draw_text(string,"brûle!") wait(40) when 4 draw_text(string,"s'endort!") wait(40) when 5 draw_text(string,"gèle!") wait(40) when 6 draw_text("Cela rend " + string, "confus!") wait(40) when 7 draw_text(string, "est appeuré!") wait(40) when 8 draw_text(string + " est", "gravement empoisonné!") wait(40) end end # S'occupe du texte et de l'animation def raise_stat(string, actor, n = 0) if actor == @actor actor_sprite = @actor_sprite elsif actor == @enemy actor_sprite = @enemy_sprite end if n == 1 text = actor.given_name + " augmente!" elsif n > 1 text = actor.given_name + " augmente beaucoup!" end if n != 0 case string when "ATK" draw_text("Ah, Attaque de",text) stage_animation(actor_sprite, $data_animations[478]) when "DFE" draw_text("Ah, Défense de",text) stage_animation(actor_sprite, $data_animations[480]) when "ATS" draw_text("Ah, Attaque Spéciale de",text) stage_animation(actor_sprite, $data_animations[484]) when "DFS" draw_text("Ah, Défense Spéciale de",text) stage_animation(actor_sprite, $data_animations[486]) when "SPD" draw_text("Ah, Vitesse de",text) stage_animation(actor_sprite, $data_animations[482]) when "EVA" draw_text("Ah, Esquive de",text) stage_animation(actor_sprite, $data_animations[488]) when "ACC" draw_text("Ah, Précision de",text) stage_animation(actor_sprite, $data_animations[490]) end elsif n == 0 case string when "ATK" draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!") wait(40) when "DFE" draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!") wait(40) when "ATS" draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!") wait(40) when "DFS" draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!") wait(40) when "SPD" draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!") wait(40) when "EVA" draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!") wait(40) when "ACC" draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!") wait(40) when 0 draw_text("Les effets positifs sont supprimés!") wait(40) end end end def reduce_stat(string, actor, n = true, self_inflicted = false) # Mist/Brume if actor.effect_list.include?(0x2E) draw_text(actor.given_name + " est", "protégé par la brume!") wait(40) return end # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab) if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted) draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!") wait(40) return end # Keen Eye / Regard Vif (ab) if actor.ability == 51 and string == "ACC" draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!") wait(40) return end # Hyper Cutter (ab) if actor.ability == 52 and string == "ATK" draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!") wait(40) return end if actor == @actor actor_sprite = @actor_sprite elsif actor == @enemy actor_sprite = @enemy_sprite end if n == -1 text = actor.given_name + " baisse!" elsif n < -1 text = actor.given_name + " baisse beaucoup!" end if n != 0 case string when "ATK" draw_text("Ah, Attaque de",text) stage_animation(actor_sprite, $data_animations[479]) when "DFE" draw_text("Ah, Défense de",text) stage_animation(actor_sprite, $data_animations[481]) when "ATS" draw_text("Ah, Attaque Spéciale de",text) stage_animation(actor_sprite, $data_animations[485]) when "DFS" draw_text("Ah, Défense Spéciale de",text) stage_animation(actor_sprite, $data_animations[487]) when "SPD" draw_text("Ah, Vitesse de",text) stage_animation(actor_sprite, $data_animations[483]) when "EVA" draw_text("Ah, Esquive de",text) stage_animation(actor_sprite, $data_animations[489]) when "ACC" draw_text("Ah, Précision de",text) stage_animation(actor_sprite, $data_animations[491]) end elsif n == 0 case string when "ATK" draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!") wait(40) when "DFE" draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!") wait(40) when "ATS" draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!") wait(40) when "DFS" draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!") wait(40) when "SPD" draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!") wait(40) when "EVA" draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!") wait(40) when "ACC" draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!") wait(40) when 0 draw_text("Les effets positifs sont supprimés!") wait(40) end end end #------------------------------------------------------------ # Appel / Rappel de Pokémon #------------------------------------------------------------ def recall_pokemon draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!") @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height @actor_sprite.y = 336 @actor_sprite.x = 153 @actor_sprite.color = @actor.ball_color @actor_sprite.color.alpha = 0 until @actor_sprite.color.alpha >= 255 @flash_sprite.opacity += 25 @actor_sprite.color.alpha += 25 Graphics.update end Audio.se_play("Audio/SE/Pokeopen.wav") loop do @actor_status.x += 20 @actor_sprite.opacity -= 25 @actor_sprite.color.alpha += 25 @actor_sprite.zoom_x -= 0.1 @actor_sprite.zoom_y -= 0.1 @flash_sprite.opacity -= 25 Graphics.update if @actor_status.x >= 711 @actor_status.visible = false @actor_status.x = 711 @actor_sprite.color.alpha = 0 @actor_sprite.opacity = 0 Graphics.update break end end end def launch_pokemon @actor_sprite.x = 153 @actor_sprite.y = 336 @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height @actor_sprite.zoom_x = 0 @actor_sprite.zoom_y = 0 #if @actor_party_status.active # @actor_party_status.x = 0 # @actor_party_status.visible = true #end name = @actor.given_name text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)] draw_text(text) @ball_sprite = Sprite.new @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite) @ball_sprite.ox = @ball_sprite.bitmap.width / 2 @ball_sprite.oy = @ball_sprite.bitmap.height / 2 @ball_sprite.x = -44 @ball_sprite.y = 324 @ball_sprite.z = @z_level + 14 t = 0 pi = 3.14 loop do t += 1 @ball_sprite.x += 5 @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi) @ball_sprite.angle = - t*63 #if @actor_party_status.active # @actor_party_status.x -= 80 #end Graphics.update if t == 40 @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite) Audio.se_play("Audio/SE/Pokeopen.wav") #if @actor_party_status.active # @actor_party_status.x = 0 # @actor_party_status.visible = false #end break end end @actor_sprite.opacity = 0 @actor_sprite.color = @actor.ball_color until @actor_sprite.zoom_x >= 0.9 @flash_sprite.opacity += 25 @ball_sprite.opacity -= 25 @actor_sprite.zoom_x += 0.1 @actor_sprite.zoom_y += 0.1 @actor_sprite.opacity += 25 Graphics.update end if FileTest.exist?(@actor.cry) Audio.se_play(@actor.cry) end @actor_sprite.zoom_x = 1 @actor_sprite.zoom_y = 1 @actor_sprite.opacity = 255 @actor_status.x = 711 @actor_status.visible = true if @actor.shiny animation = $data_animations[496] @actor_sprite.animation(animation, true) end until @actor_status.x == 311 @background.update @actor_ground.update @enemy_ground.update @actor_status.x -= 20 @actor_sprite.color.alpha -= 25 @flash_sprite.opacity -= 25 @actor_sprite.update Graphics.update end until not(@actor_sprite.effect?) @actor_sprite.update Graphics.update end @actor_status.x = 311 @actor_sprite.color.alpha = 0 @flash_sprite.opacity = 0 @ball_sprite.dispose Graphics.update end def launch_enemy_pokemon @enemy_sprite.x = 464 @enemy_sprite.y = 104 @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2 @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 @enemy_sprite.zoom_x = 0 @enemy_sprite.zoom_y = 0 string = Trainer_Info.type(@trainer_id) + " " + Trainer_Info.name(@trainer_id) draw_text(@enemy.name + " est envoyé", "par " + string + "!") @ball_sprite = Sprite.new @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite) @ball_sprite.ox = @ball_sprite.bitmap.width / 2 @ball_sprite.oy = @ball_sprite.bitmap.height / 2 @ball_sprite.x = 663 @ball_sprite.y = 104 @ball_sprite.z = @z_level + 14 t = 0 pi = 3.14 loop do t += 1 @ball_sprite.x -= 5 @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi) @ball_sprite.angle = - t*63 Graphics.update if t == 40 @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite) Audio.se_play("Audio/SE/Pokeopen.wav") break end end @enemy_sprite.opacity = 0 @enemy_sprite.color = @enemy.ball_color until @enemy_sprite.zoom_x >= 0.9 @flash_sprite.opacity += 25 @ball_sprite.opacity -= 25 @enemy_sprite.zoom_x += 0.08 @enemy_sprite.zoom_y += 0.08 @enemy_sprite.opacity += 25 Graphics.update end if FileTest.exist?(@enemy.cry) Audio.se_play(@enemy.cry) end @enemy_sprite.zoom_x = 1 @enemy_sprite.zoom_y = 1 @enemy_sprite.opacity = 255 @enemy_status.x = -377 @enemy_status.visible = true if @enemy.shiny animation = $data_animations[496] @enemy_sprite.animation(animation, true) end until @enemy_status.x == 23 @background.update @actor_ground.update @enemy_ground.update @enemy_status.x += 20 @enemy_sprite.color.alpha -= 25 @flash_sprite.opacity -= 25 @enemy_sprite.update Graphics.update end until not(@enemy_sprite.effect?) @enemy_sprite.update Graphics.update end @enemy_sprite.x = 464 @enemy_status.x = 23 @enemy_sprite.color.alpha = 0 @flash_sprite.opacity = 0 @ball_sprite.dispose Graphics.update end #------------------------------------------------------------ # Fin de combat #------------------------------------------------------------ def end_battle(result = 0) # Reset des variables et effets $battle_var.reset @actor.skill_effect_reset @actor.reset_stat_stage @actor.cure_state @actor.ability_active = false @enemy.skill_effect_reset @enemy.reset_stat_stage @enemy.cure_state @enemy.ability_active = false # ----------------------------------- Audio.me_stop wait(10) $game_system.bgm_play($game_temp.map_bgm) wait(10) Graphics.freeze # ----------------------------------- if $game_temp.battle_proc != nil $game_temp.battle_proc.call(result) $game_temp.battle_proc = nil end # Défaite $scene = Scene_Map.new end def end_battle_flee(expulsion = false) $battle_var.result_flee = true $game_system.se_play($data_system.escape_se) if expulsion draw_text(@actor.given_name, "est expulsé du combat!") loop do if @actor_sprite.x > -160 @actor_sprite.x -= 20 end Graphics.update Input.update if @actor_sprite.x <= -160 wait(40) break end end else draw_text("Vous prenez la fuite!") wait(40) end end_battle(1) end def fail_flee draw_text("Vous ne pouvez pas","vous enfuir!") wait(40) end def end_battle_flee_enemy(expulsion = false) $battle_var.result_flee = true $game_system.se_play($data_system.escape_se) if expulsion draw_text(@enemy.given_name, "est expulsé du combat!") else draw_text(@enemy.given_name + " s'échappe!") end loop do if @enemy_sprite.x < 800 @enemy_sprite.x += 20 end Graphics.update Input.update if @enemy_sprite.x >= 800 wait(40) break end end end_battle(1) end def end_battle_defeat $battle_var.result_defeat = true draw_text("Tous vos Pokémons", "ont été vaincus!") wait(40) $pokemon_party.money /= 2 if not(@lose) if $game_variables[1] == 0 print("Réglez votre point de retour!") else $game_map.setup($game_variables[1]) $game_map.display_x = $game_variables[2] $game_map.display_y = $game_variables[3] $game_player.moveto($game_variables[2], $game_variables[3]) end $game_temp.common_event_id = 2 end $game_temp.map_bgm = $game_map.bgm end_battle(2) end def draw_choice @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig) @command.x = 517 @command.y = 215 loop do Graphics.update Input.update @command.update if Input.trigger?(Input::C) and @command.index == 0 $game_system.se_play($data_system.decision_se) @command.dispose @command = nil Input.update return true end if Input.trigger?(Input::C) and @command.index == 1 $game_system.se_play($data_system.decision_se) @command.dispose @command = nil Input.update return false end end end end #------------------------------------------------------------ # Fenêtre de statut #------------------------------------------------------------ class Pokemon_Battle_Status < Window_Base def initialize(pokemon, enemy, z_level = 15) @enemy = enemy # True / False if @enemy super(23,0,332,116) else super(311,203,341,140) end self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontsmall self.contents.font.size = $fontsmallsize # self.contents.font.bold = true self.opacity = 0 self.z = z_level @pokemon = pokemon refresh end def refresh self.contents.clear level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f normal_color = Color.new(0,0,0,255) if @enemy src_rect = Rect.new(0, 0, 300, 84) bitmap = RPG::Cache.picture("battle_sprite1.png") self.contents.blt(0, 0, bitmap, src_rect, 255) draw_hp_bar(69,45, level) draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color) draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) width_text = self.contents.text_size(@pokemon.name).width + 3 draw_gender(15 + width_text, 15, @pokemon.gender) if $data_pokedex[@pokemon.id][1] src_rect = Rect.new(0, 0, 21, 21) bitmap = RPG::Cache.picture("ballbattlestatus.png") self.contents.blt(27, 45, bitmap, src_rect, 255) end if @pokemon.status != 0 string = "stat" + @pokemon.status.to_s + ".png" src_rect = Rect.new(0, 0, 60, 24) bitmap = RPG::Cache.picture(string) self.contents.blt(9, 42, bitmap, src_rect, 255) end else src_rect = Rect.new(0, 0, 309, 108) bitmap = RPG::Cache.picture("battle_sprite3.png") self.contents.blt(0, 0, bitmap, src_rect, 255) #draw_hp_bar(93,45, level) draw_text(39, 58, 249, $fs, Player.name, 0, normal_color) #draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) string = @pokemon.hp < 0 ? 0 : @pokemon.hp #draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color) if @pokemon.level < 100 level = @pokemon.next_exp.to_f / (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f else level = 0 end #draw_exp_bar(93, 99, 1.0 - level, 192) #width_text = self.contents.text_size(@pokemon.given_name).width + 3 #draw_gender(39 + width_text, 15, @pokemon.gender) if @pokemon.status != 0 string = "stat" + @pokemon.status.to_s + ".png" src_rect = Rect.new(0, 0, 60, 24) bitmap = RPG::Cache.picture(string) self.contents.blt(42, 66, bitmap, src_rect, 255) end end end def exp_refresh level = @pokemon.next_exp.to_f / (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f draw_exp_bar(93, 99, 1.0 - level, 192) end def damage_refresh(info) damage = info[0] if damage == 0 return end for i in 1..damage @pokemon.remove_hp(1) Graphics.update Graphics.update if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead? break end end end def dispose super end def draw_hp_bar(x, y, level, small = false) src_rect = Rect.new(0, 0, 198, 24) bitmap = RPG::Cache.picture("hpbar.png") if small bitmap = RPG::Cache.picture("hpbarsmall.png") end self.contents.blt(x, y, bitmap, src_rect, 255) rect1 = Rect.new(x + 45, y + 6, level*144.to_i, 3) rect2 = Rect.new(x + 45, y + 9, level*144.to_i, 6) if small rect1 = Rect.new(x + 45, y + 6, level*129.to_i, 3) rect2 = Rect.new(x + 45, y + 9, level*129.to_i, 6) end if level < 0.1 color1 = Color.new(170, 70, 70, 255) color2 = Color.new(250, 90, 60, 255) elsif level >= 0.1 and level < 0.5 color1 = Color.new(200, 170, 0, 255) color2 = Color.new(250, 225, 50, 255) else color1 = Color.new(90, 210, 125, 255) color2 = Color.new(110, 250, 170, 255) end self.contents.fill_rect(rect1, color1) self.contents.fill_rect(rect2, color2) end def draw_exp_bar(x, y, level, width) rect1 = Rect.new(x, y, level*192.to_i, 6) self.contents.fill_rect(rect1, Color.new(160, 160, 255, 255)) end def draw_gender(x, y, gender) if gender == 1 rect = Rect.new(0, 0, 18, 33) bitmap = RPG::Cache.picture("Maleb.png") self.contents.blt(x, y, bitmap, rect, 255) end if gender == 2 rect = Rect.new(0, 0, 18, 33) bitmap = RPG::Cache.picture("Femaleb.png") self.contents.blt(x, y, bitmap, rect, 255) end end end #------------------------------------------------------------ # Fenêtre de statut de l'équipe #------------------------------------------------------------ class Pokemon_Battle_Party_Status < Window_Base attr_accessor :battle_order def initialize(party, order, enemy, z_level = 15) @enemy = enemy # True / False @battle_order = order if @enemy super(0-16,63-16,315+32,42+32) else super(325-16, 261-16, 315+32,42+32) end self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 self.z = z_level @party = party refresh end def refresh self.contents.clear src_rect = Rect.new(0, 0, 315, 42) if @enemy bitmap = RPG::Cache.picture("partystatusenemy.png") else bitmap = RPG::Cache.picture("partystatus.png") end self.contents.blt(0, 0, bitmap, src_rect, 255) src_rect = Rect.new(0, 0, 21, 21) if @enemy ball_x = 231 coeff = -1 else ball_x = 63 coeff = 1 end for i in 1..@party.size bitmap = RPG::Cache.picture("ballpartystatus.png") if @party.actors[@battle_order[i-1]].dead? bitmap = RPG::Cache.picture("ballpartystatusko.png") end self.contents.blt(ball_x + coeff*30*(i-1), 3, bitmap, src_rect, 255) end end def reset_position if @enemy self.x = -16 else self.x = 325-16 end refresh end end class Pokemon_Battle_Variable attr_accessor :weather attr_accessor :actor_last_used attr_accessor :enemy_last_used attr_accessor :battle_order attr_accessor :enemy_battle_order attr_accessor :in_battle attr_accessor :actor_last_taken_damage attr_accessor :enemy_last_taken_damage attr_accessor :have_fought #liste des pokémons ayant participé par leur index attr_accessor :enemy_party attr_accessor :action_id attr_accessor :window_index attr_accessor :result_flee attr_accessor :result_win attr_accessor :result_defeat attr_accessor :last_index attr_accessor :round attr_accessor :run_count attr_accessor :money # Weather: [ catégorie, nombre de tours ] # catégorie: 0: Normal, 1: Pluie, 2: Ensoleillé, # 3: Tempête de Sable, 4: Grêle def initialize @weather = [0, 0] @actor_last_used = nil @enemy_last_used = nil @battle_order = (0..5).to_a @enemy_battle_order = (0..5).to_a @in_battle = false @actor_last_taken_damage = 0 @enemy_last_taken_damage = 0 @have_fought = [] @enemy_party = Pokemon_Party.new @action_id = 0 @window_index = 0 @result_flee = false @result_win = false @result_defeat = false @last_index = 0 @round = 0 @run_count = 0 @money = 0 end def reset @weather = [0, 0] @actor_last_used = nil @enemy_last_used = nil @battle_order = (0..5).to_a @enemy_battle_order = (0..5).to_a @in_battle = false @actor_last_taken_damage = 0 @enemy_last_taken_damage = 0 @have_fought = [] @enemy_party = Pokemon_Party.new @action_id = 0 @window_index = 0 @last_index = 0 @round = 0 @run_count = 0 @money = 0 end def reset_weather @weather = [0, 0] end def set_rain(duration = -1) @weather = [1, duration] end def rain? if @weather[0] == 1 return true else return false end end def set_sunny(duration = -1) @weather = [2, duration] end def sunny? if @weather[0] == 2 return true else return false end end def sandstorm? if @weather[0] == 3 return true else return false end end def set_sandstorm(duration = -1) @weather = [3, duration] end def hail? if @weather[0] == 4 return true else return false end end def set_hail(duration = -1) @weather = [4, duration] end def battle_end? if @result_flee or @result_win or @result_defeat return true else return false end end def add_money(amount) if @money == nil @money = 0 end @money += amount end end end |
Code: |
#============================================================================== # ■ Pokemon_Battle_Core # Pokemon Script Project - Krosk # 26/07/07 # Pokemon_Battle_Core_Safari # Therand - 01/2015 #----------------------------------------------------------------------------- # Scène à ne pas modifier de préférence #----------------------------------------------------------------------------- # Système de Combat - Pokémon Sauvage du parc safari # Composantes de programmation des réactions du pokémon sauvage face à # vos actions (BALL, APPAT, CAILLOU et FUITE). #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Vous pouvez modifier ici les réactions du pokémon sauvage # (mange l'appat, est furieux, ...) # Elle doivent ensuite etre incluse dans la BDD, dans des attaques comportant # l'id secondaire indiqué ici. #----------------------------------------------------------------------------- module POKEMON_S #------------------------------------------------------------ # Pokemon_Battle_Core_Safari # scene #------------------------------------------------------------ class Pokemon_Battle_Core_Safari #------------------------------------------------------------ # Détail du déroulement - Actions pré-round #------------------------------------------------------------ # Vérification saut de phase # Force l'utilisateur à continuer à attaquer # 0x27 # Two_turn attack # 0x2A # Multi-turn attack # 0x4B # Two_turn attack # 0x50 # Two_turn reverse # 0x75 # Roulade # 0x9F # Brouhaha / Uproar # 0x1A # Patience / Bide # 0x1B # Mania / Thrash #------------------------------------------------------------ def phase_jump(enemy = false) list = [0x27, 0x2A, 0x4B, 0x50, 0x75, 0x9F, 0x1A, 0x1B, 0x91, 0x97, 0x9B0, 0x9B1, 0x9B2, 0x9B3] if not(enemy) # Actor for effect in @actor.effect_list if list.include?(effect) @actor_skill = $battle_var.actor_last_used @phase = 2 return true end end return false elsif enemy for effect in @enemy.effect_list if list.include?(effect) @enemy_skill = $battle_var.enemy_last_used return false end end return true end end #------------------------------------------------------------ # Interdictions de switcher #------------------------------------------------------------ def switch_able(actor, enemy) # Arena Trap / Piege (ab) if enemy.ability == 71 return false end # Effets appliqués au user empêchant la fuite list = [0x1A, 0x1B, 0x6A, 0x9F, 0xB5] for effect in actor.effect_list if list.include?(effect) return false end end # Effets appliqués à l'ennemi empêchant la fuite list = [0x2A] for effect in enemy.effect_list if list.include?(effect) return false end end # Shadow Tag / Marque Ombre (ab) // Magnepiece / Magnet Pull (ab) if enemy.ability == 23 or (enemy.ability == 42 and enemy.type_steel?) draw_text("#{enemy.ability_name} de #{enemy.given_name}", "empêche le changement!") wait(40) return false end return true end #------------------------------------------------------------ # Capacité de fuite #------------------------------------------------------------ def run_able?(runner, opponent) x = (Integer(opponent.spd/4) / 255.0) rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count)) if not(flee_able(runner, opponent)) return false end if opponent.spd <= runner.spd return true elsif x == 0 return true elsif rate > 255 return true elsif rand(256) <= rate return true else return false end end #------------------------------------------------------------ # Interdictions de fuire #------------------------------------------------------------ def flee_able(actor, enemy) # Run away / Fuite (ab) if actor.ability == 50 return true end # Arena Trap / Piege (ab) if enemy.ability == 71 return false end list = [0x6A, 0xB5] for effect in actor.effect_list if list.include?(effect) return false end end # Shadow Tag / Marque Ombre (ab) // Magnepiece / Magnet Pull (ab) if enemy.ability == 23 or (enemy.ability == 42 and enemy.type_steel?) draw_text("#{enemy.ability_name} de #{enemy.given_name}", "empêche la fuite!") wait(40) return false end return true end #------------------------------------------------------------ # Vérification saut de phase de sélection d'attaque # Force l'utilisateur à utiliser la même attaque #------------------------------------------------------------ def attack_selection_jump for effect in @actor.effect_list case effect when 0x5A # Encore return true when 0x1A # Patience / Bide return true when 0x1B # Mania / Thrash return true end end return false end #------------------------------------------------------------ # Détail du déroulement - Round #------------------------------------------------------------ # Pré-actions , Actions #------------------------------------------------------------ def attack_action(user, user_skill, enemy) #------------------------------------------------------------ # Target , Sprite definition #------------------------------------------------------------ # Target target_id = user_skill.target if target_id == 0 or target_id == 4 or target_id == 8 or target_id == 20 #Opposants target = enemy elsif target_id == 10 target = user # Défini la cible comme l'acteur end # Assignation sprite et informations if user == @actor user_sprite = @actor_sprite user_status = @actor_status user_last_skill = $battle_var.actor_last_used user_last_taken_damage = $battle_var.actor_last_taken_damage elsif user == @enemy user_sprite = @enemy_sprite user_status = @enemy_status user_last_skill = $battle_var.enemy_last_used user_last_taken_damage = $battle_var.enemy_last_taken_damage end if target == @actor target_sprite = @actor_sprite target_status = @actor_status target_last_skill = $battle_var.actor_last_used target_last_taken_damage = $battle_var.actor_last_taken_damage elsif target == @enemy target_sprite = @enemy_sprite target_status = @enemy_status target_last_skill = $battle_var.enemy_last_used target_last_taken_damage = $battle_var.enemy_last_taken_damage end #------------------------------------------------------------ # Status Check #------------------------------------------------------------ # Sommeil if user.asleep? if user.sleep_check and not(user.effect_list.include?(0x9F)) # Uproar draw_text("#{user.given_name}", "dort!") status_animation(user_sprite, user.status) wait(40) # Attaques actives au sommeil # Sleep_talk/Snore non affecté par le sommeil if not([0x61, 0x5C].include?(user_skill.effect)) return end else user_status.refresh draw_text("#{user.given_name}", "se réveille!") wait(40) end end # Frozen if user.frozen? if user.froze_check if user_skill.effect == 0x7D # Defrost move user.cure user_status.refresh draw_text("#{user.given_name}", "dégèle!") wait(40) else draw_text("#{user.given_name}", "est gelé!") status_animation(user_sprite, user.status) wait(40) return end else user_status.refresh draw_text("#{user.given_name}", "dégèle!") wait(40) end end # Two turn reverse case user_skill.effect when 0x50 # Two turn reverse if user.effect_list.include?(0x50) # Déjà attaqué draw_text("#{user.given_name}", "doit recharger!") wait(40) return end end # Truant / Absentéisme (ab) if user.ability == 54 if user.ability_token == nil user.ability_token = false end if user.ability_token == true draw_text("#{user.given_name}", "paresse!") wait(40) return end end # Flinch if user.flinch? draw_text("#{user.given_name}", "est appeuré!") status_animation(user_sprite, 7) user.flinch_check wait(40) return end # Confuse if user.confused? if user.state_count > 0 draw_text("#{user.given_name}", "est confus!") status_animation(user_sprite, 6) condition = user.confuse_check if condition == true draw_text("#{user.given_name}" + " se blesse", "dans sa confusion.") damage = user.confuse_damage self_damage(user, user_sprite, user_status, damage) wait(40) return end elsif user.state_count == 0 draw_text("#{user.given_name}", "n'est plus confus!") user.cure_state wait(40) end end # Paralyze if user.paralyzed? if user.paralysis_check draw_text("#{user.given_name} est paralysé!", "Il ne peut pas attaquer!") status_animation(user_sprite, user.status) wait(40) return end end #------------------------------------------------------------ # Effets pré-accuracy_check et programmation des attaques #------------------------------------------------------------ pp_use = true jumper_end = false case user_skill.effect when 0x1A # Bide / Patience index = user.effect_list.index(0x1A) if user.effect_list.include?(0x1A) and [4,5].include?(user.status) user.effect.delete_at(index) # Supprime si endormi ou gelé end if not(user.effect_list.include?(0x1A)) draw_text("#{user.given_name}", "patiente...") wait(40) turn = rand(2) + 3 user.skill_effect(0x1A, turn, 0) jumper_end = true elsif user.effect[index][1] >= 2 # Encore en charge draw_text("#{user.given_name} patiente...") wait(40) pp_use = false jumper_end = true else pp_use = false # Changement de cible! if user == @actor target = @enemy target_sprite = @enemy_sprite target_status = @enemy_status elsif user == @enemy target = @actor target_sprite = @actor_sprite target_status = @actor_status end end when 0x1B # Thrash / Mania index = user.effect_list.index(0x1B) if user.effect_list.include?(0x1B) and [4,5].include?(user.status) user.effect.delete_at(index) # Supprime si endormi ou gelé end if not(user.effect_list.include?(0x1B)) turn = rand(2) + 2 user.skill_effect(0x1B, turn) pp_use = true else pp_use = false end when 0x27 # Razor wind / Coupe-Vent / Two turn atk if not(user.effect_list.include?(0x27)) # not(Déjà préparé) user.skill_effect(0x27, 2) draw_text("#{user.given_name} se prépare!") jumper_end = true wait(40) elsif user.effect_list.include?(0x27) pp_use = false index = user.effect_list.index(0x27) user.effect.delete_at(index) end when 0x4B # Pique/Sky attack / TTA if not(user.effect_list.include?(0x4B)) # not(Déjà préparé) user.skill_effect(0x4B, 2) draw_text("#{user.given_name} se concentre!") wait(40) jumper_end = true elsif user.effect_list.include?(0x4B) index = user.effect_list.index(0x4B) user.effect.delete_at(index) pp_use = false end when 0x91 # Skull Bash / Coud krane / TTA if not(user.effect_list.include?(0x91)) user.skill_effect(0x91, 2) draw_text("#{user.given_name} se prépare!") wait(40) n = user.change_dfe(+1) raise_stat("DFE", user, n) jumper_end = true elsif user.effect_list.include?(0x91) index = user.effect_list.index(0x91) user.effect.delete_at(index) pp_use = false end when 0x97 # Solarbeam / Lance-Soleil if $battle_var.sunny? and not(user.effect_list.include?(0x97)) # Sunny # Continue et lance l'attaque elsif not(user.effect_list.include?(0x97)) user.skill_effect(0x97, 2) draw_text("#{user.given_name} se charge!") wait(40) jumper_end = true elsif user.effect_list.include?(0x97) pp_use = false index = user.effect_list.index(0x97) user.effect.delete_at(index) end when 0x9B0 # Tunnel / Dig if not(user.effect_list.include?(0x9B0)) # not(Déjà préparé) user.skill_effect(0x9B0, 2) draw_text("#{user.given_name} creuse!") wait(40) jumper_end = true else index = user.effect_list.index(0x9B0) user.effect.delete_at(index) pp_use = false end when 0x9B1 # Fly / Vol if not(user.effect_list.include?(0x9B1)) # not(Déjà préparé) user.skill_effect(0x9B1, 2) draw_text("#{user.given_name} s'envole!") wait(40) jumper_end = true else index = user.effect_list.index(0x9B1) user.effect.delete_at(index) pp_use = false end when 0x9B2 # Rebond / Bounce if not(user.effect_list.include?(0x9B2)) # not(Déjà préparé) user.skill_effect(0x9B2, 2) draw_text("#{user.given_name} saute!") wait(40) jumper_end = true else index = user.effect_list.index(0x9B2) user.effect.delete_at(index) pp_use = false end when 0x9B3 # Dive / Plongée if not(user.effect_list.include?(0x9B3)) # not(Déjà préparé) user.skill_effect(0x9B3, 2) draw_text("#{user.given_name} plonge!") wait(40) jumper_end = true else pp_use = false index = user.effect_list.index(0x9B3) user.effect.delete_at(index) end end # Spécial dernier skill utilisé if user_last_skill != nil case user_last_skill.effect when 0xB3 # Wish / Souhait user.skill_effect(0xB3, 1) end end for effect in user.effect case effect[0] when 0x51 # Rage / Frénésie # Fin du bonus if user_skill.effect != 0x51 user.change_atk(-effect[2]) user.effect.delete(effect) end when 0x5A # Encore user_skill = user.skills_set[effect[2]] when 0x62 # Prélevement destin / Destiny Bond # Suppression état index = user.effect.index(effect) user.effect.delete_at(index) when 0x75 # Rollout/roulade pp_use = false when 0x9F # Uproar / Brouhaha pp_use = false when 0x78 # Attract if rand(2) == 1 draw_text("#{user.given_name}est amoureux!") wait(40) return end when 0xC2 # Grudge index = user.effect.index(effect) user.effect.delete_at(index) end end #------------------------------------------------------------ # Utilisation de l'attaque #------------------------------------------------------------ # PP spent if pp_use user_skill.use if user == @actor $battle_var.actor_last_used = user_skill user_last_skill = $battle_var.actor_last_used draw_text(Player.name + " utilise", "#{user_skill.name}!") wait(10) elsif user == @enemy $battle_var.enemy_last_used = user_skill user_last_skill = $battle_var.enemy_last_used #draw_text("#{user.given_name} utilise", "#{user_skill.name}!") draw_text("") wait(10) end end # Pressure / Pression if pp_use and target.ability == 46 and target == enemy and user_skill.pp > 0 user_skill.use end if jumper_end return end # Redéfinition des derniers skills utilisés user_last_skill = user_skill #------------------------------------------------------------ # Décision Hit Miss #------------------------------------------------------------ # Accuracy check n = accuracy_check(user_skill, user, target) #weather, status... # Accuracy stage # si la cible n'est pas soi meme (10), ou OHKO (0x26), pas de vérif if user_skill.target != 10 or user.effect != 0x26 n = Integer(n*accuracy_stage(user, target)) end # Hit or miss if rand(100) < n hit = true else hit = false end multi_hit = 1 # Nombre de coups total_hit = 1 # miss: indicateur que l'attaque touche l'adversaire mais inefficace # "Mais cela échoue!" miss = false #------------------------------------------------------------ # Effets pré-attaque et programmation des attaques #------------------------------------------------------------ # ( zone détermination de la précision / touche ou pas ) #------------------------------------------------------------ # Comparaison préliminaire pour les skills "copieurs" case user_skill.effect when 0x09 # Mirror move / Mimique / Condition de validité unlist = [0x52,0x09,0x39,0x53,0x5F,0x61,0x6D,0x70,0xC7,0xB4,0x8F,0x94,0xAA,0xAD,0xB2] if target_last_skill == nil or user_last_taken_damage == 0 miss = true elsif target_last_skill.target == 10 or unlist.include?(target_last_skill.effect) miss = true else user_skill = target_last_skill.clone user_skill.enable user_skill.refill end when 0x52 # Copie / Mimic list = [102, 166, 118, 165] for skill in user.skills_set list.push(skill.id) end # Conditions de validité: ne copie pas la luste ni lorsqu'il y a Morphing if target_last_skill == nil miss = true elsif list.include?(target_last_skill.id) or user.effect_list.include?(0x39) miss = true end when 0x53 # Metronome / Condition de validité list = [0x53,0x52,0x59,0x90,0x6F,0x74,0x62,0x61,0x69,0xAC,0xC3,0xB0,0xB1,0xAA] until not(list.include?(user_skill.effect) or user_skill.id == 165) # Tant que le skill copié est interdit user_skill = POKEMON_S::Skill.new(rand($data_skills_pokemon.length)+1) end when 0x61 # Sleep talk list = [] for i in 0..@target.skills_set.size - 1 list.push(i) end list.shuffle! copied_skill = target.skills_set[list.shift] until copied_skill.usable? and not([0x1A, 0x61, 0xB4, 0x09, 0x52, 0xAA, 0x9F, 0x27, 0x4B, 0x91, 0x97, 0x9B].include?(copied_skill.effect)) copied_skill = target.skills_set[list.shift] end user_skill = copied_skill when 0xB4 # Assist / Assitance no = [0x53,0x52,0x59,0x90,0x6F,0x74,0x62,0x61,0x69,0xAC,0xC3,0xB0,0xB1,0xAA,0xB4] list = [] copied_skill = user_skill if user == @actor for pokemon in @party.actors for skill in pokemon.skills_set list.push(skill.clone) end end list.shuffle! copied_skill = list.shift until not(no.include?(copied_skill)) # Jusqu'a que le skill copié est interdit copied_skill = list.shift end elsif user == @enemy for skill in user.skills_set list.push(skill.clone) end list.shuffle! copied_skill = list.shift until not(no.include?(copied_skill)) # Jusqu'à que le skill copié est interdit copied_skill = list.shift end end user_skill = copied_skill end case user_skill.effect # --------- ---------- -------- # Conditions de touche # --------- ---------- -------- when 0x11 # Hit without fail hit = true when 0x4D # Fatal Throw / Corps perdu #Hit without fail hit = true when 0x98 # Thunder if $battle_var.rain? hit = true end when 0x1D # Random Multi_hit number = rand(8) case number when 0 multi_hit = 5 when 1 multi_hit = 4 end if [2,3,4].include?(number) multi_hit = 3 elsif [5,6,7].include?(number) multi_hit = 2 end total_hit = multi_hit when 0x2C # Double Strike multi_hit = 2 total_hit = 2 when 0x4D # Twineedle / Double Dard multi_hit = 2 total_hit = 2 when 0x68 # Triple pied / Triple Kick multi_hit = 3 total_hit = 3 # --------- ---------- -------- # Conditions de foirage # --------- ---------- -------- when 0x07 # Self destruct et Damp / Moiteur (ab) if target.ability == 6 draw_text("#{target.ability_name} de #{target.given_name}", "empêche l'auto-destruction.") wait(40) return end if user.ability == 6 draw_text("#{user.ability_name} de #{user.given_name}", "empêche l'auto-destruction.") wait(40) return end when 0x20 # Heal 1/2 if user.hp == user.max_hp miss = true end when 0x23 # Light screen / Mur Lumière if user.effect_list.include?(0x23) miss = true end when 0x25 if user.hp == user.max_hp or user.asleep? miss = true end when 0x2E # Mist if user.effect_list.include?(0x2E) miss = true end when 0x41 # Reflect/ Reflet if user.effect_list.include?(0x41) miss = true end when 0x5C # Ronflement / Snore if not(user.asleep?) miss = true end when 0x7C # Rune Protect / Safeguard if user.effect_list.include?(0x7C) miss = true end when 0x39 # Transform / Morphing if target.effect_list.include?(0x39) miss = true end when 0x54 # Vampigraine / Leech seed # Fail if grass or already infected if [target.type1, target.type2].include?(5) miss = true end if user.effect_list.include?(0x54) miss = true end when 0x56 # Entrave / Disable # Conditions de miss # Skill invalide ou non possédé if target_last_skill == nil or target.skills_set.index(target_last_skill) == nil miss = true elsif target.effect_list.include?(0x56) or target_last_skill.pp == 0 miss = true end when 0x59 # Riposte / Counter # Conditions de miss if target_last_skill == nil or user_last_taken_damage == 0 miss = true elsif not(target_last_skill.physical) miss = true end when 0x64 # Depit / Spite if target_last_skill != nil if target_last_skill.pp <= 1 or target.skills_set.include?(target_last_skill) miss = true end else miss = true end when 0x6A # Regard noir / Mean Look if target.effect_list.include?(0x6A) miss = true end when 0x6B # Nightmare if not(target.asleep?) or target.effect_list.include?(0x6B) miss = true end when 0x6D # Curse / Malédiction if target.effect_list.include?(0x6D) miss = true end when 0x6F # Abri / Detection if user.effect_list.include?(0x6F) index = user.effect_list.index(0x6F) used = user.effect[index][2] + 1 rate = rand(2**16) if rate > (2**16) / used miss = true end end when 0x74 # Endure / Tenacité if user.effect_list.include?(0x74) index = user.effect_list.index(0x74) used = user.effect[index][2] + 1 rate = rand(2**16) if rate > (2**16) / used miss = true end end when 0x78 # Attract if target.effect_list.include?(0x78) or (target.gender + user.gender) != 3 miss = true end if target.ability == 12 # Benet / Oblivious (ab) draw_text("#{target.ability_name} de #{target.given_name}", "l'empêche d'être amoureux.") wait(40) return end when 0x90 # Voile miroir / Mirror Coat # Conditions de miss if not(target_last_skill.special) or user_last_taken_damage == 0 miss = true end when 0x5A # Encore if target_last_skill == nil miss = true elsif target_last_skill.pp == 0 or not(target.skills_set.include?(target_last_skill)) or [165, 227, 119].include?(target_last_skill.id) miss = true elsif target.effect_list.include?(0x5A) or user.effect_list.include?(0x5A) miss = true end when 0x5F # Gribouille / Sketch if [166, 165].include?(target_last_skill.id) or user.skills.include?(target_last_skill.id) miss = true end when 0x8E # Cognobidon / Belly drum if user.hp <= (user.max_hp / 2) or user.atk_stage >= 6 miss = true end when 0xA5 # Torment / Tourmente index = target.skills_set.index(target_last_skill) if index == nil miss = true end when 0xBA # Brick Break if hit target.effect.delete(target.effect.rassoc("0x41")) target.effect.delete(target.effect.rassoc("0x23")) end when 0xBB # Yawn if target.status != 0 or target.effect_list.include?(0x7C) miss = true end when 0xB5 if user.effect_list.include?(0xB5) miss = true end when 0xB1 # Trick if user.item_hold == 0 and target.item_hold == 0 miss = true end when 0x1E # Conversion / Adaptation # Si il existe un skill qui est valide list = [] for skill in user.skills_set list.push(skill.type) end list.delete(user.type1) list.delete(user.type2) list.delete(0) # Curse / Malédiction if list.length == 0 miss = true end when 0xB3 # Wish / Souhait if user.effect_list.include?(0xB3) miss = true end when 0xC9 # Mud Sport if user.effect_list.include?(0xC9) miss = true end when 0xD2 # Water Sport if user.effect_list.include?(0xD2) miss = true end when 0x99 # Teleport # Arena Trap / Piege (ab) // Run away / Fuite (ab) if enemy.ability == 71 and user.ability != 50 draw_text("#{target.ability_name} de #{target.given_name}", "empêche la fuite.") wait(40) return end # Magnet Pull / Magnepiege (ab) // Run away / Fuite (ab) if enemy.ability == 42 and user.type_steel? and user.ability != 50 draw_text("#{enemy.ability_name} de #{enemy.given_name}", "empêche la fuite.") wait(40) return end # Shadow Tag / Marque ombre (ab) // Run away / Fuite (ab) if enemy.ability == 23 and user.ability != 50 draw_text("#{enemy.ability_name} de #{enemy.given_name}", "empêche la fuite.") wait(40) return end end #------------------------------------------------------------ # Attaque #------------------------------------------------------------ # #------------------------------------------------------------ # Multi_hit until multi_hit == 0 multi_hit -= 1 #------------------------------------------------------------ # Programmation des attaques et effets de statut #------------------------------------------------------------ critical_special = 0 # Skill Effect case user_skill.effect when 0x2B # Good chance of critical_hit critical_special = 1 when 0x4B # Pique/Sky attack / TTA critical_special = 1 when 0x68 # Triple Kick / Triple Pied if not(user.effect_list.include?(0x68)) user.skill_effect(0x68, 1, 0) else index = user.effect_list.index(0x68) user.effect[index][2] += 1 # Accuracy check à chaque coup n = accuracy_check(user_skill, user, target) n = Integer(n*accuracy_stage(user, target)) if rand(100) <= n hit = true else hit = false end end when 0xC8 # Blaze Kick critical_special = 1 when 0xD1 # Poison Tail critical_special = 1 end # User effect for effect in user.effect case effect[0] when 0x2F # Focus energy critical_special = 2 when 0xA5 # Torment index = user.skills_set.index(user_last_skill) user.skills_set[index].disable skill_index = effect[2] user.skills_set[skill_index].enable # new index = index du skill bloqué new_index = user.skills_set.index(user_last_skill) effect[2] = new_index end end #------------------------------------------------------------ # Détermination des dommages #------------------------------------------------------------ info = damage_calculation(user_skill, user, target, critical_special) # Animation d'attaque attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite) # Invincibilité if $game_temp.god_mode hit = false end if hit and not(miss) # Damage deal to target damage = info[0] efficiency = info[2] #------------------------------------------------------------ # Effets attaque et programmation des attaques #------------------------------------------------------------ case user_skill.effect # ----------------- -------------- --------------- # Dommages Pré-déterminés / Utilisateur # ----------------- -------------- --------------- when 0x26 # OHKO if damage > 0 # Affecté par les immunités damage = target.hp end when 0x28 # Super Fang if damage > 0 # Affecté par les immunités damage = target.hp / 2 end when 0x29 # Draco-rage if damage > 0 damage = 40 end when 0x57 # Frappe Atlas if damage > 0 damage = user.level end when 0x58 # Vague Psy if damage > 0 damage = Integer( user.level * (rand(11) * 10 + 50) / 100 ) end when 0x59 # Counter / Riposte if damage > 0 damage = user_last_taken_damage * 2 end when 0x90 # Voile Miroir / Mirror Coat if damage > 0 damage = user_last_taken_damage * 2 end when 0x65 # False Swipe if target.hp - damage <= 0 damage = target.hp - 1 end when 0x7A # Cadeau . gift number = rand(256) gift = false if number < 26 damage = 120 elsif number < 102 damage = 80 elsif number < 204 damage = 40 else damage = 0 gift = true end when 0x82 # Sonic boom if damage > 0 damage = 20 end when 0xBD # Endeavor if damage > 0 damage = target.hp - user.hp end when 0x1A # Bide / Patience if damage > 0 index = user.effect_list.index(0x1A) damage = user.effect[index][2] * 2 end end # ----------------- -------------- --------------- # Dommages Pré-déterminés / Adversaire # ----------------- -------------- --------------- for effect in target.effect_list case effect when 0x6F # Abri / Detection index = target.effect_list.index(0x6F) ind = target.effect[index][1] if damage > 0 and ind == 2 damage = 0 draw_text("#{target.given_name}", "est protégé!") wait(40) return end when 0x74 # Endure/Tenacité index = target.effect_list.index(0x74) ind = target.effect[index][1] if target.hp - damage <= 0 and ind == 2 damage = target.hp - 1 draw_text("#{target.given_name}tient le coup!") wait(40) end end end # ----------------- -------------- --------------- # Capacités spéciales # ----------------- -------------- --------------- case target.ability when 10 # Absorb Volt / Volt Absorb (ab) if user_skill.type_electric? and damage > 0 damage = 0 bonus = target.max_hp / 4 heal(target, target_sprite, target_status, bonus) draw_text("#{target.ability_name} de #{target.given_name}", "restaure les PV.") wait(40) end when 11 # Absorb Eau / Water Absorb (ab) if user_skill.type_water? and damage > 0 damage = 0 bonus = target.max_hp / 4 heal(target, target_sprite, target_status, bonus) draw_text("#{target.ability_name} de #{target.given_name}", "restaure les PV.") wait(40) end when 18 # Torche / Flash Fire (ab) if user_skill.type_fire? and not(target.ability_active) damage = 0 target.ability_active = true draw_text("#{target.ability_name} de #{target.given_name}", "s'active!") wait(40) end when 25 # Garde Mystik / Wonder Guard (ab) if efficiency == 1 damage = 0 draw_text("#{target.ability_name} de #{target.given_name}", "le protège!") wait(40) end when 26 # Levitate (ab) if user_skill.type_ground? damage = 0 draw_text("#{target.ability_name} de #{target.given_name}", "le protège!") wait(40) end end effective_damage = 0 # Dommages for i in 1..damage effective_damage += 1 target.remove_hp(1) target_status.refresh if target.max_hp >= 144 and effective_damage % (target.max_hp / 144 + 1) != 0 next end Graphics.update Graphics.update if target.dead? # Loyauté target.drop_loyalty break end end damage = effective_damage # Redéfinition des derniers points de dommage infligés if user == @actor #and damage != 0 $battle_var.enemy_last_taken_damage = damage elsif user == @enemy #and damage != 0 $battle_var.actor_last_taken_damage = damage end # Multi_hit if target.dead? total_hit -= multi_hit multi_hit = 0 end #------------------------------------------------------------ # Effets post-attaque et programmation des attaques #------------------------------------------------------------ # Effectiveness if multi_hit == 0 post_attack(info, damage, user_skill.power) end # --------------------------- --------------------------------- # Détermination de l'application de l'effet supplémentaire # --------------------------- --------------------------------- ec_rate = rand(101) effect_applied = ec_rate <= user_skill.effect_chance # Serene Grace / Sérenité (ab) if user.ability == 32 effect_applied = ec_rate <= (user_skill.effect_chance * 2) end # --------------------------- --------------------------------- # Prise en compte du pourcentage de chance que l'effet s'active # Si l'ennemi est mort ou pas mort # --------------------------- --------------------------------- if ((user_skill.effect_chance != 0 and effect_applied) or user_skill.effect_chance == 0) case user_skill.effect # ----------------- -------------- ------------------- # Dommages/Récupération Post-attaques / Utilisateur # ----------------- -------------- ------------------ when 0x07 # Self_destruct rec_damage = user.hp self_damage(user, user_sprite, user_status, rec_damage) draw_text("#{user.given_name}", "se sacrifie.") wait(40) when 0x08 # Devoreve / Dream eater bonus = damage / 2 if damage > 0 and bonus == 0 bonus = 1 end if target.ability != 64 # Liquid ooze / Suintement (ab) heal(user, user_sprite, user_status, bonus) draw_text("L'énergie du #{target.given_name}", "est draînée.") wait(40) else self_damage(user, user_sprite, user_status, bonus) draw_text("#{target.ability_name} de #{target.given_name}", "réduit les PV.") wait(40) end when 0x30 # Recoil recoil_damage = damage / 4 if damage > 0 and recoil_damage == 0 recoil_damage = 1 end # Head Rock / Tete de rock (ab) // Struggle if user.ability != 69 or user_skill.id == 165 self_damage(user, user_sprite, user_status, recoil_damage) draw_text("#{user.given_name} se blesse", "en frappant.") wait(40) end when 0xC6 # Recoil recoil_damage = damage / 3 if damage > 0 and recoil_damage == 0 recoil_damage = 1 end # Head Rock / Tete de rock (ab) // Struggle if user.ability != 69 or user_skill.id == 165 self_damage(user, user_sprite, user_status, recoil_damage) draw_text("#{user.given_name} se blesse", "en frappant.") wait(40) end when 0x03 # Leech bonus = damage / 2 if damage > 0 and bonus == 0 bonus = 1 end heal(user, user_sprite, user_status, bonus) draw_text("L'énergie du #{target.given_name}", "est draînée.") wait(40) when 0x20 # Heal bonus = user.max_hp / 2 heal(user, user_sprite, user_status, bonus) draw_text("#{"#{user.given_name}"}", "se soigne!") wait(40) when 0x25 # Rest / Repos status_check(target, 4, true) target_status.refresh target.status_count = 3 # Dort pour 2 tours seulement bonus = user.max_hp heal(user, user_sprite, user_status, bonus) draw_text("#{user.given_name} a regagné", "son énergie.") wait(40) # Les 3 réactions du pokémon sauvage au parc safari # Ces actions sont complementaire aux attaques (id secondaire BDD) # La réaction à l'appat when 0x12c #300 draw_text("#{user.given_name}", "mange l'appat!") wait(40) # on calcul la chance de fuite if @decision_safari <= (@enemy.spd / 2) scene = end_battle_flee_enemy end # Le skill paisible est exécuté dans Battle_Safari, car on ne # demande pas une réaction "verbale" du pokémon sauvage # quand il est neutre (suite à une capture raté par exemple). # Si vous souhaitez en mettre une, ceci est fait pour vous when 0x12d #301 draw_text("#{user.given_name}", "est paisible...") wait(40) if @decision_safari <= (@enemy.spd * 2) scene = end_battle_flee_enemy end # Réaction au caillou when 0x12e #302 draw_text("#{user.given_name}", "est furieux!") wait(40) if @decision_safari <= (@enemy.spd * 4) scene = end_battle_flee_enemy end when 0x5B # Balance / Pain Split middle = (user.hp + target.hp)/2 user_diff = middle - user.hp heal(user, user_sprite, user_status, user_diff) target_diff = middle - target.hp heal(target, target_sprite, target_status, target_diff) when 0x7A # Cadeau if gift bonus = target.hp / 4 heal(target, target_sprite, target_status, bonus) end draw_text("Surprise!") wait(40) when 0x84 # Morning sun / Aurore weather = $battle_var.weather[0] case weather when 1 # Rainy bonus = user.max_hp / 4 when 2 # Sunny bonus = user.max_hp * 2 / 3 when 3 #Sandstorm bonus = user.max_hp / 4 when 4 # Hail bonus = user.max_hp / 4 when 0 bonus = user.max_hp / 2 end heal(user, user_sprite, user_status, bonus) when 0x85 # Synthesis / Synthese weather = $battle_var.weather[0] case weather when 1 # Rainy bonus = user.max_hp / 4 when 2 # Sunny bonus = user.max_hp * 2 / 3 when 3 #Sandstorm bonus = user.max_hp / 4 when 4 # Hail bonus = user.max_hp / 4 when 0 bonus = user.max_hp / 2 end heal(user, user_sprite, user_status, bonus) when 0x86 # Rayon Lune weather = $battle_var.weather[0] case weather when 1 # Rainy bonus = user.max_hp / 4 when 2 # Sunny bonus = user.max_hp * 2 / 3 when 3 #Sandstorm bonus = user.max_hp / 4 when 4 # Hail bonus = user.max_hp / 4 when 0 bonus = user.max_hp / 2 end heal(user, user_sprite, user_status, bonus) when 0x8E # Belly drum / Cognobidon damage = user.max_hp / 2 self_damage(user, user_sprite, user_status, damage) when 0xA2 # Avale bonus = 0 if user.effect_list.include?(0xA0) index = user.effect_list.index(0xA0) case user.effect[index][2] when 1 bonus = user.max_hp / 4 when 2 bonus = user.max_hp / 2 when 3 bonus = user.max_hp end end heal(user, user_sprite, user_status, bonus) # ----------------- -------------- ------------------- # Autres # ----------------- -------------- ------------------ when 0x26 # OHKO draw_text("K.O. en un coup!") wait(40) when 0x50 # Two_turn reverse user.skill_effect(0x50, 2) when 0x1D # Multihit if multi_hit == 0 draw_text("#{target.given_name}", "est touché #{total_hit.to_s} fois!") wait(40) else draw_text("... #{(total_hit - multi_hit).to_s} fois...") end end end faint_check(user) # --------------------------- --------------------------------- # Prise en compte du pourcentage de chance que l'effet s'active # Si l'ennemi n'est pas mort # --------------------------- --------------------------------- if ((user_skill.effect_chance != 0 and effect_applied) or user_skill.effect_chance == 0) and not(target.dead?) and (user_skill.power == 0 or (user_skill.power > 0 and efficiency != -2)) and # Cas d'une attaque dégat sans être efficace not(target.ability == 19 and user_skill.effect_chance > 0) # Ecran Poudre / Shield Dust (ab) # ----------------- -------------- --------------- # Utilisateur # ----------------- -------------- --------------- case user_skill.effect # ----------------- -------------- --------------- # Stage Effect # ----------------- -------------- --------------- when 0x0A n = target.change_atk(+1) raise_stat("ATK", target, n) when 0x0B n = target.change_dfe(+1) raise_stat("DFE", target, n) when 0x0D n = target.change_ats(+1) raise_stat("ATS", target, n) when 0x10 n = target.change_eva(+1) raise_stat("EVA", target, n) when 0x12 n = target.change_atk(-1) reduce_stat("ATK", target, n) when 0x13 n = target.change_dfe(-1) reduce_stat("DFE", target, n) when 0x14 n = target.change_spd(-1) reduce_stat("SPD", target, n) when 0x17 n = target.change_acc(-1) reduce_stat("ACC", target, n) when 0x18 n = target.change_eva(-1) reduce_stat("EVA", target, n) when 0x32 n = target.change_atk(+2) raise_stat("ATK", target, n) when 0x33 n = target.change_dfe(+2) raise_stat("DFE", target, n) when 0x34 n = target.change_spd(+2) raise_stat("SPD", target, n) when 0x35 n = target.change_ats(+2) raise_stat("ATS", target, n) when 0x36 n = target.change_dfs(+2) raise_stat("DFS", target, n) when 0x3A n = target.change_atk(-2) reduce_stat("ATK", target, n) when 0x3B n = target.change_dfe(-2) reduce_stat("DFE", target, n) when 0x3C n = target.change_spd(-2) reduce_stat("SPD", target, n) when 0x3E n = target.change_dfs(-2) reduce_stat("DFS", target, n) when 0x44 n = target.change_atk(-1) reduce_stat("ATK", target, n) when 0x45 n = target.change_dfe(-1) reduce_stat("DFE", target, n) when 0x46 n = target.change_spd(-1) reduce_stat("SPD", target, n) when 0x47 n = target.change_ats(-1) reduce_stat("ATS", target, n) when 0x48 n = target.change_dfs(-1) reduce_stat("DFS", target, n) when 0x49 n = target.change_acc(-1) reduce_stat("ACC", target, n) when 0x6C target.skill_effect(0x6C) draw_text("#{target.given_name} est tout", "petit!") wait(40) n = target.change_eva(+1) raise_stat("EVA", target, n) when 0x76 # Swagger n = target.change_atk(+2) raise_stat("ATK", target, n) status_check(target, 6) target_status.refresh when 0xA6 # Flatter n = target.change_ats(+1) raise_stat("ATS", target, n) status_check(target, 6) target_status.refresh when 0x8A n = user.change_dfe(+1) raise_stat("DFE", user, n) when 0x8B n = user.change_atk(+1) raise_stat("ATK", user, n) when 0x8C # Ancient power n = user.change_atk(+1) raise_stat("ATK", user, n) n = user.change_dfe(+1) raise_stat("DFE", user, n) n = user.change_spd(+1) raise_stat("SPD", user, n) n = user.change_ats(+1) raise_stat("ATS", user, n) n = user.change_dfs(+1) raise_stat("DFS", user, n) when 0x8E # Belly / Drum Cognobion n = user.change_atk(+12) raise_stat("ATK", user, n) when 0xA8 # Memento n = target.change_atk(-2) reduce_stat("ATK", target, n) n = target.change_ats(-2) reduce_stat("ATS", target, n) damage = user.hp self_damage(user, user_sprite, user_status, damage) when 0xB6 # Superpower n = user.change_atk(-1) reduce_stat("ATK", user, n, true) n = user.change_dfe(-1) reduce_stat("DFE", user, n, true) when 0xCC # Overheat / Psycho Boost n = user.change_ats(-2) reduce_stat("ATS", user, n, true) when 0xCD # Tickle n = target.change_atk(-1) reduce_stat("ATK", target, n) n = target.change_dfe(-1) reduce_stat("DFE", target, n) when 0xCE # Cosmic Power n = user.change_dfe(+1) raise_stat("DFE", user, n) n = user.change_dfs(+1) raise_stat("DFS", user, n) when 0xD0 # Bulk Up n = user.change_atk(+1) raise_stat("ATK", user, n) n = user.change_dfe(+1) raise_stat("DFE", user, n) when 0xD3 # Calm Mind n = user.change_ats(+1) raise_stat("ATS", user, n) n = user.change_dfs(+1) raise_stat("DFS", user, n) when 0xD4 # Dragon Dance n = user.change_atk(+1) raise_stat("ATK", user, n) n = user.change_spd(+1) raise_stat("SPD", user, n) when 0x8F # Psych Up / Boost user.atk_stage = target.atk_stage user.dfe_stage = target.dfe_stage user.spd_stage = target.spd_stage user.ats_stage = target.ats_stage user.dfs_stage = target.dfs_stage user.acc_stage = target.acc_stage user.eva_stage = target.eva_stage draw_text("#{user.given_name} copie les stats", "de "+ "#{target.given_name}"+"!") wait(40) when 0x6D # Malédiction / Curse if not(user.type_ghost?) # Non-ghost n = user.change_spd(-1) reduce_stat("SPD", user, n, true) n = user.change_atk(+1) raise_stat("ATK", user, n) n = user.change_dfe(+1) raise_stat("DFE", user, n) elsif user.type_ghost? draw_text("#{user.given_name} maudit", "#{target.given_name}!") wait(40) damage = user.max_hp / 2 self_damage(user, user_sprite, user_status, damage) target.skill_effect(0x6D) end when 0x19 # Haze / Buée Noire user.reset_stat_stage enemy.reset_stat_stage raise_stat(0, target) # ----------------- -------------- --------------- # Déroulement du combat # ----------------- -------------- --------------- when 0x1C # Expulsion du combat if target.ability == 21 # Ventouse / Suction cups (ab) draw_text("#{target.ability_name} de #{target.given_name}", "l'empêche d'être expulsé.") wait(40) else if target == @enemy end_battle_flee_enemy(true) elsif target == @actor end_battle_flee(true) end end when 0x73 # Weather / sandstorm $battle_var.set_sandstorm(5) draw_text("Une tempête de sable", "se lève...") animation = $data_animations[494] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end wait(20) when 0x88 # Weather / Rain dance $battle_var.set_rain(5) draw_text("Il commence à pleuvoir.") animation = $data_animations[493] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end wait(20) when 0x89 # weather / sunny $battle_var.set_sunny(5) draw_text("Le soleil brille.") animation = $data_animations[492] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end wait(20) when 0xA4 # Hail / Grele $battle_var.set_hail(5) draw_text("Il commence à grêler.") animation = $data_animations[495] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end wait(20) when 0x99 # Teleport if user == @actor end_battle_flee else end_battle_flee_enemy end # ----------------- -------------- --------------- # Attaques particulières # ----------------- -------------- --------------- when 0x55 # Trempette draw_text("Mais rien ne se passe...") wait(40) when 0x64 # Dépit/Spite amount = rand(4)+2 string1 = " a perdu #{amount.to_s} PP!" draw_text(target_last_used.name, string1) wait(40) target_last_used.pp -= amount when 0x7E # Magnitude / Ampleur draw_text("Séisme de magnitude...", "#{info[3].to_s}!") wait(40) when 0x69 # Thief / Larcin if target.ability == 60 draw_text("#{target.ability_name} de #{target.given_name}", "empêche le vol d'objet!") wait(40) elsif user.item_hold == 0 and target.item_hold != 0 user.item_hold = target.item_hold target.item_hold = 0 draw_text("#{user.given_name} vole ", "#{user.item_name}!") wait(40) end when 0xB1 # Trick if target.ability == 60 draw_text("#{target.ability_name} de #{target.given_name}", "empêche le vol d'objet!") wait(40) elsif not(user.item_hold == 0 and target.item_hold == 0) hold = user.item_hold user.item_hold = target.item_hold target.item_hold = hold if user.item_hold == 0 string = "et ne reçoit rien!" else string = "et reçoit #{user.item_name}!" end draw_text("#{user.given_name} échange les objets", string) wait(40) end when 0xBC # Knock Off if target.hp > 0 and target.item_hold != 0 draw_text("#{target.given_name} lâche ", Item.name(target.item_hold) + "!") target.item_hold = 0 wait(40) end when 0x22 # Pay Day / Jackpot draw_text("#{target.given_name} lâche de l'argent!") $battle_var.add_money(5*target.level) # ----------------- -------------- --------------- # Modificateur de status # ----------------- -------------- --------------- # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, # 4:Sommeil, 5:Gelé; 6: Confus, 7: Flinch, 8:Toxic when 0x01 # Sleep status_check(target, 4) target_status.refresh when 0x02 # Poison status_check(target, 1) target_status.refresh when 0x04 # Burn status_check(target, 3) target_status.refresh when 0x05 # Freeze status_check(target, 5) target_status.refresh when 0x06 # Paralyze status_check(target, 2) target_status.refresh when 0x1F # Flinch status_check(target, 7) target_status.refresh when 0x21 # Toxic status_check(target, 8) target_status.refresh when 0xCA # Toxic status_check(target, 8) target_status.refresh when 0x31 # Confuse status_check(target, 6) target_status.refresh when 0xC7 # Confuse status_check(target, 6) target_status.refresh when 0x24 # Triplattaque status_check(target, [2,3,5][rand(3)]) target_status.refresh when 0x42 # Poison (sur) status_check(target, 1) target_status.refresh when 0x43 # Paralyze (affected by immunity) status_check(target, 2) target_status.refresh when 0x4C # Confuse status_check(target, 6) target_status.refresh when 0x4D # Poison/Double dar status_check(target, 1) target_status.refresh when 0x5C # Flinch for Snore/Ronflement status_check(target, 7) target_status.refresh when 0x7D # Defrost move status_check(target, 3) target_status.refresh when 0x92 # Twister / Ouragan status_check(target, 7) target_status.refresh when 0x96 # Flinch status_check(target, 7) target_status.refresh when 0x98 # Thunder / paralyze status_check(target, 2) target_status.refresh when 0x9B2 # Bounce / Rebond status_check(target, 2) target_status.refresh #index = user.effect_list.index(0x9B2) #user.effect.delete_at(index) when 0xA7 # Burn status_check(target, 3) target_status.refresh when 0xC8 # Burn status_check(target, 3) target_status.refresh when 0xD1 # Poison Tail status_check(target, 1) target_status.refresh when 0x66 # Glas de soin / Heal Bell / Aromatherapy user.cure if user == @actor draw_text("L'équipe est soignée!") wait(40) @party.cure_party end when 0xAB # smelling salt if user.paralyzed? user.cure user_status.refresh end when 0xC1 # Refresh if user.paralyzed? or user.burn? or user.poisoned? user.cure user_status.refresh end when 0x1B # Confuse - Mania / Thrash index = user.effect_list.index(0x1B) if not(user.confused?) and user.effect[index][1] == 1 status_check(user, 6) user_status.refresh end # ----------------- -------------- --------------- # Modificateur d'effets sur la durée # ----------------- -------------- --------------- when 0x1E # Conversion / Adaptation list = [] for i in 0..user.skills_set.length-1 list.push(i) end list.shuffle! chosen_type = user.skills_set[list.pop].type until chosen_type != 0 and not([user.type1, user.type2].include?(chosen_type)) chosen_type = user.skills_set[list.pop].type end user.skill_effect(0x1E, -1, chosen_type) string = type_string(chosen_type) + "!" draw_text("#{user.given_name} est", "maintenant de type " + string) wait(40) when 0x23 # Light screen / Mur Lumière target.skill_effect(0x23, 5) draw_text("#{user.given_name}", "est protégé!") wait(40) when 0x2A # Multi Turn Attack if not(user.effect_list.include?(0x2A)) turn = rand(4) + 3 user.skill_effect(0x2A, turn) draw_text("#{target.given_name} est","piégé par " + user_skill.name+"!") wait(40) end when 0x54 # Leech Seed / Vampigraine user.skill_effect(0x54) draw_text("#{target.given_name}", "est infecté!") wait(40) when 0x70 # Picots / Spikes when 0x2F # Focus energy / Puissance user.skill_effect(0x2F) draw_text("#{user.given_name}", "se gonfle!") wait(40) when 0x2E # Brume / Mist user.skill_effect(0x2E, 5) draw_text("#{user.given_name} s'entoure", "de brume!") wait(40) when 0x39 # Transform / Morphing if user.effect_list.include?(0x56) # Cure Disable / Entrave index = user.effect_list.index(0x56) skill_index = user.effect[index][2] user.skills_set[skill_index].enable end set = [] for skill in target.skills_set adskill = skill.clone adskill.define_ppmax(5) adskill.refill adskill.enable set.push(adskill) end data = user.clone user.skill_effect(0x39, -1, data) draw_text("#{user.given_name}", "se métamorphose!") if user == @actor @actor.skills_set = set @actor.transform_effect(target) @actor_sprite.bitmap = RPG::Cache.battler(@enemy.battler_back, 0) @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height #@actor_sprite.tone = Tone.new(200,0,200,180) else @enemy.skills_set = set @enemy.transform_effect(target) @enemy_sprite.bitmap = RPG::Cache.battler(@actor.battler_face, 0) #@enemy_sprite.tone = Tone.new(200,0,200,180) end wait(40) when 0x41 # Reflect / Protection target.skill_effect(0x41, 5) draw_text("#{user.given_name}", "est protégé!") wait(40) when 0x4B # Sky attack / TTA status_check(target, 7) target_status.refresh when 0x51 # Frénésie / Rage if not(user.effect_list.include?(0x51)) user.skill_effect(0x51, -1, 0) end when 0x52 # Copie / Mimic cloned_skill = target_last_skill.clone cloned_skill.define_ppmax(5) cloned_skill.refill user.skill_effect(0x52, -1, [user_skill.clone, cloned_skill]) index = user.skills_set.index(user_skill) user.skills_set[index] = cloned_skill draw_text("#{user.given_name} copie", cloned_skill.name+"!") wait(40) when 0x56 # Disable / Entrave index = target.skills_set.index(target_last_skill) if index != nil target.skill_effect(0x56, rand(4) + 2, index) target.skills_set[index].disable draw_text(target.skills_set[index].name+" est bloqué!") wait(40) end when 0x5A # Encore index = target.skills_set.index(target_last_skill) target.skill_effect(0x5A, rand(4) + 3, index) when 0x5E # Lock-on / Verrouillage user.skill_effect(0x5E, 2) draw_text("#{user.given_name} cible #{target.given_name}!") wait(40) when 0x5F # Gribouille // Sketch index = user.skills_set.index(user_last_skill) user.skills_set[index] = target_last_skill draw_text("#{user.given_name} a copié", target_last_skill.name+"!") wait(40) when 0x62 # Prélèvement destin / Destiny Bond user.skill_effect(0x62, 2) draw_text("#{user.given_name} lie son" , "destin.") wait(40) when 0x6A # Regard Noir / Mean Look target.skill_effect(0x6A) draw_text("#{target.given_name}", "ne peut plus fuir!") wait(40) when 0x6B # Cauchemar/Nightmare target.skill_effect(0x6B) draw_text("#{target.given_name} fait des" , "cauchemars!") wait(40) when 0x6F # Abri / Détection if user.effect_list.include?(0x6F) index = user.effect_list.index(0x6F) effect = user.effect[index] effect[1] = 2 effect[2] += 1 else user.skill_effect(0x6F, 2, 1) end draw_text("#{user.given_name}", "se protège!") wait(40) when 0x72 # Requiem / Perish Song if not(user.effect_list.include?(0x72)) user.skill_effect(0x72, 4) end if not(enemy.effect_list.include?(0x72)) enemy.skill_effect(0x72, 4) end draw_text("Une chanson déprimante.") wait(40) when 0x71 # Clairvoyance / Fore Sight target.skill_effect(0x71, -1) draw_text("#{user.given_name} identifie ", "#{target.given_name}.") wait(40) when 0x74 # Tenacité/Endure if user.effect_list.include?(0x74) index = user.effect_list.index(0x74) effect = user.effect[index] effect[1] = 2 effect[2] += 1 else user.skill_effect(0x74, 1) end draw_text("#{user.given_name} résiste!") wait(40) when 0x75 # Roulade/Rollout if not(user.effect_list.include?(0x75)) user.skill_effect(0x75, 5, 5) elsif damage > 0 index = user.effect_list.index(0x75) user.effect[index][2] -= 1 elsif damage == 0 index = user.effect_list.index(0x75) user.effect.delete_at(index) end when 0x77 # Taillade / Fury Cutter if not(user.effect_list.include?(0x77)) user.skill_effect(0x77, -1, -1) elsif damage > 0 index = user.effect_list.index(0x77) user.effect[index][2] -= 1 end when 0x78 # Attract target.skill_effect(0x78) draw_text("#{target.given_name} tombe amoureux", "de #{user.given_name}"+"!") wait(40) when 0x7C # Safeguard / Rune protect target.skill_effect(0x7C, 5) draw_text("#{target.given_name}", "est protégé!") wait(40) when 0x81 # Rapid Spin / Tour rapide list = [0x54, 0x70, 0x2A] for effect in list if target.effect_list.include?(effect) index = target.effect_list.index(effect) target.effect.delete_at(index) draw_text("#{user.given_name}", "se libère!") wait(40) end end when 0x9C # Defense Curl / Boul'Armure n = user.change_dfe(+1) raise_stat("DFE", user, n) user.skill_effect(0x9C) when 0x9F # Uproar / Brouhaha turn = rand(3)+3 user.skill_effect(0x9F, turn) draw_text("#{user.given_name}", "fait un BROUHAHA!") wait(40) when 0xA0 # Stockpile if user.effect_list.include?(0xA0) index = user.effect_list.index(0xA0) case user.effect[index][2] when 1 user.effect[index][2] = 2 draw_text("#{user.given_name}", "se charge!") wait(40) when 2 user.effect[index][2] = 3 draw_text("#{user.given_name}", "se charge!") wait(40) end if user.effect[index][2] > 3 draw_text("#{user.given_name}", "est chargé à bloc!") wait(40) end else user.skill_effect(0xA0, -1, 1) draw_text("#{user.given_name}", "se charge!") wait(40) end when 0xA1 # Spit up / Relache if user.effect_list.include?(0xA0) index = user.effect_list.index(0xA0) user.effect.delete_at(index) end when 0xA2 # Swallow / Avale if user.effect_list.include?(0xA0) index = user.effect_list.index(0xA0) user.effect.delete_at(index) end when 0xA5 # Tourment index = target.skills_set.index(target_last_skill) target.skill_effect(0xA5, -1, index) target.skills_set[index].disable draw_text("#{target.given_name}", "est tourmenté!") wait(40) when 0xAE # Charge / Chargeur if user.effect_list.include?(0xAE) index = user.effect_list.index(0xAE) user.effect.delete_at(index) end user.skill_effect(0xAE, 2) draw_text("#{user.given_name}", "est chargé!") wait(40) when 0xAF # Taunt / Provoc target.skill_effect(0xAF, 2) draw_text("#{user.given_name} cède à la", "provocation!") wait(40) when 0xB5 # Ingrain / Racines user.skill_effect(0xB5) draw_text("#{user.given_name}" , "est enraciné!") wait(40) when 0xBB # Yawn target.skill_effect(0xBB, 2) draw_text("#{user.given_name}" , "baîlle!") wait(40) when 0xC2 # Grudge / Rancune user.skill_effect(0xC2, 2) draw_text("#{user.given_name}" , "est rancunier! (?)") wait(40) when 0xC9 # Mud Sport user.skill_effect(0xC9) draw_text("#{user.given_name}" , "est couvert de boue!") wait(40) when 0xD2 # Water Sport user.skill_effect(0xD2) draw_text("#{user.given_name}" , "est mouillé! ... ...") wait(40) end end # ----------------- -------------- ------------------- # Contrôle des effets adverses / Adversaire # ----------------- -------------- ------------------ for effect in target.effect_list case effect when 0x62 # Prélèvement destin / Destiny Bond if target.dead? damage = user.hp draw_text("#{target.given_name}", "est lié par le destin.") self_damage(user, user_sprite, user_status, damage) wait(40) faint_check(user) end when 0xC2 # Grudge if target.dead? and not(user.dead?) user_skill.pp = 0 end when 0x1A # Bide / Patience index = target.effect_list.index(0x1A) target.effect[index][2] += damage when 0x51 # Frénésie / Rage if damage > 0 and multi_hit == 0 # Compte une seule fois index = target.effect_list.index(0x51) target.change_atk(+1) target.effect[index][2] += 1 end end end faint_check(target) # ----------- ---------------- -------------- # Capacités spéciales # ----------- ---------------- -------------- case target.ability when 28 # Synchro (ab) if target.ability_token != nil draw_text("#{target.ability_name} de #{target.given_name}", "inflige le même statut!") wait(40) status_check(user, target.ability_token, true) user_status.refresh target.ability_token = nil end when 16 # Déguisement / Color change (ab) type = user_skill.type if [user.type1, user.type2].include?(type) and type != 0 and type != user.ability_token and damage > 0 user.ability_token = type string = type_string(type) draw_text("#{target.ability_name} de #{target.given_name}", "change le type en " + string + "!") wait(40) end when 9 # Static (ab) # Contact + dommages + 30% chance # force? if user_skill.direct? and damage > 0 and rand(100) < 30 draw_text("#{target.ability_name} de #{target.given_name}", "paralyse #{user.given_name}!") wait(40) status_check(user, 2, true) user_status.refresh wait(40) end when 24 # Peau dure / Rough skin (ab) if user_skill.direct? and damage > 0 draw_text("#{target.ability_name} de #{target.given_name}", "blesse #{user.given_name}!") rec_damage = user.max_hp / 16 self_damage(user, user_sprite, user_status, rec_damage) wait(40) end when 27 # Pose Spore / Effect Spore (ab) # Contact + dommages + 10% chance # force? if user_skill.direct? and damage > 0 and rand(100) < 10 draw_text("#{target.ability_name} de #{target.given_name}", "laisse des spores!") wait(40) status_check(user, [1, 2, 4][rand(3)], true) user_status.refresh wait(40) end when 38 # Point poison / Poison point (ab) # Contact + dommages + 30% chance # force? if user_skill.direct? and damage > 0 and rand(100) < 30 draw_text("#{target.ability_name} de #{target.given_name}", "empoisonne #{user.given_name}!") wait(40) status_check(user, 1, true) user_status.refresh wait(40) end when 49 # Corps ardent / Flame body (ab) # Contact + dommages + 30% chance # force? if user_skill.direct? and damage > 0 and rand(100) < 30 draw_text("#{target.ability_name} de #{target.given_name}", "brûle #{user.given_name}!") wait(40) status_check(user, 3, true) user_status.refresh wait(40) end when 56 # Joli sourire / Cute charm (ab) # Contact + dommages + 30% chance # force? if user_skill.direct? and damage > 0 and rand(100) < 30 and not(target.effect_list.include?(0x78) or (target.gender + user.gender) != 3) user.skill_effect(0x78) draw_text("#{target.ability_name} de #{target.given_name}", "séduit #{user.given_name}!") wait(40) end end faint_check(target) else #------------------------------------------------------- # Miss #-------------------------------------------------------- case user_skill.effect when 0x07 # Self_destruct rec_damage = user.hp self_damage(user, user_sprite, user_status, rec_damage) draw_text("#{user.given_name}","se sacrifie.") wait(40) faint_check(user) when 0x2D # Miss and self_damage damage = info[0] rec_damage = damage/2 draw_text("#{user.given_name}","retombe au sol!") self_damage(user, user_sprite, user_status, rec_damage) wait(30) faint_check(user) when 0x68 # Triple Kick multi_hit = 0 #Arret si échec when 0x9B2 # Bounce / Rebond if user.effect_list.include?(0x9B2) index = user.effect_list.index(0x9B2) user.effect.delete_at(index) end when 0x75 # Roulade/Rollout if user.effect_list.include?(0x75) index = user.effect_list.index(0x75) user.effect.delete_at(index) end end end #------------------------------------------------------- # Réduction compteur d'effets ? #-------------------------------------------------------- # user.skill_effect_end_turn user_status.refresh target_status.refresh end end #------------------------------------------------------------ # Gestion des dêgats automatique en combat # Skill utilisé sur l'adversaire # Dommages Infligés - user_skill = class Skill, enemy = class Pokemon # Renvoie: [damage, critical (true/false), efficency (-2, -1,0,1)] #------------------------------------------------------------ def damage_calculation(user_skill, user, target, critical_special = 0, shortcut = false) critical_hit = critical_decision(critical_special) level = user.level statistic_refresh user.statistic_refresh if user_skill.physical atk = (critical_hit and user.atk_stage < 0) ? user.atk_basis : user.atk dfe = (critical_hit and target.dfe_stage > 0) ? target.dfe_basis : target.dfe elsif user_skill.special atk = (critical_hit and user.ats_stage < 0) ? user.ats_basis : user.ats dfe = (critical_hit and target.dfs_stage > 0) ? target.dfs_basis : target.dfs else atk = (critical_hit and user.atk_stage < 0) ? user.atk_basis : user.atk dfe = (critical_hit and target.dfe_stage > 0) ? target.dfe_basis : target.dfe end base_damage = user_skill.power user_type1 = user.type1 user_type2 = user.type2 skill_type = user_skill.type target_type1 = target.type1 target_type2 = target.type2 weather = $battle_var.weather[0] # ------------- -------------- --------------- # Programmation des objets # ------------- -------------- --------------- # Boosts de type # ------------- -------------- --------------- case user.item_name when "MOUCH.SOIE" atk *= user_type1 == 1 ? 1.1 : 1 when "CHARBON" atk *= user_type1 == 2 ? 1.1 : 1 when "EAU MYSTIQUE" atk *= user_type1 == 3 ? 1.1 : 1 when "AIMANT" atk *= user_type1 == 4 ? 1.1 : 1 when "GRAIN MIRACL" atk *= user_type1 == 5 ? 1.1 : 1 when "GLACETERNEL" atk *= user_type1 == 6 ? 1.1 : 1 when "CEINT.NOIRE" atk *= user_type1 == 7 ? 1.1 : 1 when "PIC VENIN" atk *= user_type1 == 8 ? 1.1 : 1 when "SABLE DOUX" atk *= user_type1 == 9 ? 1.1 : 1 when "BEC POINTU" atk *= user_type1 == 10 ? 1.1 : 1 when "CUILLERTORDU" atk *= user_type1 == 11 ? 1.1 : 1 when "POUDRE ARG." atk *= user_type1 == 12 ? 1.1 : 1 when "PIERRE DURE" atk *= user_type1 == 13 ? 1.1 : 1 when "RUNE SORT" atk *= user_type1 == 14 ? 1.1 : 1 when "CROC DRAGON" atk *= user_type1 == 15 ? 1.1 : 1 when "PEAU METAL" atk *= user_type1 == 16 ? 1.1 : 1 when "LUNET.NOIRES" atk *= user_type1 == 17 ? 1.1 : 1 end # ------------- -------------- --------------- # Programmation des attaques # ------------- -------------- --------------- # Redéfinition base_damage (puissance) # ------------- -------------- --------------- data = nil case user_skill.effect when 0x07 # Self_destruct dfe = dfe / 2 when 0x63 # Base damage variant a = user.hp * 48.0 / user.max_hp if a >= 33 base_damage = 20 elsif a >= 17 base_damage = 40 elsif a >= 10 base_damage = 80 elsif a >= 5 base_damage = 100 elsif a >= 2 base_damage = 150 elsif a < 2 base_damage = 200 end when 0x7E # Magnitude / Ampleur a = rand(100) if a < 5 data = 4 base_damage = 10 elsif a < 15 data = 5 base_damage = 30 elsif a < 35 data = 6 base_damage = 50 elsif a < 65 data = 7 base_damage = 70 elsif a < 85 data = 8 base_damage = 90 elsif a < 95 data = 9 base_damage = 110 else data = 10 base_damage = 150 end when 0x68 # Triple Kick/Triple Pied if user.effect_list.include?(0x68) index = user.effect_list.index(0x68) base_damage += 10 * user.effect[index][2] end when 0x75 # Rollout / Roulade # Bonus cumulatif if user.effect_list.include?(0x75) index = user.effect_list.index(0x75) base_damage *= (5-user.effect[index][1])**2 end # Defense Curl/Boul'Armure bonus if user.effect_list.include?(0x9C) base_damage *= 2 end when 0x77 # Fury Cutter / Taillade if user.effect_list.include?(0x77) index = user.effect_list.index(0x77) multiplier = - user.effect[index][1] if multiplier < 5 base_damage *= multiplier**2 elsif multiplier >= 5 base_damage *= 5**2 end end when 0x79 # Return / Retour base_damage = user.loyalty * 10 / 25 when 0x7B # Frustration base_damage = (255 - user.loyalty) * 10 / 25 when 0xBE # Base damage basé sur hp base_damage = [1, user.hp * 150 / user.max_hp].max when 0xC4 # Low Kick string = Pokemon_Info.weight(target.id) weight = string[0..string.length-2].to_f if weight < 10 base_damage = 20 elsif weight < 25 base_damage = 40 elsif weight < 50 base_damage = 60 elsif weight < 100 base_damage = 80 elsif weight < 200 base_damage = 100 else base_damage = 120 end end # --------- --------------- ---------- # Protections adverses # --------- --------------- ---------- for effect in target.effect_list case effect when 0x9B0 # Dig / Tunnel upx2 Magnitude / Earthquake if [0x7E, 0x93].include?(user_skill.effect) base_damage *= 2 end when 0x9B1 # Vol / Fly upx2 if [0x95, 0x98, 0x92].include?(user_skill.effect) base_damage *= 2 end when 0x9B2 # Bounce upx2 if [0x95, 0x98, 0x92].include?(user_skill.effect) base_damage *= 2 end when 0x9B3 # Dive + Surf if user_skill.id == 15 base_damage *= 2 end when 0x1E # Conversion / Adaptation index = target.effect_list.index(0x1E) target_type1 = target.effect[index][2] target_type2 = 0 end end # --------- --------------- ---------- # Bonus Capacités Spéciales # --------- --------------- ---------- case user.ability when 18 # Flash Fire / Torche (ab) if user.ability_active and user_skill.type_fire? base_damage *= 1.5 end when 37 # Huge Power / Coloforce (ab) if user_skill.physical atk *= 2 end when 74 # Pure Power / Fore pure (ab) if user_skill.physical atk *= 2 end when 55 # Agitation / Hustle (ab) if user_skill.physical atk *= 1.5 end when 57 # Plus (ab) if target.ability == 58 and user_skill.special # Minus atk *= 1.5 end when 58 # Minus (ab) if target.ability == 57 and user_skill.special # Minus atk *= 1.5 end when 62 # Cran / Guts (ab) if user.status != 0 and user_skill.physical atk *= 1.5 end when 65 # Overgrow / Engrais (ab) if user.hp < (user.max_hp/3) and user_skill.type_grass? base_damage *= 1.5 end when 66 # Brasier / Blaze (ab) if user.hp < (user.max_hp/3) and user_skill.type_fire? base_damage *= 1.5 end when 67 # Torrent (ab) if user.hp < (user.max_hp/3) and user_skill.type_water? base_damage *= 1.5 end when 68 # Essaim / Swarm (ab) if user.hp < (user.max_hp/3) and user_skill.type_insect? base_damage *= 1.5 end end case target.ability when 47 # Thick Fat / Isograisse (ab) if user_skill.type_fire? or user_skill.type_ice? atk /= 2 end when 59 # Meteo / Forecast (ab) if target.ability_token == nil target.ability_token = 1 # Normal end target_type1 = target.ability_token target_type2 = 0 when 16 # Déguisement / Color Change (ab) if target.ability_token == nil target.ability_token = 1 end target_type1 = target.ability_token target_type2 = 0 when 63 # Marvel Scale / Ecaille Spe (ab) if target.status != 0 and user_skill.physical dfe *= 1.5 end end # --------- --------------- ---------- --------------- # Dommages infligés et calculs coefficients # --------- --------------- ---------- --------------- pre_damage = (((level*2/5.0+2)*base_damage*atk/dfe)/50) multiplier = 1 # Effets de la météo # Airlock / Cloud Nine (ab) if not([13, 77].include?(user.ability) or [13, 77].include?(target.ability)) if ($battle_var.sunny? and skill_type == 2) or ($battle_var.rain? and skill_type == 3) # Ensoleillé + Feu ou Pluie + Eau multiplier *= 1.5 end if ($battle_var.sunny? and skill_type == 3) or ($battle_var.rain? and skill_type == 2) # Ensoleillé + Eau ou Pluie + Feu multiplier *= 0.5 end # Météo - Lance_Soleil / Solarbeam en cas de mauvais temps if user_skill.effect == 0x97 and [1, 3, 4].include?(weather) multiplier *= 0.5 end end # Conversion / Adaptation if user.effect_list.include?(0x1E) index = user.effect_list.index(0x1E) user_type1 = user.effect[index][2] user_type2 = 0 end # Forecast / Meteo (ab) // Déguisement / Color Change (ab) if user.ability == 59 or user.ability == 16 user_type1 = user.ability_token user_type2 = 0 end # Bonus même type if skill_type == user_type1 or skill_type == user_type2 multiplier *= 1.5 end # Weather Ball / Ball'Meteo if user_skill.effect == 0xCB case weather when 1 # Pluie skill_type = 3 # Eau when 2 # Sunny skill_type = 2 # Feu when 3 # Tempete Sable skill_type = 13 # Roche when 4 # Hail skill_type = 6 # Glace end end # Complément statut # Brulure // Guts / Cran (ab) // Facade if user.status == 3 and user_skill.physical and not(user.ability == 62) and user_skill.effect != 0xA9 multiplier *= 0.5 end # ------------------ ---------- # Programmation des attaques # ------------------ ----------- # Protections et malus adverses for effect in target.effect_list case effect when 0x23 # Mur Lumière / Light Screen if user_skill.special and not(critical_hit) multiplier *= 0.5 end when 0x41 # Reflet / Reflect if user_skill.physical and not(critical_hit) multiplier *= 0.5 end when 0xAE # Charge / Chargeur if skill_type == 4 multiplier *= 2 end when 0xC9 # Mud Sport / Lance-Boue if skill_type == 4 multiplier *= 0.5 end when 0xD2 # Water Sport / Tourniquet if skill_type == 2 multiplier *= 0.5 end when 0x6C # Minimize / Lilliput if user_skill.effect == 0x96 multiplier *= 2 end when 0x71 # Clairvoyance / Foresight if [1, 7].include?(skill_type) and [target_type1, target_type2].include?(14) skill_type = 0 end end end # Bonus efficacité du type // Struggle / Lutte rate = element_rate(target_type1, target_type2, skill_type) if user_skill.id != 165 multiplier *= rate/100.0 end # Etude efficacité if rate > 100.0 # Super efficace efficiency = 1 elsif rate < 100.0 and rate > 0 # Pas très efficace efficiency = -1 elsif rate == 0 # Innefficace efficiency = -2 elsif rate == 100.0 # Normal efficiency = 0 end # Propriétés attaque case user_skill.effect when 0xA1 # Relache / Stockage // Spit up / Stockpile if user.effect_list.include?(0xA0) index = user.effect_list.index(0xA0) multiplier *= user.effect[index][2] damage = pre_damage * multiplier return [Integer(damage), false, efficiency] end when 0xA9 # Facade if [1,2,3].include?(user.status) multiplier *= 2 end when 0xAB # Smelling Salt / Stimulant if target.status == 2 multiplier *= 2 end end # Armurbaston / Battle Armor (ab) // Coque armure / Shell Armor (ab) if target.ability == 4 or target.ability == 75 critical_hit = false end # Calcul IA if shortcut return base_damage * multiplier end # Damage weight multiplier *= (100 - rand(15)) / 100.0 if critical_hit multiplier *= 2 end # Minimum dommage damage = pre_damage * multiplier if damage < 1 and damage > 0 damage = 1 end return [Integer(damage), critical_hit, efficiency, data] end #------------------------------------------------ # Calcul de précision #------------------------------------------------ def accuracy_check(user_skill, user, target) #actor: user n = user_skill.accuracy # ------------- ------------------ -------------------- # Attaques self-cible, buff # ------------- ------------------- ------------------- if user == target return n = 100 end # ------------- ------------------ -------------------- # Capacités spéciales # ------------- ------------------- ------------------- case target.ability when 8 # Voile Sable / Sand Veil (ab) if $battle_var.sandstorm? n *= 0.8 end end case user.ability when 14 # Compoundeyes / Oeil Composé (ab) n *= 1.3 when 55 # Hustle / Agitation (ab) if user_skill.physical n *= 0.8 end end for effect in user.effect_list case effect when 0x5E # Verrouillage / Lock-on return n = 100 end end # ------------- ------------------ -------------------- # Attaques intouchables # ------------- ------------------- ------------------- for effect in target.effect_list case effect when 0x9B0 # Tunnel if not([0x7E, 0x93, 0x26].include?(user_skill.effect) and user_skill.type == 9) return n = 0 end when 0x9B1 # Vol / Flying if not([0xCF, 0x92, 0x95, 0x98].include?(user_skill.effect) or user_skill.id == 18) return n = 0 end when 0x9B2 # Bounce / Rebond if not([0xCF, 0x92, 0x95, 0x98].include?(user_skill.effect) or user_skill.id == 18) return n = 0 end when 0x9B1 # Dive / Plongée if not([57, 250].include?(user_skill.id)) return n = 0 end end end case user_skill.effect # ------------- ------------------ -------------------- # Attaques réussites sous certaines conditions # ------------- ------------------- ------------------- when 0x26 # OHKO if target.ability == 5 # Fermeté / Sturdy (ab) return n = 0 end if user.level > target.level return n += (user.level - target.level) else return n = 0 end when 0x08 # Dream eater / Devorêve if not(target.asleep?) return n = 0 end when 0x1C # Whirlwind, Roar number = rand(256) if number*(user.level + target.level)/256 + 1 == target.level/4 return n = 0 end when 0x98 # Thunder if $battle_var.sunny? # Soleil return n = 50 end end # ------------- ------------------ -------------------- # Attaques à précision nulle # ------------- ------------------- ------------------- if n == 0 return n = 100 end return n end # ----------- -------------- ------------- -------- # Fonction détermination des coups critiques # ----------- -------------- ------------- -------- def critical_decision(critical_special = 0) rate = 0 rate += critical_special case rate when 0 critical_chance = rand(15) when 1 critical_chance = rand(7) when 2 critical_chance = rand(3) when 3 critical_chance = rand(2) end if rate >= 4 critical_chance = rand(1) end if critical_chance == 0 return true else return false end end #------------------------------------------------------------ # Taux de résultat aux dégâts #------------------------------------------------------------ def element_rate(target_type1, target_type2, skill_type) result = 100.0 if $data_table_type[target_type1][skill_type] != nil result = result * $data_table_type[target_type1][skill_type] else print("Erreur : vérifiez la table des types, case #{target_type1} #{skill_type}") end if $data_table_type[target_type2][skill_type] != nil result = result * $data_table_type[target_type2][skill_type] else print("Erreur : vérifiez la table des types, case #{target_type2} #{skill_type}") end return result end #------------------------------------------------------------ # Conséquences du switch sur le Pokémon #------------------------------------------------------------ def switch_effect(actor, enemy) # Reset de statut : Toxic if actor.toxic? actor.reset_toxic_count end # Reset de staut : Confuse if actor.confused? actor.cure_state end # Reset capacité spéciale actor.ability_active = false actor.ability_token = nil case actor.ability when 30 # Natural cure / Medic Nature (ab) actor.cure end # Effets supprimés lors du switch for effect in actor.effect case effect[0] when 0x1A # Bide / Patience actor.effect.delete(effect) when 0x1B # Mania / Thrash actor.effect.delete(effect) when 0x1E # Adaptation / Conversion actor.effect.delete(effect) when 0x2A # Multi turn Attack actor.effect.delete(effect) when 0x2F # Focus Energy / Puissance actor.effect.delete(effect) when 0x39 # Morphing / Transform index = actor.effect_list.index(0x39) actor.transform_effect( actor.effect[index][2] , true ) actor.effect.delete(effect) when 0x51 # Rage / Frénésie actor.change_atk(-effect[2]) actor.effect.delete(effect) when 0x52 # Copie / Mimic skill_index = actor.skills_set.index(effect[2][1]) actor.skills_set[skill_index] = effect[2][0] actor.effect.delete(effect) when 0x54 # Vampigraine actor.effect.delete(effect) when 0x56 # Entrave / Disable index = effect[0][2] actor.skills_set[index].enable actor.effect.delete(effect) when 0x5A # Encore actor.effect.delete(effect) when 0x72 # Perish Song / Requiem actor.effect.delete(effect) when 0x6C # Minimize / Lilliput actor.effect.delete(effect) when 0x6D # Curse actor.effect.delete(effect) when 0x78 # Attraction actor.effect.delete(effect) when 0x9C # Boul'Armure / Defense Curl actor.effect.delete(effect) when 0x9F # Uproar / Brouhaha actor.effect.delete(effect) when 0xA5 # Torment / Tourment index = actor.effect_list.index(0xA5) skill_index = actor.effect[index][2] actor.skills_set[skill_index].enable actor.effect.delete(effect) when 0xAE # Charge / Chargeur actor.effect.delete(effect) when 0xAF # Provoc / Taunt for skill in actor.skills_set if skill.power == 0 and not(skill.enabled?) skill.enable end end actor.effect.delete(effect) when 0xC9 # Mud Sport actor.effect.delete(effect) when 0xD2 # Water Sport actor.effect.delete(effect) end end for effect in enemy.effect case effect[0] when 0x6A # Regard noir / Mean Look enemy.effect.delete(effect) when 0x71 # Clairvoyance / Foresight enemy.effect.delete(effect) when 0x78 # Attraction enemy.effect.delete(effect) when 0x54 # Vampigraine enemy.effect.delete(effect) end end end end end |
Code: |
#============================================================================== # ■ Pokemon_Battle_Wild # Pokemon Script Project - Krosk # 20/07/07 # Pokemon_Battle_Core_Safari # Therand - 01/2015 #----------------------------------------------------------------------------- # Scène à ne pas modifier de préférence #----------------------------------------------------------------------------- # Système de Combat - Pokémon Sauvage du parc safari #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Ici se trouve le calcul de capture et l'animation de la safari ball # ainsi que la pré-décision de l'enemy #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Ordre de déroulement du combat (update) #----------------------------------------------------------------------------- module POKEMON_S #------------------------------------------------------------ # Pokemon_Battle_Safari # scene #------------------------------------------------------------ class Pokemon_Battle_Safari < Pokemon_Battle_Core_Safari attr_accessor :z_level attr_accessor :actor_status attr_accessor :actor #------------------------------------------------------------ # Fonction d'initialisation # Appel: $scene = POKEMON_S::Pokemon_Battle_Safari.new( # party, pokemon, ia) # party: $pokemon_party (classe Pokemon_Party) # pokemon: class Pokemon # ia: Fausse AI #------------------------------------------------------------ def initialize(party, pokemon, ia = false, lose_able = false) @z_level = 0 @ia = ia @lose = lose_able $battle_var.reset # Assignations données des Pokémons @enemy = pokemon if not(@enemy.given_name.include?("sauvage")) @enemy.given_name += " sauvage" end $battle_var.enemy_party.actors[0] = @enemy @party = party # Mise à jour Pokedex: Pokémon vu $data_pokedex[@enemy.id][0] = true # Génération ordre de combat @battle_order = Array.new(@party.size) @battle_order.fill {|i| i} # Désignation 1er Pokémon au combat # @actor désigne le (class) Pokémon actor_index = 0 @actor = @party.actors[actor_index] if @actor == nil print("Attention, vous n'avez pas de Pokémon dans votre équipe! Réglez ce bug.") end while @actor.dead? actor_index += 1 @actor = @party.actors[actor_index] end # Correction ordre combat (Pokémon vivant en premier) @battle_order = switch(@battle_order, 0, actor_index) # Remise à zéro résultat $battle_var.result_flee = false $battle_var.result_win = false $battle_var.result_defeat = false # Initialisation des variables de combat @phase = 0 # 0 Non décidé, 1 Attaque, 2 Switch, 3 Item, 4 Fuite @actor_action = 0 @enemy_action = 0 @start_actor_battler = Player.battler # $trainer_battler @start_enemy_battler = @enemy.battler_face $battle_var.have_fought.push(@actor.party_index) $battle_var.battle_order = @battle_order $battle_var.in_battle = true @actor.reset_stat_stage @enemy.reset_stat_stage @actor.skill_effect_reset @enemy.skill_effect_reset @actor_skill = nil @enemy_skill = nil @actor.ability_active = false @enemy.ability_active = false @item_id = 0 # item utilisé #Initialisation de toutes les variables du safari #colère @angry = 0 #Faim @eating = 0 #Multiplicateur de drop rate @chance_safari = 1 #Nombre aléatoire obtenu après tour (1 à 255) @decision_safari = 0 #verificateur si ball lancé et si pkmn capturé @ball = 0 end #------------------------------------------------------------ # Animations pré-combat #------------------------------------------------------------ def pre_battle_transition # Jingle et BGM $game_system.bgm_play($game_system.battle_bgm) Audio.me_play("Audio/ME/battle_jingle.mid") Graphics.freeze # Sélection transition s = (rand(BATTLE_TRANS)+1).to_s @background.bitmap = RPG::Cache.picture("black.png") Graphics.transition(100, "Graphics/Transitions/battle"+ s +".png") Audio.me_stop # Dessin Graphics.freeze @background.bitmap = RPG::Cache.battleback(@battleback_name) @message_background.bitmap = RPG::Cache.battleback(BATTLE_MSG) @enemy_sprite.bitmap = RPG::Cache.battler(@start_enemy_battler, 0) @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2 @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 @enemy_sprite.x -= 782 @enemy_sprite.color = Color.new(60,60,60,128) @enemy_ground.bitmap = RPG::Cache.battleback(@ground_name) @enemy_ground.ox = @enemy_ground.bitmap.width / 2 @enemy_ground.oy = @enemy_ground.bitmap.height / 2 @enemy_ground.zoom_x = @enemy_ground.zoom_y = 2.0/3 @enemy_ground.x -= 782 @actor_ground.bitmap = RPG::Cache.battleback(@ground_name) @actor_ground.ox = @actor_ground.bitmap.width / 2 @actor_ground.oy = @actor_ground.bitmap.height @actor_ground.x += 782 @actor_sprite.bitmap = RPG::Cache.battler(@start_actor_battler, 0) @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height @actor_sprite.x += 782 Graphics.transition(50, "Graphics/Transitions/battle0.png") end def pre_battle_animation # Glissement des sprites loop do @enemy_sprite.x += 17 @enemy_ground.x += 17 @actor_sprite.x -= 17 @actor_ground.x -= 17 Graphics.update if @enemy_sprite.x == 464 until @enemy_sprite.color.alpha <= 0 @enemy_sprite.color.alpha -= 20 Graphics.update end break end end # Texte draw_text("Un " + @enemy.given_name, "apparait!") if FileTest.exist?(@enemy.cry) Audio.se_play(@enemy.cry) end # Arrivé du panel de l'adversaire @enemy_status.x -= 300 @enemy_status.visible = true if @enemy.shiny animation = $data_animations[496] @enemy_sprite.animation(animation, true) end loop do @enemy_sprite.x -= 3*(-1)**(@enemy_sprite.x) @enemy_status.x += 20 @enemy_sprite.update Graphics.update if @enemy_status.x == 23 until not(@enemy_sprite.effect?) @enemy_sprite.update Graphics.update end @enemy_sprite.x = 464 break end end # Attente appui de touche loop do Graphics.update Input.update if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) break end end @text_window.contents.clear Graphics.update end #------------------------------------------------------------ # Déroulement #------------------------------------------------------------ #La pré-décision enemy de l'action à utiliser en réponse à la votre def enemy_skill_decision action = true # ------- ---------- --------- -------- # Saut de phase de sélection (ennemi) # action = false : saut # action = true : pas de saut # ------- ---------- --------- -------- action = phase_jump(true) @enemy_action = 1 #Réinitialisation entre chaque tour @decision_safari = 0 #Nombre aléatoire entre 1 et 255 inclus @decision_safari += 1 + rand(256) # Le skill paisible (ce n'est pas réelement un skill en faite, il ne # demande pas de réaction de la part du pokémon, juste un calcul) # Si ball nous indique que le joueur à utilisé une ball et raté la capture if @ball == 1 wait(40) #On vérifie si l'enemy fuit if @decision_safari <= (@enemy.spd * 2) scene = end_battle_flee_enemy end end # Le skill furieux if @angry != 0 @angry -= 1 #On prépare le skill à utiliser @enemy_skill = Skill.new(566) end # Le skill manger if @eating != 0 @eating -= 1 #On prépare le skill à utiliser @enemy_skill = Skill.new(564) end end #------------------------------------------------------------ # Rounds #------------------------------------------------------------ def end_battle_check @actor_status.refresh @enemy_status.refresh if @enemy.dead? and not(@party.dead?) end_battle_victory elsif @actor.dead? if @party.dead? end_battle_defeat else draw_text("Voulez-vous appeler", "un autre Pokémon?") if draw_choice $battle_var.window_index = @action_window.index scene = POKEMON_S::Pokemon_Party_Menu.new(0) scene.main return_data = scene.return_data # Switch de Pokémon if $battle_var.action_id == 4 or $battle_var.action_id == 6 @switch_id = return_data actor_pokemon_switch end elsif run_able?(@actor, @enemy) run else fail_flee $battle_var.window_index = @action_window.index scene = POKEMON_S::Pokemon_Party_Menu.new(0) scene.main return_data = scene.return_data # Switch de Pokémon if $battle_var.action_id == 4 or $battle_var.action_id == 6 @switch_id = return_data actor_pokemon_switch end end end end end #------------------------------------------------------------ # Items #------------------------------------------------------------ def actor_item_use # items à utiliser # Item déjà utilisé ie remplacé par 0 if @item_id == 0 return end if Item.data(@item_id)["flee"] end_battle_flee return end if Item.data(@item_id)["ball"] ball_data = Item.data(@item_id)["ball"] if catch_pokemon(ball_data) @enemy.given_name = @enemy.name @enemy.ball_data = ball_data # Changement de surnom string1 = "Voulez-vous changer le" string2 = "surnom de " + @enemy.given_name + "?" draw_text(string1, string2) if draw_choice draw_text("") scene = POKEMON_S::Pokemon_Name.new(@enemy, @z_level + 50) scene.main end # Intégration au PC if $pokemon_party.size < 6 $pokemon_party.add(@enemy) else $pokemon_party.store_captured(@enemy) string1 = @enemy.given_name string2 = "est envoyé au PC." draw_text(string1, string2) wait(40) end $battle_var.result_win = true end_battle end end end #------------------------------------------------------------ # Lancer de pokéball #------------------------------------------------------------ def catch_pokemon(ball_data) # Initialisation des données ball_name = ball_data[0] ball_rate = ball_data[1] ball_sprite = ball_data[2] ball_open_sprite = ball_data[3] ball_color = ball_data[4] if @enemy.asleep? or @enemy.frozen? status_multiplier = 2 elsif @enemy.burn? or @enemy.paralyzed? or @enemy.poisoned? or @enemy.toxic? status_multiplier = 1.5 else status_multiplier = 1 end if ball_rate.type == Array case ball_rate[0] when "type" if ball_rate[1].include?(@enemy.type1) ball_rate = ball_rate[2] elsif ball_rate[1].include?(@enemy.type2) ball_rate = ball_rate[2] elsif ball_rate[3] != nil ball_rate = ball_rate[3] else ball_rate = 1 end when "id" if ball_rate[1].include?(@enemy.id) ball_rate = ball_rate[2] elsif ball_rate[3] != nil ball_rate = ball_rate[3] else ball_rate = 1 end when "level" max = 99 if ball_rate[2] != nil max = ball_rate[2] end ball_rate = eval( sprintf( ball_rate[1], @enemy.level ) ) if ball_rate <= 1 ball_rate = 1 end if ball_rate >= max ball_rate = max end when "time" max = 99 if ball_rate[2] != nil max = ball_rate[2] end ball_rate = eval( sprintf( ball_rate[1], $battle_var.round ) ) if ball_rate <= 1 ball_rate = 1 end if ball_rate >= max ball_rate = max end else ball_rate = 1 end end # Calcul des la possibilité de capture. # Source : Poképedia (http://www.pokepedia.fr/index.php/Capture_des_Pok%C3%A9mon) # Conversion des valeurs utilisé en flottant maxhp = @enemy.maxhp_basis.to_f hp = @enemy.hp.to_f rareness = @enemy.rareness.to_f ball_rate = 1.5#Le taux de la ball (Safari ball = X1.5) status_multiplier = status_multiplier.to_f chance_safari = @chance_safari#On convertis notre variable "multiplicatrice" # Calcul du premier flottant # ball_rate est multiplié par un multiple de 2 en fonction du nombre de caillou/appat a = Float(((maxhp * 3 - 2 * hp) * rareness * (ball_rate * chance_safari) * status_multiplier)/(maxhp * 3)) if a >= 255 # Le Pokémon est capturé j = 4 else # Deuxième chance de capture b = 65535.0 * Math.sqrt(Math.sqrt(a/255.0)) j = 0 # Initialement, la ball ne bouge pas. for i in 0...4 if rand(65535) <= b # Ajoute un mouvement de la ball pour chaque nombre aléatoire en dessous de b j += 1 # Il y a une chance pour qu'ils soient tous en dessous de b et que le Pokémon soit capturé au rattrapage (comme au bac) end end end # Procédure / Animation # Lancer # Animation forcé de la safari ball draw_text(Player.name + " utilise", "SAFARI BALL!") @ball_sprite = Sprite.new @ball_sprite.bitmap = RPG::Cache.picture("ball12") @ball_sprite.x = -25 @ball_sprite.y = 270 @ball_sprite.z = @z_level + 16 t = 0.0 pi = Math::PI loop do t += 16 @ball_sprite.y = (270.0 - 230.0 * Math.sin(2 * pi / 3.0 * t / 445.0)).to_i @ball_sprite.x = -15 + t Graphics.update if @ball_sprite.x >= 445 @ball_sprite.bitmap = RPG::Cache.picture("ballopen12") break end end count = j # "Aspiration" @enemy_sprite.color = Color.new(0, 0, 0, 255) @enemy_sprite.color.alpha = 0 @ball_sprite.z -= 2 until @enemy_sprite.color.alpha >= 255 @flash_sprite.opacity += 50 @enemy_sprite.color.alpha += 50 Graphics.update end Audio.se_play("Audio/SE/Pokeopen.wav") loop do @enemy_sprite.zoom_x -= 0.1 @enemy_sprite.zoom_y -= 0.1 @enemy_sprite.opacity -= 25 @flash_sprite.opacity -= 25 Graphics.update if @enemy_sprite.zoom_x <= 0.1 @flash_sprite.opacity = 0 @enemy_sprite.opacity = 0 break end end @ball_sprite.bitmap = RPG::Cache.picture("ball12") # Oscillement t = 0 r = 0 loop do t += 1 @ball_sprite.y = 81 + 50*(1-Math.exp(-t/20.0)*(Math.cos(t*2*pi/30.0)).abs) if @ball_sprite.y >= 81+45 and r < 6 r += 1 Audio.se_play("Audio/SE/Pokerebond.wav") end Graphics.update if t >= 60 break end end while count > 0 count -= 1 t = 0 Audio.se_play("Audio/SE/Pokemove.wav") loop do t += 4 @ball_sprite.angle = 40*Math.sin(2*pi*t/100.0) @ball_sprite.x = 449 - 12*Math.sin(2*pi*t/100.0) @ball_sprite.y = 131 + 12*Math.sin(2*pi*t/100.0) Graphics.update if t == 100 @ball_sprite.angle = 0 break end end end if j != 4 # Echappé @ball_sprite.bitmap = RPG::Cache.picture("ball12") @ball_sprite.z -= 1 Audio.se_stop Audio.se_play("Audio/SE/Pokeopenbreak.wav") @enemy_sprite.oy = @enemy_sprite.bitmap.height @enemy_sprite.y += @enemy_sprite.bitmap.height / 2 loop do @enemy_sprite.opacity += 25 @enemy_sprite.zoom_x += 0.1 @enemy_sprite.zoom_y += 0.1 @ball_sprite.opacity -= 25 @flash_sprite.opacity += 25 Graphics.update if @enemy_sprite.zoom_x >= 1 @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 @enemy_sprite.y -= @enemy_sprite.bitmap.height / 2 Graphics.update @ball_sprite.dispose break end end until @enemy_sprite.color.alpha <= 0 @enemy_sprite.color.alpha -= 25 @flash_sprite.opacity -= 25 Graphics.update end @enemy_sprite.color.alpha = 0 @enemy_sprite.opacity = 255 @flash_sprite.opacity = 0 Graphics.update string1 = j == 3 ? "Mince!" : j == 2 ? "Aaaah!" : j == 1 ? "Raah!" : "Oh non!" string2 = j == 3 ? "Ca y était presque!" : j == 2 ? "Presque!" : j == 1 ? "Ca y était presque!" : "Le POKéMON s'est libéré!" draw_text(string1, string2) wait(40) else # Attrapé $battle_var.action_id = 2 Audio.me_play("Audio/ME/PkmRS-Caught.mid") @enemy_caught = true draw_text("Et hop! " + @enemy.given_name , "est attrapé!") wait(90) wait_hit if not($data_pokedex[@enemy.id][1]) draw_text(@enemy.name + " est ajouté", "au pokédex.") wait(50) wait_hit $data_pokedex[@enemy.id][0] = true $data_pokedex[@enemy.id][1] = true scene = POKEMON_S::Pokemon_Detail.new(@enemy.id, false, 0, "combat", 9999) scene.main wait(10) Graphics.transition wait(10) end until @ball_sprite.opacity <= 0 @ball_sprite.opacity -= 25 Graphics.update end end if j != 4 return false elsif j == 4 return true end end #------------------------------------------------------------ # Fin de combat #------------------------------------------------------------ def end_battle_victory #Audio.bgm_fade(800) $battle_var.result_win = true @actor_status.z = @z_level + 15 #$game_system.me_play($game_system.battle_end_me) Audio.me_play("Audio/ME/fainted_jingle.mid") Audio.bgm_play("Audio/BGM/PkmRS-Victory.mid") # Réduction du nombre de participants $battle_var.have_fought.uniq! for index in $battle_var.have_fought actor = $pokemon_party.actors[index] if actor.dead? $battle_var.have_fought.delete(index) end end number = $battle_var.have_fought.length @enemy.skill_effect_reset @enemy.reset_stat_stage evolve_checklist = [] type = 1 # PIECE RUNE/AMULET COIN money_rate = 1 # EXP SHARE/MULTI EXP exp_share_number = 0 for pokemon in $pokemon_party.actors if not(pokemon.dead?) and Item.data(pokemon.item_hold)["expshare"] exp_share_number += 1 end end # Exp de bataille for actor in $pokemon_party.actors if actor.dead? next end amount = nil if $battle_var.have_fought.include?(actor.party_index) amount = actor.exp_calculation(@enemy.battle_list, @enemy.level, number, type, exp_share_number) # Tag objet if Item.data(actor.item_hold)["amuletcoin"] money_rate = 2 end end if Item.data(actor.item_hold)["expshare"] and not($battle_var.have_fought.include?(actor.party_index)) and not(actor.dead?) amount = actor.exp_calculation(@enemy.battle_list, @enemy.level, number, type, exp_share_number, 0) end if amount != nil actor.skill_effect_reset actor.reset_stat_stage actor.add_bonus(@enemy.battle_list) draw_text(actor.given_name + " a gagné", amount.to_s + " points d'expérience!") Graphics.update wait_hit for i in 1..amount actor.add_exp_battle(1) if actor.level_check actor.level_up(self) evolve_checklist.push(actor) end if actor == @actor if @actor.exp_list[@actor.level+1] != nil and @actor.level < MAX_LEVEL divide = (@actor.exp_list[@actor.level+1]-@actor.exp_list[@actor.level])/192 if divide == 0 divide = 1 end if (@actor.exp - @actor.exp_list[@actor.level])%divide == 0 @actor_status.exp_refresh Graphics.update end end end end end end @actor_status.refresh Graphics.update if $battle_var.money > 0 $battle_var.money *= money_rate draw_text(Player.name + " gagne " + ($battle_var.money).to_s + "$!") $pokemon_party.add_money($battle_var.money) wait(40) end wait(30) $game_system.bgm_play($game_temp.map_bgm) for actor in evolve_checklist info = actor.evolve_check if info != false scene = POKEMON_S::Pokemon_Evolve.new(actor, info, @z_level + 200) scene.main end end end_battle end end end |
Code: |
module POKEMON_S class Pokemon_Party attr_accessor :steps end end |
Code: |
if $game_variables[39] == 1 bitmap = RPG::Cache.picture("battle_sprite3.png") self.contents.blt(0, 0, bitmap, src_rect, 255) #draw_hp_bar(93,45, level) draw_text(39, 58, 249, $fs, Player.name, 0, normal_color) #draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) string = @pokemon.hp < 0 ? 0 : @pokemon.hp #draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color) if @pokemon.level < 100 level = @pokemon.next_exp.to_f / (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f else level = 0 end #draw_exp_bar(93, 99, 1.0 - level, 192) #width_text = self.contents.text_size(@pokemon.given_name).width + 3 #draw_gender(39 + width_text, 15, @pokemon.gender) else bitmap = RPG::Cache.picture("battle_sprite2.png") self.contents.blt(0, 0, bitmap, src_rect, 255) draw_hp_bar(93,45, level) draw_text(39, 6, 249, $fs, @pokemon.given_name, 0, normal_color) draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) string = @pokemon.hp < 0 ? 0 : @pokemon.hp draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color) if @pokemon.level < 100 level = @pokemon.next_exp.to_f / (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f else level = 0 end draw_exp_bar(93, 99, 1.0 - level, 192) width_text = self.contents.text_size(@pokemon.given_name).width + 3 draw_gender(39 + width_text, 15, @pokemon.gender) end |
Code: |
#============================================================================== # ■ Pokemon_Battle_Core # Pokemon Script Project - Krosk # 20/07/07 # Pokemon_Battle_Core_Safari # Therand - 01/2015 #----------------------------------------------------------------------------- # Scène à ne pas modifier de préférence #----------------------------------------------------------------------------- # Système de Combat - Safari #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Cette scene définit les actions propres au parc safari, vous pouvez modifier # les choix d'actions (BALL, APPAT, CAILLOU et FUITE) et leur effets direct # (initialisation de compteurs, tour à effectuer, action préliminaire,...) #----------------------------------------------------------------------------- module POKEMON_S #------------------------------------------------------------ # Pokemon_Battle_Core_Safari # noyau possédant les fonctions propres au parc safari #------------------------------------------------------------ #------------------------------------------------------------ # Fonctions à définir à l'extérieur # initialize # pre_battle_animation # enemy_skill_decision # end_battle_check # actor_item_use # catch_pokemon # run_able? # end_battle_victory #------------------------------------------------------------ class Pokemon_Battle_Core_Safari attr_accessor :z_level attr_accessor :actor_status attr_accessor :actor attr_accessor :actor_sprite #------------------------------------------------------------ # main #------------------------------------------------------------ def main # Pré-création des Sprites # Fond if @battleback_name != "" @battleback_name = $game_map.battleback_name + ".png" @ground_name = "ground" + $game_map.battleback_name + ".png" else print("Attention, réglez le BattleBack du Tileset.") @battleback_name = "battle0.png" @ground_name = "groundbattle0.png" end @background = Sprite.new @background.z = @z_level # Fond du message @message_background = Sprite.new @message_background.y = 336 @message_background.z = @z_level + 19 # Sprite de flash @flash_sprite = Sprite.new @flash_sprite.bitmap = RPG::Cache.picture("black.png") @flash_sprite.color = Color.new(255,255,255) @flash_sprite.opacity = 0 @flash_sprite.z = @z_level + 13 # Fenetre de texte @text_window = Window_Base.new(4, 340, 632, 136) @text_window.opacity = 0 @text_window.z = @z_level + 20 @text_window.contents = Bitmap.new(600 + 32, 104 + 32) @text_window.contents.font.name = $fontface @text_window.contents.font.size = $fontsizebig # Fenetre d'action s1 = "BALL" s2 = "CAILLOU" s3 = "APPAT" s4 = "FUITE" @action_window = Window_Command.new(320, [s1, s3, s2, s4], $fontsizebig, 2, 56) @action_window.x = 320 @action_window.y = 336 @action_window.z = @z_level + 21 @action_window.height = 144 @action_window.active = false @action_window.visible = false @action_window.index = 0 # Viewport battle_viewport = Viewport.new(0, 0, 640, 336) battle_viewport.z = @z_level + 15 # Sprites acteurs # Positions par défaut des centres @enemy_sprite = RPG::Sprite.new(battle_viewport) @enemy_sprite.x = 464 @enemy_sprite.y = 104 @enemy_sprite.z = @z_level + 15 @enemy_ground = RPG::Sprite.new @enemy_ground.x = 464 @enemy_ground.y = 149 @enemy_ground.z = @z_level + 11 @actor_sprite = RPG::Sprite.new(battle_viewport) @actor_sprite.x = 153 @actor_sprite.y = 336 @actor_sprite.z = @z_level + 15 @actor_ground = RPG::Sprite.new @actor_ground.x = 153 @actor_ground.y = 386 @actor_ground.z = @z_level + 11 # Création fenêtre de statut @actor_status = Pokemon_Battle_Status.new(@actor, false, @z_level + 15) @enemy_status = Pokemon_Battle_Status.new(@enemy, true, @z_level + 15) @actor_status.visible = false @enemy_status.visible = false @enemy_caught = false @actor_party_status = Pokemon_Battle_Party_Status.new(@party, @battle_order, false, @z_level + 10) @enemy_party_status = Pokemon_Battle_Party_Status.new($battle_var.enemy_party, $battle_var.enemy_battle_order, true, @z_level + 10) @actor_party_status.visible = false @enemy_party_status.visible = false # note: .active = true activera les animations liées à ces fenêtres @actor_party_status.active = false @enemy_party_status.active = false # Lancement des animations pre_battle_transition pre_battle_animation # Effets pré-premier round post_round_effect Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end # Fin de scene Graphics.freeze @background.dispose @message_background.dispose @flash_sprite.dispose @text_window.dispose @action_window.dispose @enemy_ground.dispose @actor_ground.dispose if @skill_window != nil @skills_window.dispose end if @ball_sprite != nil @ball_sprite.dispose end @enemy_sprite.dispose @actor_sprite.dispose @actor_status.dispose @enemy_status.dispose @actor_party_status.dispose @enemy_party_status.dispose end #------------------------------------------------------------ # Déroulement #------------------------------------------------------------ def update # Animation test : séquence de test d'une animation if false if $temp == nil $temp = false @actor_sprite.register_position @enemy_sprite.register_position end animation = $data_animations[15] # tappez le numéro de l'anim à tester if not @enemy_sprite.effect? and not @actor_sprite.effect? if $temp @enemy_sprite.reset_position @actor_sprite.register_position @actor_sprite.animation(animation, true, true) $temp = !$temp else @actor_sprite.reset_position @enemy_sprite.register_position @enemy_sprite.animation(animation, true) $temp = !$temp end end @actor_sprite.update @enemy_sprite.update return end case @phase when 0 # Phase d'initialisation @phase = 1 # Création fenêtre de skill list = [] for skill in @actor.skills_set list.push(skill.name) end while list.size < 4 list.push(" ---") end @skills_window = Window_Command.new(512, list, $fontsizebig, 2, 56) @skills_window.x = 0 @skills_window.y = 336 @skills_window.height = 144 @skills_window.visible = false @skills_window.active = false # Compétences bloquées for i in 0..@actor.skills_set.length-1 skill = @actor.skills_set[i] if not(skill.usable?) @skills_window.disable_item(i) end end # Curseur sur le dernier choix if $battle_var.last_index == nil $battle_var.last_index = 0 @skills_window.index = 0 else @skills_window.index = $battle_var.last_index end # Création fenêtre description de skill @skill_descr = Window_Base.new(512, 336, 128, 144) @skill_descr.contents = Bitmap.new(96, 144) @skill_descr.contents.font.name = $fontface @skill_descr.contents.font.size = $fontsizebig @skill_descr.visible = false skill_descr_refresh # Activation fenêtre @actor_status.visible = true @enemy_status.visible = true # ------- ---------- --------- -------- # Saut de phase de sélection actor # ------- ---------- --------- -------- jumped = phase_jump # Activations fenêtres if not(jumped) draw_text("Que doit faire", "" + Player.name + " ?") @action_window.visible = true @action_window.active= true $battle_var.action_id = 0 end when 1 # Phase d'attente d'action @action_window.update @skills_window.update if @skills_window.active and input skill_descr_refresh end if Input.trigger?(Input::C) and @action_window.active case @action_window.index when 0 # Selection BALL $game_system.se_play($data_system.decision_se) @action_window.active = false @action_window.visible = false # Si le nombre de ball == 0, le joueur n'a plus de BALL if $pokemon_party.item_number(12) == 0 draw_text("Vous n'avez plus de SAFARI BALL!") wait(40) #On revient à la phase d'attente du joueur. @phase = 0 @ball = 0 else # Sinon on continue l'action # en retirant une SAFARI BALL $pokemon_party.add_item(12, -1) $battle_var.action_id = 1 #Ceci renvoit à la méthode de capture incluse dans Battle_Safari catch_pokemon(12) end # Si la ball ne capture pas le pokemon, on continue l'action if $battle_var.action_id == 1 @phase = 0 # @ball = 1 sert à indiquer au Battle_Core 4 que le joueur à lancé une BALL @ball = 1 #ce sera donc à l'enemy scene = enemy_skill_decision end # Si la capture réussi if $battle_var.action_id == 2 #on donne les bonnes variables pour la ball utilisée dans le pokédex @item_id = 12 $data_ball = 12 # On ajoute le pokémon à l'équipe, avec les donné de la ball (fake) ball_data = Item.data(@item_id)["ball"] @enemy.given_name = @enemy.name @enemy.ball_data = ball_data # Changement de surnom string1 = "Voulez-vous changer le" string2 = "surnom de " + @enemy.given_name + "?" draw_text(string1, string2) if draw_choice draw_text("") scene = POKEMON_S::Pokemon_Name.new(@enemy, @z_level + 50) scene.main end # Intégration au PC if $pokemon_party.size < 6 $pokemon_party.add(@enemy) else $pokemon_party.store_captured(@enemy) string1 = @enemy.given_name string2 = "est envoyé au PC." draw_text(string1, string2) wait(40) end #On fini le combat $battle_var.result_win = true end_battle end when 1 # Selection APPAT $game_system.se_play($data_system.decision_se) @action_window.active = false @action_window.visible = false # On initialise/calcul les compteurs de faim, colère @ball = 0 @angry = 0 @eating += 1 + rand(6) #@chance_safari est incluse dans le calcul de capture #vous le trouverez dans Pokemon_Safari @chance_safari /= 2 #Si @chance_safari == 0 alors l'augmenter de un, #tout simplement pour éviter d'avoir une erreur/un drop rate incorrecte #si le joueur utilise plusieurs appat de suite (le @chance_safari doit #toujours valoir 1 OU un multiple de 2) if@chance_safari == 0 @chance_safari += 1 end # Le lancement de l'appat @actor_action = 1 @phase = 2 @actor_skill = Skill.new(562) # APPAT when 2 # Selection CAILLOU $game_system.se_play($data_system.decision_se) @action_window.active = false @action_window.visible = false # On initialise/calcul les compteurs de faim, colère et doublage du rate @ball = 0 @angry += 1 + rand(6) @eating = 0 @chance_safari *= 2 #juste au cas ou... if@chance_safari == 0 @chance_safari += 1 end # Le lancement du caillou @actor_action = 1 @phase = 2 @actor_skill = Skill.new(563) # CAILLOU return when 3 # sélection FUITE # ------- ---------- --------- -------- # Vérification fuite permise # ------- ---------- --------- -------- @action_window.visible = false if not(flee_able(@actor, @enemy)) $game_system.se_play($data_system.buzzer_se) @action_window.visible = true draw_text("Que doit faire", "" + Player.name + " ?") return end @action_window.visible = true @action_window.active = false @action_window.visible = false @text_window.contents.clear run end return end if Input.trigger?(Input::C) and @skills_window.active index = @skills_window.index skill = @actor.skills_set[index] if skill != nil and skill.usable? @actor_action = 1 @phase = 2 @skills_window.active = false @skills_window.visible= false @skill_descr.visible = false @action_window.active = false @action_window.visible= false @actor_skill = @actor.skills_set[index] $battle_var.last_index = @skills_window.index else $game_system.se_play($data_system.buzzer_se) end end if Input.trigger?(Input::B) and @skills_window.active $game_system.se_play($data_system.decision_se) @skills_window.active = false @skills_window.visible = false @skill_descr.visible = false @action_window.active = true @phase = 0 end when 2 # Phase d'action automatisée @action_window.visible = false @action_window.active = false enemy_skill_decision statistic_refresh turn_order phase2 phase3 # Phase de switch de fin de tour $battle_var.action_id = 4 end_battle_check if $battle_var.battle_end? return end # Fin de tour / Post_Round effects post_round_effect @actor_status.refresh @enemy_status.refresh if $battle_var.battle_end? return end # Phase de switch post_round $battle_var.action_id = 6 end_battle_check @phase = 0 if $battle_var.battle_end? return end # Incrémentation nombre de tours $battle_var.round += 1 end return end #------------------------------------------------------------ # Vérifications préliminaires et ordre d'action #------------------------------------------------------------ def statistic_refresh @actor.statistic_refresh @enemy.statistic_refresh end #Recherche de priorité def turn_order # Comparaison des priorités if @actor_skill == nil or @enemy_skill == nil @strike_first = true return end if @actor_action != 1 # Attaque @strike_first = false return end if @actor_skill.priority > @enemy_skill.priority @strike_first = true elsif @actor_skill.priority < @enemy_skill.priority @strike_first = false else # En cas d'égalité if @enemy.spd > @actor.spd @strike_first = false elsif @enemy.spd < @actor.spd @strike_first = true else @strike_first = rand(2)>0 ? true : false end end end #------------------------------------------------------------ # Rounds #------------------------------------------------------------ def phase2 # Pré_Rounds @action_window.visible = false @action_window.active = false @actor_status.visible = true @enemy_status.visible = true @actor_status.refresh @enemy_status.refresh draw_text("","") # Préround 1: Fuite if @actor_action == 4 run end if @enemy_action == 4 enemy_run end # Préround 2: Item if @actor_action == 3 actor_item_use end if @enemy_action == 3 enemy_item_use end # Préround 3: Switch Pokémon if @actor_action == 2 actor_pokemon_switch end if @enemy_action == 2 enemy_pokemon_switch end @actor_status.refresh @enemy_status.refresh end # Round: Attaques def phase3 if @strike_first if @actor_action == 1 and not(@actor.dead?) attack_action(@actor, @actor_skill, @enemy) end else if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?) attack_action(@enemy, @enemy_skill, @actor) end end faint_check if @actor.dead? or @enemy.dead? or $battle_var.battle_end? return end if not(@strike_first) if @actor_action == 1 and not(@actor.dead?) attack_action(@actor, @actor_skill, @enemy) end else if not(@enemy_caught) and @enemy_action == 1 and not(@enemy.dead?) attack_action(@enemy, @enemy_skill, @actor) end end faint_check if @actor.dead? or @enemy.dead? or $battle_var.battle_end? return end end #------------------------------------------------------------ # Fonctions auxiliaires #------------------------------------------------------------ def switch(list, id1, id2) if id1 <= id2 list.insert(id1, list[id2]) list.delete_at(id2+1) list.insert(id2 + 1, list[id1+1]) list.delete_at(id1+1) return list else switch(list, id2, id1) end end # Fonction auxiliaire def input if Input.trigger?(Input::C) or Input.trigger?(Input::B) or Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT) return true end return false end def draw_text(line1 = "", line2 = "") if line1.type == Array if line1[1] != nil draw_text(line1[0], line1[1]) else draw_text(line1[0]) end else Graphics.freeze @text_window.contents.clear @text_window.draw_text(12, 0, 460, 50, line1) @text_window.draw_text(12, 55, 460, 50, line2) Graphics.transition(5) end end def draw_text_valid(line1 = "", line2 = "") draw_text(line1, line2) loop do Graphics.update Input.update if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) break end end end def wait(frame) i = 0 loop do i += 1 Graphics.update if i >= frame break end end end def wait_hit loop do Graphics.update Input.update if input $game_system.se_play($data_system.decision_se) break end end end def update_sprite @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0) @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0) @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2 @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 end #------------------------------------------------------------ # ----------------------- Interface ------------------------- #------------------------------------------------------------ #------------------------------------------------------------ # Fenêtre de description #------------------------------------------------------------ def skill_descr_refresh @skill_descr.contents.clear index = @skills_window.index skill = @actor.skills_set[index] if skill != nil string = skill.pp.to_s + "/" + skill.ppmax.to_s type = skill.type else string = "---" type = 0 end normal_color = Color.new(60,60,60) @skill_descr.contents.font.color = normal_color #@skill_descr.contents.draw_text(0,6,60,39, "PP:") @skill_descr.contents.draw_text(0,6,96,39, string, 1) #@skill_descr.contents.draw_text(0,60,140,39, "TP:") draw_type(0, 60, type) end def draw_type(x, y, type) src_rect = Rect.new(0, 0, 96, 42) bitmap = RPG::Cache.picture("T" + type.to_s + ".png") @skill_descr.contents.blt(x, y, bitmap, src_rect, 255) end #------------------------------------------------------------ # ------------------ Fonctions de combat -------------------- #------------------------------------------------------------ #------------------------------------------------------------ # Fonctions spéciales - programmation des attaques #------------------------------------------------------------ def heal(user, user_sprite, user_status, bonus) value = bonus.abs for i in 1..value if bonus >= 0 user.add_hp(1) else user.remove_hp(1) end if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0 next end user_status.refresh Graphics.update Graphics.update if user.hp >= user.max_hp or user.dead? break end end end def self_damage(user, user_sprite, user_status, damage) if damage > 0 Audio.se_play("Audio/SE/Hit.wav", 100) blink(user_sprite) end for i in 1..damage user.remove_hp(1) user_status.refresh if user.max_hp >= 144 and i % (user.max_hp / 144 + 1) != 0 next end Graphics.update Graphics.update if user.dead? break end end end #------------------------------------------------------------ # Fonctions communes - Programmation des attaques #------------------------------------------------------------ # 0: Normal, 1: Poison, 2: Paralysé, 3: Brulé, 4:Sommeil, 5:Gelé # 6: Confus, 7: Flinch, 8: Toxic #------------------------------------------------------------ # 1 Normal 2 Feu 3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol # 10 vol 11 psy 12insecte 13 roche 14 spectre 15 dragon 16 acier 17 tenebre #------------------------------------------------------------ # Fonction à appeler en cas d'effets sur le statut def status_check(target, status, forcing = false) # Immunités # Poison if (target.type_poison? or target.type_steel?) and (status == 1 or status == 8) draw_text(target.given_name + " est insensible", "au poison!") wait(40) return end # Freeze if status == 5 and target.type_ice? draw_text(target.given_name + " est insensible", "au gel!") wait(40) return end # Burn if status == 3 and target.type_fire? draw_text(target.given_name + " est insensible", "aux brûlures!") wait(40) return end # Soleil if status == 5 and $battle_var.sunny? draw_text("Le soleil empêche " + target.given_name, "de geler!") wait(40) return end # Lumber / Echauffement (ab) if status == 2 and target.ability == 7 draw_text(target.ability_name + " de " + target.given_name , "empêche la paralysie.") wait(40) return end # Ignifu-voile / Water Veil (ab) if status == 3 and target.ability == 41 draw_text(target.ability_name + " de " + target.given_name , "empêche les brûlures.") wait(40) return end # Insomnia (ab) // Vital Spirit / Esprit Vital (ab) if status == 4 and (target.ability == 15 or target.ability == 72) draw_text(target.ability_name + " de " + target.given_name , "empêche le sommeil.") wait(40) return end # Vaccin / Immunity (ab) if [1, 8].include?(status) and target.ability == 17 draw_text(target.ability_name + " de " + target.given_name , "empêche l'empoisonnement.") wait(40) return end # Armumagma / Magma Armor (ab) if target.ability == 40 and status == 5 draw_text(target.ability_name + " de " + target.given_name , "empêche le gel.") wait(40) return end # Tempo Perso / Own Tempo (ab) if status == 6 and target.ability == 20 draw_text(target.ability_name + " de " + target.given_name , "empêche la confusion.") wait(40) return end # Attention / Inner focus (ab) if target.ability == 39 and status == 7 draw_text(target.ability_name + " de " + target.given_name , "empêche la peur.") wait(40) return end # Synchronize (ab) if target.ability == 28 and [1, 2, 3, 8].include?(status) target.ability_token = status if status == 8 target.ability_token = 1 end end if [1,2,3,4,5,8].include?(target.status) and not(forcing) and not([6, 7].include?(status)) status_string(target, -target.status) # animation elsif status == 6 and target.confused? and not(forcing) status_string(target, -6) elsif target.effect_list.include?(0x7C) and status != 7 # Rune Protect/Safeguard draw_text(target.given_name + "est", "protégé des altérations!") wait(40) elsif target.effect_list.include?(0x9F) and status == 4 # Uproar draw_text(target.given_name + " ne peux pas dormir", "à cause du brouhaha!") wait(40) else case status when 1 target.status_poison(forcing) when 2 target.status_paralyze(forcing) when 3 target.status_burn(forcing) when 4 target.status_sleep(forcing) when 5 target.status_frozen(forcing) when 6 target.status_confuse when 7 target.status_flinch when 8 target.status_toxic(forcing) end status_string(target, status) end end def accuracy_stage(user, target) stage = user.acc_stage - target.eva_stage stage = stage < -6 ? -6 : stage > 6 ? 6 : stage # --------------- ---------------- -------------- # Programmation des attaques # --------------- ---------------- -------------- # Clairvoyayance / Foresight if target.effect_list.include?(0x71) stage = user.acc_stage end # --------------- ---------------- -------------- # --------------- ---------------- -------------- case stage when -6 return 33.0/100 when -5 return 36.0/100 when -4 return 43.0/100 when -3 return 50.0/100 when -2 return 60.0/100 when -1 return 75.0/100 when 0 return 1 when 1 return 133.0/100 when 2 return 166.0/100 when 3 return 2 when 4 return 250.0/100 when 5 return 133.0/50 when 6 return 3 end end #------------------------------------------------------------ # Post_round #------------------------------------------------------------ def post_round_effect # --------- -------------- -------------------- # Fin des effets "at the end of a round" # --------- -------------- -------------------- # Suppression état appeuré (ne dure que un tour) @actor.flinch_check @enemy.flinch_check # Suppression état autre if @actor.dead? @actor.cure @actor.cure_state end if @enemy.dead? @enemy.cure @enemy.cure_state end # --------- -------------- -------------------- # Programmation des attaques en Post-round # --------- -------------- -------------------- # Cycle commun 0 - Souhait et Météo # --------- -------------- -------------------- post_round_cycle0 # --------- -------------- -------------------- # Cycle individuel 1 # Programmation des attaques # Effets du statut # --------- -------------- -------------------- if @strike_first post_round_cycle_1(@actor, @enemy) post_round_cycle_1(@enemy, @actor) else post_round_cycle_1(@enemy, @actor) post_round_cycle_1(@actor, @enemy) end # --------- -------------- -------------------- # Cycle 2 # Programmation des attaques # Dommages finaux # --------- -------------- -------------------- if @strike_first post_round_cycle_2(@actor, @enemy) post_round_cycle_2(@enemy, @actor) else post_round_cycle_2(@enemy, @actor) post_round_cycle_2(@actor, @enemy) end @actor.skill_effect_clean @enemy.skill_effect_clean faint_check # Round suivant if $battle_var.round == nil $battle_var.round = 0 end $battle_var.round += 1 end # --------- -------------- -------------------- # Cycle commun 0 - Météo et Souhait # --------- -------------- -------------------- def post_round_cycle0 if @strike_first list = [[@actor, @actor_sprite, @actor_status], [@enemy, @enemy_sprite, @enemy_status]] else list = [[@enemy, @enemy_sprite, @enemy_status], [@actor, @actor_sprite, @actor_status]] end # Suppression du contrôle pour un pokémon mort for array in list if array[0].dead? list.delete(array) end end for array in list actor = array[0] actor.skill_effect_end_turn for effect in actor.effect_list case effect when 0x56 # Entrave / Disable index = actor.effect_list.index(0x56) if actor.effect[index][1] == 0 skill_id = actor.effect[index][2] skill = actor.skills_set[skill_id] skill.enable draw_text(skill.name + " de "+ actor.given_name, "est rétablie!") wait(40) end when 0x5A # Encore index = actor.effect_list.index(0x5A) if actor.skills_set[index].pp == 0 actor.effect[index][1] = 0 # Fin de l'effet end when 0x75 # Rollout index = actor.effect_list.index(0x75) ## N'a pas fait de dégât ce tour ci >> Supprimé #if actor.effect[index][2] != actor.effect[index][1] # actor.effect.delete_at(index) #end if actor.asleep? or actor.frozen? actor.effect.delete_at(index) end when 0x77 # Taillade / Fury Cutter index = actor.effect_list.index(0x77) # N'a pas fait de dégât ce tour ci >> Supprimé if actor.effect[index][2] != actor.effect[index][1] actor.effect.delete_at(index) end end end end weather = $battle_var.weather[0] $battle_var.weather[1] -= 1 count = $battle_var.weather[1] # Souhait -- Programmation des attaques for array in list target = array[0] target_sprite = array[1] target_status = array[2] if target.effect_list.include?(0xB3) bonus = target.hp / 2 draw_text("Un souhait est réalisé.") heal(target, target_sprite, target_status, bonus) wait(40) end end # Pluie if $battle_var.rain? and count != 0 draw_text("La pluie continue de", "tomber.") animation = $data_animations[493] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end wait(20) elsif $battle_var.rain? and count == 0 draw_text("La pluie s'est arrêtée.") wait(40) $battle_var.reset_weather end # Ensoleillé if $battle_var.sunny? and count != 0 draw_text("Les rayons du soleil","tapent fort.") animation = $data_animations[492] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end wait(20) elsif $battle_var.sunny? and count == 0 draw_text("Le soleil est parti.") wait(40) $battle_var.reset_weather end # Tempete de sable if $battle_var.sandstorm? and count != 0 draw_text("La tempête de sable souffle.") animation = $data_animations[494] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end # Dégats for array in list target = array[0] target_sprite = array[1] target_status = array[2] if target.type_ground? or target.type_rock? or target.type_steel? target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) or target.ability == 8 next end damage = target.max_hp / 16 heal(target, target_sprite, target_status, -damage) end elsif $battle_var.sandstorm? and count == 0 draw_text("La tempête de sable s'est arretée.") wait(40) $battle_var.reset_weather end # Grêle if $battle_var.hail? and count > 0 draw_text("Il grêle...") animation = $data_animations[495] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) #and Input.trigger?(Input::C) break end end # Dégâts for array in list target = array[0] target_sprite = array[1] target_status = array[2] if target.type_ice? or target.effect_list.include?(0x9B0) or target.effect_list.include?(0x9B3) next end damage = target.max_hp / 16 heal(target, target_sprite, target_status, -damage) end elsif $battle_var.hail? and count == 0 draw_text("La grêle s'est arrêtée.") wait(40) $battle_var.reset_weather end end # --------- -------------- -------------------- # Cycle individuel 1 # --------- -------------- -------------------- def post_round_cycle_1(actor, enemy) if actor == @actor actor_status = @actor_status actor_sprite = @actor_sprite enemy_status = @enemy_status enemy_sprite = @enemy_sprite elsif actor == @enemy actor_status = @enemy_status actor_sprite = @enemy_sprite enemy_status = @actor_status enemy_sprite = @actor_sprite end # Suppression du contrôle pour un Pokémon mort if actor.dead? return end # --------- -------------- -------------------- # Programmation des attaques et des capa # --------- -------------- -------------------- for effect in actor.effect_list case effect when 0xB5 # Ingrain / Racines bonus = actor.max_hp / 16 draw_text(actor.given_name + " puise", "de l'énergie dans la terre.") heal(actor, actor_sprite, actor_status, bonus) wait(40) end end case actor.ability when 44 # Cuvette / Rain Dish (ab) if $battle_var.rain? bonus = actor.max_hp / 16 draw_text(actor.ability_name + " de " + actor.given_name, "restaure les PV.") heal(actor, actor_sprite, actor_status, bonus) wait(40) end when 54 # Absentéisme / Truant (ab) if actor.ability_token == nil actor.ability_token = true end if actor.ability_token == true actor.ability_token = false elsif actor.ability_token == false actor.ability_token = true end when 61 # Mue / Shed skin (ab) if actor.status != 0 and rand(100) < 30 actor.cure draw_text(actor.ability_name + " de " + actor.given_name, "guérit le statut.") wait(40) end end for effect in enemy.effect_list case effect when 0x54 # Leech Seed / Vampigraine malus = actor.max_hp / 8 draw_text("L'énergie de " + actor.given_name,"est drainée!") heal(actor, actor_sprite, actor_status, -malus) heal(enemy, enemy_sprite, enemy_status, malus) wait(40) when 0x2A # Multi_turn attack damage = actor.max_hp / 16 draw_text(actor.given_name, "est piégé!") self_damage(actor, actor_sprite, actor_status, damage) wait(40) end end if actor.dead? return end # --------- -------------- -------------------- # Inspection des statuts # --------- -------------- -------------------- if actor.status == 1 # Poison damage = actor.poison_effect draw_text(actor.given_name + " souffre", "du poison.") status_animation(actor_sprite, actor.status) heal(actor, actor_sprite, actor_status, -damage) wait(20) end if actor.status == 8 # Toxic damage = actor.toxic_effect draw_text(actor.given_name + " souffre", "gravement du poison.") status_animation(actor_sprite, actor.status) heal(actor, actor_sprite, actor_status, -damage) wait(20) end if actor.status == 3 #Burn damage = actor.burn_effect draw_text(actor.given_name + " souffre", "de ses brûlures.") status_animation(actor_sprite, actor.status) heal(actor, actor_sprite, actor_status, -damage) wait(20) end actor.confuse_decrement if actor.dead? return end # --------- -------------- -------------------- # Programmation des attaques # --------- -------------- -------------------- for effect in actor.effect_list case effect when 0x6B # Nightmare / Cauchemar if actor.asleep? damage = actor.max_hp / 4 draw_text(actor.given_name + " fait", "un chauchemar!") heal(actor, actor_sprite, actor_status, -damage) wait(20) else index = actor.effect_list.index(0x6B) actor.effect.delete_at(index) end when 0x6D # Curse damage = actor.max_hp / 4 draw_text(actor.given_name + " est", "maudit!") heal(actor, actor_sprite, actor_status, -damage) wait(20) when 0x9F # Uproar / Brouhaha if actor.asleep? actor.cure draw_text(actor.given_name + " se réveille", "à cause du brouhaha!") wait(40) end if actor.frozen? #Fin de l'effet index = actor.effect_list.index(0x9F) actor.effect.delete_at(index) end when 0xAF # Taunt / Provoc index = actor.effect_list.index(0xAF) for skill in actor.skills_set if skill.power == 0 and actor.effect[index][1] > 0 draw_text(skill.name + " est bloqué!") skill.disable wait(40) elsif actor.effect[index][1] == 0 draw_text(skill.name + " est rétablit.") skill.enable wait(40) end end when 0xBB # Yawn / Baillement if actor.status == 0 status_check(actor, 4) actor_status.refresh end end end if actor.dead? return end # --------- -------------- -------------------- # Berry check # --------- -------------- -------------------- if Item.data(actor.item_hold)["leftovers"] and actor.hp != actor.max_hp draw_text(actor.given_name + " récupère un peu", "de vie avec " + Item.name(actor.item_hold) + ".") bonus = actor.max_hp / 16 if bonus == 0 bonus = 1 end heal(actor, actor_sprite, actor_status, bonus) wait(40) end end # --------- -------------- -------------------- # Cycle individuel 2 # --------- -------------- -------------------- def post_round_cycle_2(actor, enemy) # Redéfinition if actor == @actor actor_status = @actor_status actor_sprite = @actor_sprite enemy_status = @enemy_status enemy_sprite = @enemy_sprite elsif actor == @enemy actor_status = @enemy_status actor_sprite = @enemy_sprite enemy_status = @actor_status enemy_sprite = @actor_sprite end # Suppression du contrôle pour un pokémon mort if actor.dead? return end # --------- -------------- -------------------- # Programmation des capacités # --------- -------------- -------------------- case actor.ability when 2 # Crachin / Drizzle (ab) if not($battle_var.rain?) # Pluie draw_text(actor.ability_name + " de " + actor.given_name, "invoque la pluie.") wait(40) animation = $data_animations[493] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end end $battle_var.set_rain when 45 # Sable Volant / Sand stream (ab) if not($battle_var.sandstorm?) # Tempete Sable draw_text(actor.ability_name + " de " + actor.given_name, "réveille une tempête.") wait(40) animation = $data_animations[494] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end end $battle_var.set_sandstorm when 70 # Sècheresse / Drought (ab) if not($battle_var.sunny?) # Soleil draw_text(actor.ability_name + " de " + actor.given_name, "intensifie le soleil.") wait(40) animation = $data_animations[492] @actor_sprite.animation(animation, true) loop do @actor_sprite.update Graphics.update Input.update if not(@actor_sprite.effect?) break end end end $battle_var.set_sandstorm when 3 # Speed Boost (ab) draw_text(actor.ability_name + " de " + actor.given_name, "augmente la Vitesse.") actor.change_spd(+1) stage_animation(actor_sprite, $data_animations[482]) wait(40) when 22 # Intimidate (ab) if not(actor.ability_active) actor.ability_active = true draw_text(actor.ability_name + " de " + actor.given_name, "réduit l'Attaque de " + enemy.given_name + ".") enemy.change_atk(-1) stage_animation(enemy_sprite, $data_animations[479]) wait(40) end when 59 # Forecast / Meteo (ab) if $battle_var.sunny? and not(actor.type_fire?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en FEU!") actor.ability_token = 2 actor.form = 2 update_sprite wait(40) elsif $battle_var.rain? and not(actor.type_water?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en EAU!") actor.ability_token = 3 actor.form = 3 update_sprite wait(40) elsif $battle_var.hail? and not(actor.type_ice?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en GLACE!") actor.ability_token = 6 actor.form = 6 update_sprite wait(40) elsif not(actor.type_normal?) draw_text("#{actor.ability_name} de #{actor.given_name}", "change son type en NORMAL!") actor.ability_token = 1 actor.form = 0 update_sprite wait(40) end end # --------- -------------- -------------------- # Programmation des attaques # --------- -------------- -------------------- for effect in actor.effect_list case effect when 0x72 # Requiem / Perish Song index = actor.effect_list.index(0x72) number = actor.effect[index][1] if number > 0 if number > 1 string = "#{number.to_s} tours" elsif number == 1 string = "#{number.to_s} tour" end draw_text("Plus que #{string}", "pour #{actor.given_name}...") wait(40) else draw_text("#{actor.given_name} est", "K.O. par REQUIEM!") damage = actor.hp heal(actor, actor_sprite, actor_status, -damage) wait(40) end end end # --------- -------------- -------------------- # Nettoyage des compteurs d'effets # --------- -------------- -------------------- for effect in actor.effect case effect when [0x10, 0] # Reflet / Reflect draw_text("L'effet de REFLET est", "terminé.") wait(40) when [0x23, 0] # Light Screen draw_text("L'effet de MUR LUMIERE est", "terminé.") wait(40) when [0x2E, 0] # Brume / Mist draw_text("La brume se dissipe.") wait(40) when [0x7C, 0] # Rune Protect / Safeguard draw_text("L'effet de RUNE PROTECT", "est terminé.") wait(40) end end if actor.dead? return end end #------------------------------------------------------------ # Items #------------------------------------------------------------ def actor_item_use # items à utiliser # Item déjà utilisé ie remplacé par 0 if @item_id == 0 return end end #------------------------------------------------------------ # Switch de pokémon #------------------------------------------------------------ def actor_pokemon_switch if @switch_id != -1 if not(@actor.dead?) @actor_status.visible = true else @actor_status.visible = false end switch_effect(@actor, @enemy) if not(@actor.dead?) recall_pokemon end @battle_order = switch(@battle_order, 0, @switch_id) @actor = @party.actors[@battle_order[0]] @actor_sprite.bitmap = RPG::Cache.battler(@actor.battler_back, 0) @actor_status = Pokemon_Battle_Status.new(@actor, false) @actor_status.visible = false if not($battle_var.have_fought.include?(@actor.party_index)) $battle_var.have_fought.push(@actor.party_index) end launch_pokemon @actor_status.visible = true @switch_id = -1 end end def enemy_pokemon_switch if @enemy_switch_id != -1 if not(@enemy.dead?) @enemy_status.visible = true else @enemy_status.visible = false end switch_effect(@enemy, @actor) if not(@enemy.dead?) recall_enemy_pokemon end @enemy_battle_order = switch($battle_var.enemy_battle_order, 0, @enemy_switch_id) @enemy = $battle_var.enemy_party.actors[$battle_var.enemy_battle_order[0]] $data_pokedex[@enemy.id][0] = true @enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0) @enemy_status = Pokemon_Battle_Status.new(@enemy, true) @enemy_status.visible = false launch_enemy_pokemon @enemy_status.visible = true @enemy_switch_id = -1 end end #------------------------------------------------------------ # Fuite #------------------------------------------------------------ def run if run_able?(@actor, @enemy) $battle_var.run_count += 1 @action_window.active = false @action_window.visible = false end_battle_flee else $battle_var.run_count += 1 fail_flee @phase = 2 @actor_action = 0 $battle_var.action_id = 0 end end def run_able?(runner, opponent) x = (Integer(opponent.spd/4) % 255) rate = Integer(runner.spd*32/x)+(30*($battle_var.run_count)) if not(flee_able(runner, opponent)) return false end if opponent.spd <= runner.spd return true elsif x == 0 return true elsif rate > 255 return true elsif rand(256) <= rate return true else return false end end def run_enemy if run_able?(@enemy, @actor) end_battle_flee_enemy end end #------------------------------------------------------------ # Animations supplémentaires au combat #------------------------------------------------------------ # Défaites / KO #------------------------------------------------------------ def enemy_down # Si déjà vaincu if @enemy_sprite.zoom_y == 0 return end # Sinon @enemy_sprite.oy = @enemy_sprite.bitmap.height @enemy_sprite.y += @enemy_sprite.bitmap.height / 2 if FileTest.exist?(@enemy.cry) Audio.se_play(@enemy.cry) end wait(50) Audio.se_play("Audio/SE/Down.wav") loop do @enemy_status.x -= 20 #@enemy_sprite.zoom_y -= 0.05 @enemy_sprite.y += 8 @enemy_sprite.opacity -= 20 Graphics.update #if @enemy_sprite.zoom_y <= 0.0 if @enemy_sprite.y >= 348 @enemy_sprite.zoom_y = 0 break end end @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 @enemy_sprite.y -= @enemy_sprite.bitmap.height draw_text(@enemy.given_name, "est K.O.!") wait(40) end def actor_down # Si déjà vaincu #if @actor_sprite.zoom_y <= 0.0 if @actor_sprite.y >= 576 return end # Sinon if FileTest.exist?(@actor.cry) Audio.se_play(@actor.cry) end wait(50) Audio.se_play("Audio/SE/Down.wav") loop do @actor_status.x += 20 #@actor_sprite.zoom_y -= 0.05 @actor_sprite.y += 12 @actor_sprite.opacity -= 20 Graphics.update #if @actor_sprite.zoom_y <= 0.0 if @actor_sprite.y >= 576 break end end draw_text(@actor.given_name, "est K.O.!") wait(40) end #------------------------------------------------------------ # Attaques #------------------------------------------------------------ def attack_animation(info, hit, miss, user, user_skill, user_sprite, target_sprite) if miss wait(40) draw_text("Mais cela échoue!") wait(40) return end if user == @enemy reverse = true else reverse = false end efficiency = info[2] if hit and efficiency != -2 # Animation utilisateur animation_user = $data_animations[user_skill.user_anim_id] user_sprite.register_position if animation_user != nil user_sprite.animation(animation_user, true, reverse) until not(user_sprite.effect?) user_sprite.update Graphics.update end end user_sprite.reset_position user_sprite.update Graphics.update # Animation Cible animation_target = $data_animations[user_skill.target_anim_id] target_sprite.register_position if animation_target != nil target_sprite.animation(animation_target, true, reverse) until not(target_sprite.effect?) target_sprite.update Graphics.update end end target_sprite.reset_position target_sprite.update Graphics.update if info[0] > 0 case efficiency when 0 # Normal Audio.se_play("Audio/SE/Hit.wav", 100) blink(target_sprite, 3, 3) when 1 # Super efficace Audio.se_play("Audio/SE/Hitplus.wav", 100) blink(target_sprite, 2, 5) when -1 # Peu efficace Audio.se_play("Audio/SE/Hitlow.wav", 100) blink(target_sprite, 4, 2) end end elsif not(hit) wait(40) draw_text(user.given_name, "rate son attaque!") wait(40) end end def blink(sprite, frame = 4, number = 3) for i in 0..number wait(frame) sprite.opacity = 0 Graphics.update wait(frame) sprite.opacity = 255 Graphics.update end end def post_attack(info, damage, power) efficiency = info[2] if damage == 0 and (efficiency != -2 or power == 0) return end critical = info[1] if critical and efficiency != -2 #critical_hit draw_text("Coup critique!") wait(40) end case efficiency when 1 draw_text("C'est super efficace!") wait(40) when -1 draw_text("Ce n'est pas très efficace...") wait(40) when -2 draw_text("Ca ne l'affecte pas...") wait(40) end end def faint_check(user = nil) if user == nil faint_check(@actor) faint_check(@enemy) end if user == @actor and user.dead? actor_down end if user == @enemy and user.dead? enemy_down end end #------------------------------------------------------------ # Statut et stats #------------------------------------------------------------ def status_animation(sprite, status) animation = $data_animations[469 + status] sprite.animation(animation, true) loop do sprite.update Graphics.update Input.update if not(sprite.effect?) break end end end def stage_animation(sprite, animation) sprite.animation(animation, true) loop do sprite.update Graphics.update Input.update if not(sprite.effect?) wait(20) break end end end # 1 Normal 2 Feu 3 Eau 4 Electrique 5 Plante 6 Glace 7 Combat 8 Poison 9 Sol # 10 Vol 11 Psy 12 Insecte 13 Roche 14 Spectre 15 Dragon 16 Acier 17 Tenebres def type_string(type) case type when 0 return "???" when 1 return "NORMAL" when 2 return "FEU" when 3 return "EAU" when 4 return "ELECTRIK" when 5 return "PLANTE" when 6 return "GLACE" when 7 return "COMBAT" when 8 return "POISON" when 9 return "SOL" when 10 return "VOL" when 11 return "PSY" when 12 return "INSECTE" when 13 return "ROCHE" when 14 return "SPECTRE" when 15 return "DRAGON" when 16 return "ACIER" when 17 return "TENEBRES" end end # Changement (ou pas) de statut def status_string(actor, status) string = actor.given_name case status when -1 draw_text(string + " est", "déjà empoisonné!") wait(40) when -2 draw_text(string + " est", "déjà paralysé!") wait(40) when -3 draw_text(string,"brûle déjà!") wait(40) when -4 draw_text(string,"dort déjà!") wait(40) when -5 draw_text(string, "est déjà gelé!") wait(40) when -6 draw_text(string, "est déjà confus!") wait(40) when -8 draw_text(string + " est", "déjà gravement empoisonné!") wait(40) when 1 draw_text(string, "est empoisonné!") wait(40) when 2 draw_text(string, "est paralysé!") wait(40) when 3 draw_text(string,"brûle!") wait(40) when 4 draw_text(string,"s'endort!") wait(40) when 5 draw_text(string,"gèle!") wait(40) when 6 draw_text("Cela rend " + string, "confus!") wait(40) when 7 draw_text(string, "est appeuré!") wait(40) when 8 draw_text(string + " est", "gravement empoisonné!") wait(40) end end # S'occupe du texte et de l'animation def raise_stat(string, actor, n = 0) if actor == @actor actor_sprite = @actor_sprite elsif actor == @enemy actor_sprite = @enemy_sprite end if n == 1 text = actor.given_name + " augmente!" elsif n > 1 text = actor.given_name + " augmente beaucoup!" end if n != 0 case string when "ATK" draw_text("Ah, Attaque de",text) stage_animation(actor_sprite, $data_animations[478]) when "DFE" draw_text("Ah, Défense de",text) stage_animation(actor_sprite, $data_animations[480]) when "ATS" draw_text("Ah, Attaque Spéciale de",text) stage_animation(actor_sprite, $data_animations[484]) when "DFS" draw_text("Ah, Défense Spéciale de",text) stage_animation(actor_sprite, $data_animations[486]) when "SPD" draw_text("Ah, Vitesse de",text) stage_animation(actor_sprite, $data_animations[482]) when "EVA" draw_text("Ah, Esquive de",text) stage_animation(actor_sprite, $data_animations[488]) when "ACC" draw_text("Ah, Précision de",text) stage_animation(actor_sprite, $data_animations[490]) end elsif n == 0 case string when "ATK" draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus haut!") wait(40) when "DFE" draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus haut!") wait(40) when "ATS" draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus haut!") wait(40) when "DFS" draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus haut!") wait(40) when "SPD" draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus haut!") wait(40) when "EVA" draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus haut!") wait(40) when "ACC" draw_text("Ah, Précision de ",actor.given_name + " n'ira pas plus haut!") wait(40) when 0 draw_text("Les effets positifs sont supprimés!") wait(40) end end end def reduce_stat(string, actor, n = true, self_inflicted = false) # Mist/Brume if actor.effect_list.include?(0x2E) draw_text(actor.given_name + " est", "protégé par la brume!") wait(40) return end # Clear Body / Corps Sain (ab) // White Smoke / Ecran fumée (ab) if (actor.ability == 29 or actor.ability == 73) and not(self_inflicted) draw_text(actor.ability_name + " de " + actor.given_name, "empêche la réduction!") wait(40) return end # Keen Eye / Regard Vif (ab) if actor.ability == 51 and string == "ACC" draw_text(actor.ability_name + " de " + actor.given_name, "conserve la Précision!") wait(40) return end # Hyper Cutter (ab) if actor.ability == 52 and string == "ATK" draw_text(actor.ability_name + " de " + actor.given_name, "conserve l'Attaque!") wait(40) return end if actor == @actor actor_sprite = @actor_sprite elsif actor == @enemy actor_sprite = @enemy_sprite end if n == -1 text = actor.given_name + " baisse!" elsif n < -1 text = actor.given_name + " baisse beaucoup!" end if n != 0 case string when "ATK" draw_text("Ah, Attaque de",text) stage_animation(actor_sprite, $data_animations[479]) when "DFE" draw_text("Ah, Défense de",text) stage_animation(actor_sprite, $data_animations[481]) when "ATS" draw_text("Ah, Attaque Spéciale de",text) stage_animation(actor_sprite, $data_animations[485]) when "DFS" draw_text("Ah, Défense Spéciale de",text) stage_animation(actor_sprite, $data_animations[487]) when "SPD" draw_text("Ah, Vitesse de",text) stage_animation(actor_sprite, $data_animations[483]) when "EVA" draw_text("Ah, Esquive de",text) stage_animation(actor_sprite, $data_animations[489]) when "ACC" draw_text("Ah, Précision de",text) stage_animation(actor_sprite, $data_animations[491]) end elsif n == 0 case string when "ATK" draw_text("Ah, Attaque de",actor.given_name + " n'ira pas plus bas!") wait(40) when "DFE" draw_text("Ah, Défense de",actor.given_name + " n'ira pas plus bas!") wait(40) when "ATS" draw_text("Ah, Attaque Spéciale de",actor.given_name + " n'ira pas plus bas!") wait(40) when "DFS" draw_text("Ah, Défense Spéciale de",actor.given_name + " n'ira pas plus bas!") wait(40) when "SPD" draw_text("Ah, Vitesse de",actor.given_name + " n'ira pas plus bas!") wait(40) when "EVA" draw_text("Ah, Esquive de",actor.given_name + " n'ira pas plus bas!") wait(40) when "ACC" draw_text("Ah, Précision de",actor.given_name + " n'ira pas plus bas!") wait(40) when 0 draw_text("Les effets positifs sont supprimés!") wait(40) end end end #------------------------------------------------------------ # Appel / Rappel de Pokémon #------------------------------------------------------------ def recall_pokemon draw_text("Ca suffit, " + @actor.given_name + "!", "Reviens!") @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height @actor_sprite.y = 336 @actor_sprite.x = 153 @actor_sprite.color = @actor.ball_color @actor_sprite.color.alpha = 0 until @actor_sprite.color.alpha >= 255 @flash_sprite.opacity += 25 @actor_sprite.color.alpha += 25 Graphics.update end Audio.se_play("Audio/SE/Pokeopen.wav") loop do @actor_status.x += 20 @actor_sprite.opacity -= 25 @actor_sprite.color.alpha += 25 @actor_sprite.zoom_x -= 0.1 @actor_sprite.zoom_y -= 0.1 @flash_sprite.opacity -= 25 Graphics.update if @actor_status.x >= 711 @actor_status.visible = false @actor_status.x = 711 @actor_sprite.color.alpha = 0 @actor_sprite.opacity = 0 Graphics.update break end end end def launch_pokemon @actor_sprite.x = 153 @actor_sprite.y = 336 @actor_sprite.ox = @actor_sprite.bitmap.width / 2 @actor_sprite.oy = @actor_sprite.bitmap.height @actor_sprite.zoom_x = 0 @actor_sprite.zoom_y = 0 #if @actor_party_status.active # @actor_party_status.x = 0 # @actor_party_status.visible = true #end name = @actor.given_name text = [name + "! Go!", name + "! A toi!", name + "! A l'attaque!", name + "! Fonce!"][rand(4)] draw_text(text) @ball_sprite = Sprite.new @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_sprite) @ball_sprite.ox = @ball_sprite.bitmap.width / 2 @ball_sprite.oy = @ball_sprite.bitmap.height / 2 @ball_sprite.x = -44 @ball_sprite.y = 324 @ball_sprite.z = @z_level + 14 t = 0 pi = 3.14 loop do t += 1 @ball_sprite.x += 5 @ball_sprite.y = 336 - 130 * Math.sin(t/40.0*pi) @ball_sprite.angle = - t*63 #if @actor_party_status.active # @actor_party_status.x -= 80 #end Graphics.update if t == 40 @ball_sprite.bitmap = RPG::Cache.picture(@actor.ball_open_sprite) Audio.se_play("Audio/SE/Pokeopen.wav") #if @actor_party_status.active # @actor_party_status.x = 0 # @actor_party_status.visible = false #end break end end @actor_sprite.opacity = 0 @actor_sprite.color = @actor.ball_color until @actor_sprite.zoom_x >= 0.9 @flash_sprite.opacity += 25 @ball_sprite.opacity -= 25 @actor_sprite.zoom_x += 0.1 @actor_sprite.zoom_y += 0.1 @actor_sprite.opacity += 25 Graphics.update end if FileTest.exist?(@actor.cry) Audio.se_play(@actor.cry) end @actor_sprite.zoom_x = 1 @actor_sprite.zoom_y = 1 @actor_sprite.opacity = 255 @actor_status.x = 711 @actor_status.visible = true if @actor.shiny animation = $data_animations[496] @actor_sprite.animation(animation, true) end until @actor_status.x == 311 @background.update @actor_ground.update @enemy_ground.update @actor_status.x -= 20 @actor_sprite.color.alpha -= 25 @flash_sprite.opacity -= 25 @actor_sprite.update Graphics.update end until not(@actor_sprite.effect?) @actor_sprite.update Graphics.update end @actor_status.x = 311 @actor_sprite.color.alpha = 0 @flash_sprite.opacity = 0 @ball_sprite.dispose Graphics.update end def launch_enemy_pokemon @enemy_sprite.x = 464 @enemy_sprite.y = 104 @enemy_sprite.ox = @enemy_sprite.bitmap.width / 2 @enemy_sprite.oy = @enemy_sprite.bitmap.height / 2 @enemy_sprite.zoom_x = 0 @enemy_sprite.zoom_y = 0 string = Trainer_Info.type(@trainer_id) + " " + Trainer_Info.name(@trainer_id) draw_text(@enemy.name + " est envoyé", "par " + string + "!") @ball_sprite = Sprite.new @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_sprite) @ball_sprite.ox = @ball_sprite.bitmap.width / 2 @ball_sprite.oy = @ball_sprite.bitmap.height / 2 @ball_sprite.x = 663 @ball_sprite.y = 104 @ball_sprite.z = @z_level + 14 t = 0 pi = 3.14 loop do t += 1 @ball_sprite.x -= 5 @ball_sprite.y = 128 - 80 * Math.sin(t/40.0*pi) @ball_sprite.angle = - t*63 Graphics.update if t == 40 @ball_sprite.bitmap = RPG::Cache.picture(@enemy.ball_open_sprite) Audio.se_play("Audio/SE/Pokeopen.wav") break end end @enemy_sprite.opacity = 0 @enemy_sprite.color = @enemy.ball_color until @enemy_sprite.zoom_x >= 0.9 @flash_sprite.opacity += 25 @ball_sprite.opacity -= 25 @enemy_sprite.zoom_x += 0.08 @enemy_sprite.zoom_y += 0.08 @enemy_sprite.opacity += 25 Graphics.update end if FileTest.exist?(@enemy.cry) Audio.se_play(@enemy.cry) end @enemy_sprite.zoom_x = 1 @enemy_sprite.zoom_y = 1 @enemy_sprite.opacity = 255 @enemy_status.x = -377 @enemy_status.visible = true if @enemy.shiny animation = $data_animations[496] @enemy_sprite.animation(animation, true) end until @enemy_status.x == 23 @background.update @actor_ground.update @enemy_ground.update @enemy_status.x += 20 @enemy_sprite.color.alpha -= 25 @flash_sprite.opacity -= 25 @enemy_sprite.update Graphics.update end until not(@enemy_sprite.effect?) @enemy_sprite.update Graphics.update end @enemy_sprite.x = 464 @enemy_status.x = 23 @enemy_sprite.color.alpha = 0 @flash_sprite.opacity = 0 @ball_sprite.dispose Graphics.update end #------------------------------------------------------------ # Fin de combat #------------------------------------------------------------ def end_battle(result = 0) # Reset des variables et effets $battle_var.reset @actor.skill_effect_reset @actor.reset_stat_stage @actor.cure_state @actor.ability_active = false @enemy.skill_effect_reset @enemy.reset_stat_stage @enemy.cure_state @enemy.ability_active = false # ----------------------------------- Audio.me_stop wait(10) $game_system.bgm_play($game_temp.map_bgm) wait(10) Graphics.freeze # ----------------------------------- if $game_temp.battle_proc != nil $game_temp.battle_proc.call(result) $game_temp.battle_proc = nil end # Défaite $scene = Scene_Map.new end def end_battle_flee(expulsion = false) $battle_var.result_flee = true $game_system.se_play($data_system.escape_se) if expulsion draw_text(@actor.given_name, "est expulsé du combat!") loop do if @actor_sprite.x > -160 @actor_sprite.x -= 20 end Graphics.update Input.update if @actor_sprite.x <= -160 wait(40) break end end else draw_text("Vous prenez la fuite!") wait(40) end end_battle(1) end def fail_flee draw_text("Vous ne pouvez pas","vous enfuir!") wait(40) end def end_battle_flee_enemy(expulsion = false) $battle_var.result_flee = true $game_system.se_play($data_system.escape_se) if expulsion draw_text(@enemy.given_name, "est expulsé du combat!") else draw_text(@enemy.given_name + " s'échappe!") end loop do if @enemy_sprite.x < 800 @enemy_sprite.x += 20 end Graphics.update Input.update if @enemy_sprite.x >= 800 wait(40) break end end end_battle(1) end def end_battle_defeat $battle_var.result_defeat = true draw_text("Tous vos Pokémons", "ont été vaincus!") wait(40) $pokemon_party.money /= 2 if not(@lose) if $game_variables[1] == 0 print("Réglez votre point de retour!") else $game_map.setup($game_variables[1]) $game_map.display_x = $game_variables[2] $game_map.display_y = $game_variables[3] $game_player.moveto($game_variables[2], $game_variables[3]) end $game_temp.common_event_id = 2 end $game_temp.map_bgm = $game_map.bgm end_battle(2) end def draw_choice @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig) @command.x = 517 @command.y = 215 loop do Graphics.update Input.update @command.update if Input.trigger?(Input::C) and @command.index == 0 $game_system.se_play($data_system.decision_se) @command.dispose @command = nil Input.update return true end if Input.trigger?(Input::C) and @command.index == 1 $game_system.se_play($data_system.decision_se) @command.dispose @command = nil Input.update return false end end end end #------------------------------------------------------------ # Fenêtre de statut #------------------------------------------------------------ class Pokemon_Battle_Status < Window_Base def initialize(pokemon, enemy, z_level = 15) @enemy = enemy # True / False if @enemy super(23,0,332,116) else super(311,203,341,140) end self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontsmall self.contents.font.size = $fontsmallsize # self.contents.font.bold = true self.opacity = 0 self.z = z_level @pokemon = pokemon refresh end def refresh self.contents.clear level = @pokemon.hp.to_f / @pokemon.maxhp_basis.to_f normal_color = Color.new(0,0,0,255) if @enemy src_rect = Rect.new(0, 0, 300, 84) bitmap = RPG::Cache.picture("battle_sprite1.png") self.contents.blt(0, 0, bitmap, src_rect, 255) draw_hp_bar(69,45, level) draw_text(15, 6, 249, $fs, @pokemon.name, 0, normal_color) draw_text(15, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) width_text = self.contents.text_size(@pokemon.name).width + 3 draw_gender(15 + width_text, 15, @pokemon.gender) if $data_pokedex[@pokemon.id][1] src_rect = Rect.new(0, 0, 21, 21) bitmap = RPG::Cache.picture("ballbattlestatus.png") self.contents.blt(27, 45, bitmap, src_rect, 255) end if @pokemon.status != 0 string = "stat" + @pokemon.status.to_s + ".png" src_rect = Rect.new(0, 0, 60, 24) bitmap = RPG::Cache.picture(string) self.contents.blt(9, 42, bitmap, src_rect, 255) end else src_rect = Rect.new(0, 0, 309, 108) if $game_variables[47] == 1 bitmap = RPG::Cache.picture("battle_sprite3.png") self.contents.blt(0, 0, bitmap, src_rect, 255) #draw_hp_bar(93,45, level) draw_text(47, 58, 249, $fs, Player.name, 0, normal_color) #draw_text(39, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) string = @pokemon.hp < 0 ? 0 : @pokemon.hp #draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color) if @pokemon.level < 100 level = @pokemon.next_exp.to_f / (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f else level = 0 end #draw_exp_bar(93, 99, 1.0 - level, 192) #width_text = self.contents.text_size(@pokemon.given_name).width + 3 #draw_gender(39 + width_text, 15, @pokemon.gender) else bitmap = RPG::Cache.picture("battle_sprite2.png") self.contents.blt(0, 0, bitmap, src_rect, 255) draw_hp_bar(93,45, level) draw_text(47, 6, 249, $fs, @pokemon.given_name, 0, normal_color) draw_text(47, 6, 249, $fs, "N." + @pokemon.level.to_s, 2, normal_color) string = @pokemon.hp < 0 ? 0 : @pokemon.hp draw_text(43, 60, 233, $fs, string.to_s + " / " + @pokemon.maxhp_basis.to_s, 2, normal_color) if @pokemon.level < 100 level = @pokemon.next_exp.to_f / (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f else level = 0 end draw_exp_bar(93, 99, 1.0 - level, 192) width_text = self.contents.text_size(@pokemon.given_name).width + 3 draw_gender(47 + width_text, 15, @pokemon.gender) end if @pokemon.status != 0 string = "stat" + @pokemon.status.to_s + ".png" src_rect = Rect.new(0, 0, 60, 24) bitmap = RPG::Cache.picture(string) self.contents.blt(42, 66, bitmap, src_rect, 255) end end end def exp_refresh level = @pokemon.next_exp.to_f / (@pokemon.exp_list[@pokemon.level+1] - @pokemon.exp_list[@pokemon.level]).to_f draw_exp_bar(93, 99, 1.0 - level, 192) end def damage_refresh(info) damage = info[0] if damage == 0 return end for i in 1..damage @pokemon.remove_hp(1) Graphics.update Graphics.update if @pokemon.hp >= @pokemon.max_hp or @pokemon.dead? break end end end def dispose super end def draw_hp_bar(x, y, level, small = false) src_rect = Rect.new(0, 0, 198, 24) bitmap = RPG::Cache.picture("hpbar.png") if small bitmap = RPG::Cache.picture("hpbarsmall.png") end self.contents.blt(x, y, bitmap, src_rect, 255) rect1 = Rect.new(x + 45, y + 6, level*144.to_i, 3) rect2 = Rect.new(x + 45, y + 9, level*144.to_i, 6) if small rect1 = Rect.new(x + 45, y + 6, level*129.to_i, 3) rect2 = Rect.new(x + 45, y + 9, level*129.to_i, 6) end if level < 0.1 color1 = Color.new(170, 70, 70, 255) color2 = Color.new(250, 90, 60, 255) elsif level >= 0.1 and level < 0.5 color1 = Color.new(200, 170, 0, 255) color2 = Color.new(250, 225, 50, 255) else color1 = Color.new(90, 210, 125, 255) color2 = Color.new(110, 250, 170, 255) end self.contents.fill_rect(rect1, color1) self.contents.fill_rect(rect2, color2) end def draw_exp_bar(x, y, level, width) rect1 = Rect.new(x, y, level*192.to_i, 6) self.contents.fill_rect(rect1, Color.new(160, 160, 255, 255)) end def draw_gender(x, y, gender) if gender == 1 rect = Rect.new(0, 0, 18, 33) bitmap = RPG::Cache.picture("Maleb.png") self.contents.blt(x, y, bitmap, rect, 255) end if gender == 2 rect = Rect.new(0, 0, 18, 33) bitmap = RPG::Cache.picture("Femaleb.png") self.contents.blt(x, y, bitmap, rect, 255) end end end #------------------------------------------------------------ # Fenêtre de statut de l'équipe #------------------------------------------------------------ class Pokemon_Battle_Party_Status < Window_Base attr_accessor :battle_order def initialize(party, order, enemy, z_level = 15) @enemy = enemy # True / False @battle_order = order if @enemy super(0-16,63-16,315+32,42+32) else super(325-16, 261-16, 315+32,42+32) end self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 self.z = z_level @party = party refresh end def refresh self.contents.clear src_rect = Rect.new(0, 0, 315, 42) if @enemy bitmap = RPG::Cache.picture("partystatusenemy.png") else bitmap = RPG::Cache.picture("partystatus.png") end self.contents.blt(0, 0, bitmap, src_rect, 255) src_rect = Rect.new(0, 0, 21, 21) if @enemy ball_x = 231 coeff = -1 else ball_x = 63 coeff = 1 end for i in 1..@party.size bitmap = RPG::Cache.picture("ballpartystatus.png") if @party.actors[@battle_order[i-1]].dead? bitmap = RPG::Cache.picture("ballpartystatusko.png") end self.contents.blt(ball_x + coeff*30*(i-1), 3, bitmap, src_rect, 255) end end def reset_position if @enemy self.x = -16 else self.x = 325-16 end refresh end end class Pokemon_Battle_Variable attr_accessor :weather attr_accessor :actor_last_used attr_accessor :enemy_last_used attr_accessor :battle_order attr_accessor :enemy_battle_order attr_accessor :in_battle attr_accessor :actor_last_taken_damage attr_accessor :enemy_last_taken_damage attr_accessor :have_fought #liste des pokémons ayant participé par leur index attr_accessor :enemy_party attr_accessor :action_id attr_accessor :window_index attr_accessor :result_flee attr_accessor :result_win attr_accessor :result_defeat attr_accessor :last_index attr_accessor :round attr_accessor :run_count attr_accessor :money # Weather: [ catégorie, nombre de tours ] # catégorie: 0: Normal, 1: Pluie, 2: Ensoleillé, # 3: Tempête de Sable, 4: Grêle def initialize @weather = [0, 0] @actor_last_used = nil @enemy_last_used = nil @battle_order = (0..5).to_a @enemy_battle_order = (0..5).to_a @in_battle = false @actor_last_taken_damage = 0 @enemy_last_taken_damage = 0 @have_fought = [] @enemy_party = Pokemon_Party.new @action_id = 0 @window_index = 0 @result_flee = false @result_win = false @result_defeat = false @last_index = 0 @round = 0 @run_count = 0 @money = 0 end def reset @weather = [0, 0] @actor_last_used = nil @enemy_last_used = nil @battle_order = (0..5).to_a @enemy_battle_order = (0..5).to_a @in_battle = false @actor_last_taken_damage = 0 @enemy_last_taken_damage = 0 @have_fought = [] @enemy_party = Pokemon_Party.new @action_id = 0 @window_index = 0 @last_index = 0 @round = 0 @run_count = 0 @money = 0 end def reset_weather @weather = [0, 0] end def set_rain(duration = -1) @weather = [1, duration] end def rain? if @weather[0] == 1 return true else return false end end def set_sunny(duration = -1) @weather = [2, duration] end def sunny? if @weather[0] == 2 return true else return false end end def sandstorm? if @weather[0] == 3 return true else return false end end def set_sandstorm(duration = -1) @weather = [3, duration] end def hail? if @weather[0] == 4 return true else return false end end def set_hail(duration = -1) @weather = [4, duration] end def battle_end? if @result_flee or @result_win or @result_defeat return true else return false end end def add_money(amount) if @money == nil @money = 0 end @money += amount end end end |
Noriel- a écrit: |
Therand: Pour commencer merci ![]() Et non pour l'id de la Ball. {{{Spoiler}}} |
Noriel- a écrit: |
Therand: Pour commencer merci ![]() Sans l'id associé le jeu aurait probablement planté lors de l'envoi de celle-ci. {{{Spoiler}}} |