Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.08 KB | None | 0 0
  1.   def pbSwitch(favorDraws=false)
  2.     if !favorDraws
  3.       return if @decision>0
  4.     else
  5.       return if @decision==5
  6.     end
  7.     pbJudge()
  8.     return if @decision>0
  9.     firstbattlerhp=@battlers[0].hp
  10.     switched=[]
  11.     loop do    # SAGE ADDED
  12.       for index in 0...4
  13.         next if !@doublebattle && pbIsDoubleBattler?(index)
  14.         next if @battlers[index] && !@battlers[index].isFainted?
  15.         next if !pbCanChooseNonActive?(index)
  16.         if !pbOwnedByPlayer?(index)
  17.           if !pbIsOpposing?(index) || (@opponent && pbIsOpposing?(index))
  18.             newenemy=pbSwitchInBetween(index,false,false)
  19.             newenemyname=newenemy
  20.             if newenemy>=0 && isConst?(pbParty(index)[newenemy].ability,PBAbilities,:ILLUSION)
  21.               newenemyname=pbGetLastPokeInTeam(index)
  22.             end
  23.             opponent=pbGetOwner(index)
  24.             if !@doublebattle && firstbattlerhp>0 && @shiftStyle && @opponent &&
  25.                 @internalbattle && pbCanChooseNonActive?(0) && pbIsOpposing?(index) &&
  26.                 @battlers[0].effects[PBEffects::Outrage]==0
  27.               pbDisplayPaused(_INTL("{1} is about to send in {2}.",opponent.fullname,pbParty(index)[newenemyname].name))
  28.               if pbDisplayConfirm(_INTL("Will {1} change Pokémon?",self.pbPlayer.name))
  29.                 newpoke=pbSwitchPlayer(0,true,true)
  30.                 if newpoke>=0
  31.                   newpokename=newpoke
  32.                   if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
  33.                     newpokename=pbGetLastPokeInTeam(0)
  34.                   end
  35.                   pbDisplayBrief(_INTL("{1}, that's enough! Come back!",@battlers[0].name))
  36.                   pbRecallAndReplace(0,newpoke,newpokename)
  37.                   switched.push(0)
  38.                 end
  39.               end
  40.             end
  41.             pbRecallAndReplace(index,newenemy,newenemyname,false,false)
  42.             switched.push(index)
  43.           end
  44.         elsif @opponent
  45.           newpoke=pbSwitchInBetween(index,true,false)
  46.           newpokename=newpoke
  47.           if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
  48.             newpokename=pbGetLastPokeInTeam(index)
  49.           end
  50.           pbRecallAndReplace(index,newpoke,newpokename)
  51.           switched.push(index)
  52.         else
  53.           switch=false
  54.           if !pbDisplayConfirm(_INTL("Use next Pokémon?"))
  55.             switch=(pbRun(index,true)<=0)
  56.           else
  57.             switch=true
  58.           end
  59.           if switch
  60.             newpoke=pbSwitchInBetween(index,true,false)
  61.             newpokename=newpoke
  62.             if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
  63.               newpokename=pbGetLastPokeInTeam(index)
  64.             end
  65.             pbRecallAndReplace(index,newpoke,newpokename)
  66.             switched.push(index)
  67.           end
  68.         end
  69.       end
  70.       if switched.length>0
  71.         priority=pbPriority
  72.         for i in priority
  73.           i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
  74.         end
  75.       else    # SAGE ADDED
  76.         break    # SAGE ADDED
  77.       end
  78.     end    # SAGE ADDED
  79.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement