Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Pokémon Outbreaks - By Vendily [v20] - v4
- #===============================================================================
- # This script adds in the Mass Outbreak of Pokémon that appear on a random map.
- # It uses the Gen 4 version of the mechanics, so when the save is loaded, if
- # there is no active outbreak and the switch is active, will pick one outbreak
- # at random and spawn them at a 40% encounter rate. Feel free to change that of
- # course.
- #===============================================================================
- # This script includes some utility functions, such as the ability to
- # randomly set a new outbreak at will with pbGenerateOutbreak, and get the
- # location and species of an outbreak, pbOutbreakInformation (which can save in
- # two variables, for species and map in that order). The variables contain
- # strings for names, or -1 if there is no outbreak. It will also return the map
- # id and species index for your scripting uses.
- #===============================================================================
- # * The length of time that an encounter will last in hours. (Default 24)
- # * The percent chance an outbroken Pokémon will spawn in place of
- # a regular one. (Default 40)
- # * The switch used to enable outbreaks, -1 to not use a switch. (Default 100)
- # * A set of arrays each containing details of a wild encounter that can only
- # occur via Pokémon Outbreaks. The information within is as follows:
- # - Map ID on which this encounter can occur.
- # - Species.
- # - Minimum possible level.
- # - Maximum possible level.
- # - Allowed encounter types (GameData::EncounterType#type).
- #===============================================================================
- PluginManager.register({
- :name => "Pokémon Outbreaks",
- :version => "4.0",
- :link => "https://reliccastle.com/resources/266/",
- :credits => "Vendily"
- })
- module Settings
- OUTBREAK_TIME = 24
- OUTBREAK_CHANCE = 40
- OUTBREAK_SWITCH = 100
- OUTBREAK_SPECIES = [
- [5,:DODUO,2,2,[:land]],
- [5,:VOLTORB,28,29,[:land]],
- [2,:MILOTIC,12,16,[:water,:fishing]]
- ]
- end
- class PokemonGlobalMetadata
- attr_accessor :currentOutbreak
- end
- EventHandlers.add(:on_wild_species_chosen,:outbreak_change_mon,
- proc {|encounter|
- next if !encounter
- next if Settings::OUTBREAK_SWITCH>0 && !$game_switches[Settings::OUTBREAK_SWITCH]
- next if $game_temp.poke_radar_data &&
- encounter[0] == $game_temp.poke_radar_data[0] &&
- encounter[1] == $game_temp.poke_radar_data[1]
- if !$PokemonGlobal.currentOutbreak ||
- $PokemonGlobal.currentOutbreak[0]<=-1 ||
- ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>Settings::OUTBREAK_TIME*60*60)
- $PokemonGlobal.currentOutbreak=[-1,nil]
- end
- if $PokemonGlobal.currentOutbreak[0]>-1
- newenc=Settings::OUTBREAK_SPECIES[$PokemonGlobal.currentOutbreak[0]]
- next if $game_map&.map_id != newenc[0]
- next if !newenc[4].include?(GameData::EncounterType.get($game_temp.encounter_type).type)
- if rand(100)<Settings::OUTBREAK_CHANCE
- level=rand(newenc[3]-newenc[2])+newenc[2]
- encounter[0] = newenc[1]
- encounter[1] = level
- end
- end
- }
- )
- EventHandlers.add(:on_frame_update,:outbreak_update,
- proc {
- next if Settings::OUTBREAK_SWITCH>0 && !$game_switches[Settings::OUTBREAK_SWITCH]
- if !$PokemonGlobal.currentOutbreak ||
- $PokemonGlobal.currentOutbreak[0]<=-1 ||
- ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>Settings::OUTBREAK_TIME*60*60)
- pbGenerateOutbreak
- end
- }
- )
- def pbGenerateOutbreak
- index=rand(Settings::OUTBREAK_SPECIES.length)
- $PokemonGlobal.currentOutbreak=[index,pbGetTimeNow]
- end
- def pbOutbreakInformation(speciesvar=-1,mapvar=-1)
- if !$PokemonGlobal.currentOutbreak ||
- $PokemonGlobal.currentOutbreak[0]<=-1 ||
- ((pbGetTimeNow-$PokemonGlobal.currentOutbreak[1])>Settings::OUTBREAK_TIME*60*60)
- $PokemonGlobal.currentOutbreak=[-1,nil]
- $game_variables[speciesvar]=-1 if speciesvar>0
- $game_variables[mapvar]=-1 if mapvar>0
- return [-1,-1]
- end
- newenc=Settings::OUTBREAK_SPECIES[$PokemonGlobal.currentOutbreak[0]]
- species=newenc[1]
- $game_variables[speciesvar]=GameData::Species.get(species).name if speciesvar>0
- $game_variables[mapvar]=pbGetMessage(MessageTypes::MapNames,newenc[0]) if mapvar>0
- return [newenc[0],species]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement