Customizable PokeDex

Customizable PokeDex

Pokémon Essentials Version
v19 ✅
Everyone knows that dex entries are made up. We had our suspicions after Macargo, but after the Gen 8 fossils, it's practically confirmed.

So, why not let the players get in on the fun?

(If you like the menu used in this GIF, be sure to check out Luka's Modular Pause Menu!)


Code
Paste in a new section above Main!

module Custom_Entries
attr_accessor :entries


@entries = []
end



class Player
include Custom_Entries
end


def customEntry?(species)
idno = GameData::Species.get(species).id_number
if $Trainer.entries &&
$Trainer.entries[idno]!=nil &&
$Trainer.entries[idno]!=" " &&
$Trainer.entries[idno]!=""
return true
else
return false
end
end


def entry(species,var)
idno = GameData::Species.get(species).id_number
if customEntry?(species)
$game_variables[var] = $Trainer.entries[idno]
else
$game_variables[var] = GameData::Species.get(species).pokedex_entry
end

end

class PokemonPokedexInfo_Scene

def drawPageInfo
@sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_info"))
overlay = @sprites["overlay"].bitmap
base = Color.new(88, 88, 80)
shadow = Color.new(168, 184, 184)
imagepos = []
if @brief
imagepos.push([_INTL("Graphics/Pictures/Pokedex/overlay_info"), 0, 0])
end
species_data = GameData::Species.get_species_form(@species, @form)
# Write various bits of text
indexText = "???"
if @dexlist[@index][4] > 0
indexNumber = @dexlist[@index][4]
indexNumber -= 1 if @dexlist[@index][5]
indexText = sprintf("%03d", indexNumber)
end
textpos = [
[_INTL("{1}{2} {3}", indexText, " ", species_data.name),
246, 36, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)],
[_INTL("Height"), 314, 152, 0, base, shadow],
[_INTL("Weight"), 314, 184, 0, base, shadow]
]
if $Trainer.owned?(@species)
# Write the category
textpos.push([_INTL("{1} Pokémon", species_data.category), 246, 68, 0, base, shadow])
# Write the height and weight
height = species_data.height
weight = species_data.weight
if System.user_language[3..4] == "US" # If the user is in the United States
inches = (height / 0.254).round
pounds = (weight / 0.45359).round
textpos.push([_ISPRINTF("{1:d}'{2:02d}\"", inches / 12, inches % 12), 460, 152, 1, base, shadow])
textpos.push([_ISPRINTF("{1:4.1f} lbs.", pounds / 10.0), 494, 184, 1, base, shadow])
else
textpos.push([_ISPRINTF("{1:.1f} m", height / 10.0), 470, 152, 1, base, shadow])
textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 184, 1, base, shadow])
end
# Draw the Pokédex entry text
entry = species_data.pokedex_entry
if !$Trainer.entries
$Trainer.entries = []
GameData::Species.each do |sp|
$Trainer.entries[sp.id_number] = ""
end
end
idno = species_data.id_number
if $Trainer.entries[idno]!=nil &&
$Trainer.entries[idno]!=" " &&
$Trainer.entries[idno]!=""
entry = $Trainer.entries[idno]
end
drawTextEx(overlay, 40, 244, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines
entry, base, shadow)
# Draw the footprint
footprintfile = GameData::Species.footprint_filename(@species, @form)
if footprintfile
footprint = RPG::Cache.load_bitmap("",footprintfile)
overlay.blt(226, 138, footprint, footprint.rect)
footprint.dispose
end
# Show the owned icon
imagepos.push(["Graphics/Pictures/Pokedex/icon_own", 212, 44])
# Draw the type icon(s)
type1 = species_data.type1
type2 = species_data.type2
type1_number = GameData::Type.get(type1).id_number
type2_number = GameData::Type.get(type2).id_number
type1rect = Rect.new(0, type1_number * 32, 96, 32)
type2rect = Rect.new(0, type2_number * 32, 96, 32)
overlay.blt(296, 120, @typebitmap.bitmap, type1rect)
overlay.blt(396, 120, @typebitmap.bitmap, type2rect) if type1 != type2
else
# Write the category
textpos.push([_INTL("????? Pokémon"), 246, 68, 0, base, shadow])
# Write the height and weight
if System.user_language[3..4] == "US" # If the user is in the United States
textpos.push([_INTL("???'??\""), 460, 152, 1, base, shadow])
textpos.push([_INTL("????.? lbs."), 494, 184, 1, base, shadow])
else
textpos.push([_INTL("????.? m"), 470, 152, 1, base, shadow])
textpos.push([_INTL("????.? kg"), 482, 184, 1, base, shadow])
end
end
# Draw all text
pbDrawTextPositions(overlay, textpos)
# Draw all images
pbDrawImagePositions(overlay, imagepos)
end

def pbScene
GameData::Species.play_cry_from_species(@species, @form)
loop do
Graphics.update
Input.update
pbUpdate
dorefresh = false
if Input.trigger?(Input::ACTION)
pbSEStop
GameData::Species.play_cry_from_species(@species, @form) if @page == 1
elsif Input.trigger?(Input::BACK)
pbPlayCloseMenuSE
break
elsif Input.trigger?(Input::USE)
if @page==2 # Area
# dorefresh = true
elsif @page==3 # Forms
if @available.length>1
pbPlayDecisionSE
pbChooseForm
dorefresh = true
end
end
elsif Input.trigger?(Input::ALT) && $Trainer.owned?(@species)
if @page==1
if !$Trainer.entries
$Trainer.entries = []
GameData::Species.each do |sp|
$Trainer.entries[sp.id_number] = ""
end
end
species_data = GameData::Species.get_species_form(@species, @form)
idno = species_data.id_number
$Trainer.entries[idno]=pbMessageFreeText(_INTL("New PokéDex entry?"),"",false,170,Graphics.width)
dorefresh = true
drawPageInfo
end
elsif Input.trigger?(Input::UP)
oldindex = @index
pbGoToPrevious
if @index!=oldindex
pbUpdateDummyPokemon
@available = pbGetAvailableForms
pbSEStop
(@page==1) ? GameData::Species.play_cry_from_species(@species, @form) : pbPlayCursorSE
dorefresh = true
end
elsif Input.trigger?(Input::DOWN)
oldindex = @index
pbGoToNext
if @index!=oldindex
pbUpdateDummyPokemon
@available = pbGetAvailableForms
pbSEStop
(@page==1) ? GameData::Species.play_cry_from_species(@species, @form) : pbPlayCursorSE
dorefresh = true
end
elsif Input.trigger?(Input::LEFT)
oldpage = @page
@page -= 1
@page = 1 if @page<1
@page = 3 if @page>3
if @page!=oldpage
pbPlayCursorSE
dorefresh = true
end
elsif Input.trigger?(Input::RIGHT)
oldpage = @page
@page += 1
@page = 1 if @page<1
@page = 3 if @page>3
if @page!=oldpage
pbPlayCursorSE
dorefresh = true
end
end
if dorefresh
drawPage(@page)
end
end
return @index
end



end

Ruby:
module Custom_Entries
  attr_accessor :entries


  @entries = []
end



class PokeBattle_Trainer
include Custom_Entries
end


def customEntry?(species)
  species = getID(PBSpecies,species)
  if $Trainer.entries && $Trainer.entries[species]!=nil && $Trainer.entries[species]!=" " && $Trainer.entries[species]!=""
    return true
  else
    return false
  end
end


def entry(species,var)
  species = getID(PBSpecies,species)
    if $Trainer.entries && $Trainer.entries[species]!=nil && $Trainer.entries[species]!=" " && $Trainer.entries[species]!=""
      $game_variables[var] = $Trainer.entries[species]
    else
      $game_variables[var] = pbGetMessage(MessageTypes::Entries,species)
  end

end

class PokemonPokedexInfo_Scene

  def drawPageInfo
    @sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_info"))
    overlay = @sprites["overlay"].bitmap
    base   = Color.new(88,88,80)
    shadow = Color.new(168,184,184)
    imagepos = []
    if @brief
      imagepos.push([_INTL("Graphics/Pictures/Pokedex/overlay_info"),0,0])
    end
    # Write various bits of text
    indexText = "???"
    if @dexlist[@index][4]>0
      indexNumber = @dexlist[@index][4]
      indexNumber -= 1 if @dexlist[@index][5]
      indexText = sprintf("%03d",indexNumber)
    end
    textpos = [
       [_INTL("{1}{2} {3}",indexText," ",PBSpecies.getName(@species)),
          246,42,0,Color.new(248,248,248),Color.new(0,0,0)],
       [_INTL("Height"),314,158,0,base,shadow],
       [_INTL("Weight"),314,190,0,base,shadow]
    ]
    if $Trainer.owned[@species]
      speciesData = pbGetSpeciesData(@species,@form)
      fSpecies = pbGetFSpeciesFromForm(@species,@form)
      # Write the kind
      kind = pbGetMessage(MessageTypes::Kinds,fSpecies)
      kind = pbGetMessage(MessageTypes::Kinds,@species) if !kind || kind==""
      textpos.push([_INTL("{1} Pokémon",kind),246,74,0,base,shadow])
      # Write the height and weight
      height = speciesData[SpeciesHeight] || 1
      weight = speciesData[SpeciesWeight] || 1
      if pbGetCountry==0xF4   # If the user is in the United States
        inches = (height/0.254).round
        pounds = (weight/0.45359).round
        textpos.push([_ISPRINTF("{1:d}'{2:02d}\"",inches/12,inches%12),460,158,1,base,shadow])
        textpos.push([_ISPRINTF("{1:4.1f} lbs.",pounds/10.0),494,190,1,base,shadow])
      else
        textpos.push([_ISPRINTF("{1:.1f} m",height/10.0),470,158,1,base,shadow])
        textpos.push([_ISPRINTF("{1:.1f} kg",weight/10.0),482,190,1,base,shadow])
      end
      # Draw the Pokédex entry text
      entry = pbGetMessage(MessageTypes::Entries,fSpecies)
      entry = pbGetMessage(MessageTypes::Entries,@species) if !entry || entry==""
      if !$Trainer.entries
        $Trainer.entries = []
        for i in 1..PBSpecies.maxValue
          $Trainer.entries[i]         = ""
        end
      end
        if $Trainer.entries[@species]!=nil && $Trainer.entries[@species]!=" " && $Trainer.entries[@species]!=""
          entry = $Trainer.entries[@species]
        end
      drawTextEx(overlay,40,240,Graphics.width-(40*2),4,entry,base,shadow)
      # Draw the footprint
      footprintfile = pbPokemonFootprintFile(@species,@form)
      if footprintfile
        footprint = BitmapCache.load_bitmap(footprintfile)
        overlay.blt(226,138,footprint,footprint.rect)
        footprint.dispose
      end
      # Show the owned icon
      imagepos.push(["Graphics/Pictures/Pokedex/icon_own",212,44])
      # Draw the type icon(s)
      type1 = speciesData[SpeciesType1] || 0
      type2 = speciesData[SpeciesType2] || type1
      type1rect = Rect.new(0,type1*32,96,32)
      type2rect = Rect.new(0,type2*32,96,32)
      overlay.blt(296,120,@typebitmap.bitmap,type1rect)
      overlay.blt(396,120,@typebitmap.bitmap,type2rect) if type1!=type2
    else
      # Write the kind
      textpos.push([_INTL("????? Pokémon"),246,74,0,base,shadow])
      # Write the height and weight
      if pbGetCountry()==0xF4 # If the user is in the United States
        textpos.push([_INTL("???'??\""),460,158,1,base,shadow])
        textpos.push([_INTL("????.? lbs."),494,190,1,base,shadow])
      else
        textpos.push([_INTL("????.? m"),470,158,1,base,shadow])
        textpos.push([_INTL("????.? kg"),482,190,1,base,shadow])
      end
    end
    # Draw all text
    pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
    # Draw all images
    pbDrawImagePositions(overlay,imagepos)
  end


  def pbScene
    pbPlayCrySpecies(@species,@form)
    loop do
      Graphics.update
      Input.update
      pbUpdate
      dorefresh = false
      if Input.trigger?(Input::A)
        pbSEStop
        pbPlayCrySpecies(@species,@form) if @page==1
      elsif Input.trigger?(Input::B)
        pbPlayCloseMenuSE
        break
      elsif Input.trigger?(Input::C)
        if @page==2   # Area
#          dorefresh = true
        elsif @page==3   # Forms
          if @available.length>1
            pbPlayDecisionSE
            pbChooseForm
            dorefresh = true
          end
        end
      elsif Input.trigger?(Input::ALT) && $Trainer.owned[@species]
        if @page==1
          if !$Trainer.entries
            $Trainer.entries = []
            for i in 1..PBSpecies.maxValue
              $Trainer.entries[i]         = ""
            end
          end
          $Trainer.entries[@species]=pbMessageFreeText(_INTL("New PokéDex entry?"),"",false,170,Graphics.width)
          dorefresh = true
          drawPageInfo
        end
      elsif Input.trigger?(Input::UP)
        oldindex = @index
        pbGoToPrevious
        if @index!=oldindex
          pbUpdateDummyPokemon
          @available = pbGetAvailableForms
          pbSEStop
          (@page==1) ? pbPlayCrySpecies(@species,@form) : pbPlayCursorSE
          dorefresh = true
        end
      elsif Input.trigger?(Input::DOWN)
        oldindex = @index
        pbGoToNext
        if @index!=oldindex
          pbUpdateDummyPokemon
          @available = pbGetAvailableForms
          pbSEStop
          (@page==1) ? pbPlayCrySpecies(@species,@form) : pbPlayCursorSE
          dorefresh = true
        end
      elsif Input.trigger?(Input::LEFT)
        oldpage = @page
        @page -= 1
        @page = 1 if @page<1
        @page = 3 if @page>3
        if @page!=oldpage
          pbPlayCursorSE
          dorefresh = true
        end
      elsif Input.trigger?(Input::RIGHT)
        oldpage = @page
        @page += 1
        @page = 1 if @page<1
        @page = 3 if @page>3
        if @page!=oldpage
          pbPlayCursorSE
          dorefresh = true
        end
      end
      if dorefresh
        drawPage(@page)
      end
    end
    return @index
  end




end

Using this script
There's a few customizable bits of interest here:
  • ALT is the key to edit the dex entry. You could make this any other key you'd like, I just picked alt because a) it wasn't used for anything else, but was still coded in, and b) using alt to alter something feels easy to remember.
  • New PokeDex Entry? The text that appears when the message box pops up. Maybe you'd like something more personal there, like "What should I tell people about this Pokemon?"
  • 170 is the character limit for entries. I put it here because that seems to be about the limit of standard entries, but if your dex has a bigger or smaller size for entries, you may want to alter this.

You can add some more conditions to this if you want to restrict how the player edits them. Like, maybe you only want them to be allowed to make notes on a Pokemon they've caught, or you only want them to edit one species of Pokemon.

This updated version also has some script calls you can use! customEntry?(:SPECIES) returns true if the player has a custom entry for the species, and false if they don't. entry(:SPECIES,number) will set Variable (number) to the Pokemon's current dex entry, whether it's a custom entry or just the default one.

So, obviously the player has plenty that they can do here (memes, new text, battle strategies), but I think there's also some fun possibilities on the dev's end, too. Since these are global variables, you can have events react to the fact that the player has affected them.
  • You could let the player discover a Pokémon, and leave their dex entry as ?????? for the player to fill in.
  • You could let the player uncover the truth behind a certain Pokémon and correct a misunderstanding about it. Like, maybe the original dex entry about Absol talks about it being a harbinger of doom, and NPCs avoid it, but after the player alters the entry, some NPCs will even begin bringing Absol into their homes. (Of course, you might have to run into some separation of game and story here, because you can't possibly anticipate every entry yourself, so there'd be nothing to stop a player from typing "Actually Absol is really bad" and still getting this result)
  • There might be some aficionado of a certain species of Pokémon who will offer a prize if you write a glowing review for that species in the PokeDex. (Although, again, nothing stopping the player from writing something ridiculous and getting the prize anyways)
  • These entries can be referenced directly in dialogue as well, so you could have NPCs mentioning to each other they heard some new comments about a certain Pokémon lately.
Future Goals
  • Create a way to edit the form's entry as well
  • There's a well-known problem where old saves will crash viewing the PokeDex if the number of Pokemon has changed- I'd like to make a little fix for that in here while I'm at it.
  • Clean up this page a bit, I'm sure I could compress the old code down to a set of instructions
  • Get a little graphic for the rewrite command
Let me preface this by saying that, while the code is very simple, you also have to do something that is going to make your coding a bit messy: You have to add several hundred global variables to your project. Specifically, add enough variables to cover all the Pokemon in your Pokedex.

But from there, it's very easy to implement. In PScreen_PokeDexEntry, find this text:
Ruby:
# Draw the Pokédex entry text
      entry = pbGetMessage(MessageTypes::Entries,fSpecies)
      entry = pbGetMessage(MessageTypes::Entries,@species) if !entry || entry==""
      drawTextEx(overlay,40,240,Graphics.width-(40*2),4,entry,base,shadow)
Replace it with this:
Ruby:
      $game_variables[1] =@species
        varnum=@species+100
        entry = pbGetMessage(MessageTypes::Entries,fSpecies)
        entry = pbGetMessage(MessageTypes::Entries,@species) if !entry || entry==""
          if $game_variables[varnum]!=0 && $game_variables[varnum]!=" "
            entry = $game_variables[varnum]
          end
      drawTextEx(overlay,40,240,Graphics.width-(40*2),4,entry,base,shadow)
The 100 here is to make the variables start at the right place. In this example, my variables for the dex entries will start at 101, and keep going until they reach the end. If you're already using variable 101, you might change this 100 to 101, so that they begin on 102. You will need all of these slots to be unused for this to work. Otherwise, the dex entry will be overwritten by whatever else you use the variable for, or vice versa.

Ruby:
$game_variables[1] =@species
This puts the species in a variable so we can refer to it in another section.
Ruby:
varnum=@species+100
This creates a value to store the number of the corresponding variable for this Pokemon
Ruby:
entry = pbGetMessage(MessageTypes::Entries,fSpecies)
      entry = pbGetMessage(MessageTypes::Entries,@species) if !entry || entry==""
These lines generate the regular entry.
Ruby:
if $game_variables[varnum]!=0 && $game_variables[varnum]!=" "
This checks to see if there's anything stored in the Pokemon's "entry variable". The second check is for if the player backs out of the entry box, so there's a way to return to the original.
Ruby:
 entry = $game_variables[varnum]
Sets entry to the "entry variable" for the Pokemon.
Ruby:
 end
Ruby:
drawTextEx(overlay,40,240,Graphics.width-(40*2),4,entry,base,shadow)
Draws the text

Now, a bit further down the page, you'll need to put this code in pbScene. You can put it in front of any line beginning with elsif- elsif Input.trigger?(Input::B), elsif Input.trigger?(Input::C), etc.
Ruby:
      elsif Input.trigger?(Input::ALT)
        varnum=$game_variables[1]+100
          if @page==1
            $game_variables[varnum]=Kernel.pbMessageFreeText(_INTL("New PokéDex entry?")," ",false,170,Graphics.width)
            dorefresh = true
            drawPageInfo
          end


Ruby:
elsif Input.trigger?(Input::ALT)
Tells the game it will perform this if the player presses alt
Ruby:
varnum=$game_variables[1]+100
Creates varnum again, because it was in a separate def. (This is why we used variable 1 earlier)
Ruby:
 if @page==1
If the player is on the info page when they press alt
Ruby:
 $game_variables[varnum]=Kernel.pbMessageFreeText(_INTL("New PokéDex entry?")," ",false,170,Graphics.width)
Creates a string based on the player entering text, and saves it to the Pokemon's "entry variable".
Ruby:
  dorefresh = true
          drawPageInfo
Done to redraw the page and let the player see what their entry looks like.
end
Credits
Credits to TechSkylander1518, please!
Author
TechSkylander1518
Views
1,537
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from TechSkylander1518

Latest updates

  1. Quick v19 update!

    v19-compatible! I do still need to clean up the page a bit, and I might swap this out for a set...
  2. The "I actually know what I'm doing" update

    It's plug-and-play! There's some easy script calls to check for custom entries! You don't have...
Top