• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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.

Checking a player's egg for its species?

  • 91
    Posts
    15
    Years
    • Seen Sep 5, 2015
    What's the script to check for the species of an Egg? I tried the following:

    "pbHasSpecies?(:SPECIES)" would do the trick, but Eggs are not considered as species when not born.
    "$Trainer.party[0].egg?" only returns whether that Pokemon is an Egg or not, but doesn't check species.
    "pbHasEgg?(:SPECIES)" simply returns true if the species targetted can breed or be bred.

    Im doing a Game Corner Egg Store with coins. I want the player to be able to choose a "Mysterious Egg" among other species. When choosing the Mysterious Egg (which is simply a Caterpie) then I want to check for the Species (so it's not any of the other possible species) so if it IS Caterpie, then I change its species, change moves, make shiny, change steps...

    I can already purchase eggs with no problem, but the problem comes in checking the egg bought in order to change it if it's the special one.

    Script looks like this:
    Spoiler:

    Then of course check if the party is full etc. That part is working well so no problem with that.

    I know I should be looking at the code in the purchase script (pbSet) as it's storing the species into a variable, but when using $game_variables[1]=:CATERPIE the conditional branch is completely ignored (doesn't even go to Else).

    Clueless. Hope someone with more knowledge can help me learn.
     
    Last edited:
    A simple edit to pbHasSpecies will do the trick

    Code:
    def pbHasSpecies?(species[COLOR="Red"],ignoreeggs=true[/COLOR])
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg? [COLOR="red"]&& ignoreeggs[/COLOR]
        return true if pokemon.species==species
      end
      return false
    end
     
    A simple edit to pbHasSpecies will do the trick

    Code:
    def pbHasSpecies?(species[COLOR="Red"],ignoreeggs=true[/COLOR])
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg? [COLOR="red"]&& ignoreeggs[/COLOR]
        return true if pokemon.species==species
      end
      return false
    end
    It does! Problem is, if the player actually has the Pokémon inside the "mysterious egg", problems arise, but I'm just going an unobtainable Pokémon for the Egg. Thank you.
     
    Edit: Don't tell me it's the "egg?" and "isEgg?" thing lol... Yes it is... Now I have YET another problem.
    Edit2: All working! Apparently I really didn't have def lastparty in my scripts... Weird.
     
    Last edited:
    Purchase script:
    Code:
    item=[:BULBASAUR,:CHARMANDER,
          :SQUIRTLE,:MEOWTH,
          :CATERPIE,0][pbGet(1)]
    price=[30,30,30,15,20,
           0][pbGet(1)]
    lv=[9,8,18,25,26,0][pbGet(1)]
    if item && item!=0
      item=getID(PBSpecies,item)
    end
    pbSet(1,item); pbSet(2,price)
    pbSet(3,PBSpecies.getName(item))
    pbSet(4,lv)
    You already HAVE the species of the egg. It's stored in Variable 1. Get it with pbGet(1). Compare it to Caterpie with pbGet(1)==PBSpecies::CATERPIE. Note the double equals signs.
     
    Back
    Top