• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Random Pokemon in adoption with stats in sign

2
Posts
7
Years
    • Seen Jun 14, 2016
    Hello guys! So, the title says it all, i want to make an adoption center, where random pokemon spawn every day. (except for legendaries, and very rare pokemon (e.g. Rotomon))
    And i want to show their stats (attack, special attack, IVs, Nature) in a sign post next to them, so the player can know how the pokemon he is going to adopt is.
    How can i do this??? is there an special script for this?
    Thanks for the help in advance.
    Max.
     
    Last edited:
    129
    Posts
    8
    Years
    • Seen Mar 23, 2023
    What you can do is show the summary screen of the pokemon in question when you interact with the sign. Put the following into a script command on the sign (maybe after a text command or two about what the sign is):

    Code:
    party = [
      #[Insert a reference to the generated pokemon here]
    ]
    scene=PokemonSummaryScene.new
    screen=PokemonSummary.new(scene)
    screen.pbStartScreen(party,0)

    This will open up the pokemon's summary screen so the player can peruse it all they want. (I pulled this code from my own project, so I know it works.)
     
    2
    Posts
    7
    Years
    • Seen Jun 14, 2016
    Thanks, but i still need to find out how to make random pokemon appear in the adoption center map.
     
    129
    Posts
    8
    Years
    • Seen Mar 23, 2023
    Ah. It sounded to me like you had that part figured out already. I guess I misread.

    I decided to go all out with this one. Expect to see this on a tutorial on the Wiki soon enough. The following should be put into a new script section above main:

    Code:
    #===============================================================================
    # 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

    Then, in your adoption center map, you can have a lady like in the attached images.

    Note: I have tested most of the functionality, but there may be a couple minor bugs.
     

    Attachments

    • Random Pokemon in adoption with stats in sign
      PkmnAdoption1.PNG
      22.1 KB · Views: 9
    • Random Pokemon in adoption with stats in sign
      PkmnAdoption2.PNG
      20.6 KB · Views: 8
    Back
    Top