Advertisement
TechSkylander1518

Mass Flag Adder v20

Jun 24th, 2023 (edited)
1,386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.13 KB | None | 0 0
  1. def pbMassFlag(pbs,flag,array)
  2.   case pbs
  3.     when :Items
  4.       GameData::Item.each do |itm|
  5.         next if !array.include?(itm.id)
  6.         item_hash = {
  7.           :id          => itm.id,
  8.           :name        => itm.real_name,
  9.           :name_plural => itm.real_name_plural,
  10.           :pocket      => itm.pocket,
  11.           :price       => itm.price,
  12.           :sell_price  => itm.sell_price,
  13.           :description => itm.real_description,
  14.           :field_use   => itm.field_use,
  15.           :battle_use  => itm.battle_use,
  16.           :consumable  => itm.consumable,
  17.           :flags       => itm.flags.push(flag),
  18.           :move        => itm.move
  19.         }
  20.         GameData::Item.register(item_hash)
  21.       end
  22.       GameData::Item.save
  23.       Compiler.write_items
  24.     when :Moves
  25.       GameData::Move.each do |move|
  26.         next if !array.include?(move.id)
  27.         move_hash = {
  28.           :id            => move.id,
  29.           :name          => move.name,
  30.           :function_code => move.function_code,
  31.           :base_damage   => move.base_damage,
  32.           :type          => move.type,
  33.           :category      => move.category,
  34.           :accuracy      => move.accuracy,
  35.           :total_pp      => move.total_pp,
  36.           :effect_chance => move.effect_chance,
  37.           :target        => move.target,
  38.           :priority      => move.priority,
  39.           :flags         => move.flags.push(flag),
  40.           :description   => move.description
  41.         }
  42.         GameData::Move.register(move_hash)
  43.       end
  44.       GameData::Move.save
  45.       Compiler.write_moves
  46.     when :Species
  47.           GameData::Species.each do |spec|
  48.           next if !array.include?(spec.id)
  49.           moves = []
  50.           spec.moves.each_with_index { |m, i| moves.push(m.clone.push(i)) }
  51.           moves.sort! { |a, b| (a[0] == b[0]) ? a[2] <=> b[2] : a[0] <=> b[0] }
  52.           moves.each { |m| m.pop }
  53.           evolutions = []
  54.           spec.evolutions.each { |e| evolutions.push(e.clone) if !e[3] }
  55.           types = [spec.types[0], spec.types[1]].uniq.compact          # Types
  56.           types = nil if types.empty?
  57.           egg_groups = [spec.egg_groups[0], spec.egg_groups[1]].uniq.compact   # Egg groups
  58.           egg_groups = nil if egg_groups.empty?
  59.           abilities = [spec.abilities[0], spec.abilities[1]].uniq.compact    # Abilities
  60.           hidden_abilities = [spec.hidden_abilities[0], spec.hidden_abilities[1], spec.hidden_abilities[2], spec.hidden_abilities[3]].uniq.compact   # Hidden abilities
  61.           # Construct species hash
  62.           species_hash = {
  63.             :id                 => spec.id,
  64.             :name               => spec.real_name,
  65.             :form_name          => spec.real_form_name,
  66.             :category           => spec.real_category,
  67.             :pokedex_entry      => spec.real_pokedex_entry,
  68.             :types              => types,              # 5, 6
  69.             :base_stats         => spec.base_stats,
  70.             :evs                => spec.evs,
  71.             :base_exp           => spec.base_exp, #spec.calculated_exp for scripted xp
  72.             :growth_rate        => spec.growth_rate,
  73.             :gender_ratio       => spec.gender_ratio,
  74.             :catch_rate         => spec.catch_rate,
  75.             :happiness          => spec.happiness,
  76.             :moves              => moves,
  77.             :tutor_moves        => spec.tutor_moves.clone,
  78.             :egg_moves          => spec.egg_moves.clone,
  79.             :abilities          => abilities,          # 17, 18
  80.             :hidden_abilities   => hidden_abilities,   # 19, 20, 21, 22
  81.             :wild_item_common   => spec.wild_item_common.clone,
  82.             :wild_item_uncommon => spec.wild_item_uncommon.clone,
  83.             :wild_item_rare     => spec.wild_item_rare.clone,
  84.             :egg_groups         => egg_groups,         # 26, 27
  85.             :hatch_steps        => spec.hatch_steps,
  86.             :incense            => spec.incense,
  87.             :offspring          => spec.offspring,
  88.             :evolutions         => evolutions,
  89.             :height             => spec.height,
  90.             :weight             => spec.weight,
  91.             :color              => spec.color,
  92.             :shape              => spec.shape,
  93.             :habitat            => spec.habitat,
  94.             :generation         => spec.generation,
  95.             :flags              => spec.flags.push(flag)
  96.           }
  97.           # Add species' data to records
  98.           GameData::Species.register(species_hash)
  99.         end
  100.         GameData::Species.save
  101.         Compiler.write_pokemon
  102.   end
  103. end
  104.  
  105.  
  106. def pbMassTutor(move,array)
  107.   GameData::Species.each do |spec|
  108.   next if !array.include?(spec.id)
  109.   moves = []
  110.   spec.moves.each_with_index { |m, i| moves.push(m.clone.push(i)) }
  111.   moves.sort! { |a, b| (a[0] == b[0]) ? a[2] <=> b[2] : a[0] <=> b[0] }
  112.   moves.each { |m| m.pop }
  113.   evolutions = []
  114.   spec.evolutions.each { |e| evolutions.push(e.clone) if !e[3] }
  115.   types = [spec.types[0], spec.types[1]].uniq.compact          # Types
  116.   types = nil if types.empty?
  117.   egg_groups = [spec.egg_groups[0], spec.egg_groups[1]].uniq.compact   # Egg groups
  118.   egg_groups = nil if egg_groups.empty?
  119.   abilities = [spec.abilities[0], spec.abilities[1]].uniq.compact    # Abilities
  120.   hidden_abilities = [spec.hidden_abilities[0], spec.hidden_abilities[1], spec.hidden_abilities[2], spec.hidden_abilities[3]].uniq.compact   # Hidden abilities
  121.   # Construct species hash
  122.   species_hash = {
  123.     :id                 => spec.id,
  124.     :name               => spec.real_name,
  125.     :form_name          => spec.real_form_name,
  126.     :category           => spec.real_category,
  127.     :pokedex_entry      => spec.real_pokedex_entry,
  128.     :types              => types,              # 5, 6
  129.     :base_stats         => spec.base_stats,
  130.     :evs                => spec.evs,
  131.     :base_exp           => spec.base_exp, #spec.calculated_exp for scripted xp
  132.     :growth_rate        => spec.growth_rate,
  133.     :gender_ratio       => spec.gender_ratio,
  134.     :catch_rate         => spec.catch_rate,
  135.     :happiness          => spec.happiness,
  136.     :moves              => moves,
  137.     :tutor_moves        => spec.tutor_moves.clone.push(move).uniq!.sort,
  138.     :egg_moves          => spec.egg_moves.clone,
  139.     :abilities          => abilities,          # 17, 18
  140.     :hidden_abilities   => hidden_abilities,   # 19, 20, 21, 22
  141.     :wild_item_common   => spec.wild_item_common.clone,
  142.     :wild_item_uncommon => spec.wild_item_uncommon.clone,
  143.     :wild_item_rare     => spec.wild_item_rare.clone,
  144.     :egg_groups         => egg_groups,         # 26, 27
  145.     :hatch_steps        => spec.hatch_steps,
  146.     :incense            => spec.incense,
  147.     :offspring          => spec.offspring,
  148.     :evolutions         => evolutions,
  149.     :height             => spec.height,
  150.     :weight             => spec.weight,
  151.     :color              => spec.color,
  152.     :shape              => spec.shape,
  153.     :habitat            => spec.habitat,
  154.     :generation         => spec.generation,
  155.     :flags              => spec.flags
  156.   }
  157.   # Add species' data to records
  158.   GameData::Species.register(species_hash)
  159.   end
  160.   GameData::Species.save
  161.   Compiler.write_pokemon
  162. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement