From c62d4f4a52fad61d897010f0bd1f24b6e31440a2 Mon Sep 17 00:00:00 2001 From: Luc Dube Date: Sun, 21 Apr 2024 04:37:30 -0400 Subject: [PATCH 1/5] implemented pluck, bug bite --- src/data/move.ts | 58 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index d5bd71ad2e1..488a87e00ee 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -12,10 +12,10 @@ import * as Utils from "../utils"; import { WeatherType } from "./weather"; import { ArenaTagSide, ArenaTrapTag } from "./arena-tag"; import { ArenaTagType } from "./enums/arena-tag-type"; -import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, NoTransformAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr } from "./ability"; +import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, NoTransformAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr, PreventBerryUseAbAttr, BlockItemTheftAbAttr } from "./ability"; import { Abilities } from "./enums/abilities"; import { allAbilities } from './ability'; -import { PokemonHeldItemModifier } from "../modifier/modifier"; +import { PokemonHeldItemModifier, BerryModifier } from "../modifier/modifier"; import { BattlerIndex } from "../battle"; import { Stat } from "./pokemon-stat"; import { TerrainType } from "./terrain"; @@ -25,6 +25,7 @@ import { ModifierPoolType } from "#app/modifier/modifier-type"; import { Command } from "../ui/command-ui-handler"; import { Biome } from "./enums/biome"; import i18next, { Localizable } from '../plugins/i18n'; +import { BerryType, BerryEffectFunc, getBerryEffectFunc } from './berry'; export enum MoveCategory { PHYSICAL, @@ -1099,6 +1100,55 @@ export class RemoveHeldItemAttr extends MoveEffectAttr { } } +export class EatBerryAttr extends MoveEffectAttr { + protected chosenBerry: BerryModifier; + constructor() { + super(true, MoveEffectTrigger.HIT); + } + + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + if (!super.apply(user, target, move, args)) + return false; + + getBerryEffectFunc(this.chosenBerry.berryType)(target); + + if (!--this.chosenBerry.stackCount) + target.scene.removeModifier(this.chosenBerry); + target.scene.updateModifiers(target.isPlayer()); + + return true; + } + + getTargetHeldBerries(target: Pokemon): BerryModifier[] { + return target.scene.findModifiers(m => m instanceof BerryModifier + && (m as BerryModifier).pokemonId === target.id, target.isPlayer()) as BerryModifier[]; + } + +} + +export class StealEatBerryAttr extends EatBerryAttr { + constructor() { + super(); + } + + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + const heldBerries = this.getTargetHeldBerries(target).filter(i => i.getTransferrable(false)); + + if (heldBerries.length) { + this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)]; + + if (!--this.chosenBerry.stackCount) + target.scene.removeModifier(this.chosenBerry); + target.scene.updateModifiers(target.isPlayer()); + + user.scene.queueMessage(getPokemonMessage(user, ` stole and ate\n${target.name}'s ${this.chosenBerry.type.name}!`)); + return super.apply(user, user, move, args); + } + + return false; + } +} + export class HealStatusEffectAttr extends MoveEffectAttr { private effects: StatusEffect[]; @@ -4634,6 +4684,7 @@ export function initMoves() { .makesContact(false) .ignoresProtect(), new AttackMove(Moves.PLUCK, Type.FLYING, MoveCategory.PHYSICAL, 60, 100, 20, -1, 0, 4) + .attr(StealEatBerryAttr) .partial(), new StatusMove(Moves.TAILWIND, Type.FLYING, -1, 15, -1, 0, 4) .windMove() @@ -4870,6 +4921,7 @@ export function initMoves() { new AttackMove(Moves.JUDGMENT, Type.NORMAL, MoveCategory.SPECIAL, 100, 100, 10, -1, 0, 4) .partial(), new AttackMove(Moves.BUG_BITE, Type.BUG, MoveCategory.PHYSICAL, 60, 100, 20, -1, 0, 4) + .attr(StealEatBerryAttr) .partial(), new AttackMove(Moves.CHARGE_BEAM, Type.ELECTRIC, MoveCategory.SPECIAL, 50, 90, 10, 70, 0, 4) .attr(StatChangeAttr, BattleStat.SPATK, 1, true), @@ -5656,7 +5708,7 @@ export function initMoves() { .partial(), new StatusMove(Moves.TEATIME, Type.NORMAL, -1, 10, -1, 0, 8) .target(MoveTarget.ALL) - .unimplemented(), + .attr(EatBerryAttr), new StatusMove(Moves.OCTOLOCK, Type.FIGHTING, 100, 15, -1, 0, 8) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1) .partial(), From 3c8dc6c3366b1931d90df7a56e0950e010630f01 Mon Sep 17 00:00:00 2001 From: Luc Dube Date: Sun, 21 Apr 2024 16:53:20 -0400 Subject: [PATCH 2/5] steal blocked by sticky hold --- src/data/move.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/data/move.ts b/src/data/move.ts index 488a87e00ee..9bba34b0960 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1132,6 +1132,12 @@ export class StealEatBerryAttr extends EatBerryAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + + const cancelled = new Utils.BooleanHolder(false); + applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); + if(cancelled.value == true) + return false; + const heldBerries = this.getTargetHeldBerries(target).filter(i => i.getTransferrable(false)); if (heldBerries.length) { From d716b9b107202ceec397ca8b70a6645e715d0a6f Mon Sep 17 00:00:00 2001 From: Luc Dube Date: Sun, 21 Apr 2024 17:36:32 -0400 Subject: [PATCH 3/5] implemented teatime --- src/data/move.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 9bba34b0960..eb5efb65ebf 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1104,12 +1104,20 @@ export class EatBerryAttr extends MoveEffectAttr { protected chosenBerry: BerryModifier; constructor() { super(true, MoveEffectTrigger.HIT); + this.chosenBerry = undefined; } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { if (!super.apply(user, target, move, args)) return false; + if(this.chosenBerry === undefined) { // if no berry has been provided, pick a random berry from their inventory + const heldBerries = this.getTargetHeldBerries(target); + if(heldBerries.length <= 0) + return false; + this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)]; + } + getBerryEffectFunc(this.chosenBerry.berryType)(target); if (!--this.chosenBerry.stackCount) @@ -4690,8 +4698,7 @@ export function initMoves() { .makesContact(false) .ignoresProtect(), new AttackMove(Moves.PLUCK, Type.FLYING, MoveCategory.PHYSICAL, 60, 100, 20, -1, 0, 4) - .attr(StealEatBerryAttr) - .partial(), + .attr(StealEatBerryAttr), new StatusMove(Moves.TAILWIND, Type.FLYING, -1, 15, -1, 0, 4) .windMove() .target(MoveTarget.USER_SIDE) @@ -4927,8 +4934,7 @@ export function initMoves() { new AttackMove(Moves.JUDGMENT, Type.NORMAL, MoveCategory.SPECIAL, 100, 100, 10, -1, 0, 4) .partial(), new AttackMove(Moves.BUG_BITE, Type.BUG, MoveCategory.PHYSICAL, 60, 100, 20, -1, 0, 4) - .attr(StealEatBerryAttr) - .partial(), + .attr(StealEatBerryAttr), new AttackMove(Moves.CHARGE_BEAM, Type.ELECTRIC, MoveCategory.SPECIAL, 50, 90, 10, 70, 0, 4) .attr(StatChangeAttr, BattleStat.SPATK, 1, true), new AttackMove(Moves.WOOD_HAMMER, Type.GRASS, MoveCategory.PHYSICAL, 120, 100, 15, -1, 0, 4) @@ -5713,8 +5719,8 @@ export function initMoves() { .makesContact(false) .partial(), new StatusMove(Moves.TEATIME, Type.NORMAL, -1, 10, -1, 0, 8) - .target(MoveTarget.ALL) - .attr(EatBerryAttr), + .attr(EatBerryAttr) + .target(MoveTarget.ALL), new StatusMove(Moves.OCTOLOCK, Type.FIGHTING, 100, 15, -1, 0, 8) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1) .partial(), From da0cda3646c8b7a7f47f4d706b8291580dc4cd82 Mon Sep 17 00:00:00 2001 From: Luc Dube Date: Sun, 21 Apr 2024 18:42:31 -0400 Subject: [PATCH 4/5] added stuff cheeks --- src/data/move.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/move.ts b/src/data/move.ts index eb5efb65ebf..237584831d8 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5704,7 +5704,11 @@ export function initMoves() { .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, true, false, 1) .bitingMove(), new SelfStatusMove(Moves.STUFF_CHEEKS, Type.NORMAL, -1, 10, 100, 0, 8) - .unimplemented(), + .attr(StatChangeAttr, BattleStat.DEF, 2) + .attr(EatBerryAttr) + .condition((user, target, move) => target.scene.findModifiers(m => m instanceof BerryModifier + && (m as BerryModifier).pokemonId === target.id, target.isPlayer()).length > 0 ) + .target(MoveTarget.USER), new SelfStatusMove(Moves.NO_RETREAT, Type.FIGHTING, -1, 5, 100, 0, 8) .attr(StatChangeAttr, [ BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD ], 1, true) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, true, true, 1), From f42358d3aa162e594264c57d63b6ef3e439d50b2 Mon Sep 17 00:00:00 2001 From: Luc Dube Date: Sun, 21 Apr 2024 23:16:34 -0400 Subject: [PATCH 5/5] added berry pouch support --- src/data/move.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 237584831d8..01e8a0cc1e8 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -15,7 +15,7 @@ import { ArenaTagType } from "./enums/arena-tag-type"; import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, NoTransformAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr, PreventBerryUseAbAttr, BlockItemTheftAbAttr } from "./ability"; import { Abilities } from "./enums/abilities"; import { allAbilities } from './ability'; -import { PokemonHeldItemModifier, BerryModifier } from "../modifier/modifier"; +import { PokemonHeldItemModifier, BerryModifier, PreserveBerryModifier } from "../modifier/modifier"; import { BattlerIndex } from "../battle"; import { Stat } from "./pokemon-stat"; import { TerrainType } from "./terrain"; @@ -1120,9 +1120,14 @@ export class EatBerryAttr extends MoveEffectAttr { getBerryEffectFunc(this.chosenBerry.berryType)(target); - if (!--this.chosenBerry.stackCount) - target.scene.removeModifier(this.chosenBerry); - target.scene.updateModifiers(target.isPlayer()); + const preserve = new Utils.BooleanHolder(false); + target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve); + + if (!preserve.value){ + if (!--this.chosenBerry.stackCount) + target.scene.removeModifier(this.chosenBerry); + target.scene.updateModifiers(target.isPlayer()); +} return true; }