Advertisement
Vendily

Pokemon Outbreaks v19

Jan 8th, 2022 (edited)
2,758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.16 KB | None | 0 0
  1. #===============================================================================
  2. # Pokémon Outbreaks - By Vendily [v19] - v3.1
  3. #===============================================================================
  4. # This script adds in the Mass outbreak of pokemon that appear on a random map.
  5. # It uses the Gen 4 version of the mechanics, so when the save is loaded, if
  6. #  there is no active outbreak and the switch is active, will pick one outbreak
  7. #  at random and spawn them at a 40% encounter rate. Feel free to change that of
  8. #  course.
  9. #===============================================================================
  10. # This script includes some utility functions, such as the ability to
  11. #  randomly set a new outbreak at will with pbGenerateOutbreak, and get the
  12. #  location and species of an outbreak, pbOutbreakInformation (which can save in
  13. #  two variables,  for species and map in that order). The variables contain
  14. #  strings for names, or -1 if there is no outbreak. It will also return the map
  15. #  id and species index for your scripting uses.
  16. #===============================================================================
  17. # * The length of time that an encounter will last in hours. (Default 24)
  18. # * The percent chance an outbroken pokemon will spawn in place of
  19. #    a regular one. (Default 40)
  20. # * The switch used to enable outbreaks. (Default 100)
  21. # * A set of arrays each containing details of a wild encounter that can only
  22. #      occur via Pokemon Outbreaks. The information within is as follows:
  23. #      - Map ID on which this encounter can occur.
  24. #      - Species.
  25. #      - Minimum possible level.
  26. #      - Maximum possible level.
  27. #      - Allowed encounter types.
  28. #===============================================================================
  29. PluginManager.register({
  30.   :name    => "Pokémon Outbreaks",
  31.   :version => "3.1",
  32.   :link    => "https://reliccastle.com/resources/266/",
  33.   :credits => "Vendily"
  34. })
  35.  
  36. OUTBREAK_TIME    = 24
  37. OUTBREAK_CHANCE  = 40
  38. OUTBREAK_SWITCH  = 100
  39. OUTBREAK_SPECIES = [
  40.     [5,:DODUO,2,2,[:Land]],
  41.     [5,:VOLTORB,28,29,[:Land,:LandNight]],
  42.     [2,:MILOTIC,12,16,[:Water]]
  43.     ]
  44. class PokemonGlobalMetadata
  45.   attr_accessor :currentOutbreak
  46. end
  47.  
  48. EncounterModifier.register(proc {|encounter|
  49.    next encounter if !encounter
  50.    next encounter if !$game_switches[OUTBREAK_SWITCH]
  51.    if $PokemonTemp.pokeradar &&
  52.       encounter[0] == $PokemonTemp.pokeradar[0] &&
  53.       encounter[1] == $PokemonTemp.pokeradar[1]
  54.      next encounter
  55.    end
  56.    if !$PokemonGlobal.currentOutbreak ||
  57.        $PokemonGlobal.currentOutbreak[0]<=-1 ||
  58.        ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>OUTBREAK_TIME*60*60)
  59.      $PokemonGlobal.currentOutbreak=[-1,nil]
  60.    end
  61.    if $PokemonGlobal.currentOutbreak[0]>-1
  62.      newenc=OUTBREAK_SPECIES[$PokemonGlobal.currentOutbreak[0]]
  63.      next encounter if $game_map && $game_map.map_id!=newenc[0]
  64.      next encouter if !newenc[4].include?($PokemonEncounters.encounter_type)
  65.      if rand(100)<OUTBREAK_CHANCE
  66.        level=rand(newenc[3]-newenc[2])+newenc[2]
  67.        next [newenc[1],level]
  68.      end
  69.    end
  70.    next encounter
  71. })
  72.  
  73. Events.onMapUpdate+=proc {|sender,e|
  74.   next if !$game_switches[OUTBREAK_SWITCH]
  75.   if !$PokemonGlobal.currentOutbreak ||
  76.      $PokemonGlobal.currentOutbreak[0]<=-1 ||
  77.      ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>OUTBREAK_TIME*60*60)
  78.      pbGenerateOutbreak
  79.   end
  80. }
  81.  
  82. def pbGenerateOutbreak
  83.   index=rand(OUTBREAK_SPECIES.length)
  84.   $PokemonGlobal.currentOutbreak=[index,pbGetTimeNow]
  85. end
  86.  
  87. def pbOutbreakInformation(speciesvar,mapvar)
  88.   if !$PokemonGlobal.currentOutbreak ||
  89.     $PokemonGlobal.currentOutbreak[0]<=-1 ||
  90.     ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>OUTBREAK_TIME*60*60)
  91.       $PokemonGlobal.currentOutbreak=[-1,nil]
  92.       $game_variables[speciesvar]=-1 if speciesvar>0
  93.       $game_variables[mapvar]=-1 if mapvar>0
  94.       return [-1,-1]
  95.   end
  96.   newenc=OUTBREAK_SPECIES[$PokemonGlobal.currentOutbreak[0]]
  97.   species=newenc[1]
  98.   $game_variables[speciesvar]=GameData::Species.get(species).name if speciesvar>0
  99.   $game_variables[mapvar]=pbGetMessage(MessageTypes::MapNames,newenc[0]) if mapvar>0
  100.   return [newenc[0],species]
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement