#===============================================================================
# Pokemon Adoption Center - by Tustin2121
#===============================================================================
module Adoption
# The global variable to store the pokemon in
ADOPTIONVAR = 30
# The mapid of the adoption center, or 0 for the current map
ADOPTIONMAP = 0
# Number of days between refreshes of the adopted mon
REFRESHTIME = 1
# Pokemon to exlude entirely from the adoption pool
EXCLUDE = [
# --- Edit Below ---
:ARTICUNO, :ZAPDOS, :MOLTRES, :MEWTWO, :MEW,
:RAIKOU, :ENTEI, :SUICUNE, :LUGIA, :HOOH, :CELEBI,
:REGICE, :REGIROCK, :REGISTEEL, :REGIGIGAS,
:LATIAS, :LATIOS,
:GROUDON, :KYOGRE, :RAYQUAZA, :JIRACHI, :DEOXYS,
:AZELF, :MESPRIT, :UXIE, :PHIONE, :MANAPHY, :SHAYMIN,
:DIALGA, :PALKIA, :GIRATINA, :ARCEUS,
:CRESSELIA, :DARKRAI, :HEATRAN, :VICTINI,
:COBALION, :TERRAKION, :VIRIZION, :KELDEO,
:TORNADUS, :THUNDURUS, :LANDORUS,
:MELOETTA, :GENESECT,
:ZEKROM, :RESHIRAM, :KYUREM,
:XERNEAS, :YVELTAL, :ZYGARDE, :DIANCIE, :HOOPA, :VOLCANION
# --- Edit Above ---
].map {|species| getID(PBSpecies,species) }
# Pokemon to apply a rarity chance to. Everything else is equal chance with
# each other. Format is :POKEMON => RarityChance (out of 1.0)
RARE = {
# --- Edit Below ---
:UNOWN => 0.1,
# --- Edit Above ---
}
RARE.each {|key,val| RARE[getID(PBSpecies,key)]=val }
# Pokemon in the adoption center will be between these levels
MIN_LEVEL = 5
MAX_LEVEL = 30
# Only generate baby pokemon
BABY_ONLY = false
# Keep pokemon as Foreign mon (act as traded) upon adoption
FORIEGN_MON = false
#=============================================================================
class << self
def cooledDown?
time = pbGet(ADOPTIONVAR)
return true if !time || !time.is_a?(Array)
time = time[0]
return true if !time
now=pbGetTimeNow
elapsed=(now.to_i-time)/86400
elapsed+=1 if (now.to_i-time)%86400>(now.hour*3600+now.min*60+now.sec)
return elapsed>=REFRESHTIME
end
def generateAdopted()
species=0
minLevel=0
loop do
species = rand(PBSpecies.maxValue)+1
if BABY_ONLY
species=pbGetBabySpecies(species)
end
next if EXCLUDE.include?(species)
if RARE.has_key?(species)
next if rand() > RARE[species]
end
minLevel=pbGetMinimumLevel(species)
next if minLevel > MAX_LEVEL
break # We have a good species
end
level = [rand(MAX_LEVEL-MIN_LEVEL)+MIN_LEVEL, minLevel].max
# Generate our pokemon
pkmn = PokeBattle_Pokemon.new(species,level)
pkmn.obtainLevel = level-rand(level)
pkmn.obtainMap = 0
# Assign a random forigen id to this pokemon
pkmn.trainerID = $Trainer.getForeignID
pkmn.ot = "?????" # Must set a name, or the game will show a "RENTAL" pokemon
# If you wanted to assign random names to this pokemon's OT, then this would
# be the place to do it.
pbSet(ADOPTIONVAR, [pbGetTimeNow.to_i, pkmn])
end
def adoptMon()
if pbBoxesFull?
Kernel.pbMessage(_INTL("There's no more room for Pokémon!\1"))
Kernel.pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
return false
end
v = pbGet(Adoption::ADOPTIONVAR)
pkmn = v[1]
shiny = pkmn.isShiny? # Must preserve shininess
if !FORIEGN_MON
pkmn.ot = $Trainer.name
pkmn.trainerID = $Trainer.id
pkmn.otgender = $Trainer.gender
if (shiny); pkmn.makeShiny; else; pkmn.makeNotShiny; end
end
pkmn.obtainMap = (ADOPTIONMAP>0)? ADOPTIONMAP : $game_map.map_id
pkmn.obtainMode = 0 # Met
pkmn.obtainLevel = pkmn.level
Kernel.pbMessage(_INTL("{1} adopted {2}!\\se[PokemonGet]\1",$Trainer.name,pkmn.name))
$Trainer.seen[pkmn.species]=true
$Trainer.owned[pkmn.species]=true
pbSeenForm(pkmn)
if !FORIEGN_MON
pbNickname(pkmn)
end
pbStorePokemon(pkmn)
v[1] = nil
$game_map.need_refresh = true
end
end
end
def pbAdoptionPokemonGenerate()
if Adoption.cooledDown?
Adoption.generateAdopted
end
end
def pbAdoptionHasPokemon?
if Adoption.cooledDown?
Adoption.generateAdopted
end
v = pbGet(Adoption::ADOPTIONVAR)
return false if !v || !v.is_a?(Array)
return true if v[1]
return false
end
def pbAdoptionPokemonGetName(varnum)
v = pbGet(Adoption::ADOPTIONVAR)
if !v || !v[1]
pbSet(varnum,"[EMPTY]")
else
pbSet(varnum, v[1].name)
end
end
def pbAdoptionShowPokemon()
pbFadeOutIn(9999) {
party = [
pbGet(Adoption::ADOPTIONVAR)[1]
]
scene=PokemonSummaryScene.new
screen=PokemonSummary.new(scene)
screen.pbStartScreen(party,0)
}
end
def pbAdoptionAdopt()
return if !$Trainer
Adoption.adoptMon
end