If you are upgrading from a previous version you MUST delete the old plugin folder completely before installing this version!
## Version 2.0.0
### Bug Fixes
####
Terastallization AI Improvements
- Fixed Terastallization Eligibility: Corrected wild Pokémon Terastallization checks to properly allow Boss Pokémon with
tera_type > 0 to Terastallize
- Improved Tera Scoring Logic: Enhanced AI decision-making for when to use Terastallization in battle
- AIBattler Wrapper Compatibility: Fixed method delegation issues in
AIBattler wrapper for Terastallization-related methods
- Battle Constant Access: Resolved incorrect calls to battle-related methods and constants in Tera intelligence
####
Compatibility Fixes
- DBK Plugin Compatibility: Improved compatibility with Deluxe Battle Kit plugins, particularly for Terastallization and Dynamax mechanics
- Method Delegation: Fixed missing method delegations in
AIBattler wrapper class to ensure all Battle::Battler methods are properly accessible
- Plugin Load Order: Resolved issues with plugin initialization and load order dependencies
####
General Stability
- Nil Safety Checks: Added additional nil-safety checks throughout the codebase to prevent crashes
- Error Handling: Improved error handling in AI decision-making processes
- Debug Output: Enhanced debug logging for easier troubleshooting
### Code Quality Improvements
- Code Documentation: Added inline comments for complex AI logic sections
- Consistency: Standardized method naming conventions across modules
- Performance: Minor optimizations in frequently-called AI methods
### New Features
####
Ability Handlers
-
Wonder Guard (Shedinja):
- ONLY use super-effective moves (+100 if SE, -200 if neutral/NVE)
- Status moves still work (+40)
- Massively prioritize KO'ing Wonder Guard users (+80)
-
Moody (Random stat boosts):
- +45 priority to KO before lucky boosts accumulate
- +35 urgency if already has 2+ boosted stats
- Haze/Clear Smog valued at +60 to reset random boosts
- 1.5x threat multiplier (unpredictable danger)
-
Truant (Attacks every other turn):
- -60 threat reduction (massively crippled)
- +40 free setup/switch on rest turns
- +45 for setup moves vs Truant users (free boost time)
- 0.4x threat multiplier
-
Slow Start (Halved Atk/Spe for 5 turns):
- +30 base advantage + 5 per remaining turn
- +40 reduced threat during active window
- -30 increased threat after Slow Start ends
- 0.5x threat during, 1.0x after
-
Neutralizing Gas (Suppresses all abilities):
- Calculates net impact: our ability reliance vs opponent's
- +30 per critical opponent ability suppressed
- -35 per critical ally ability lost
-
Gastro Acid (Permanent ability suppression):
- +90 vs critical abilities (Wonder Guard, Magic Bounce, Huge Power, etc.)
- +40 vs normal abilities
- -50 if target has no ability
####
Hyper-Specific Stat-Boost Items
-
Adrenaline Orb (Speed +1 when Intimidated):
- -35 don't switch in Intimidate user (triggers their boost)
- -25 additional if opponent is offensive threat
- +20 if counters opponent's Intimidate
-
Snowball (Attack +1 when hit by Ice):
- -30 using Ice move triggers +1 Attack on physical attacker
- +50 if KO anyway (override concern)
- +5 if target is special (Attack boost irrelevant)
-
Absorb Bulb (SpAtk +1 when hit by Water):
- -35 Water move on special attacker = +1 SpAtk
- +10 if target is physical (SpAtk boost less relevant)
-
Luminous Moss (SpDef +1 when hit by Water):
- -25 base penalty, -15 if using special moves
- Makes special attacks weaker
-
Cell Battery (Attack +1 when hit by Electric):
- -30 Electric move on physical attacker
- +30 if target is Ground-type (immune, won't trigger)
-
Throat Spray (SpAtk +2 when using sound move):
- +50 sound move triggers HUGE +2 SpAtk boost
- +30 for healthy sweepers getting boost
- +20 if have multiple sound moves
- 1.3x threat multiplier if target has sound moves
-
Room Service (Speed -1 in Trick Room):
- +30 fast Pokemon in Trick Room (lower speed = better)
- -10 already slow Pokemon (wasteful)
- +20 if can set Trick Room
- +35 synergy with Trick Room setter
####
Combo Move Strategies
-
Pledge Combinations (Fire/Water/Grass Pledge):
- +70 base combo score
-
Sea of Fire (Fire+Grass): +45 passive burn damage, +25 vs healthy teams
-
Rainbow (Water+Fire): +35 double secondary effect chance, +20 if have good effects
-
Swamp (Grass+Water): +60 quarter opponent speed, +40 vs faster threats
- +30 combo power boost to 150 BP
- +20 if partner slower (combo this turn), -30 if faster (delayed)
-
Fusion Moves (Fusion Flare/Bolt):
- +50 if partner has complementary move
- +30 if partner faster (guaranteed 2x power)
- +40 for 200 BP combined power
-
Special Combo Moves:
-
Electrify: +60 if we have Ground immunity (target's move becomes useless)
-
After You: +40 make slow partner move early, +30 for setup, +25 for strong move
-
Instruct: +70 ally repeats powerful move, +90 ally repeats setup (double boost!)
####
Gimmick Strategies
-
Tera-Type Prediction:
- Common pattern database (Azumarill → Water/Fairy, Garchomp → Ground/Fire)
- Moveset analysis for STAB tera detection
- +60 if move matches predicted Tera type
- +50 if Tera boost secures KO
- +70 if Tera removes SE weakness
- 1.2x threat for opponents with Tera available
-
Max Move Field Effects:
-
Max Airstream (Flying): +70 Speed boost to team, +40 in Doubles, +35 to outspeed
-
G-Max Steelsurge (Steel): +80 Stealth Rock, +25 per Flying/Fire/Bug/Ice opponent
-
Weather Max Moves: Calculated weather benefits (Sun/Rain/Sand/Hail)
-
Terrain Max Moves: +40 base, +30 for Electric move boost, +35 priority blocking
-
Stat-Boost Max Moves: +50 for beneficial stats, +35 for opponent debuffs
-
Z-Move Optimization:
- +90 if secures KO
- +60 if KOs last Pokemon (wins game)
- +40 if KOs win condition
- -40 if doesn't KO (wasted nuke)
- -50 if target already low HP (overkill)
####
Advanced Ability System
-
Snowball Detection (Moxie, Beast Boost, Soul-Devouring, Chilling Neigh, Grim Neigh):
- Don't feed kills to Moxie users unless KO'ing them (+30 for KO, -20 for chip damage)
- Urgent priority (+25) if they already have +1 or more boosts
- Prevents snowball scenarios where one KO leads to sweep
-
Reverse Ability Strategy (Contrary, Defiant, Competitive):
- NEVER use stat-lowering moves on Contrary (-50 penalty, inverts to buff!)
- Avoid Intimidate switch-ins vs Defiant/Competitive (-40, triggers +2)
- Prioritize KO'ing Contrary users before they set up with Leaf Storm
-
Speed Shift Awareness (Unburden, Speed Boost, Slow Start):
- DON'T trigger Unburden with Knock Off (-35 unless KO)
- 2.5x threat multiplier when Unburden is active (no item)
- Detect Slow Start weakness (0.3x threat for 5 turns)
-
Switch Ability Strategy (Regenerator, Natural Cure, Shed Skin):
- Predict Regenerator switches at 40-60% HP (free 33% heal)
- Penalty for forcing Regenerator out (-15 on Whirlwind/Roar)
- 1.4x threat multiplier for sustain potential
####
Disruption Move Intelligence
-
Taunt Strategy:
- +60 vs setup sweepers (Swords Dance, Nasty Plot, etc.)
- +45 vs walls (blocks Recover, Roost, Wish)
- +35 vs hazard setters (Stealth Rock, Spikes)
- +15 if outspeeding (locks them in helplessly)
-
Encore Strategy:
- +80 to lock setup moves (waste their turns)
- +70 to lock into immunity moves (free setup time)
- +50 to lock status moves (Protect, Recover becomes useless)
- -40 if locking into super-effective attacks (bad idea!)
-
Knock Off Strategy:
- +100 vs Mega Stones (prevents Mega Evolution!)
- +70 vs Choice items (unlocks their moveset)
- +60 vs Focus Sash at full HP (removes survival)
- +50 vs defensive items (Leftovers, Assault Vest, Eviolite)
- +40 vs Heavy-Duty Boots if hazards are up
-
Trick/Switcheroo Strategy:
- +80 to give Choice item to support Pokemon (cripples them)
- +60 to give Lagging Tail/Iron Ball (speed control)
- +50 to steal valuable items
- -40 penalty for losing our own valuable items
####
Advanced Item Awareness
-
Pinch Berry Detection (Sitrus, Liechi, Salac, Custap, etc.):
- Don't chip Sitrus Berry into activation range (-20) unless KO through heal
- DON'T trigger stat-boost berries (-35 for Liechi/Petaya/Salac)
- 25%/50% HP activation thresholds per berry type
-
Type Resist Berries (Occa, Passho, Wacan, etc.):
- -25 if our SE move will be halved
- +40 if we still KO through resistance
-
Eject Mechanics (Eject Button, Red Card, Eject Pack):
- +15 to force weak targets out (Eject Button)
- -30 if Red Card forces us out
- -35 if Eject Pack lets them escape stat drops
-
Air Balloon Strategy:
- -80 if using Ground move on balloon holder (immunity)
- +15 to pop it with any other move
- +10 bonus if we have Ground coverage for follow-up
-
Weakness Policy:
- +30 if KO before trigger
- -50 if triggering +2/+2 boost
- -30 additional if target is high-offense sweeper
-
Contact Damage (Rocky Helmet, Iron Barbs):
- -25 contact penalty at low HP
- +20 if move KOs despite recoil
####
Weather & Terrain Wars
-
Weather Strategy:
- +50 to counter opponent's beneficial weather (Sun vs Rain team)
- Auto-calculate weather benefits (Fire moves in Sun, Water in Rain, etc.)
- +40 for ability synergy (Chlorophyll + Sun, Swift Swim + Rain)
- +30 for offensive weather (boosts our moves)
- +15 chip damage weather vs non-immune types
-
Terrain Strategy:
- +45 to counter opponent's terrain
- Electric Terrain: +25 per Electric move, +15 sleep prevention
- Grassy Terrain: +20 per Grass move, +20 passive healing
- Misty Terrain: +25 per Dragon move opponent has, +20 status immunity
- Psychic Terrain: +25 per Psychic move, +30 priority blocking
- +35 for terrain ability synergy (Surge Surfer, Grass Pelt)
####
Special Move Strategies
-
Pain Split:
- +80 if we're <35% HP and target >60% (huge heal)
- +40 if emergency (<20% HP, could save from KO)
- -40 if we're higher HP than target (lose HP)
- +20 vs high max HP targets (Blissey, Snorlax)
-
Healing Wish / Lunar Dance:
- +50 per injured sweeper on team (heal win condition)
- +60 if last hope sacrifice (2v1 scenario)
- -70 if too healthy to sacrifice (>40% HP)
- Lunar Dance +30 for curing status
-
Final Gambit:
- +100 if KOs target
- +50 if KOs boosted sweeper
- +80 if KOs last Pokemon (wins game!)
- -60 if doesn't KO and wastes sacrifice
-
Memento:
- +70 vs boosted sweepers (cripple -2/-2)
- +50 vs high-offense threats
- -60 if too healthy (>30% HP)
-
Rapid Spin / Defog:
- +30 per hazard layer removed
- +25 for Stealth Rock removal
- +15 per teammate weak to hazards
- Defog: +40 to remove opponent screens, -15 per opponent hazard removed
-
Endeavor:
- +60 if target HP > 2x our HP
- +40 if we have priority follow-up
- -60 if we're >50% HP (useless)
-
False Swipe:
-
-999 score in PVP/Trainer battles (never use competitively!)
- Only acceptable in wild battles
---
####
Advanced Damage Calculation System
-
Ability-Aware Calculations: Full implementation of 30+ abilities affecting damage:
-
Immunities: Levitate (Ground), Volt/Water/Flash Fire Absorb, Sap Sipper, Wonder Guard
-
Resistance Modifiers: Thick Fat (0.5x Fire/Ice), Filter/Solid Rock (0.75x super effective)
-
Offensive Boosts: Adaptability (2.0x STAB), Huge/Pure Power (2x Attack), Guts (1.5x when statused)
-
Defensive Boosts: Marvel Scale (1.5x Def when statused)
-
Weather Synergy: Solar Power (1.5x SpA in Sun), Swift Swim/Chlorophyll/Sand Rush speed doubles
-
Item-Aware Calculations:
-
Offensive: Choice Band/Specs (1.5x), Life Orb (1.3x), type-boost items
-
Defensive: Assault Vest (1.5x SpD), Eviolite (1.5x both defenses for NFE Pokemon)
- Weather/Terrain Integration: Sun boosts Fire 1.5x & nerfs Water 0.5x, Rain opposite
- Burn Mechanics: Physical moves halved by burn UNLESS attacker has Guts
- Accurate Formula: Uses official Pokemon damage formula with level scaling, STAB, random roll averaging
####
Setup Move Detection System
- Setup Move Database: 30+ setup moves tracked (Swords Dance, Dragon Dance, Nasty Plot, etc.)
- Threat Evaluation: AI assigns threat scores based on opponent stat boosts
- +1 Offensive boost = 20 points threat
- +1 Speed boost = 15 points threat
- Moveset contains setup = +10 points
-
Strategic Response: AI prioritizes switching or attacking boosted opponents before they snowball
####
Speed Tier Awareness
-
Pre-Switch Speed Calc: Calculates party Pokemon speed BEFORE switching in
- Nature modifiers (Jolly/Timid +10%, Brave/Quiet -10%)
- Item effects (Choice Scarf 1.5x, Iron Ball 0.5x)
- Ability effects (Swift Swim in Rain, Chlorophyll in Sun, etc.)
- Matchup Evaluation: +15 score for outspeeding opponent, -5 for being slower
- OHKO Priority: +10 bonus if faster AND can hit super effectively
####
Debug & Analysis Tools
- Damage Breakdown Logs: Shows complete calculation (effectiveness, stats, modifiers, abilities)
- Switch Decision Logs: Explains WHY AI switched (or stayed) with detailed reasoning
- Performance Tracking: Logs execution time for critical AI decisions
####
Performance Optimizations
- Type Effectiveness Caching: Repeated type checks cached per battle
- Setup Move Caching: Setup move lookups memoized
- Constants Extraction: Magic numbers → named constants (STAB_MULTIPLIER, DAMAGE_RANDOM_MULTIPLIER, etc.)
---
### Bug Fixes
####
Critical Damage Calculation Bug
- Issue:
calculate_incoming_damage used hardcoded multipliers (2.0/1.0/0.5) instead of actual effectiveness values
- Impact: AI overestimated damage by 2x for dual-type resistances (e.g., Ferroseed vs Electric showed 77% instead of 38.5%)
- Fix: Now uses actual
Effectiveness.calculate return value divided by NORMAL_EFFECTIVE_MULTIPLIER
####
Deprecated API Elimination
-
Fixed 25 bugs total across 4 files:
-
Move_Scorer.rb (4 fixes):
user.lastMoveUsed →
user.battler.lastMoveUsed (AIBattler wrapper)
-
Switch_Intelligence.rb (8 fixes): All
.type1/.type2 →
.types or
.pbTypes(true)
-
Pivot_Moves.rb (8 fixes): Fixed
Pokemon::Move.damagingMove? error + type API
-
Prediction_System.rb (4 fixes): Type access in prediction logic
-
Duck-Typing Fix: Line 540 now checks
is_a?(Battle::Battler) before choosing type accessor
####
Modularization Preparation
- Separated cache initialization (
initialize_switch_caches)
- Separated speed calculations (
calculate_party_speed)
- Separated threat evaluation (
evaluate_setup_threat)
- Ready for future file splitting (damage_calculator.rb, setup_detector.rb, etc.)
---
### Testing & Validation
####
Verified Scenarios
- Ferroseed (GRASS/STEEL) vs Electric = 0.5x damage (GRASS resists)
- Charizard (FIRE/FLYING) vs Rock = 4.0x damage (both weak)
- Levitate Pokemon immune to Ground moves
- Thick Fat halves Fire/Ice damage correctly
- Choice Band boosts physical damage by 1.5x
- Burn halves physical damage UNLESS Guts active
- Rain boosts Water 1.5x, nerfs Fire 0.5x
### Bug Fixes
####
Critical Fixes
- Damage Calculation Bug: Fixed
calculate_incoming_damage using hardcoded multipliers instead of actual effectiveness values
- Tera Compatibility: Resolved compatibility issues with Terastallization mechanics
- Division by Zero: Fixed error in
PP_Tracker and crash in Hazard_Control
- Burn Mechanics: Fixed burn damage reduction not applying to physical moves
- Type-Boosting Items: Fixed items being overlooked in damage calculations
####
Move Behavior Fixes
- Move Repetition Spam: Implemented
score_move_repetition_penalty (-40 for status, -15 for attacks)
- Move Memory Tracking: Now tracks ALL battlers' moves for proper prediction
- Redundant Status Moves: Added failure checks for Leech Seed, Substitute, Yawn, Taunt, Encore, etc.
- Status Condition Spam: Added checks for 20+ status moves vs already-statused targets
- Screen/Hazard Spam: Fixed setting up already-active screens/hazards
####
API Fixes
- Deprecated Types API: Fixed 13 instances using
.types[0] instead of pbTypes(true)
- Misty Terrain Bug: Fixed incorrect
hasActiveAbility?([:LEVITATE]) syntax
- AIBattler Wrapper: Fixed
user.lastMoveUsed → user.battler.lastMoveUsed
- Duck-Typing Fix: Proper
is_a?(Battle::Battler) checks before type accessor
- Battler Index Safety: Added
get_battler_index() helper for handling Battler objects and integer indices