SHARE
TWEET

Pokemon Outbreaks

Vendily Dec 30th, 2018 (edited) 302 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # Pokemon Outbreaks - By Vendily [v17] - v2
  3. # This script adds in the Mass outbreak of pokemon that appear on a random map.
  4. # It uses the Gen 4 version of the mechanics, so when the save is loaded, if
  5. #  there is no active outbreak and the switch is active, will pick one outbreak
  6. #  at random and spawn them at a 40% encounter rate. Feel free to change that of
  7. #  course.
  8. # This script includes some utility functions, such as the ability to
  9. #  randomly set a new outbreak at will with pbGenerateOutbreak, and get the
  10. #  location and species of an outbreak, pbOutbreakInformation (which can save in
  11. #  two variables,  for species and map in that order). The variables contain
  12. #  strings for names, or -1 if there is no outbreak. It will also return the map
  13. #  id and species index for your scripting uses.
  14. # * The length of time that an encounter will last in hours. (Default 24)
  15. # * The percent chance an outbroken pokemon will spawn in place of
  16. #    a regular one. (Default 40)
  17. # * The switch used to enable outbreaks. (Default 100)
  18. # * A set of arrays each containing details of a wild encounter that can only
  19. #      occur via Pokemon Outbreaks. The information within is as follows:
  20. #      - Map ID on which this encounter can occur.
  21. #      - Species.
  22. #      - Minimum possible level.
  23. #      - Maximum possible level.
  24. #      - Allowed encounter types.
  25. #===============================================================================
  26. OUTBREAKTIME    = 24
  27. OUTBREAKCHANCE  = 40
  28. OUTBREAKSWITCH  = 100
  29. OUTBREAKSPECIES = [
  30.     [5,:DODUO,2,2,[EncounterTypes::Land]],
  31.     [5,:VOLTORB,28,29,[EncounterTypes::Land,EncounterTypes::LandNight]],
  32.     [2,:MILOTIC,12,16,[EncounterTypes::Water]]
  33.     ]
  34. class PokemonGlobalMetadata
  35.   attr_accessor :currentOutbreak
  36. end
  37.  
  38. EncounterModifier.register(proc {|encounter|
  39.    return encounter if !encounter
  40.    return encounter if !$game_switches[OUTBREAKSWITCH]
  41.    if !$PokemonGlobal.currentOutbreak ||
  42.      $PokemonGlobal.currentOutbreak[0]<=-1 ||
  43.      ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>OUTBREAKTIME*60*60)
  44.      $PokemonGlobal.currentOutbreak=[-1,nil]
  45.    end
  46.    if $PokemonGlobal.currentOutbreak[0]>-1
  47.      newenc=OUTBREAKSPECIES[$PokemonGlobal.currentOutbreak[0]]
  48.      return encounter if $game_map && $game_map.map_id!=newenc[0]
  49.      return encounter if !newenc[4].include?($PokemonEncounters.pbEncounterType)
  50.      if rand(100)<OUTBREAKCHANCE
  51.        level=rand(newenc[3]-newenc[2])+newenc[2]
  52.        return [getID(PBSpecies,newenc[1]),level]
  53.      end
  54.    end
  55.    return encounter
  56. })
  57.  
  58. Events.onMapUpdate+=proc {|sender,e|
  59.   next if !$game_switches[OUTBREAKSWITCH]
  60.   if !$PokemonGlobal.currentOutbreak ||
  61.      $PokemonGlobal.currentOutbreak[0]<=-1 ||
  62.      ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>OUTBREAKTIME*60*60)
  63.      pbGenerateOutbreak
  64.   end
  65. }
  66.  
  67. def pbGenerateOutbreak
  68.   index=rand(OUTBREAKSPECIES.length)
  69.   $PokemonGlobal.currentOutbreak=[index,pbGetTimeNow]
  70. end
  71.  
  72. def pbOutbreakInformation(speciesvar,mapvar)
  73.   if !$PokemonGlobal.currentOutbreak ||
  74.     $PokemonGlobal.currentOutbreak[0]<=-1 ||
  75.     ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>OUTBREAKTIME*60*60)
  76.       $PokemonGlobal.currentOutbreak=[-1,nil]
  77.       $game_variables[speciesvar]=-1 if speciesvar>0
  78.       $game_variables[mapvar]=-1 if mapvar>0
  79.       return [-1,-1]
  80.   end
  81.   newenc=OUTBREAKSPECIES[$PokemonGlobal.currentOutbreak[0]]
  82.   species=getID(PBSpecies,newenc[1])
  83.   $game_variables[speciesvar]=PBSpecies.getName(species) if speciesvar>0
  84.   $game_variables[mapvar]=pbGetMessage(MessageTypes::MapNames,newenc[0]) if mapvar>0
  85.   return [newenc[0],species]
  86. 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
 
Top