mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Resolved all remaining TODO comments for AI (except testing), fixed effects of moves that can end the battle
This commit is contained in:
@@ -38,14 +38,16 @@ class Battle::AI
|
||||
|
||||
# Assumes that pkmn's ability is not negated by a global effect (e.g.
|
||||
# Neutralizing Gas).
|
||||
# pkmn is either a Battle::AI::AIBattler or a Pokemon. move is a Battle::Move.
|
||||
# pkmn is either a Battle::AI::AIBattler or a Pokemon.
|
||||
# move is a Battle::Move or a Pokemon::Move.
|
||||
def pokemon_can_absorb_move?(pkmn, move, move_type)
|
||||
return false if pkmn.is_a?(Battle::AI::AIBattler) && !pkmn.ability_active?
|
||||
# Check pkmn's ability
|
||||
# Anything with a Battle::AbilityEffects::MoveImmunity handler
|
||||
case pkmn.ability_id
|
||||
when :BULLETPROOF
|
||||
return move.bombMove?
|
||||
move_data = GameData::Move.get(move.id)
|
||||
return move_data.has_flag?("Bomb")
|
||||
when :FLASHFIRE
|
||||
return move_type == :FIRE
|
||||
when :LIGHTNINGROD, :MOTORDRIVE, :VOLTABSORB
|
||||
@@ -53,7 +55,8 @@ class Battle::AI
|
||||
when :SAPSIPPER
|
||||
return move_type == :GRASS
|
||||
when :SOUNDPROOF
|
||||
return move.soundMove?
|
||||
move_data = GameData::Move.get(move.id)
|
||||
return move_data.has_flag?("Sound")
|
||||
when :STORMDRAIN, :WATERABSORB, :DRYSKIN
|
||||
return move_type == :WATER
|
||||
when :TELEPATHY
|
||||
@@ -62,7 +65,7 @@ class Battle::AI
|
||||
when :WONDERGUARD
|
||||
types = pkmn.types
|
||||
types = pkmn.pbTypes(true) if pkmn.is_a?(Battle::AI::AIBattler)
|
||||
return Effectiveness.super_effective_type?(move_type, *types)
|
||||
return !Effectiveness.super_effective_type?(move_type, *types)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -157,24 +160,72 @@ class Battle::AI
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# TODO: Add more items.
|
||||
BASE_ITEM_RATINGS = {
|
||||
4 => [:CHOICEBAND, :CHOICESCARF, :CHOICESPECS, :DEEPSEATOOTH, :LEFTOVERS,
|
||||
:LIGHTBALL, :THICKCLUB],
|
||||
3 => [:ADAMANTORB, :GRISEOUSORB, :LIFEORB, :LUSTROUSORB, :SOULDEW],
|
||||
2 => [:BLACKBELT, :BLACKGLASSES, :CHARCOAL, :DRAGONFANG, :HARDSTONE,
|
||||
10 => [:EVIOLITE, :FOCUSSASH, :LIFEORB, :THICKCLUB],
|
||||
9 => [:ASSAULTVEST, :BLACKSLUDGE, :CHOICEBAND, :CHOICESCARF, :CHOICESPECS,
|
||||
:DEEPSEATOOTH, :LEFTOVERS],
|
||||
8 => [:LEEK, :STICK, :THROATSPRAY, :WEAKNESSPOLICY],
|
||||
7 => [:EXPERTBELT, :LIGHTBALL, :LUMBERRY, :POWERHERB, :ROCKYHELMET,
|
||||
:SITRUSBERRY],
|
||||
6 => [:KINGSROCK, :LIECHIBERRY, :LIGHTCLAY, :PETAYABERRY, :RAZORFANG,
|
||||
:REDCARD, :SALACBERRY, :SHELLBELL, :WHITEHERB,
|
||||
# Type-resisting berries
|
||||
:BABIRIBERRY, :CHARTIBERRY, :CHILANBERRY, :CHOPLEBERRY, :COBABERRY,
|
||||
:COLBURBERRY, :HABANBERRY, :KASIBBERRY, :KEBIABERRY, :OCCABERRY,
|
||||
:PASSHOBERRY, :PAYAPABERRY, :RINDOBERRY, :ROSELIBERRY, :SHUCABERRY,
|
||||
:TANGABERRY, :WACANBERRY, :YACHEBERRY,
|
||||
# Gems
|
||||
:BUGGEM, :DARKGEM, :DRAGONGEM, :ELECTRICGEM, :FAIRYGEM, :FIGHTINGGEM,
|
||||
:FIREGEM, :FLYINGGEM, :GHOSTGEM, :GRASSGEM, :GROUNDGEM, :ICEGEM,
|
||||
:NORMALGEM, :POISONGEM, :PSYCHICGEM, :ROCKGEM, :STEELGEM, :WATERGEM,
|
||||
# Legendary Orbs
|
||||
:ADAMANTORB, :GRISEOUSORB, :LUSTROUSORB, :SOULDEW,
|
||||
# Berries that heal HP and may confuse
|
||||
:AGUAVBERRY, :FIGYBERRY, :IAPAPABERRY, :MAGOBERRY, :WIKIBERRY],
|
||||
5 => [:CUSTAPBERRY, :DEEPSEASCALE, :EJECTBUTTON, :FOCUSBAND, :JABOCABERRY,
|
||||
:KEEBERRY, :LANSATBERRY, :MARANGABERRY, :MENTALHERB, :METRONOME,
|
||||
:MUSCLEBAND, :QUICKCLAW, :RAZORCLAW, :ROWAPBERRY, :SCOPELENS,
|
||||
:WISEGLASSES,
|
||||
# Type power boosters
|
||||
:BLACKBELT, :BLACKGLASSES, :CHARCOAL, :DRAGONFANG, :HARDSTONE,
|
||||
:MAGNET, :METALCOAT, :MIRACLESEED, :MYSTICWATER, :NEVERMELTICE,
|
||||
:POISONBARB, :SHARPBEAK, :SILKSCARF, :SILVERPOWDER, :SOFTSAND,
|
||||
:POISONBARB, :SHARPBEAK, :SILKSCARF,:SILVERPOWDER, :SOFTSAND,
|
||||
:SPELLTAG, :TWISTEDSPOON,
|
||||
:ODDINCENSE, :ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE,
|
||||
# Plates
|
||||
:DRACOPLATE, :DREADPLATE, :EARTHPLATE, :FISTPLATE, :FLAMEPLATE,
|
||||
:ICICLEPLATE, :INSECTPLATE, :IRONPLATE, :MEADOWPLATE, :MINDPLATE,
|
||||
:PIXIEPLATE, :SKYPLATE, :SPLASHPLATE, :SPOOKYPLATE, :STONEPLATE,
|
||||
:TOXICPLATE, :ZAPPLATE,
|
||||
:ODDINCENSE, :ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE,
|
||||
:MUSCLEBAND, :WISEGLASSES],
|
||||
1 => [:METRONOME],
|
||||
-2 => [:LAGGINGTAIL, :STICKYBARB],
|
||||
-4 => [:BLACKSLUDGE, :FLAMEORB, :IRONBALL, :TOXICORB]
|
||||
# Weather/terrain extenders
|
||||
:DAMPROCK, :HEATROCK, :ICYROCK, :SMOOTHROCK, :TERRAINEXTENDER],
|
||||
4 => [:ADRENALINEORB, :APICOTBERRY, :BLUNDERPOLICY, :CHESTOBERRY,
|
||||
:EJECTPACK, :ENIGMABERRY, :GANLONBERRY, :HEAVYDUTYBOOTS,
|
||||
:ROOMSERVICE, :SAFETYGOGGLES, :SHEDSHELL, :STARFBERRY],
|
||||
3 => [:BIGROOT, :BRIGHTPOWDER, :LAXINCENSE, :LEPPABERRY, :PERSIMBERRY,
|
||||
:PROTECTIVEPADS, :UTILITYUMBRELLA,
|
||||
# Status problem-curing berries (except Chesto which is in 4)
|
||||
:ASPEARBERRY, :CHERIBERRY, :PECHABERRY, :RAWSTBERRY],
|
||||
2 => [:ABSORBBULB, :BERRYJUICE, :CELLBATTERY, :GRIPCLAW, :LUMINOUSMOSS,
|
||||
:MICLEBERRY, :ORANBERRY, :SNOWBALL, :WIDELENS, :ZOOMLENS,
|
||||
# Terrain seeds
|
||||
:ELECTRICSEED, :GRASSYSEED, :MISTYSEED, :PSYCHICSEED],
|
||||
1 => [:AIRBALLOON, :BINDINGBAND, :DESTINYKNOT, :FLOATSTONE, :LUCKYPUNCH,
|
||||
:METALPOWDER, :QUICKPOWDER,
|
||||
# Drives
|
||||
:BURNDRIVE, :CHILLDRIVE, :DOUSEDRIVE, :SHOCKDRIVE,
|
||||
# Memories
|
||||
:BUGMEMORY, :DARKMEMORY, :DRAGONMEMORY, :ELECTRICMEMORY,
|
||||
:FAIRYMEMORY, :FIGHTINGMEMORY, :FIREMEMORY, :FLYINGMEMORY,
|
||||
:GHOSTMEMORY, :GRASSMEMORY, :GROUNDMEMORY, :ICEMEMORY, :POISONMEMORY,
|
||||
:PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY
|
||||
],
|
||||
0 => [:SMOKEBALL],
|
||||
-5 => [:FULLINCENSE, :LAGGINGTAIL, :RINGTARGET],
|
||||
-6 => [:MACHOBRACE, :POWERANKLET, :POWERBAND, :POWERBELT, :POWERBRACER,
|
||||
:POWERLENS, :POWERWEIGHT],
|
||||
-7 => [:FLAMEORB, :IRONBALL, :TOXICORB],
|
||||
-9 => [:STICKYBARB]
|
||||
}
|
||||
end
|
||||
|
||||
@@ -342,9 +393,71 @@ Battle::AI::Handlers::ItemRanking.add(:ADAMANTORB,
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:AGUAVBERRY,
|
||||
proc { |item, score, battler, ai|
|
||||
if Settings::MECHANICS_GENERATION == 7 # Heals 50%
|
||||
score += 2
|
||||
elsif Settings::MECHANICS_GENERATION <= 6 # Heals 12.5%
|
||||
score -= 3
|
||||
end
|
||||
if ai.trainer.high_skill?
|
||||
if battler.battler.nature.stat_changes.any? { |val| val[0] == :SPECIAL_DEFENSE && val[1] < 0 }
|
||||
score -= 2 # Will confuse
|
||||
end
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:ASSAULTVEST,
|
||||
proc { |item, score, battler, ai|
|
||||
if ai.trainer.high_skill?
|
||||
score += 1 if !battler.check_for_move { |m| m.statusMove? && !m.is_a?(Battle::Move::UseMoveTargetIsAboutToUse) }
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:BERRYJUICE,
|
||||
proc { |item, score, battler, ai|
|
||||
next [10 - (battler.totalhp / 15), 1].max
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:BIGROOT,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move do |m|
|
||||
m.is_a?(Battle::Move::HealUserByHalfOfDamageDone) ||
|
||||
m.is_a?(Battle::Move::HealUserByHalfOfDamageDoneIfTargetAsleep) ||
|
||||
m.is_a?(Battle::Move::HealUserByThreeQuartersOfDamageDone) ||
|
||||
m.is_a?(Battle::Move::HealUserByTargetAttackLowerTargetAttack1) ||
|
||||
m.is_a?(Battle::Move::StartLeechSeedTarget)
|
||||
end
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:BINDINGBAND,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::BindTarget) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.copy(:BINDINGBAND, :GRIPCLAW)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:BLACKSLUDGE,
|
||||
proc { |item, score, battler, ai|
|
||||
next 4 if battler.has_type?(:POISON)
|
||||
next score if battler.has_type?(:POISON)
|
||||
next -9
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:CHESTOBERRY,
|
||||
proc { |item, score, battler, ai|
|
||||
if ai.trainer.high_skill?
|
||||
score += 1 if battler.has_move_with_function("HealUserFullyAndFallAsleep")
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
@@ -367,6 +480,20 @@ Battle::AI::Handlers::ItemRanking.add(:CHOICESPECS,
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.copy(:CHOICESPECS, :WISEGLASSES)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:DEEPSEASCALE,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.isSpecies?(:CLAMPERL)
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:DAMPROCK,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartRainWeather) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:DEEPSEATOOTH,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.isSpecies?(:CLAMPERL) &&
|
||||
@@ -375,6 +502,62 @@ Battle::AI::Handlers::ItemRanking.add(:DEEPSEATOOTH,
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:ELECTRICSEED,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartElectricTerrain) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:EVIOLITE,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.pokemon.species_data.get_evolutions(true).length > 0
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:FIGYBERRY,
|
||||
proc { |item, score, battler, ai|
|
||||
if Settings::MECHANICS_GENERATION == 7 # Heals 50%
|
||||
score += 2
|
||||
elsif Settings::MECHANICS_GENERATION <= 6 # Heals 12.5%
|
||||
score -= 3
|
||||
end
|
||||
if ai.trainer.high_skill?
|
||||
if battler.battler.nature.stat_changes.any? { |val| val[0] == :ATTACK && val[1] < 0 }
|
||||
score -= 2 # Will confuse
|
||||
end
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:FLAMEORB,
|
||||
proc { |item, score, battler, ai|
|
||||
next 0 if battler.status != :NONE
|
||||
next 7 if battler.wants_status_problem?(:BURN)
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:FULLINCENSE,
|
||||
proc { |item, score, battler, ai|
|
||||
if ai.trainer.high_skill?
|
||||
score = 7 if battler.has_active_ability?(:ANALYTIC)
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.copy(:FULLINCENSE, :LAGGINGTAIL)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:GRASSYSEED,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartGrassyTerrain) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:GRISEOUSORB,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.isSpecies?(:GIRATINA) &&
|
||||
@@ -383,6 +566,36 @@ Battle::AI::Handlers::ItemRanking.add(:GRISEOUSORB,
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:HEATROCK,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartSunWeather) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:IAPAPABERRY,
|
||||
proc { |item, score, battler, ai|
|
||||
if Settings::MECHANICS_GENERATION == 7 # Heals 50%
|
||||
score += 2
|
||||
elsif Settings::MECHANICS_GENERATION <= 6 # Heals 12.5%
|
||||
score -= 3
|
||||
end
|
||||
if ai.trainer.high_skill?
|
||||
if battler.battler.nature.stat_changes.any? { |val| val[0] == :DEFENSE && val[1] < 0 }
|
||||
score -= 2 # Will confuse
|
||||
end
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:ICYROCK,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartHailWeather) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:IRONBALL,
|
||||
proc { |item, score, battler, ai|
|
||||
next 0 if battler.has_move_with_function?("ThrowUserItemAtTarget")
|
||||
@@ -390,6 +603,27 @@ Battle::AI::Handlers::ItemRanking.add(:IRONBALL,
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:KINGSROCK,
|
||||
proc { |item, score, battler, ai|
|
||||
if ai.trainer.high_skill?
|
||||
score += 1 if battler.check_for_move { |m| m.multiHitMove? }
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.copy(:KINGSROCK, :RAZORFANG)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:LEEK,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if (battler.battler.isSpecies?(:FARFETCHD) || battler.battler.isSpecies?(:SIRFETCHD)) &&
|
||||
battler.check_for_move { |m| m.damagingMove? }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.copy(:LEEK, :STICK)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:LIGHTBALL,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.isSpecies?(:PIKACHU) &&
|
||||
@@ -398,6 +632,24 @@ Battle::AI::Handlers::ItemRanking.add(:LIGHTBALL,
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:LIGHTCLAY,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move do |m|
|
||||
m.is_a?(Battle::Move::StartWeakenPhysicalDamageAgainstUserSide) ||
|
||||
m.is_a?(Battle::Move::StartWeakenSpecialDamageAgainstUserSide) ||
|
||||
m.is_a?(Battle::Move::StartWeakenDamageAgainstUserSideIfHail)
|
||||
end
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:LUCKYPUNCH,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.isSpecies?(:CHANSEY)
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:LUSTROUSORB,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.isSpecies?(:PALKIA) &&
|
||||
@@ -406,18 +658,106 @@ Battle::AI::Handlers::ItemRanking.add(:LUSTROUSORB,
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:MAGOBERRY,
|
||||
proc { |item, score, battler, ai|
|
||||
if Settings::MECHANICS_GENERATION == 7 # Heals 50%
|
||||
score += 2
|
||||
elsif Settings::MECHANICS_GENERATION <= 6 # Heals 12.5%
|
||||
score -= 3
|
||||
end
|
||||
if ai.trainer.high_skill?
|
||||
if battler.battler.nature.stat_changes.any? { |val| val[0] == :SPEED && val[1] < 0 }
|
||||
score -= 2 # Will confuse
|
||||
end
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:METALPOWDER,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.battler.isSpecies?(:DITTO) && !battler.effects[PBEffects::Transform]
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.copy(:METALPOWDER, :QUICKPOWDER)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:MISTYSEED,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartMistyTerrain) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:ORANBERRY,
|
||||
proc { |item, score, battler, ai|
|
||||
next [10 - (battler.totalhp / 8), 1].max
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:POWERHERB,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move do |m|
|
||||
m.is_a?(Battle::Move::TwoTurnMove) &&
|
||||
!m.is_a?(Battle::Move::TwoTurnAttackInvulnerableInSkyTargetCannotAct)
|
||||
end
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:PSYCHICSEED,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartPsychicTerrain) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:RINGTARGET,
|
||||
proc { |item, score, battler, ai|
|
||||
has_immunity = false
|
||||
battler.pbTypes(true).each do |type|
|
||||
has_immunity = GameData::Type.get(type).immunities.length > 0
|
||||
break if has_immunity
|
||||
end
|
||||
next score if has_immunity
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:SMOOTHROCK,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.is_a?(Battle::Move::StartSandstormWeather) }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:SOULDEW,
|
||||
proc { |item, score, battler, ai|
|
||||
next 0 if !battler.battler.isSpecies?(:LATIAS) && !battler.battler.isSpecies?(:LATIOS)
|
||||
if Settings::SOUL_DEW_POWERS_UP_TYPES
|
||||
next 0 if !battler.has_damaging_move_of_type?(:PSYCHIC, :DRAGON)
|
||||
elsif !battler.check_for_move { |m| m.specialMove?(m.type) }
|
||||
next 1 # Also boosts SpDef
|
||||
elsif battler.check_for_move { |m| m.specialMove?(m.type) }
|
||||
next 10
|
||||
else
|
||||
next 6 # Boosts SpDef
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:TERRAINEXTENDER,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move do |m|
|
||||
m.is_a?(Battle::Move::StartElectricTerrain) ||
|
||||
m.is_a?(Battle::Move::StartGrassyTerrain) ||
|
||||
m.is_a?(Battle::Move::StartMistyTerrain) ||
|
||||
m.is_a?(Battle::Move::StartPsychicTerrain)
|
||||
end
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:THICKCLUB,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if (battler.battler.isSpecies?(:CUBONE) || battler.battler.isSpecies?(:MAROWAK)) &&
|
||||
@@ -426,6 +766,61 @@ Battle::AI::Handlers::ItemRanking.add(:THICKCLUB,
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:THROATSPRAY,
|
||||
proc { |item, score, battler, ai|
|
||||
next score if battler.check_for_move { |m| m.soundMove? }
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:TOXICORB,
|
||||
proc { |item, score, battler, ai|
|
||||
next 0 if battler.status != :NONE
|
||||
next 7 if battler.wants_status_problem?(:POISON)
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:WHITEHERB,
|
||||
proc { |item, score, battler, ai|
|
||||
if ai.trainer.high_skill?
|
||||
score += 1 if battler.has_move_with_function("LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2")
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:WIKIBERRY,
|
||||
proc { |item, score, battler, ai|
|
||||
if Settings::MECHANICS_GENERATION == 7 # Heals 50%
|
||||
score += 2
|
||||
elsif Settings::MECHANICS_GENERATION <= 6 # Heals 12.5%
|
||||
score -= 3
|
||||
end
|
||||
if ai.trainer.high_skill?
|
||||
if battler.battler.nature.stat_changes.any? { |val| val[0] == :SPECIAL_ATTACK && val[1] < 0 }
|
||||
score -= 2 # Will confuse
|
||||
end
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.add(:ZOOMLENS,
|
||||
proc { |item, score, battler, ai|
|
||||
if ai.trainer.high_skill?
|
||||
score += 1 if battler.stages[:ACCURACY] < 0
|
||||
battler.battler.eachMove do |m|
|
||||
next if m.accuracy == 0 || m.is_a?(Battle::Move::OHKO)
|
||||
next if m.accuracy > 70
|
||||
score += 1
|
||||
break
|
||||
end
|
||||
end
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.addIf(:type_boosting_items,
|
||||
proc { |item|
|
||||
next [:BLACKBELT, :BLACKGLASSES, :CHARCOAL, :DRAGONFANG, :HARDSTONE,
|
||||
@@ -469,3 +864,36 @@ Battle::AI::Handlers::ItemRanking.addIf(:type_boosting_items,
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Battle::AI::Handlers::ItemRanking.addIf(:gems,
|
||||
proc { |item|
|
||||
next [:FIREGEM, :WATERGEM, :ELECTRICGEM, :GRASSGEM, :ICEGEM, :FIGHTINGGEM,
|
||||
:POISONGEM, :GROUNDGEM, :FLYINGGEM, :PSYCHICGEM, :BUGGEM, :ROCKGEM,
|
||||
:GHOSTGEM, :DRAGONGEM, :DARKGEM, :STEELGEM, :FAIRYGEM, :NORMALGEM].include?(item)
|
||||
},
|
||||
proc { |item, score, battler, ai|
|
||||
score += 2 if Settings::MECHANICS_GENERATION <= 5 # 1.5x boost rather than 1.3x
|
||||
boosted_type = {
|
||||
:BUGGEM => :BUG,
|
||||
:DARKGEM => :DARK,
|
||||
:DRAGONGEM => :DRAGON,
|
||||
:ELECTRICGEM => :ELECTRIC,
|
||||
:FAIRYGEM => :FAIRY,
|
||||
:FIGHTINGGEM => :FIGHTING,
|
||||
:FIREGEM => :FIRE,
|
||||
:FLYINGGEM => :FLYING,
|
||||
:GHOSTGEM => :GHOST,
|
||||
:GRASSGEM => :GRASS,
|
||||
:GROUNDGEM => :GROUND,
|
||||
:ICEGEM => :ICE,
|
||||
:NORMALGEM => :NORMAL,
|
||||
:POISONGEM => :POISON,
|
||||
:PSYCHICGEM => :PSYCHIC,
|
||||
:ROCKGEM => :ROCK,
|
||||
:STEELGEM => :STEEL,
|
||||
:WATERGEM => :WATER,
|
||||
}[item]
|
||||
next score if boosted_type && battler.has_damaging_move_of_type?(boosted_type)
|
||||
next 0
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user