Advertisement
Vendily

Wild Mon Scale compat w/ OW Encount

Jul 24th, 2020
2,792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.54 KB | None | 0 0
  1. EncounterModifier.register(proc {|encounter|
  2.   return nil if !encounter
  3.   difficulty= LevelBalance::calcDifficulty
  4.   badges = $Trainer.numbadges
  5.   balance = pbBalancedLevel($Trainer.party)
  6.   mlv=0
  7.   for poke in $Trainer.pokemonParty
  8.     mlv=poke.level if poke.level>mlv
  9.   end
  10.   case difficulty
  11.   when 0 #Light
  12.     l = balance/3 - 2 + rand(5)
  13.   when 1 #Easy
  14.     l = 2*balance/3  - 4 + rand(8)
  15.   when 2 #Medium
  16.     l = 3*(balance + 4*mlv)/20 - 4 + rand(8)
  17.   when 3 #Hard
  18.     l = 4*(balance + 4*mlv)/25 - 2 + rand(8)
  19.   when 4 #Insane
  20.     l = (balance + 4*mlv)/6 - 4 + rand(4+balance/10)
  21.   else #Extreme
  22.     l = 9*(balance + 4*mlv)/50 - 4 + rand(4+balance/10)
  23.   end
  24.   newlevel=l
  25.   newlevel=1 if newlevel<1
  26.   newlevel=PBExperience::MAXLEVEL if newlevel>PBExperience::MAXLEVEL
  27.   #now we evolve the pokémon, if applicable
  28.   species = encounter[0]
  29.   newspecies = pbGetBabySpecies(species) # revert to the first evolution
  30.   evoflag=0 #used to track multiple evos not done by lvl
  31.   endevo=false
  32.   loop do #beginning of loop to evolve species
  33.     nl = newlevel + 5
  34.     nl = MAXIMUMLEVEL if nl > MAXIMUMLEVEL
  35.     pkmn = PokeBattle_Pokemon.new(newspecies, nl)
  36.     cevo = Kernel.pbCheckEvolution(pkmn)
  37.     evo = pbGetEvolvedFormData(newspecies)
  38.     if evo
  39.       evo = evo[rand(evo.length - 1)]
  40.       # here we evolve things that don't evolve through level
  41.       # that's what we check with evo[0]!=4
  42.       #notice that such species have cevo==-1 and wouldn't pass the last check
  43.       #to avoid it we set evoflag to 1 (with some randomness) so that
  44.       #pokemon may have its second evolution (Raichu, for example)
  45.       if evo && cevo < 1 && rand(50) <= newlevel
  46.         if evo[0] != 4 && rand(50) <= newlevel
  47.         newspecies = evo[2]
  48.            if evoflag == 0 && rand(50) <= newlevel
  49.              evoflag=1
  50.            else
  51.              evoflag=0
  52.            end
  53.          end
  54.       else
  55.       endevo=true  
  56.       end
  57.     end
  58.     if evoflag==0 || endevo
  59.     if  cevo == -1 || rand(50) > newlevel
  60.       # Breaks if there no more evolutions or randomnly
  61.       # Randomness applies only if the level is under 50
  62.       break
  63.     else
  64.       newspecies = evo[2]
  65.     end
  66.     end
  67.   end
  68.   #fixing some things such as Bellossom would turn into Vileplume
  69.   #check if original species could evolve (Bellosom couldn't)
  70.   couldevo=pbGetEvolvedFormData(species)
  71.   #check if current species can evolve
  72.   evo = pbGetEvolvedFormData(newspecies)
  73.   if evo.length<1 && couldevo.length<1
  74.   else
  75.      species=newspecies
  76.   end
  77.   return [species,newlevel]
  78. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement