diff --git a/.gitignore b/.gitignore index 55f9203a8..a19a17696 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,4 @@ src/data/battle-anim-raw-data*.ts src/data/battle-anim-data.ts src/overrides.ts -coverage \ No newline at end of file +coverage diff --git a/src/data/ability.ts b/src/data/ability.ts index eec1240e1..b0f5476a0 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -887,6 +887,30 @@ export class VariableMovePowerAbAttr extends PreAttackAbAttr { } } +export class PreAttackChangeType extends PreAttackAbAttr{ + private condition: PokemonAttackCondition; + + constructor (condition:PokemonAttackCondition) { + super(true); + this.condition = condition; + } + + applyPreAttack(pokemon:Pokemon,passive:boolean,defender:Pokemon,move:PokemonMove): boolean{ + const MoveType = move.getMove().type; + const originalType = pokemon.getTypes(); + + if (this.condition(pokemon,defender,move.getMove())){ + if (originalType.length > 1 || originalType[0] !== MoveType){ + pokemon.summonData.types = [MoveType]; + pokemon.battleSummonData.abilityTriggered = true; + pokemon.updateInfo(); + pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` tranformed\ninto the ${Utils.toReadableString(Type[MoveType])} type!`)); + } + } + return false; + } +} + export class VariableMoveTypeAbAttr extends AbAttr { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { //const power = args[0] as Utils.IntegerHolder; @@ -3144,7 +3168,7 @@ export function initAbilities() { new Ability(Abilities.CHEEK_POUCH, 6) .unimplemented(), new Ability(Abilities.PROTEAN, 6) - .unimplemented(), + .attr(PreAttackChangeType,(user,target,move) => move.id !== Moves.STRUGGLE && !user.isTerastallized() && user.battleSummonData.abilityTriggered === false), new Ability(Abilities.FUR_COAT, 6) .attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => move.category === MoveCategory.PHYSICAL, 0.5) .ignorable(), @@ -3364,7 +3388,7 @@ export function initAbilities() { new Ability(Abilities.DAUNTLESS_SHIELD, 8) .attr(PostSummonStatChangeAbAttr, BattleStat.DEF, 1, true), new Ability(Abilities.LIBERO, 8) - .unimplemented(), + .attr(PreAttackChangeType,(user,target,move) => move.id !== Moves.STRUGGLE && !user.isTerastallized() && user.battleSummonData.abilityTriggered === false), new Ability(Abilities.BALL_FETCH, 8) .unimplemented(), new Ability(Abilities.COTTON_DOWN, 8) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index b20096513..ac1b784b5 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -27,6 +27,7 @@ import { TempBattleStat } from '../data/temp-battle-stat'; import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from '../data/arena-tag'; import { ArenaTagType } from "../data/enums/arena-tag-type"; import { Biome } from "../data/enums/biome"; +import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, PreAttackChangeType } from '../data/ability'; import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr } from '../data/ability'; import { Abilities } from "#app/data/enums/abilities"; import PokemonData from '../system/pokemon-data'; @@ -1256,6 +1257,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // 2nd argument is for MoveTypeChangePowerMultiplierAbAttr applyAbAttrs(VariableMoveTypeAbAttr, source, null, variableType, typeChangeMovePowerMultiplier); applyPreAttackAbAttrs(MoveTypeChangeAttr, source, this, battlerMove, variableType, typeChangeMovePowerMultiplier); + applyPreAttackAbAttrs(PreAttackChangeType,source,this,battlerMove,) const type = variableType.value as Type; const types = this.getTypes(true, true); @@ -3109,12 +3111,13 @@ export class PokemonSummonData { export class PokemonBattleData { public hitCount: integer = 0; public endured: boolean = false; - public berriesEaten: BerryType[] = []; + public berriesEaten: BerryType[] = []; } export class PokemonBattleSummonData { public turnCount: integer = 1; public moveHistory: TurnMove[] = []; + public abilityTriggered: boolean = false; } export class PokemonTurnData {