• 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!
Mass Flag/TutorMove adder

v20.1 Mass Flag/TutorMove adder 2023-06-30

This resource pertains to version 20.1 of Pokémon Essentials.
Pokémon Essentials Version
v20.1 ➖
1688091111434.png

Quick little script to let you add a flag to several PBS entries at once, rather than needing to scroll through for each one.
Useful for when you're creating a new category for a mechanic, especially if you plan on sharing this with others.

(I'll be using this with some public concepts in the future!)​

Code​

Can be downloaded as a plugin for v20 here, or paste in a new script section above Main.
Ruby:
def pbMassFlag(pbs,flag,array)
  case pbs
    when :Items
      GameData::Item.each do |itm|
        next if !array.include?(itm.id)
        item_hash = {
          :id          => itm.id,
          :name        => itm.real_name,
          :name_plural => itm.real_name_plural,
          :pocket      => itm.pocket,
          :price       => itm.price,
          :sell_price  => itm.sell_price,
          :description => itm.real_description,
          :field_use   => itm.field_use,
          :battle_use  => itm.battle_use,
          :consumable  => itm.consumable,
          :flags       => itm.flags.push(flag),
          :move        => itm.move
        }
        GameData::Item.register(item_hash)
      end
      GameData::Item.save
      Compiler.write_items
    when :Moves
      GameData::Move.each do |move|
        next if !array.include?(move.id)
        move_hash = {
          :id            => move.id,
          :name          => move.name,
          :function_code => move.function_code,
          :base_damage   => move.base_damage,
          :type          => move.type,
          :category      => move.category,
          :accuracy      => move.accuracy,
          :total_pp      => move.total_pp,
          :effect_chance => move.effect_chance,
          :target        => move.target,
          :priority      => move.priority,
          :flags         => move.flags.push(flag),
          :description   => move.description
        }
        GameData::Move.register(move_hash)
      end
      GameData::Move.save
      Compiler.write_moves
    when :Species, :Pokemon
          GameData::Species.each do |spec|
          next if !array.include?(spec.id)
          moves = []
          spec.moves.each_with_index { |m, i| moves.push(m.clone.push(i)) }
          moves.sort! { |a, b| (a[0] == b[0]) ? a[2] <=> b[2] : a[0] <=> b[0] }
          moves.each { |m| m.pop }
          evolutions = []
          spec.evolutions.each { |e| evolutions.push(e.clone) if !e[3] }
          types = [spec.types[0], spec.types[1]].uniq.compact          # Types
          types = nil if types.empty?
          egg_groups = [spec.egg_groups[0], spec.egg_groups[1]].uniq.compact   # Egg groups
          egg_groups = nil if egg_groups.empty?
          abilities = [spec.abilities[0], spec.abilities[1]].uniq.compact    # Abilities
          hidden_abilities = [spec.hidden_abilities[0], spec.hidden_abilities[1], spec.hidden_abilities[2], spec.hidden_abilities[3]].uniq.compact   # Hidden abilities
          # Construct species hash
          species_hash = {
            :id                 => spec.id,
            :name               => spec.real_name,
            :form_name          => spec.real_form_name,
            :category           => spec.real_category,
            :pokedex_entry      => spec.real_pokedex_entry,
            :types              => types,              # 5, 6
            :base_stats         => spec.base_stats,
            :evs                => spec.evs,
            :base_exp           => spec.base_exp, #spec.calculated_exp for scripted xp
            :growth_rate        => spec.growth_rate,
            :gender_ratio       => spec.gender_ratio,
            :catch_rate         => spec.catch_rate,
            :happiness          => spec.happiness,
            :moves              => moves,
            :tutor_moves        => spec.tutor_moves.clone,
            :egg_moves          => spec.egg_moves.clone,
            :abilities          => abilities,          # 17, 18
            :hidden_abilities   => hidden_abilities,   # 19, 20, 21, 22
            :wild_item_common   => spec.wild_item_common.clone,
            :wild_item_uncommon => spec.wild_item_uncommon.clone,
            :wild_item_rare     => spec.wild_item_rare.clone,
            :egg_groups         => egg_groups,         # 26, 27
            :hatch_steps        => spec.hatch_steps,
            :incense            => spec.incense,
            :offspring          => spec.offspring,
            :evolutions         => evolutions,
            :height             => spec.height,
            :weight             => spec.weight,
            :color              => spec.color,
            :shape              => spec.shape,
            :habitat            => spec.habitat,
            :generation         => spec.generation,
            :flags              => spec.flags.push(flag)
          }
          # Add species' data to records
          GameData::Species.register(species_hash)
        end
        GameData::Species.save
        Compiler.write_pokemon
  end
end


def pbMassTutor(move,array)
  GameData::Species.each do |spec|
  next if !array.include?(spec.id)
  moves = []
  spec.moves.each_with_index { |m, i| moves.push(m.clone.push(i)) }
  moves.sort! { |a, b| (a[0] == b[0]) ? a[2] <=> b[2] : a[0] <=> b[0] }
  moves.each { |m| m.pop }
  evolutions = []
  spec.evolutions.each { |e| evolutions.push(e.clone) if !e[3] }
  types = [spec.types[0], spec.types[1]].uniq.compact          # Types
  types = nil if types.empty?
  egg_groups = [spec.egg_groups[0], spec.egg_groups[1]].uniq.compact   # Egg groups
  egg_groups = nil if egg_groups.empty?
  abilities = [spec.abilities[0], spec.abilities[1]].uniq.compact    # Abilities
  hidden_abilities = [spec.hidden_abilities[0], spec.hidden_abilities[1], spec.hidden_abilities[2], spec.hidden_abilities[3]].uniq.compact   # Hidden abilities
  # Construct species hash
  species_hash = {
    :id                 => spec.id,
    :name               => spec.real_name,
    :form_name          => spec.real_form_name,
    :category           => spec.real_category,
    :pokedex_entry      => spec.real_pokedex_entry,
    :types              => types,              # 5, 6
    :base_stats         => spec.base_stats,
    :evs                => spec.evs,
    :base_exp           => spec.base_exp, #spec.calculated_exp for scripted xp
    :growth_rate        => spec.growth_rate,
    :gender_ratio       => spec.gender_ratio,
    :catch_rate         => spec.catch_rate,
    :happiness          => spec.happiness,
    :moves              => moves,
    :tutor_moves        => spec.tutor_moves.clone.push(move).uniq!.sort,
    :egg_moves          => spec.egg_moves.clone,
    :abilities          => abilities,          # 17, 18
    :hidden_abilities   => hidden_abilities,   # 19, 20, 21, 22
    :wild_item_common   => spec.wild_item_common.clone,
    :wild_item_uncommon => spec.wild_item_uncommon.clone,
    :wild_item_rare     => spec.wild_item_rare.clone,
    :egg_groups         => egg_groups,         # 26, 27
    :hatch_steps        => spec.hatch_steps,
    :incense            => spec.incense,
    :offspring          => spec.offspring,
    :evolutions         => evolutions,
    :height             => spec.height,
    :weight             => spec.weight,
    :color              => spec.color,
    :shape              => spec.shape,
    :habitat            => spec.habitat,
    :generation         => spec.generation,
    :flags              => spec.flags
  }
  # Add species' data to records
  GameData::Species.register(species_hash)
  end
  GameData::Species.save
  Compiler.write_pokemon
end
(This is possibly v21-compatible, I haven't tested yet)

Using the script​

The method for flags is pbMassFlag(pbs,flag,array), where:
  • pbs is which PBS file you're editing. (Should be a symbol, with a : in front of it) Right now, the script only works with three - :Moves, :Items, and :Pokemon (or :Species). I may update this for map/ability flags, depending on the demand.
  • flag is the flag being added to each entry. Should be a string (in quotes)
  • array is an array of each ID you're adding the flag to.
So, for example, in Substitube's Held Items video, they mention a Jingle Bells item that would only work with deer Pokémon, and list all the Pokémon they think should qualify. So I'd run this script:
pbMassFlag(:Pokemon,"Deer",[:STANTLER,:DEERLING,:SAWSBUCK,:COBALION,:TERRAKION,:VIRIZION,:XERNEAS,:WYRDEER,:TINGLU])
(And I'd probably use extendtext.exe or add some line breaks...)

And the Deer flag would be added to all those Pokémon, so I could just check it in a script!

Not using Gen 9 mons? No worries! What this script does is check each entry in the PBS to see if its ID is included in the given array, rather than grab data from each item in the array. That means if there's no Wyrdeer in your PBS, it won't cause any errors! (It also means that if there's a typo, you won't know about it unless you check yourself 😅)

For adding TM/tutor moves, it's pretty much the same, just fewer arguments. pbMassTutor(move,array), where
  • move is the ID of the move to add
  • array is an array of each Pokémon ID you're adding the move to.
As an added bonus, this will also handle alphabetizing the TutorMoves entry for each species it adds to.

So, for example, if I wanted to add Comeuppance as a tutor move rather than a level-up move, I'd do this:

pbMassTutor(:COMEUPPANCE,[:HOUNDOUR,:HOUNDOOM,:HONCHKROW])

Currently, this only edits the base species, and I don't think you could edit alternate forms. (That means that if you wanted to add a move to Alolan Raichu but not Kanto Raichu, for example, you'd be out of luck) You may be able to try :SPECIES_FORM, but I haven't yet tested that.

I'll also be working on a version of this that works with a blacklist rather than a whitelist, for near-universal moves like Hidden Power.
Credits
Credit to TechSkylander1518, please! (Technically there's no way I could tell if you used this without crediting, but I'd appreciate it all the same lol)
Author
TechSkylander1518
Downloads
432
Views
1,407
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from TechSkylander1518

Latest reviews

This resource is saving me so much time when assigning flags to all of the Pokemon in my game. Sure, I have to type them all out in the event command, but it beats having to scroll through the large Pokemon.txt file!

The only real way this could be improved is by supporting more PBS files (Such as Pokemon Forms and Map Metadata).
Back
Top