Advertisement
Guest User

Party Switcher 18+

a guest
Apr 6th, 2021
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.28 KB | None | 0 0
  1. #==============================================================================#
  2. #                         Party Switcher (Based on Reborn's code)              #
  3. #                                                                              #
  4. #==============================================================================#
  5. PluginManager.register({
  6.   :name => "Party Switcher",
  7.   :version => "2.0",
  8.   :credits => "Michael, TechSkylander1518, Marcello, ZeroKid",
  9.   :link => "https://reliccastle.com/resources/323/"
  10. })
  11.  
  12. #--------------------------------------------------------------------------------
  13. #Allows for the storing and switching of mons
  14. #--------------------------------------------------------------------------------
  15. module PokeBattle_BattleCommon
  16.   def pbStorePokemon(pokemon)
  17.     if !(pokemon.isShadow? rescue false)
  18.       if pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?",pokemon.name))
  19.         species=PBSpecies.getName(pokemon.species)
  20.         nickname=@scene.pbNameEntry(_INTL("{1}'s nickname?",species),pokemon)
  21.         pokemon.name=nickname if nickname!=""
  22.       end
  23.     end
  24.     if $Trainer.party.length<6
  25.       $Trainer.party[$Trainer.party.length]=pokemon
  26.       return -1
  27.     else
  28.       monsent=false
  29.       while !monsent
  30.         if pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
  31.           iMon = -2
  32.           eggcount = 0
  33.           for i in $Trainer.party
  34.             next if i.isEgg?
  35.             eggcount += 1
  36.           end
  37.           pbFadeOutIn(99999){
  38.             sscene  = PokemonParty_Scene.new
  39.             sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  40.             sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
  41.             loop do
  42.               iMon=sscreen.pbChoosePokemon
  43.                if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
  44.                 pbMessage("That's your last Pokémon!")              
  45.               else
  46.                 sscreen.pbEndScene
  47.                 break
  48.               end
  49.             end
  50.           }
  51.           if !(iMon < 0)
  52.             iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
  53.             if iBox >= 0
  54.               monsent=true
  55.               $Trainer.party[iMon].heal
  56.               pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
  57.               $Trainer.party[iMon] = nil
  58.               $Trainer.party.compact!
  59.               $Trainer.party[$Trainer.party.length]=pokemon
  60.               return -1
  61.             else
  62.               pbMessage("No space left in the PC.")
  63.               return false
  64.             end
  65.           end      
  66.         else
  67.           monsent=true
  68.           pokemon.heal
  69.           oldcurbox=$PokemonStorage.currentBox
  70.           storedbox=$PokemonStorage.pbStoreCaught(pokemon)
  71.           if storedbox<0
  72.             pbDisplayPaused(_INTL("Can't catch any more..."))
  73.             return oldcurbox
  74.           else
  75.             return storedbox
  76.           end
  77.         end
  78.       end      
  79.     end
  80.   end
  81. end  
  82.  
  83. def pbStorePokemon(pokemon)
  84.   if pbBoxesFull?
  85.     pbMessage(_INTL("There's no more room for Pokémon!\1"))
  86.     pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
  87.     return
  88.   end
  89.   pokemon.pbRecordFirstMoves
  90.   if $Trainer.party.length<6
  91.     $Trainer.party[$Trainer.party.length]=pokemon
  92.   else
  93.     monsent=false
  94.     while !monsent
  95.       if pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
  96.         iMon = -2
  97.         eggcount = 0
  98.         for i in $Trainer.party
  99.           next if i.isEgg?
  100.           eggcount += 1
  101.         end
  102.         pbFadeOutIn(99999){
  103.           sscene  = PokemonParty_Scene.new
  104.           sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  105.           sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
  106.           loop do
  107.             iMon=sscreen.pbChoosePokemon
  108.             if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
  109.               pbMessage("That's your last Pokémon!")              
  110.             else
  111.               sscreen.pbEndScene
  112.               break
  113.             end
  114.           end
  115.         }
  116.         if !(iMon < 0)    
  117.           iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
  118.           if iBox >= 0
  119.             monsent=true
  120.             $Trainer.party[iMon].heal
  121.             pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
  122.             $Trainer.party[iMon] = nil
  123.             $Trainer.party.compact!
  124.             $Trainer.party[$Trainer.party.length]=pokemon
  125.           else
  126.             pbMessage("No space left in the PC.")
  127.             return false
  128.           end
  129.         end      
  130.       else
  131.         monsent=true
  132.         oldcurbox=$PokemonStorage.currentBox
  133.         storedbox=$PokemonStorage.pbStoreCaught(pokemon)
  134.         curboxname=$PokemonStorage[oldcurbox].name
  135.         boxname=$PokemonStorage[storedbox].name
  136.         creator=nil
  137.         creator=pbGetStorageCreator if $PokemonGlobal.seenStorageCreator
  138.         if storedbox!=oldcurbox
  139.           if creator
  140.             pbMessage(_INTL("Box \"{1}\" on {2}'s PC was full.\1",curboxname,creator))
  141.           else
  142.             pbMessage(_INTL("Box \"{1}\" on someone's PC was full.\1",curboxname))
  143.           end
  144.           pbMessage(_INTL("{1} was transferred to box \"{2}.\"",pokemon.name,boxname))
  145.         else
  146.           if creator
  147.             pbMessage(_INTL("{1} was transferred to {2}'s PC.\1",pokemon.name,creator))
  148.           else
  149.             pbMessage(_INTL("{1} was transferred to someone's PC.\1",pokemon.name))
  150.           end
  151.           pbMessage(_INTL("It was stored in box \"{1}\".",boxname))
  152.         end
  153.       end    
  154.     end
  155.   end
  156. end
  157.  
  158. def pbAddPokemonSilent(pokemon,level=nil,seeform=true)
  159.   return false if !pokemon || pbBoxesFull? || !$Trainer
  160.   if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
  161.     pokemon=getID(PBSpecies,pokemon)
  162.   end
  163.   if pokemon.is_a?(Integer) && level.is_a?(Integer)
  164.     pokemon=PokeBattle_Pokemon.new(pokemon,level,$Trainer)
  165.   end
  166.   if pokemon.ot == ""
  167.     pokemon.ot = $Trainer.name
  168.     pokemon.trainerID = $Trainer.id
  169.   end  
  170.   $Trainer.seen[pokemon.species]=true
  171.   $Trainer.owned[pokemon.species]=true
  172.   pbSeenForm(pokemon) if seeform
  173.   pokemon.pbRecordFirstMoves
  174.   if $Trainer.party.length<6
  175.     $Trainer.party[$Trainer.party.length]=pokemon
  176.   else
  177.     monsent=false
  178.     while !monsent
  179.       if pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
  180.         iMon = -2
  181.         eggcount = 0
  182.         for i in $Trainer.party
  183.           next if i.isEgg?
  184.           eggcount += 1
  185.         end
  186.         pbFadeOutIn(99999){
  187.           sscene  = PokemonParty_Scene.new
  188.           sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  189.           sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
  190.           loop do
  191.             iMon=sscreen.pbChoosePokemon
  192.             if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
  193.               pbMessage("That's your last Pokémon!")              
  194.             else
  195.               sscreen.pbEndScene
  196.               break
  197.             end
  198.           end
  199.         }
  200.         if !(iMon < 0)
  201.           iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
  202.           if iBox >= 0
  203.             monsent=true
  204.             pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
  205.             $Trainer.party[iMon] = nil
  206.             $Trainer.party.compact!
  207.             $Trainer.party[$Trainer.party.length]=pokemon
  208.           else
  209.             pbMessage("No space left in the PC.")
  210.             return false
  211.           end
  212.         end      
  213.       else
  214.         monsent=true
  215.         storedbox = $PokemonStorage.pbStoreCaught(pokemon)
  216.         if pokemon.isEgg?
  217.          oldcurbox=$PokemonStorage.currentBox
  218.          #storedbox=$PokemonStorage.pbStoreCaught(pokemon)
  219.          curboxname=$PokemonStorage[oldcurbox].name
  220.          boxname=$PokemonStorage[storedbox].name
  221.          creator=nil
  222.          creator=pbGetStorageCreator if $PokemonGlobal.seenStorageCreator
  223.           if storedbox!=oldcurbox
  224.             if creator
  225.               pbMessage(_INTL("Box \"{1}\" on {2}'s PC was full.\1",curboxname,creator))
  226.             else
  227.               pbMessage(_INTL("Box \"{1}\" on someone's PC was full.\1",curboxname))
  228.             end
  229.             pbMessage(_INTL("{1} was transferred to box \"{2}.\"",pokemon.name,boxname))
  230.           else
  231.             if creator
  232.               pbMessage(_INTL("{1} was transferred to {2}'s PC.\1",pokemon.name,creator))
  233.             else
  234.               pbMessage(_INTL("{1} was transferred to someone's PC.\1",pokemon.name))
  235.             end
  236.             pbMessage(_INTL("It was stored in box \"{1}\".",boxname))
  237.           end
  238.         end
  239.       end
  240.     end    
  241.   end
  242.   return true
  243. end
  244.  
  245.  
  246. def pbAddForeignPokemon(pokemon,level=nil,ownerName=nil,nickname=nil,ownerGender=0,seeform=true)
  247.   return false if !pokemon || pbBoxesFull? || !$Trainer
  248.   pokemon = getID(PBSpecies,pokemon)
  249.   if pokemon.is_a?(Integer) && level.is_a?(Integer)
  250.     pokemon = pbNewPkmn(pokemon,level)
  251.   end
  252.   # Set original trainer to a foreign one (if ID isn't already foreign)
  253.   if pokemon.trainerID==$Trainer.id
  254.     pokemon.trainerID = $Trainer.getForeignID
  255.     pokemon.ot        = ownerName if ownerName && ownerName!=""
  256.     pokemon.otgender  = ownerGender
  257.   end
  258.   # Set nickname
  259.   pokemon.name = nickname[0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE] if nickname && nickname!=""
  260.   # Recalculate stats
  261.   pokemon.calcStats
  262.   if ownerName
  263.     pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon from {2}.\1",$Trainer.name,ownerName))
  264.   else
  265.     pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon.\1",$Trainer.name))
  266.   end
  267.   pbStorePokemon(pokemon)
  268.   $Trainer.seen[pokemon.species]  = true
  269.   $Trainer.owned[pokemon.species] = true
  270.   pbSeenForm(pokemon) if seeform
  271.   return true
  272. end
  273.  
  274. def pbGenerateEgg(pokemon,text="")
  275.   return false if !pokemon || pbBoxesFull? || !$Trainer
  276.   pokemon = getID(PBSpecies,pokemon)
  277.   if pokemon.is_a?(Integer)
  278.     pokemon = pbNewPkmn(pokemon,EGG_LEVEL)
  279.   end
  280.   # Get egg steps
  281.   eggSteps = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesStepsToHatch)
  282.   # Set egg's details
  283.   pokemon.name       = _INTL("Egg")
  284.   pokemon.eggsteps   = eggSteps
  285.   pokemon.obtainText = text
  286.   pokemon.calcStats
  287.   # Add egg to party
  288.   if pbBoxesFull?
  289.     pbMessage(_INTL("There's no more room for Pokémon!\1"))
  290.     pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
  291.     return
  292.   end
  293.   if $Trainer.party.length<6
  294.     $Trainer.party[$Trainer.party.length]=pokemon
  295.   else
  296.     monsent=false
  297.     while !monsent
  298.       if pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
  299.         iMon = -2
  300.         eggcount = 0
  301.         for i in $Trainer.party
  302.           next if i.isEgg?
  303.           eggcount += 1
  304.         end
  305.         pbFadeOutIn(99999){
  306.           sscene  = PokemonParty_Scene.new
  307.           sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
  308.           sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
  309.           loop do
  310.             iMon=sscreen.pbChoosePokemon
  311.             if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
  312.               pbMessage("That's your last Pokémon!")              
  313.             else
  314.               sscreen.pbEndScene
  315.               break
  316.             end
  317.           end
  318.         }
  319.         if !(iMon < 0)    
  320.           iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
  321.           if iBox >= 0
  322.             monsent=true
  323.             $Trainer.party[iMon].heal
  324.             pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
  325.             $Trainer.party[iMon] = nil
  326.             $Trainer.party.compact!
  327.             $Trainer.party[$Trainer.party.length]=pokemon
  328.           else
  329.             pbMessage("No space left in the PC.")
  330.             return false
  331.           end
  332.         end      
  333.       else
  334.         monsent=true
  335.         oldcurbox=$PokemonStorage.currentBox
  336.         storedbox=$PokemonStorage.pbStoreCaught(pokemon)
  337.         curboxname=$PokemonStorage[oldcurbox].name
  338.         boxname=$PokemonStorage[storedbox].name
  339.         creator=nil
  340.         creator=pbGetStorageCreator if $PokemonGlobal.seenStorageCreator
  341.         if storedbox!=oldcurbox
  342.           if creator
  343.             pbMessage(_INTL("Box \"{1}\" on {2}'s PC was full.\1",curboxname,creator))
  344.           else
  345.             pbMessage(_INTL("Box \"{1}\" on someone's PC was full.\1",curboxname))
  346.           end
  347.           pbMessage(_INTL("{1} was transferred to box \"{2}.\"",pokemon.name,boxname))
  348.         else
  349.           if creator
  350.             pbMessage(_INTL("{1} was transferred to {2}'s PC.\1",pokemon.name,creator))
  351.           else
  352.             pbMessage(_INTL("{1} was transferred to someone's PC.\1",pokemon.name))
  353.           end
  354.           pbMessage(_INTL("It was stored in box \"{1}\".",boxname))
  355.         end
  356.       end    
  357.     end
  358.   end
  359. end
  360. alias pbAddEgg pbGenerateEgg
  361. alias pbGenEgg pbGenerateEgg
  362.  
  363.  
  364.  
  365.  
  366. #--------------------------------------------------------------------------------
  367. #Provides Evolution Check on Party Switcher
  368. #--------------------------------------------------------------------------------
  369. class PokemonTemp
  370.   attr_accessor :encounterType
  371.   attr_accessor :evolutionLevels
  372.   attr_accessor :party # changed added
  373. end
  374.  
  375. Events.onStartBattle+=proc {|sender,e| # Changed added $PokemonTemp.party to fix party swap evo bug
  376.   $PokemonTemp.party = []
  377.   $PokemonTemp.evolutionLevels = []
  378.   for i in 0...$Trainer.party.length
  379.     $PokemonTemp.party[i] = $Trainer.party[i]
  380.     $PokemonTemp.evolutionLevels[i] = $Trainer.party[i].level
  381.   end
  382. }
  383.  
  384. def pbEvolutionCheck(currentlevels)
  385.   for i in 0...currentlevels.length
  386.     pokemon = $Trainer.party[i]
  387.     next if $PokemonTemp.party[i] != $Trainer.party[i] # changed added to fix party swap evo bug
  388.     next if pokemon.hp==0 && !NEWEST_BATTLE_MECHANICS
  389.     if pokemon && (!currentlevels[i] || pokemon.level!=currentlevels[i])
  390.       newspecies = pbCheckEvolution(pokemon)
  391.       if newspecies>0
  392.         evo = PokemonEvolutionScene.new
  393.         evo.pbStartScreen(pokemon,newspecies)
  394.         evo.pbEvolution
  395.         evo.pbEndScreen
  396.       end
  397.     end
  398.   end
  399. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement