Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Move] Corrosive Gas #4793

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2760,9 +2760,12 @@ export default class BattleScene extends SceneBase {
modifiers.splice(modifiers.indexOf(modifier), 1);
}
}
const nullifiedModifiers = modifiers.filter(modifier =>
!(modifier instanceof PokemonHeldItemModifier) || !modifier.isNullified
);

this.updatePartyForModifiers(player ? this.getPlayerParty() : this.getEnemyParty(), instant).then(() => {
(player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers);
(player ? this.modifierBar : this.enemyModifierBar).updateModifiers(nullifiedModifiers);
if (!player) {
this.updateUIPositions();
}
Expand Down
55 changes: 54 additions & 1 deletion src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7502,6 +7502,59 @@ export class ExposedMoveAttr extends AddBattlerTagAttr {
}
}

/**
* Nullifies a Pokemon's held item until the battle ends.
* Simulates the item being removed, but it just neutralizes it until the next battle
* Used by: {@linkcode Moves.CORROSIVE_GAS | Corrosive Gas}
*
* @extends MoveEffectAttr
* @see {@linkcode apply}
*/
export class NullifyHeldItemAttr extends MoveEffectAttr {
constructor() {
super(false, { trigger: MoveEffectTrigger.HIT });
}

/**
*
* @param user {@linkcode Pokemon} that used the move
* @param target Target {@linkcode Pokemon} that the moves applies to
* @param move {@linkcode Move} that is used
* @param args N/A
* @returns {boolean} True if an item was nullified
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (move.hitsSubstitute(user, target)) {
return false;
}
const cancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // Check for abilities that block item theft
if (cancelled.value === true) {
return false;
}

const heldItems = this.getTargetHeldItems(target).filter(i => i.isTransferable);

if (heldItems.length) {
const nullifiedItem = heldItems[user.randSeedInt(heldItems.length)];

nullifiedItem.nullify();
nullifiedItem.isTransferable = false;
target.scene.updateModifiers(target.isPlayer());

user.scene.queueMessage(i18next.t("moveTriggers:corrosiveGasItem", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target), itemName: nullifiedItem.type.name }));

}
applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false);
return true;
}

getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] {
return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& m.pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[];
}
}


const unknownTypeCondition: MoveConditionFunc = (user, target, move) => !user.getTypes().includes(Type.UNKNOWN);

Expand Down Expand Up @@ -10034,7 +10087,7 @@ export function initMoves() {
.makesContact(false),
new StatusMove(Moves.CORROSIVE_GAS, Type.POISON, 100, 40, -1, 0, 8)
.target(MoveTarget.ALL_NEAR_OTHERS)
.unimplemented(),
.attr(NullifyHeldItemAttr),
new StatusMove(Moves.COACHING, Type.FIGHTING, -1, 10, -1, 0, 8)
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.DEF ], 1)
.target(MoveTarget.NEAR_ALLY),
Expand Down
13 changes: 11 additions & 2 deletions src/modifier/modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ export class TerastallizeAccessModifier extends PersistentModifier {
export abstract class PokemonHeldItemModifier extends PersistentModifier {
public pokemonId: number;
public isTransferable: boolean = true;
public isNullified: boolean = false;

constructor(type: ModifierType, pokemonId: number, stackCount?: number) {
super(type, stackCount);
Expand All @@ -655,13 +656,21 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
abstract matchType(_modifier: Modifier): boolean;

match(modifier: Modifier) {
return this.matchType(modifier) && (modifier as PokemonHeldItemModifier).pokemonId === this.pokemonId;
return this.matchType(modifier) && (modifier as PokemonHeldItemModifier).pokemonId === this.pokemonId && !this.isNullified;
}

getArgs(): any[] {
return [ this.pokemonId ];
}

nullify() {
this.isNullified = true;
}

removeNullification() {
this.isNullified = false;
}

/**
* Applies the {@linkcode PokemonHeldItemModifier} to the given {@linkcode Pokemon}.
* @param pokemon The {@linkcode Pokemon} that holds the held item
Expand All @@ -676,7 +685,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
* @returns if {@linkcode PokemonHeldItemModifier} should be applied
*/
override shouldApply(pokemon?: Pokemon, ..._args: unknown[]): boolean {
return !!pokemon && (this.pokemonId === -1 || pokemon.id === this.pokemonId);
return !this.isNullified && !!pokemon && (this.pokemonId === -1 || pokemon.id === this.pokemonId);
}

isIconVisible(scene: BattleScene): boolean {
Expand Down
11 changes: 10 additions & 1 deletion src/phases/battle-end-phase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BattleScene from "#app/battle-scene";
import { applyPostBattleAbAttrs, PostBattleAbAttr } from "#app/data/ability";
import { LapsingPersistentModifier, LapsingPokemonHeldItemModifier } from "#app/modifier/modifier";
import { LapsingPersistentModifier, LapsingPokemonHeldItemModifier, PokemonHeldItemModifier } from "#app/modifier/modifier";
import { BattlePhase } from "./battle-phase";
import { GameOverPhase } from "./game-over-phase";

Expand Down Expand Up @@ -43,6 +43,15 @@ export class BattleEndPhase extends BattlePhase {

for (const pokemon of this.scene.getPokemonAllowedInBattle()) {
applyPostBattleAbAttrs(PostBattleAbAttr, pokemon);
const heldItems = pokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier) as PokemonHeldItemModifier[];
for (const item of heldItems) {
if (item.isNullified) {
item.removeNullification();
if (item.isTransferable === false) {
item.isTransferable = true;
}
}
}
}

if (this.scene.currentBattle.moneyScattered) {
Expand Down
Loading
Loading