SHARE
TWEET

Party Switcher

a guest Jul 18th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #--------------------------------------------------------------------------------
  2. #Allows for the storing and switching of mons
  3. #--------------------------------------------------------------------------------
  4. module PokeBattle_BattleCommon
  5.   def pbStorePokemon(pokemon)
  6.     if !(pokemon.isShadow? rescue false)
  7.       if pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?",pokemon.name))
  8.         species=PBSpecies.getName(pokemon.species)
  9.         nickname=@scene.pbNameEntry(_INTL("{1}'s nickname?",species),pokemon)
  10.         pokemon.name=nickname if nickname!=""
  11.       end
  12.     end
  13.     if $Trainer.party.length<6
  14.       $Trainer.party[$Trainer.party.length]=pokemon
  15.       return -1
  16.     else
  17.       monsent=false
  18.       while !monsent
  19.         if Kernel.pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
  20.           iMon = -2
  21.           eggcount = 0
  22.           for i in $Trainer.party
  23.             next if i.isEgg?
  24.             eggcount += 1
  25.           end
  26.           pbFadeOutIn(99999){
  27.             sscene  = PokemonParty_Scene.new
  28.             sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  29.             sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
  30.             loop do
  31.               iMon=sscreen.pbChoosePokemon
  32.                if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
  33.                 Kernel.pbMessage("That's your last Pokémon!")              
  34.               else
  35.                 sscreen.pbEndScene
  36.                 break
  37.               end
  38.             end
  39.           }
  40.           if !(iMon < 0)
  41.             iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
  42.             if iBox >= 0
  43.               monsent=true
  44.               player.party[iMon].heal
  45.               Kernel.pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
  46.               $Trainer.party[iMon] = nil
  47.               $Trainer.party.compact!
  48.               $Trainer.party[$Trainer.party.length]=pokemon
  49.               return -1
  50.             else
  51.               Kernel.pbMessage("No space left in the PC.")
  52.               return false
  53.             end
  54.           end      
  55.         else
  56.           monsent=true
  57.           pokemon.heal
  58.           oldcurbox=$PokemonStorage.currentBox
  59.           storedbox=$PokemonStorage.pbStoreCaught(pokemon)
  60.           if storedbox<0
  61.             pbDisplayPaused(_INTL("Can't catch any more..."))
  62.             return oldcurbox
  63.           else
  64.             return storedbox
  65.           end
  66.         end
  67.       end      
  68.     end
  69.   end
  70. end  
  71.  
  72. def pbStorePokemon(pokemon)
  73.   if pbBoxesFull?
  74.     Kernel.pbMessage(_INTL("There's no more room for Pokémon!\1"))
  75.     Kernel.pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
  76.     return
  77.   end
  78.   pokemon.pbRecordFirstMoves
  79.   if $Trainer.party.length<6
  80.     $Trainer.party[$Trainer.party.length]=pokemon
  81.   else
  82.     monsent=false
  83.     while !monsent
  84.       if Kernel.pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
  85.         iMon = -2
  86.         eggcount = 0
  87.         for i in $Trainer.party
  88.           next if i.isEgg?
  89.           eggcount += 1
  90.         end
  91.         pbFadeOutIn(99999){
  92.           sscene  = PokemonParty_Scene.new
  93.           sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  94.           sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
  95.           loop do
  96.             iMon=sscreen.pbChoosePokemon
  97.             if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
  98.               Kernel.pbMessage("That's your last Pokémon!")              
  99.             else
  100.               sscreen.pbEndScene
  101.               break
  102.             end
  103.           end
  104.         }
  105.         if !(iMon < 0)    
  106.           iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
  107.           if iBox >= 0
  108.             monsent=true
  109.             $Trainer.party[iMon].heal
  110.             Kernel.pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
  111.             $Trainer.party[iMon] = nil
  112.             $Trainer.party.compact!
  113.             $Trainer.party[$Trainer.party.length]=pokemon
  114.           else
  115.             Kernel.pbMessage("No space left in the PC.")
  116.             return false
  117.           end
  118.         end      
  119.       else
  120.         monsent=true
  121.         oldcurbox=$PokemonStorage.currentBox
  122.         storedbox=$PokemonStorage.pbStoreCaught(pokemon)
  123.         curboxname=$PokemonStorage[oldcurbox].name
  124.         boxname=$PokemonStorage[storedbox].name
  125.         creator=nil
  126.         creator=Kernel.pbGetStorageCreator if $PokemonGlobal.seenStorageCreator
  127.         if storedbox!=oldcurbox
  128.           if creator
  129.             Kernel.pbMessage(_INTL("Box \"{1}\" on {2}'s PC was full.\1",curboxname,creator))
  130.           else
  131.             Kernel.pbMessage(_INTL("Box \"{1}\" on someone's PC was full.\1",curboxname))
  132.           end
  133.           Kernel.pbMessage(_INTL("{1} was transferred to box \"{2}.\"",pokemon.name,boxname))
  134.         else
  135.           if creator
  136.             Kernel.pbMessage(_INTL("{1} was transferred to {2}'s PC.\1",pokemon.name,creator))
  137.           else
  138.             Kernel.pbMessage(_INTL("{1} was transferred to someone's PC.\1",pokemon.name))
  139.           end
  140.           Kernel.pbMessage(_INTL("It was stored in box \"{1}\".",boxname))
  141.         end
  142.       end    
  143.     end
  144.   end
  145. end
  146.  
  147. def pbAddPokemonSilent(pokemon,level=nil,seeform=true)
  148.   return false if !pokemon || pbBoxesFull? || !$Trainer
  149.   if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
  150.     pokemon=getID(PBSpecies,pokemon)
  151.   end
  152.   if pokemon.is_a?(Integer) && level.is_a?(Integer)
  153.     pokemon=PokeBattle_Pokemon.new(pokemon,level,$Trainer)
  154.   end
  155.   if pokemon.ot == ""
  156.     pokemon.ot = $Trainer.name
  157.     pokemon.trainerID = $Trainer.id
  158.   end  
  159.   $Trainer.seen[pokemon.species]=true
  160.   $Trainer.owned[pokemon.species]=true
  161.   pbSeenForm(pokemon) if seeform
  162.   pokemon.pbRecordFirstMoves
  163.   if $Trainer.party.length<6
  164.     $Trainer.party[$Trainer.party.length]=pokemon
  165.   else
  166.     monsent=false
  167.     while !monsent
  168.       if Kernel.pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
  169.         iMon = -2
  170.         eggcount = 0
  171.         for i in $Trainer.party
  172.           next if i.isEgg?
  173.           eggcount += 1
  174.         end
  175.         pbFadeOutIn(99999){
  176.           sscene  = PokemonParty_Scene.new
  177.           sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  178.           sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
  179.           loop do
  180.             iMon=sscreen.pbChoosePokemon
  181.             if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
  182.               Kernel.pbMessage("That's your last Pokémon!")              
  183.             else
  184.               sscreen.pbEndScene
  185.               break
  186.             end
  187.           end
  188.         }
  189.         if !(iMon < 0)
  190.           iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
  191.           if iBox >= 0
  192.             monsent=true
  193.             Kernel.pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
  194.             $Trainer.party[iMon] = nil
  195.             $Trainer.party.compact!
  196.             $Trainer.party[$Trainer.party.length]=pokemon
  197.           else
  198.             Kernel.pbMessage("No space left in the PC.")
  199.             return false
  200.           end
  201.         end      
  202.       else
  203.         monsent=true
  204.         storedbox = $PokemonStorage.pbStoreCaught(pokemon)
  205.         if pokemon.isEgg?
  206.          oldcurbox=$PokemonStorage.currentBox
  207.          #storedbox=$PokemonStorage.pbStoreCaught(pokemon)
  208.          curboxname=$PokemonStorage[oldcurbox].name
  209.          boxname=$PokemonStorage[storedbox].name
  210.          creator=nil
  211.          creator=Kernel.pbGetStorageCreator if $PokemonGlobal.seenStorageCreator
  212.           if storedbox!=oldcurbox
  213.             if creator
  214.               Kernel.pbMessage(_INTL("Box \"{1}\" on {2}'s PC was full.\1",curboxname,creator))
  215.             else
  216.               Kernel.pbMessage(_INTL("Box \"{1}\" on someone's PC was full.\1",curboxname))
  217.             end
  218.             Kernel.pbMessage(_INTL("{1} was transferred to box \"{2}.\"",pokemon.name,boxname))
  219.           else
  220.             if creator
  221.               Kernel.pbMessage(_INTL("{1} was transferred to {2}'s PC.\1",pokemon.name,creator))
  222.             else
  223.               Kernel.pbMessage(_INTL("{1} was transferred to someone's PC.\1",pokemon.name))
  224.             end
  225.             Kernel.pbMessage(_INTL("It was stored in box \"{1}\".",boxname))
  226.           end
  227.         end
  228.       end
  229.     end    
  230.   end
  231.   return true
  232. end
  233.  
  234. #--------------------------------------------------------------------------------
  235. #Provides Evolution Check on Party Switcher
  236. #--------------------------------------------------------------------------------
  237. class PokemonTemp
  238.   attr_accessor :encounterType
  239.   attr_accessor :evolutionLevels
  240.   attr_accessor :party # changed added
  241. end
  242.  
  243. Events.onStartBattle+=proc {|sender,e| # Changed added $PokemonTemp.party to fix party swap evo bug
  244.   $PokemonTemp.party = []
  245.   $PokemonTemp.evolutionLevels = []
  246.   for i in 0...$Trainer.party.length
  247.     $PokemonTemp.party[i] = $Trainer.party[i]
  248.     $PokemonTemp.evolutionLevels[i] = $Trainer.party[i].level
  249.   end
  250. }
  251.  
  252. def pbEvolutionCheck(currentlevels)
  253.   for i in 0...currentlevels.length
  254.     pokemon = $Trainer.party[i]
  255.     next if $PokemonTemp.party[i] != $Trainer.party[i] # changed added to fix party swap evo bug
  256.     next if pokemon.hp==0 && !USENEWBATTLEMECHANICS
  257.     if pokemon && (!currentlevels[i] || pokemon.level!=currentlevels[i])
  258.       newspecies = Kernel.pbCheckEvolution(pokemon)
  259.       if newspecies>0
  260.         evo = PokemonEvolutionScene.new
  261.         evo.pbStartScreen(pokemon,newspecies)
  262.         evo.pbEvolution
  263.         evo.pbEndScreen
  264.       end
  265.     end
  266.   end
  267. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top