Vendily

Rescue Chain

Nov 21st, 2018
698
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # Rescue Chain - By Vendily [v17]
  3. # This script makes it so that if you chain pokemon of the same evolutionary
  4. #  family together, an evolved form of the species will appear.
  5. # I used no references and I completly misinterpreted a description of SOS
  6. #  battles as this thing.
  7. # * Minimum length of chain before evolved forms begin to appear. With every
  8. #    multiple, the chance for the evolved form or a second evolved form to appear
  9. #    increases. (Default 10)
  10. # * Chance that the evolved form will even show up, 1 out of this constant.
  11. #    (Default 4, for 1/4 chance, it's probably too high)
  12. # * Random number added to the minimum level this pokemon can evolve at or
  13. #    the wild pokemon's current level if it evolves through item (Default 5)
  14. # * Disable this modifier while the pokeradar is being used.
  15. #    I recommend leaving it as is as the pokeradar may behave strangely and the
  16. #    two scripts may reset each others' chain. (Default true)
  17. # * The maps where this effect can only take place in.
  18. # * The maps where this effect will never happen. Ever.
  19. # * The switch to disable this effect. (Default -1)
  20. #===============================================================================
  21. EVOCHAINLENGTH      = 10
  22. EVORANDCHANCE       = 4
  23. EVOLEVELWOBBLE      = 5
  24. EVOPKRADERDISABLE   = true
  25. EVOMAPSWHITELIST    = []
  26. EVOMAPSBLACKLIST    = []
  27. EVODISABLESWITCH    = -1
  28. class PokemonTemp
  29.   attr_accessor :rescuechain # [chain length, evo family]
  30. end
  31.  
  32. Events.onStartBattle+=proc {|sender,e|
  33.    next if EVOMAPSBLACKLIST.include?($game_map.map_id)
  34.    next if EVOMAPSWHITELIST.length>0 && !EVOMAPSWHITELIST.include?($game_map.map_id)
  35.    next if EVODISABLESWITCH>0 && $game_switches[EVODISABLESWITCH]
  36.    next if EVOPKRADERDISABLE && !$PokemonTemp.pokeradar.nil?
  37.    next if !$PokemonGlobal.roamEncounter.nil?
  38.    pokemon=e[0]
  39.    next if pokemon.nil?
  40.    if !$PokemonTemp.rescuechain
  41.      $PokemonTemp.rescuechain=[0,nil]
  42.    end
  43.    family=pbGetBabySpecies(pokemon.fSpecies)
  44.    if family != $PokemonTemp.rescuechain[1]
  45.      $PokemonTemp.rescuechain=[0,family]
  46.    end
  47.    if $PokemonTemp.rescuechain[0]>=EVOCHAINLENGTH
  48.      for i in 0..($PokemonTemp.rescuechain[0]/EVOCHAINLENGTH).floor()
  49.        evodata=pbGetEvolvedFormData(pokemon.fSpecies)
  50.        if evodata.length>0 && rand(EVORANDCHANCE)==0
  51.          fspecies=evodata[rand(evodata.length)][2]
  52.          newspecies,newform=pbGetSpeciesFromFSpecies(fspecies)
  53.          level=pbGetMinimumLevel(fspecies)
  54.          level=[level,pokemon.level].max
  55.          level+=rand(EVOLEVELWOBBLE)
  56.          pokemon.species=newspecies
  57.          pokemon.form=newform
  58.          pokemon.level=level
  59.          pokemon.name=PBSpecies.getName(newspecies)
  60.          pokemon.calcStats
  61.          pokemon.resetMoves
  62.        end
  63.      end
  64.    end
  65. }
  66.  
  67. Events.onWildBattleEnd+=proc {|sender,e|
  68.    next if EVOMAPSBLACKLIST.include?($game_map.map_id)
  69.    next if EVOMAPSWHITELIST.length>0 && !EVOMAPSWHITELIST.include?($game_map.map_id)
  70.    next if EVODISABLESWITCH>0 && $game_switches[EVODISABLESWITCH]
  71.    next if EVOPKRADERDISABLE && !$PokemonTemp.pokeradar.nil?
  72.    next if !$PokemonTemp.rescuechain
  73.    species=e[0]
  74.    result=e[2]
  75.    family=pbGetBabySpecies(species)
  76.    if (result==1 || result == 4) && family==$PokemonTemp.rescuechain[1]
  77.      $PokemonTemp.rescuechain[0]+=1
  78.    end
  79.  
  80. }
RAW Paste Data