• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Type match-up summary

Resource Type match-up summary 1.1.0

Savage7590

Novice
Member
Joined
Apr 11, 2021
Posts
15
Hey thanks for getting back to me, I did that in both scripts and for some reason I'm still getting them to show maybe there's something else I'm suppose to delete as well?
 

Savage7590

Novice
Member
Joined
Apr 11, 2021
Posts
15
Yeah I always do full compile on startup whenever I make modifications to plugins and to script. Sorry for the inconvenience maybe there's a call somewhere else within? I don't a thing about scripting so just throwing it out there. Unless there's another way I should be compiling, I only know holding CTRL when starting up in debug, and through debug before starting a game.
 

ThatWelshOne_

Champion
Member
Yeah I always do full compile on startup whenever I make modifications to plugins and to script. Sorry for the inconvenience maybe there's a call somewhere else within? I don't a thing about scripting so just throwing it out there. Unless there's another way I should be compiling, I only know holding CTRL when starting up in debug, and through debug before starting a game.
I just tested removing the lines I told you to remove and the sprites go away as expected.
What version of Essentials are you using?
 

Savage7590

Novice
Member
Joined
Apr 11, 2021
Posts
15
I have v19.1 I'll attach the script here, I think I might've missed a line or something? Well I tried attaching the file but wouldn't upload so I'll paste it here.
class TypeMatch_Scene

# Filename for base graphic
WINDOWSKIN = "base.png"

# Choose whether you want the background to animate
MOVINGBACKGROUND = true

def initialize
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
end

def pbStartScene
addBackgroundPlane(@sprites,"bg","TypeMatch/bg",@viewport)
@sprites["base"] = IconSprite.new(0,0,@viewport)
@sprites["base"].setBitmap("Graphics/Pictures/TypeMatch/"+WINDOWSKIN)
@sprites["base"].ox = @sprites["base"].bitmap.width/2
@sprites["base"].oy = @sprites["base"].bitmap.height/2
@sprites["base"].x = Graphics.width/2; @sprites["base"].y = Graphics.height/2 - 16
@h = @sprites["base"].y - @sprites["base"].oy
@w = @sprites["base"].x - @sprites["base"].ox
@typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
2.times do |i|
end
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow",8,40,28,2,@viewport)
@sprites["rightarrow"].x = Graphics.width - @sprites["rightarrow"].bitmap.width
@sprites["rightarrow"].y = Graphics.height/2 - @sprites["rightarrow"].bitmap.height/16
@sprites["rightarrow"].visible = false
@sprites["rightarrow"].play
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow",8,40,28,2,@viewport)
@sprites["leftarrow"].x = 0
@sprites["leftarrow"].y = Graphics.height/2 - @sprites["rightarrow"].bitmap.height/16
@sprites["leftarrow"].visible = false
@sprites["leftarrow"].play
@sprites["bottombar"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
@sprites["bottombar"].bitmap.fill_rect(0,Graphics.height-32,Graphics.width,32,Color.new(48,192,216))
@sprites["bottombar"].visible = true
@sprites["text"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
@overlay_text = @sprites["text"].bitmap
pbSetSystemFont(@overlay_text)
@sprites["type"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
@overlay_type = @sprites["type"].bitmap
@types = []
GameData::Type.each { |s| @types.push(s.id) if !s.pseudo_type }
@types.sort!
end

def pbTypeMatchUp
@index = 0
type = @types[@index]
@init = true
drawTypes(type)
pbFadeInAndShow(@sprites) { pbUpdate }
loop do
Graphics.update
Input.update
pbUpdate
refresh = false
if Input.trigger?(Input::RIGHT) && @index< @types.length-1
pbPlayCursorSE
@index +=1
newType = @types[@index]
refresh = true
elsif Input.trigger?(Input::LEFT) && @index> 0
pbPlayCursorSE
@index -=1
newType = @types[@index]
refresh = true
elsif Input.trigger?(Input::USE) # Option to choose specific type
oldType = @types[@index]
newType = pbChooseTypeFromList(oldType, oldType)
if oldType != newType
@index = @types.index(newType)
refresh = true
end
elsif Input.trigger?(Input::BACK)
pbPlayCloseMenuSE
break
end
drawTypes(newType) if refresh
end
end

def drawTypes(type)
@sprites["rightarrow"].visible = (@index < @types.length-1) ? true : false
@sprites["leftarrow"].visible = (@index > 0) ? true : false
@overlay_type.clear
s = getRandomSpeciesFromType(type)
2.times do |i|
end
# Selected type
type = GameData::Type.get(type)
@overlay_type.blt(Graphics.width/2-32,@h+20,@typebitmap.bitmap,
Rect.new(0, type.id_number * 28, 64, 28))
# Weaknesses
weak = type.weaknesses
weaktype_rect = []
weak.each_with_index do |s, i|
t = GameData::Type.get(s).id_number
weaktype_rect.push(Rect.new(0, t * 28, 64, 28))
@overlay_type.blt(@w+40,@h+102+28*i,@typebitmap.bitmap,weaktype_rect)
end
# Resistances
resist = type.resistances
# Because Steel typing has an annoying number of resistances
xPos = (resist.length >6) ? [Graphics.width/2-64,Graphics.width/2] : Graphics.width/2-32
resisttype_rect = []
resist.each_with_index do |s, i|
t = GameData::Type.get(s).id_number
resisttype_rect.push(Rect.new(0, t * 28, 64, 28))
x = (xPos.is_a?(Array)) ? xPos[i/6] : xPos
@overlay_type.blt(x,@h+102+28*(i%6),@typebitmap.bitmap,
resisttype_rect)
end
# Immunities
immune = type.immunities
immunetype_rect = []
immune.each_with_index do |s, i|
t = GameData::Type.get(s).id_number
immunetype_rect.push(Rect.new(0, t * 28, 64, 28))
@overlay_type.blt(@w+280,@h+102+28*i,@typebitmap.bitmap,immunetype_rect)
end
base = Color.new(80,80,88)
shadow = Color.new(160,160,168)
textpos = [
["Weak",@w+72,@h+62,2,base,shadow],
["Resist",Graphics.width/2,@h+62,2,base,shadow],
["Immune",@w+312,@h+62,2,base,shadow],
["USE: Jump",4,Graphics.height-38,0,Color.new(248,248,248),Color.new(72,80,88)],
["ARROWS: Navigate",Graphics.width/2,Graphics.height-38,2,Color.new(248,248,248),Color.new(72,80,88)],
["BACK: Exit",Graphics.width-4,Graphics.height-38,1,Color.new(248,248,248),Color.new(72,80,88)]
]
pbDrawTextPositions(@overlay_text,textpos) if @init
@init = false
end

def pbUpdate
pbUpdateSpriteHash(@sprites)
if @sprites["bg"] && MOVINGBACKGROUND
@sprites["bg"].ox-=1
@sprites["bg"].oy-=1
end
end

# Dipose stuff at the end
def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites)
@typebitmap.dispose
@viewport.dispose
end

# Borrowed from the editor scripts
# Renamed so as to not break anything anywhere else
def pbChooseTypeFromList(default = nil, currType)
commands = []
GameData::Type.each { |t| commands.push([t.id_number, t.name, t.id]) if !t.pseudo_type }
return pbChooseList(commands, default, currType, 1)
end

end

class TypeMatch_Screen

def initialize(scene)
@scene = scene
end

def pbStartScreen
@scene.pbStartScene
@scene.pbTypeMatchUp
@scene.pbEndScene
end

end

def pbTypeMatchUI
pbFadeOutIn {
scene = TypeMatch_Scene.new
screen = TypeMatch_Screen.new(scene)
screen.pbStartScreen
}
end
 

KaylanVT

Rookie
Member
Joined
Feb 17, 2023
Posts
4
Quick question. How would I restrict the Species Type Match to only show pokemon the player has seen in the pokedex in v20.1?
 

ThatWelshOne_

Champion
Member
Quick question. How would I restrict the Species Type Match to only show pokemon the player has seen in the pokedex in v20.1?
I think you could delete lines 51 and 52 which look like this for me:
Ruby:
region = pbGetCurrentRegion
@species = pbAllRegionalSpecies(region)
And then change line 56 to this:
Ruby:
GameData::Species.each { |s| @species.push(s.id) if s.form == 0 && $player.seen?(s) }
I imagine your game will crash if the player hasn't seen any Pokémon, so bear that in mind.
 

Jangajinx

An Overly Ambitious Developer
Member
Joined
Apr 21, 2023
Posts
213
I am a bit lost here so after adding the national dex or johto dex. I only see up to mew and no other generation after that. Is anyone able to help me get it to show every pokemon?
 

ThatWelshOne_

Champion
Member
I am a bit lost here so after adding the national dex or johto dex. I only see up to mew and no other generation after that. Is anyone able to help me get it to show every pokemon?
If you open 002_SpeciesTypeMatch_UI.rb, you can just delete lines 51 and 52. By default, the script only shows the Pokémon defined in the regional dex for the region you're currently in, or the national dex if a regional dex is not defined.
 

Jangajinx

An Overly Ambitious Developer
Member
Joined
Apr 21, 2023
Posts
213
If you open 002_SpeciesTypeMatch_UI.rb, you can just delete lines 51 and 52. By default, the script only shows the Pokémon defined in the regional dex for the region you're currently in, or the national dex if a regional dex is not defined.
Worked like a charm! Much love!
 

gameguy39

Rookie
Member
Joined
Jul 27, 2019
Posts
6
This is an older thread, but I had a question and was wondering if there was an answer. I want to go directly to a particular pokemon with their index when in battle. Is there any way to change this within the code? I see under species there is an index that I can change, but how do I change that from outside the script? And How do I check what index is the opponent's pokemon?
 

ThatWelshOne_

Champion
Member
This is an older thread, but I had a question and was wondering if there was an answer. I want to go directly to a particular pokemon with their index when in battle. Is there any way to change this within the code? I see under species there is an index that I can change, but how do I change that from outside the script? And How do I check what index is the opponent's pokemon?
Unless I'm misunderstanding, I don't think your question relates to this resource (I don't know the answer to your question anyway).
Your best bet is to make a Questions thread about this topic or join our Discord server and ask in the help channel.
 

gameguy39

Rookie
Member
Joined
Jul 27, 2019
Posts
6
I've done some heavy modifying to the script that I wanted to share for anyone that was interested in it while browsing through it or if ThatWelshOne_ wants to take this into consideration:

You can use a custom array of pokemon species in order to create a smaller version of the available pokemon. I was looking for a way to narrow this down to only show the pokemon currently in battle. This was a little difficult but I finally found out how to do it.

All of these edits are only in the SpeciesTypeMatch_UI script. I haven't touched the other one.

I removed lines 51-57 as instead of defining the species within the method pbStartScene I am defining it right at the beginning when you call pbSpeciesTypeMatchUI. This allows me to create an argument for the method that will return nil if no custom array is defined, then defaulting to the region as normal within the script.

New pbSpeciesTypeMatchUI:
def pbSpeciesTypeMatchUI(custom_species = nil)
  pbFadeOutIn {
    scene = SpeciesTypeMatch_Scene.new
    screen = SpeciesTypeMatch_Screen.new(scene)

    #If the custom species array isn't empty, it will use the custom array of pokemon.
    if custom_species && !custom_species.empty?
      # Use the custom_species array if it is provided
      scene.instance_variable_set(:@species, custom_species)
    else
      # If custom_species is not provided or empty, load species from the Pokédex
      region = pbGetCurrentRegion
      species = pbAllRegionalSpecies(region)
      if !species || species.empty?
        species = []
        GameData::Species.each { |s| species.push(s.id) if s.form == 0 }
      end
      scene.instance_variable_set(:@species, species)
    end

    screen.pbStartScreen
  }
end

You can now pass a custom array of pokemon into the script and it will create a smaller list of just those chosen pokemon. I implemented this as a way to show the screen in the middle of battle, only showing the pokemon that are currently in battle. This DOES work with double battles. Here's how to implement it.

Battle_Scene changes, starting line 113:
  #Starts on line 113 of Battle_Scene
  def pbFrameUpdate(cw = nil)
    cw&.update
    @battle.battlers.each_with_index do |b, i|
      next if !b
      @sprites["dataBox_#{i}"]&.update(@frameCounter)
      @sprites["pokemon_#{i}"]&.update(@frameCounter)
      @sprites["shadow_#{i}"]&.update(@frameCounter)
    end
      #Runs script when T button is pressed. You can change to any button.
    if Input.triggerex?(:T)
        #Creates an array populated by all current unique pokemon on the field.
      custom_species = @battle.battlers.map { |battler| battler.species }.uniq
        #Runs the species type match script with the custom species array.
      pbSpeciesTypeMatchUI(custom_species)
    end
  end

I am using this in my upcoming fan game where I have changed the balance of the types, so this was something I REALLY wanted to implement. Not sure that this place in the Battle_Scene is the best place for calling the script, but I'm just glad I could get it to work.

Hope this helps someone else.
 

LuckyBunny

The Chonky Bunny
Member
Joined
Jun 29, 2022
Posts
8
I don't know if anyone will see this, but I added more than a few types to my game, and the type matchup GUI crashed almost instantly upon seeing one of them, and I know it's not just that type, because an altered version of the Grass type also crashed the game instantly (from Bulbasaur). I don't know if there's any way to fix this, but it didn't give me much info as to why it crashed, so your guess is as good as mine. (Yes, it also crashes on a majority of other types)


=================

[2023-12-16 03:15:30 -0500]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]

Script error in Common Event, map 43 (Wild Gate)
Exception: TypeError
Message: Argument 0: Expected fixnum

***Full script:
pbTypeMatchUI

Backtrace:
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:121:in `blt'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:121:in `block in drawTypes'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:117:in `each'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:117:in `each_with_index'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:117:in `drawTypes'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:87:in `block in pbTypeMatchUp'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:61:in `loop'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:61:in `pbTypeMatchUp'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:187:in `pbStartScreen'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:197:in `block in pbTypeMatchUI'
 

ThatWelshOne_

Champion
Member
I don't know if anyone will see this, but I added more than a few types to my game, and the type matchup GUI crashed almost instantly upon seeing one of them, and I know it's not just that type, because an altered version of the Grass type also crashed the game instantly (from Bulbasaur). I don't know if there's any way to fix this, but it didn't give me much info as to why it crashed, so your guess is as good as mine. (Yes, it also crashes on a majority of other types)


=================

[2023-12-16 03:15:30 -0500]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]

Script error in Common Event, map 43 (Wild Gate)
Exception: TypeError
Message: Argument 0: Expected fixnum

***Full script:
pbTypeMatchUI

Backtrace:
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:121:in `blt'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:121:in `block in drawTypes'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:117:in `each'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:117:in `each_with_index'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:117:in `drawTypes'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:87:in `block in pbTypeMatchUp'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:61:in `loop'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:61:in `pbTypeMatchUp'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:187:in `pbStartScreen'
[Type Match-up UI] 001_SingleTypeMatch_UI.rb:197:in `block in pbTypeMatchUI'
I need more information than that, sorry. How have you defined your new types in your PBS file? What do you mean by "an altered version of the Grass type"?
 

LuckyBunny

The Chonky Bunny
Member
Joined
Jun 29, 2022
Posts
8
I need more information than that, sorry. How have you defined your new types in your PBS file? What do you mean by "an altered version of the Grass type"?
I've abandoned the project, but I'll still respond. Yes, I did define the new types in my PBS files, and the altered version of Grass type is just grass type with the proper alterations made to make it have weaknesses, resistances, etc. as the new types require. I've just kind of defined stuff as normal. It was a random project I made out of boredom, so I'll 100% share the types PBS here just in case it helps, but here's what the Grass type I mentioned looks like:
#-------------------------------
[GRASS]
Name = Grass
IconPosition = 12
IsSpecialType = true
Weaknesses = FLYING,POISON,BUG,FIRE,ICE,VIBE,FURRY,BAD,SILLY,SHARP,GENDER,LEFT,BEAN,BOOMER,OU,TECH,PLASTIC,PAINT,CHAOS,WACK
Resistances = GROUND,WATER,GRASS,ELECTRIC,LIQUID,ANCIENT,CRAB,ZOOMER,PIKACHU,OHIO,WIND,LIGHT,BLOOD,ZOMBIE,FAIRY
Immunities = GAMER
 

Attachments

  • types.txt
    23.4 KB · Views: 16

ThatWelshOne_

Champion
Member
I've abandoned the project, but I'll still respond. Yes, I did define the new types in my PBS files, and the altered version of Grass type is just grass type with the proper alterations made to make it have weaknesses, resistances, etc. as the new types require. I've just kind of defined stuff as normal. It was a random project I made out of boredom, so I'll 100% share the types PBS here just in case it helps, but here's what the Grass type I mentioned looks like:
#-------------------------------
[GRASS]
Name = Grass
IconPosition = 12
IsSpecialType = true
Weaknesses = FLYING,POISON,BUG,FIRE,ICE,VIBE,FURRY,BAD,SILLY,SHARP,GENDER,LEFT,BEAN,BOOMER,OU,TECH,PLASTIC,PAINT,CHAOS,WACK
Resistances = GROUND,WATER,GRASS,ELECTRIC,LIQUID,ANCIENT,CRAB,ZOOMER,PIKACHU,OHIO,WIND,LIGHT,BLOOD,ZOMBIE,FAIRY
Immunities = GAMER
I think you either didn't add graphics for all these new types (most likely looking at the code and error message) or I didn't account for a type having 20 weaknesses and 15 resistances and that breaks the code.
 

notminiac

Novice
Member
Joined
Feb 24, 2024
Posts
18
Hello! I thought of adding an Item that let's you see a Type Chart (like a Town Map) and I was wondering how to add the functionality. Tried this simple script but it didn't work.
1710390429321.png

How could I make it work correctly? Additionally, how could I open a window that asks if you want to see a single-type chart (with pbTypeMatchUI) or a Species-specific chart (with pbSpeciesTypeMatchUI)?

Thank you for your plugin!
 
Back
Top