This commit is contained in:
André Bastos Dias 2026-06-02 14:05:48 +01:00 committed by GitHub
commit 1500e68c8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 24 additions and 66 deletions

View File

@ -23,9 +23,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
this.hint("In Gen 1, Toxic's counter is retained after Rest and applies to PSN/BRN.", true);
}
},
onAfterSwitchInSelf(pokemon) {
this.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));
},
},
par: {
name: 'par',
@ -119,9 +116,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
this.hint("In Gen 1, Toxic's counter is retained after Rest and applies to PSN/BRN.", true);
}
},
onAfterSwitchInSelf(pokemon) {
this.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));
},
},
tox: {
inherit: true,

View File

@ -157,11 +157,6 @@ export const Scripts: ModdedBattleScriptsData = {
}
}
const abortMove = () => {
this.battle.clearActiveMove(true);
this.battle.runEvent('AfterMoveSelf', pokemon, target, move);
};
if (move.id === 'cannotmove') {
if (pokemon.status === 'slp') {
this.battle.hint(
@ -179,7 +174,7 @@ export const Scripts: ModdedBattleScriptsData = {
"the move execution will never resolve."
);
}
abortMove();
this.battle.clearActiveMove(true);
return;
}
@ -188,11 +183,11 @@ export const Scripts: ModdedBattleScriptsData = {
this.battle.setActiveMove(move, pokemon, target);
if (pokemon.moveThisTurn || !this.battle.runEvent('BeforeMove', pokemon, target, move)) {
abortMove();
this.battle.clearActiveMove(true);
return;
}
if (move.beforeMoveCallback?.call(this.battle, pokemon, target, move)) {
abortMove();
this.battle.clearActiveMove(true);
return;
}
@ -212,7 +207,7 @@ export const Scripts: ModdedBattleScriptsData = {
this.battle.hint(
"In Gen 1, a Pokémon might default to using a move that doesn't match the move of the slot it last selected.",
);
abortMove();
this.battle.clearActiveMove(true);
return;
}
}
@ -268,9 +263,6 @@ export const Scripts: ModdedBattleScriptsData = {
pokemon.side.lastMove = move;
this.battle.runEvent('AfterMove', pokemon, target, move);
if (!target || target.hp > 0) {
this.battle.runEvent('AfterMoveSelf', pokemon, target, move);
}
}
}
return moveResult;

View File

@ -9,9 +9,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
onAfterMoveSelf(pokemon) {
this.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));
},
onAfterSwitchInSelf(pokemon) {
this.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));
},
},
par: {
name: 'par',
@ -88,9 +85,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
onAfterMoveSelf(pokemon) {
this.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));
},
onAfterSwitchInSelf(pokemon) {
this.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));
},
},
confusion: {
inherit: true,

View File

@ -83,8 +83,6 @@ export const Scripts: ModdedBattleScriptsData = {
if (pokemon.moveThisTurn || !this.battle.runEvent('BeforeMove', pokemon, target, move)) {
this.battle.debug(`${pokemon.fullname} move interrupted; movedThisTurn: ${pokemon.moveThisTurn}`);
this.battle.clearActiveMove(true);
// This is only run for sleep
this.battle.runEvent('AfterMoveSelf', pokemon, target, move);
return;
}
if (move.beforeMoveCallback) {
@ -142,8 +140,6 @@ export const Scripts: ModdedBattleScriptsData = {
// If target fainted
if (target && target.hp <= 0) {
delete pokemon.volatiles['partialtrappinglock'];
} else {
this.battle.runEvent('AfterMoveSelf', pokemon, target, move);
}
if (pokemon.volatiles['mustrecharge']) this.battle.add('-mustrecharge', pokemon);

View File

@ -9,9 +9,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
onAfterMoveSelf(pokemon) {
residualdmg(this, pokemon);
},
onAfterSwitchInSelf(pokemon) {
residualdmg(this, pokemon);
},
},
par: {
name: 'par',
@ -87,9 +84,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
onAfterMoveSelf(pokemon) {
residualdmg(this, pokemon);
},
onAfterSwitchInSelf(pokemon) {
residualdmg(this, pokemon);
},
},
tox: {
name: 'tox',
@ -109,9 +103,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
pokemon.status = 'psn' as ID;
this.add('-status', pokemon, 'psn', '[silent]');
},
onAfterSwitchInSelf(pokemon) {
this.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));
},
},
confusion: {
inherit: true,
@ -245,9 +236,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
onAfterMoveSelf(pokemon) {
if (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;
},
onAfterSwitchInSelf(pokemon) {
if (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;
},
},
};

View File

@ -412,7 +412,7 @@ export const Moves: import('../../../sim/dex-moves').ModdedMoveDataTable = {
onResidual: undefined, // no inherit
onAfterMoveSelfPriority: 1,
onAfterMoveSelf(pokemon) {
if (pokemon.status === 'slp') this.damage(pokemon.baseMaxhp / 4);
if (this.effectState.source.hp) this.damage(pokemon.baseMaxhp / 4);
},
},
},

View File

@ -114,8 +114,6 @@ export const Scripts: ModdedBattleScriptsData = {
if (!this.battle.runEvent('BeforeMove', pokemon, target, move)) {
this.battle.runEvent('MoveAborted', pokemon, target, move);
this.battle.clearActiveMove(true);
// This is only run for sleep and fully paralysed.
this.battle.runEvent('AfterMoveSelf', pokemon, target, move);
return;
}
if (move.beforeMoveCallback) {
@ -136,7 +134,6 @@ export const Scripts: ModdedBattleScriptsData = {
pokemon.moveUsed(move);
this.battle.actions.useMove(move, pokemon, { target, sourceEffect: options?.sourceEffect });
this.battle.singleEvent('AfterMove', move, null, pokemon, target, move);
if (!move.selfSwitch && pokemon.side.foe.active[0].hp) this.battle.runEvent('AfterMoveSelf', pokemon, target, move);
},
tryMoveHit(target, pokemon, move) {
const positiveBoostTable = [1, 1.33, 1.66, 2, 2.33, 2.66, 3];

View File

@ -19,9 +19,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
onSwitchIn(pokemon) {
pokemon.addVolatile('brnattackdrop');
},
onAfterSwitchInSelf(pokemon) {
residualdmg(this, pokemon);
},
},
par: {
name: 'par',
@ -118,9 +115,6 @@ export const Conditions: import('../../../sim/dex-conditions').ModdedConditionDa
onAfterMoveSelf(pokemon) {
if (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;
},
onAfterSwitchInSelf(pokemon) {
if (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;
},
},
};

View File

@ -16,10 +16,6 @@ export const Scripts: ModdedBattleScriptsData = {
actions: {
inherit: true,
runSwitch(pokemon) {
this.battle.runEvent('EntryHazard', pokemon);
this.battle.runEvent('SwitchIn', pokemon);
if (this.battle.gen <= 2) {
// pokemon.lastMove is reset for all Pokemon on the field after a switch. This affects Mirror Move.
for (const poke of this.battle.getAllActive()) poke.lastMove = null;
@ -33,9 +29,6 @@ export const Scripts: ModdedBattleScriptsData = {
}
}
}
if (!pokemon.side.faintedThisTurn && pokemon.draggedIn !== this.battle.turn) {
this.battle.runEvent('AfterSwitchInSelf', pokemon);
}
}
if (!pokemon.hp) return false;
pokemon.isStarted = true;

View File

@ -150,7 +150,11 @@ export class BattleActions {
if (isDrag && this.battle.gen === 2) pokemon.draggedIn = this.battle.turn;
pokemon.previouslySwitchedIn++;
if (isDrag && this.battle.gen >= 5) {
if (this.battle.gen <= 4) {
this.battle.runEvent('EntryHazard', pokemon);
this.battle.runEvent('SwitchIn', pokemon);
}
if (isDrag) {
// runSwitch happens immediately so that Mold Breaker can make hazards bypass Clear Body and Levitate
this.runSwitch(pokemon);
} else {

View File

@ -65,7 +65,7 @@ export interface SwitchAction {
pokemon: Pokemon;
/** pokemon to switch to */
target: Pokemon;
/** effect that called the switch (eg U */
/** effect that called the switch (eg U-turn) */
sourceEffect: Effect | null;
}

View File

@ -2839,6 +2839,17 @@ export class Battle {
break;
}
if (this.gen <= 2) {
if (action.choice === 'move' && !action.pokemon.switchFlag) {
this.runEvent('AfterMoveSelf', action.pokemon);
} else if (action.choice === 'switch' || (action.choice === 'instaswitch' && action.sourceEffect)) {
this.runEvent('AfterMoveSelf', action.target);
}
}
// Gen 4 and earlier: clear active move so Mold Breaker doesn't allow hazards to bypass Clear Body and Levitate
if (this.gen <= 4) this.clearActiveMove();
// phazing (Roar, etc)
for (const side of this.sides) {
for (const pokemon of side.active) {
@ -2849,7 +2860,7 @@ export class Battle {
}
}
this.clearActiveMove();
if (this.gen > 4) this.clearActiveMove();
// fainting

View File

@ -18,7 +18,6 @@ export interface EventMethods {
onAfterMega?: (this: Battle, pokemon: Pokemon) => void;
onAfterSetStatus?: (this: Battle, status: Condition, target: Pokemon, source: Pokemon, effect: Effect) => void;
onAfterSubDamage?: MoveEventMethods['onAfterSubDamage'];
onAfterSwitchInSelf?: (this: Battle, pokemon: Pokemon) => void;
onAfterTerastallization?: (this: Battle, pokemon: Pokemon) => void;
onAfterUseItem?: (this: Battle, item: Item, pokemon: Pokemon) => void;
onAfterTakeItem?: (this: Battle, item: Item, pokemon: Pokemon) => void;
@ -27,7 +26,7 @@ export interface EventMethods {
onAfterMoveSecondarySelf?: MoveEventMethods['onAfterMoveSecondarySelf'];
onAfterMoveSecondary?: MoveEventMethods['onAfterMoveSecondary'];
onAfterMove?: MoveEventMethods['onAfterMove'];
onAfterMoveSelf?: CommonHandlers['VoidSourceMove'];
onAfterMoveSelf?: (this: Battle, pokemon: Pokemon) => void;
onAttract?: (this: Battle, target: Pokemon, source: Pokemon) => void;
onAccuracy?: (
this: Battle, accuracy: number, target: Pokemon, source: Pokemon, move: ActiveMove
@ -130,7 +129,6 @@ export interface EventMethods {
onFoeAfterHit?: MoveEventMethods['onAfterHit'];
onFoeAfterSetStatus?: (this: Battle, status: Condition, target: Pokemon, source: Pokemon, effect: Effect) => void;
onFoeAfterSubDamage?: MoveEventMethods['onAfterSubDamage'];
onFoeAfterSwitchInSelf?: (this: Battle, pokemon: Pokemon) => void;
onFoeAfterUseItem?: (this: Battle, item: Item, pokemon: Pokemon) => void;
onFoeAfterBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: Effect) => void;
onFoeAfterFaint?: (this: Battle, length: number, target: Pokemon, source: Pokemon, effect: Effect) => void;
@ -228,7 +226,6 @@ export interface EventMethods {
onSourceAfterHit?: MoveEventMethods['onAfterHit'];
onSourceAfterSetStatus?: (this: Battle, status: Condition, target: Pokemon, source: Pokemon, effect: Effect) => void;
onSourceAfterSubDamage?: MoveEventMethods['onAfterSubDamage'];
onSourceAfterSwitchInSelf?: (this: Battle, pokemon: Pokemon) => void;
onSourceAfterUseItem?: (this: Battle, item: Item, pokemon: Pokemon) => void;
onSourceAfterBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: Effect) => void;
onSourceAfterFaint?: (this: Battle, length: number, target: Pokemon, source: Pokemon, effect: Effect) => void;
@ -328,7 +325,6 @@ export interface EventMethods {
onAnyAfterHit?: MoveEventMethods['onAfterHit'];
onAnyAfterSetStatus?: (this: Battle, status: Condition, target: Pokemon, source: Pokemon, effect: Effect) => void;
onAnyAfterSubDamage?: MoveEventMethods['onAfterSubDamage'];
onAnyAfterSwitchInSelf?: (this: Battle, pokemon: Pokemon) => void;
onAnyAfterUseItem?: (this: Battle, item: Item, pokemon: Pokemon) => void;
onAnyAfterBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: Effect) => void;
onAnyAfterFaint?: (this: Battle, length: number, target: Pokemon, source: Pokemon, effect: Effect) => void;
@ -504,7 +500,6 @@ export interface PokemonEventMethods extends EventMethods {
onAllyAfterHit?: MoveEventMethods['onAfterHit'];
onAllyAfterSetStatus?: (this: Battle, status: Condition, target: Pokemon, source: Pokemon, effect: Effect) => void;
onAllyAfterSubDamage?: MoveEventMethods['onAfterSubDamage'];
onAllyAfterSwitchInSelf?: (this: Battle, pokemon: Pokemon) => void;
onAllyAfterUseItem?: (this: Battle, item: Item, pokemon: Pokemon) => void;
onAllyAfterBoost?: (this: Battle, boost: SparseBoostsTable, target: Pokemon, source: Pokemon, effect: Effect) => void;
onAllyAfterFaint?: (this: Battle, length: number, target: Pokemon, source: Pokemon, effect: Effect) => void;