diff --git a/src/battle-phases.ts b/src/battle-phases.ts index d9ad0002423..0fb9b6c9c0d 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -25,7 +25,7 @@ import { Gender } from "./data/gender"; import { Weather, WeatherType, getRandomWeatherType, getWeatherDamageMessage, getWeatherLapseMessage } from "./data/weather"; import { TempBattleStat } from "./data/temp-battle-stat"; import { ArenaTagType, ArenaTrapTag, TrickRoomTag } from "./data/arena-tag"; -import { Abilities, CheckTrappedAbAttr, IgnoreOpponentStatChangesAbAttr, PostDefendAbAttr, PostSummonAbAttr, PostTurnAbAttr, PostWeatherLapseAbAttr, PreWeatherDamageAbAttr, ProtectStatAbAttr, StatChangeMultiplierAbAttr, SuppressWeatherEffectAbAttr, applyAbAttrs, applyCheckTrappedAbAttrs, applyPostDefendAbAttrs, applyPostSummonAbAttrs, applyPostTurnAbAttrs, applyPostWeatherLapseAbAttrs, applyPreStatChangeAbAttrs, applyPreWeatherEffectAbAttrs } from "./data/ability"; +import { Abilities, CheckTrappedAbAttr, IgnoreOpponentStatChangesAbAttr, PostDefendAbAttr, PostSummonAbAttr, PostTurnAbAttr, PostWeatherLapseAbAttr, PreWeatherDamageAbAttr, ProtectStatAbAttr, StatChangeMultiplierAbAttr, LowerHpWeakerAbAttr, SuppressWeatherEffectAbAttr, applyAbAttrs, applyCheckTrappedAbAttrs, applyPostDefendAbAttrs, applyPostSummonAbAttrs, applyPostTurnAbAttrs, applyPostWeatherLapseAbAttrs, applyPreStatChangeAbAttrs, applyPreWeatherEffectAbAttrs } from "./data/ability"; import { Unlockables, getUnlockableName } from "./system/unlockables"; import { getBiomeKey } from "./arena"; import { BattleType, BattlerIndex, TurnCommand } from "./battle"; @@ -2033,6 +2033,10 @@ export class DamagePhase extends PokemonPhase { } this.applyDamage(); + + const pokemon = this.getPokemon() + const stats = this.getPokemon().stats + applyAbAttrs(LowerHpWeakerAbAttr,pokemon , null, stats); } applyDamage() { diff --git a/src/data/ability.ts b/src/data/ability.ts index bcf2ff66a09..e351bb86e9d 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -123,6 +123,29 @@ export class StabBoostAbAttr extends AbAttr { } } +export class LowerHpWeakerAbAttr extends AbAttr { + private hpLeft: integer; + + constructor(hpLeft: integer) { + super(true) + + this.hpLeft = hpLeft; + } + + apply(pokemon: Pokemon, cancelled: Utils.BooleanHolder, args: any[]): boolean { + const hpRatio = pokemon.getHpRatio(); + + if (hpRatio <= this.hpLeft) { + args[0] *= 55.5 + args[1] *= 55.5 + args[2] *= 55.5 + args[3] *= 55.5 + } + + return true; + } +} + export class ReceivedTypeDamageMultiplierAbAttr extends PreDefendAbAttr { private moveType: Type; private powerMultiplier: number; @@ -1507,7 +1530,8 @@ export function initAbilities() { new Ability(Abilities.CONTRARY, "Contrary", "Makes stat changes have an opposite effect.", 5) .attr(StatChangeMultiplierAbAttr, -1), new Ability(Abilities.CURSED_BODY, "Cursed Body (N)", "May disable a move used on the Pokémon.", 5), - new Ability(Abilities.DEFEATIST, "Defeatist (N)", "Lowers stats when HP drops below half.", 5), + new Ability(Abilities.DEFEATIST, "Defeatist", "Lowers stats when HP drops below half.", 5) + .attr(LowerHpWeakerAbAttr, 0.5), new Ability(Abilities.DEFIANT, "Defiant (N)", "Sharply raises Attack when the Pokémon's stats are lowered.", 5), new Ability(Abilities.FLARE_BOOST, "Flare Boost (N)", "Powers up special attacks when burned.", 5), new Ability(Abilities.FRIEND_GUARD, "Friend Guard (N)", "Reduces damage done to allies.", 5), diff --git a/src/pokemon.ts b/src/pokemon.ts index 695f4db5694..281a3b01bb9 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -39,7 +39,7 @@ export enum FieldPosition { RIGHT } -const ABILITY_OVERRIDE = Abilities.NONE; +const ABILITY_OVERRIDE = Abilities.DEFEATIST; const MOVE_OVERRIDE = Moves.NONE; const OPP_ABILITY_OVERRIDE = Abilities.NONE;