Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #If a Pokemon's base Attack and Special Atk are within this range,
- #the Pokemon is considered a mixed attacker. Otherwise, the Pokemon
- #will be considered a physical/special attacker, depending on which is higher.
- MIXED_ATTACKER_LIMIT = 10
- def pbSetBuilder
- if pbConfirmMessage(_INTL("Would you like me to suggest a set for one of your Pokémon?"))
- pbChoosePokemon(1, 3)
- if pbGet(1) < 0 #cancelled
- pbMessage(_INTL("Let me know if you'd like me to suggest a set for your Pokémon."))
- return
- elsif pbGetPokemon(1).egg?
- pbMessage(_INTL("I can't suggest a set for an Egg... Come back to me after you've hatched it."))
- return
- elsif pbGetPokemon(1).shadowPokemon?
- pbMessage(_INTL("Maybe you should focus on purifying your Pokémon first..."))
- return
- end
- poke = pbGetPokemon(1)
- name = poke.name
- species_data = poke.species_data
- species_name = species_data.real_name
- ana = (species_name.starts_with_vowel?) ? "an" : "a"
- type1 = species_data.types[0]
- type2 = (species_data.types.length > 1) ? species_data.types[1] : species_data.types[0]
- #Check base stats to see if physical, special, or mixed attacker
- base_stats = species_data.base_stats
- atk = base_stats[:ATTACK]
- spatk = base_stats[:SPECIAL_ATTACK]
- if (atk - spatk).abs > MIXED_ATTACKER_LIMIT
- if atk > spatk
- attacker = :PHYSICAL
- else
- attacker = :SPECIAL
- end
- else
- attacker = :MIXED
- end
- #Create array of known moves
- knownmoves = []
- poke.moves.each { |m| knownmoves.push(m.id) }
- pbMessage(_INTL("{1} {2}, huh? Hm...",ana.capitalize,species_name))
- #Create arrays of weaknesses, resistances, immunities, and double weaknesses
- weakness = []
- resist = []
- immune = []
- dweakness = []
- GameData::Type.each do |t|
- eff = Effectiveness.calculate(t.id, type1, type2)
- weakness.push(t.id) if Effectiveness.super_effective?(eff)
- resist.push(t.id) if Effectiveness.not_very_effective?(eff)
- immune.push(t.id) if Effectiveness.ineffective?(eff)
- dweakness.push(t.id) if eff > Effectiveness::SUPER_EFFECTIVE_MULTIPLIER
- end
- cover = {}
- GameData::Type.each do |t|
- cover[t.id] = 0
- for i in 0...weakness.length
- weak = weakness[i]
- eff = Effectiveness.calculate(t.id, weak)
- cover[t.id] += 1 if Effectiveness.super_effective?(eff)
- end
- end
- coverbest = []
- cover.each { |k, v| coverbest.push(k) if v == cover.values.max }
- coverstring = ""
- for i in 0...coverbest.length
- coverbest[i] = GameData::Type.get(coverbest[i]).real_name + "-"
- end
- coverstring = pbArrayToString(coverbest,"or")
- weaktext = (weakness.length > 1) ? "weaknesses" : "weakness"
- pbMessage(_INTL("You'll want a #{coverstring}type move to take care of its #{weaktext}."))
- tutor = species_data.tutor_moves
- level = []
- for i in 0...species_data.moves.length
- level.push(species_data.moves[i][1])
- end
- movepool = tutor + level
- covermove = :HIDDENPOWER
- covermovedata = GameData::Move.get(covermove)
- for i in 0...movepool.length
- movedata = GameData::Move.get(movepool[i])
- next unless coverbest.include?(movedata.type)
- next unless movedata.power > covermovedata.power
- covermove = movepool[i]
- covermovedata = movedata
- end
- pbMessage(_INTL("Your best bet would be #{covermovedata.real_name}."))
- #Forget any useless moves
- useless = [:SPLASH,:HOLDHANDS,:CELEBRATE]
- if useless.intersect?(knownmoves)
- useless = useless & knownmoves
- if useless.length > 1
- pbSymbolArrayNames(useless,:Move)
- uselessstring = pbArrayToString(useless)
- pbMessage(_INTL("You'll definitely want to forget #{uselessstring}."))
- pbMessage(_INTL("They... don't do anything..."))
- else
- movename = GameData::Move.get(useless[0]).real_name
- pbMessage(_INTL("You'll definitely want to forget #{movename}."))
- pbMessage(_INTL("That... doesn't do anything..."))
- end
- end
- #Check if has Spit Up and/or Swallow but not Stockpile
- reqstockpile = [:SPITUP,:SWALLOW]
- if reqstockpile.intersect?(knownmoves) && !poke.hasMove?(:STOCKPILE)
- nostock = reqstockpile & knownmoves
- nostock = pbSymbolArrayNames(nostock,:Move)
- nostock = pbArrayToString(nostock, "or")
- pbMessage(_INTL("#{name} can't make use of #{nostock} without Stockpile."))
- end
- #If Pokemon has Iron Fist, recommend punching moves.
- if poke.hasAbility?(:IRONFIST)
- possiblepunch = []
- GameData::Move.each { |move|
- possiblepunch.push(move.id) if move.flags.any? { |f| f[/^Punching$/i] } && movepool.include?(move.id)
- }
- pbMessage(_INTL("#{name} has Iron Fist, which powers up punching moves..."))
- if possiblepunch.length > 0
- possiblepunch = pbSymbolArrayNames(possiblepunch,:Move)
- possiblepunch = pbArrayToString(possiblepunch, "or")
- pbMessage(_INTL("You might teach it #{possiblepunch}."))
- if GameData::Item.exists?(:PUNCHINGGLOVE)
- pbMessage(_INTL("You might also give it a Punching Glove. That will power up those moves even further, and you'll avoid contact with your targets."))
- end
- else
- pbMessage(_INTL("But it can't actually learn any punching move. Kind of a waste..."))
- end
- end
- pbMessage(_INTL("For a held item..."))
- #Check if species has a Mega Stone
- megastones = []
- GameData::Species.each do |data|
- next if data.species != poke.species || data.unmega_form != poke.form_simple || !data.mega_stone
- megastones.push(data.mega_stone)
- end
- if megastones.length > 0
- megastring = ""
- for i in 0...megastones.length
- name = GameData::Item.get(megastones[i]).real_name
- megastring += (name.starts_with_vowel?) ? "an " : "a "
- megastring += name
- megastring += ", " if coverbest.length > 2 && i < coverbest.length - 1
- megastring += " or " if coverbest.length > 1 && i == coverbest.length - 2
- end
- pbMessage(_INTL("Well, you can never go wrong with #{megastring}."))
- end
- #Recommend berry for double weakness
- if dweakness.length > 0
- conversion_hash = {
- :FIGHTING => :CHOPLEBERRY,
- :FLYING => :COBABERRY,
- :POISON => :KEBIABERRY,
- :GROUND => :SHUCABERRY,
- :ROCK => :CHARTIBERRY,
- :BUG => :TANGABERRY,
- :GHOST => :KASIBBERRY,
- :STEEL => :BABIRIBERRY,
- :DARK => :COLBURBERRY,
- :FIRE => :OCCABERRY,
- :WATER => :PASSHOBERRY,
- :GRASS => :RINDOBERRY,
- :ELECTRIC => :WACANBERRY,
- :PSYCHIC => :PAYAPABERRY,
- :ICE => :YACHEBERRY,
- :DRAGON => :HABANBERRY,
- :FAIRY => :ROSELIBERRY
- }
- if dweakness.length > 1
- for i in 0...dweakness.length
- dweak = dweakness[i]
- berry = conversion_hash[dweak]
- end
- else
- berry = conversion_hash[dweakness[0]]
- berry = GameData::Item.get(berry).real_name
- dweak = GameData::Type.get(dweakness[0]).real_name
- pbMessage(_INTL("A #{berry} could be useful, to help #{name}'s double weakness against #{dweak}."))
- end
- end
- # conversion_hash = {
- # :NORMAL => :SILKSCARF,
- # :FIGHTING => :BLACKBELT,
- # :FLYING => :SHARPBEAK,
- # :POISON => :POISONBARB,
- # :GROUND => :SOFTSAND,
- # :ROCK => :HARDSTONE,
- # :BUG => :SILVERPOWDER,
- # :GHOST => :SPELLTAG,
- # :STEEL => :METALCOAT,
- # :DARK => :BLACKGLASSES,
- # :FIRE => :CHARCOAL,
- # :WATER => :MYSTICWATER,
- # :GRASS => :MIRACLESEED,
- # :ELECTRIC => :MAGNET,
- # :PSYCHIC => :TWISTEDSPOON,
- # :ICE => :NEVERMELTICE,
- # :DRAGON => :DRAGONFANG,
- # :FAIRY => :FAIRYFEATHER
- # }
- # conversion_hash = {
- # :DROUGHT => :Sun,
- # :DRIZZLE => :Rain,
- # :SNOWWARNING => :Hail,
- # :SANDSTREAM => :Sandstorm
- # }
- # conversion_hash = {
- # :SUNNYDAY => :Sun,
- # :RAINDANCE => :Rain,
- # :HAIL => :Hail,
- # :SANDSTORM => :Sandstorm
- # }
- # conversion_hash = {
- # :Sun => :HEATROCK,
- # :Rain => :DAMPROCK,
- # :Hail => :ICYROCK,
- # :SANDSTORM => :SMOOTHROCK
- # }
- #Weather rocks
- if poke.hasAbility?(:DROUGHT)
- pbMessage(_INTL("Since #{name} has #{wset}, you might want a #{wrock} to make the #{weather} last longer."))
- end
- #If Pokemon can evolve, suggest Eviolite.
- if species_data.get_evolutions(true).length > 0 && GameData::Item.exists?(:EVIOLITE)
- pbMessage(_INTL("Since #{name} can evolve further, it could hold an Eviolite to raise its Defense and Special Defense by 50%."))
- end
- #If Pokemon has Poison Heal, suggest Toxic Orb
- if poke.hasAbility?(:POISONHEAL) && GameData::Item.exists?(:TOXICORB)
- pbMessage(_INTL("Since #{name} has the Ability Poison Heal, you might consider a Toxic Orb, to inflict bad poisoning on the first turn."))
- pbMessage(_INTL("You've probably guessed from the name, but Poison Heal makes a Pokémon recover HP from poisoning instead of losing it!"))
- pbMessage(_INTL("And you could use Fling to poison your foe, too!")) if poke.hasMove?(:FLING)
- pbMessage(_INTL("And you could pass it onto a foe to poison them, too!")) if [:BESTOW,:TRICK,:SWITCHEROO].intersect?(knownmoves)
- pbMessage(_INTL("Be careful not to lose the Ability in battle, though, or #{name} will start taking damage again."))
- end
- #If Pokemon has Guts and is not Fire-type, suggest Flame Orb
- if poke.hasAbility?(:GUTS) && !poke.hasType?(:FIRE) && GameData::Item.exists?(:FLAMEORB)
- pbMessage(_INTL("Since #{name} has the Ability Guts, you might consider a Flame Orb, to inflict a burn on the first turn."))
- pbMessage(_INTL("It'll still take damage every turn, but it won't suffer the Attack loss - in fact, it'll be boosted by 50%!"))
- pbMessage(_INTL("Being burned means you can't suffer any other major status condition, either - can't be paralyzed, frozen, badly poisoned..."))
- pbMessage(_INTL("And you could use Fling to burn your foe, too!")) if poke.hasMove?(:FLING)
- pbMessage(_INTL("And you could pass it onto a foe to burn them, too!")) if [:BESTOW,:TRICK,:SWITCHEROO].intersect?(knownmoves)
- end
- #Mention Light Clay if knows a move that sets up screens
- if [:REFLECT,:LIGHTCLAY,:AURORAVEIL].intersect?(knownmoves) && GameData::Item.exists?(:LIGHTCLAY)
- end
- #If weak to Ground, mention Air Balloon
- if weakness.include?(:GROUND) && GameData::Item.exists?(:AIRBALLOON)
- pbMessage(_INTL("An Air Balloon could help take care of that Ground weakness - until it pops, of course."))
- if dweakness.include?(:GROUND)
- pbMessage(_INTL("#{name} is doubly weak to Ground, so I'd definitely consider it."))
- end
- end
- #If doubly weak to Rock, mention
- if dweakness.include?(:ROCK) && GameData::Item.exists?(:HEAVYDUTYBOOTS) && GameData::Move.exists?(:STEALTHROCKS)
- pbMessage(_INTL("If you're facing a foe who uses Stealth Rocks, you might want to look into Heavy-Duty Boots for #{name}. Its double Rock weakness means Stealth Rock will take quite a chunk of its HP."))
- end
- #If weak to Water, mention Luminous Moss
- if weakness.include?(:WATER)
- pbMessage(_INTL("Since #{name} is weak to Water, foes will probably use that against it. You could work that to your advantage with a Luminous Moss."))
- pbMessage(_INTL("It won't stop the damage, but it'll boost your Special Defense by one stage the first time you're hit by a Water-type move."))
- #If also special/mixed attacker, mention Absorb Bulb
- if [:SPECIAL,:MIXED].include?(attacker)
- pbMessage(_INTL("You could also try an Absorb Bulb. Same idea, but it boosts Special Attack rather than Special Defense."))
- end
- end
- #If weak to Electric and physical/mixed attacker, mention Cell Battery
- if weakness.include?(:ELECTRIC) && [:PHYSICAL,:MIXED].include?(attacker) && GameData::Item.exists?(:CELLBATTERY)
- pbMessage(_INTL("Since #{name} is weak to Electric, foes will probably use that against it. You could work that to your advantage with a Cell Battery."))
- pbMessage(_INTL("It won't stop the damage, but it'll boost your Attack by one stage the first time you're hit by an Electric-type move."))
- end
- #Species-specific held items
- case species_data.id
- when :FARFETCHD, :SIRFETCHD
- pbMessage(_INTL("Since #{name} is #{ana} #{species_name}, it could use a Leek to boost its critical hit ratio.")) if GameData::Item.exists?(:LEEK)
- when :PIKACHU
- pbMessage(_INTL("Since #{name} is #{ana} #{species_name}, it could use a Light Ball to boost its Attack and Special Attack."))
- when :DITTO
- pbMessage(_INTL("Since #{name} is #{ana} #{species_name}, it could use a Metal Powder to boost its Defense, or a Quick Powder to boost its Speed."))
- pbMessage(_INTL("These don't work after using Transform, though - it's mostly just to make sure you get a chance to use it."))
- when :CHANSEY
- pbMessage(_INTL("Since #{name} is #{ana} #{species_name}, it could use a Lucky Punch to boost its critical hit ratio."))
- when :CUBONE, :MAROWAK
- pbMessage(_INTL("Since #{name} is #{ana} #{species_name}, it could use a Thick Club to boost its Attack."))
- when :SILVALLY
- pbMessage(_INTL("Well, the neat thing about Silvally is that its RKS System lets it change to any type, as long as it's holding the right Memory."))
- end
- #If Poison-type, mention Black Sludge
- if species_data.types.include?(:POISON)
- pbMessage(_INTL("Since #{name} is Poison-type, it could hold a Black Sludge. It restores HP each turn, just like Leftovers, but if another Pokémon steals it and they're not Poison-type themselves, they'll take damage!"))
- end
- #If Pokemon knows any sound moves and is a special/mixed attacker, mention Throat Spray
- if GameData::Item.exists?(:THROATSPRAY) && [:SPECIAL,:MIXED].include?(attacker)
- knownsoundmoves = []
- poke.moves.each { |m| knownsoundmoves.push(m.id) if m.flags.any? { |f| f[/^Sound$/i]} }
- if knownsoundmoves.length > 0
- knownsoundmoves = pbSymbolArrayNames(knownsoundmoves,:Move)
- knownsoundmoves = pbArrayToString(knownsoundmoves, "or")
- pbMessage(_INTL("Throat Spray raises a Pokémon's Special Attack after using a sound-based move, although it's consumed after use. #{name} could use it after using #{knownsoundmoves}."))
- end
- end
- #Player said "No" to initial question
- else
- pbMessage(_INTL("Let me know if you'd like me to suggest a set for your Pokémon."))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement