• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!

Event script to count Pokémon by Type or Shape?

JayCee

Rookie
Member
Joined
Mar 25, 2026
Posts
1
So I am having a lot of fun fumbling through making my first fan-game but have hit a wall with one of my ideas. I want there to be an NPC who rewards the player based on how many different Pokémon they have seen of X type or body shape. Like, a badge or prize for seeing 10 different Dragon types or 40 Insectoid-shaped Pokemon.

I don't think I can modify player.pokedex.seen_count to filter itself like that. But I know the Pokédex can retrieve this information via its search screen as it displays a figure under Search Results but I cannot make sense of how a script would count this data in an event.

Thanks for any help!
 
Ruby:
Expand Collapse Copy
# Returns the number of seen Pokémon of the given type
# The type argument is a symbol (e.g. :DRAGON)
def pokedexSeenType(type)
  type_id = GameData::Type.get(type).id
  count = 0
  GameData::Species.each do |species|
    # If you want to count each alternate form, remove the next line
    next unless species.form == 0
    next unless $player.pokedex.seen?(species.id)
    next unless species.types.include?(type_id)
    count += 1
  end
  return count
end

# Returns the number of seen Pokémon of the given shape
# The shape argument is a symbol (e.g. :Insectoid)
def pokedexSeenShape(shape)
  shape_id = GameData::BodyShape.get(shape).id
  count = 0
  GameData::Species.each do |species|
    next unless species.form == 0
    next unless $player.pokedex.seen?(species.id)
    next unless species.shape == shape_id
    count += 1
  end
  return count
end

To use these in an event script command:
count1 = pokedexSeenType(:DRAGON)
count2 = pokedexSeenShape(:Insectoid)
pbMessage(_INTL("You have seen {1} Dragon-type and {2} Insectoid-shaped Pokémon",count1,count2))

Alternatively, you can store the counts in variables with pbSet and have the NPC refer to them like this:
"You have seen \v[1] Dragon-type and \v[2] Insectoid-shaped Pokémon."
 
Back
Top