pokemon-showdown/data/mods/fusionevolutionuu/conditions.ts
Guangcong Luo f9fdc73133
Support per-pokemon Residual handlers in Side/Field conditions (#8222)
For side conditions, `onStart`/`onRestart`/`onResidual`/`onEnd`
have been renamed `onSideStart`/`onSideRestart`/`onSideResidual`/`onSideEnd`,
with the `onResidualOrder` properties renamed `onSideResidualOrder`.

For field conditions, `onStart`/`onRestart`/`onResidual`/`onEnd`
have been renamed `onFieldStart`/`onFieldRestart`/`onFieldResidual`/`onFieldEnd`,
with the `onResidualOrder` properties renamed `onFieldResidualOrder`.

(The `onField` and `onSide` part helps make it clear to the type system
that the first argument is a Field or Side, not a Pokemon.)

Side and field conditions can now use `onResidual` to tick separately
on each pokemon in Speed order. `onResidualOrder` (the per-pokemon
tick) can be timed separate from `onSideResidualOrder` (the
per-condition tick), allowing conditions to end at a different priority
than they tick per-pokemon.

Relatedly, `onTeamPreview` and `onStart` in formats now need to be
`onFieldTeamPreview` and `onFieldStart`.

Unrelatedly, `effectData` has been renamed `effectState`, and the
corresponding state containers (`pokemon.statusData`,
`pokemon.speciesData`, `pokemon.itemData`, `pokemon.abilityData`,
`field.weatherData`, `field.terrainData`) have been similarly renamed. I
renamed the types a while ago, but I was holding off renaming the fields
because it would be a breaking change. But this is a breaking change
anyway, so we might as well do it now.

Note: `onResidual` will tick even on `onSideEnd` turns, although
`onSideResidual` won't. When refactoring weather, remember to
check `this.state.duration` so you don't deal weather damage on the
ending turn.

Intended as a better fix for #8216
2021-04-25 10:55:54 -07:00

132 lines
3.8 KiB
TypeScript

export const Conditions: {[k: string]: ModdedConditionData} = {
// Status conditions slightly tweaked to exclude Therapeutic
brn: {
name: 'brn',
effectType: 'Status',
onStart(target, source, sourceEffect) {
if (sourceEffect && sourceEffect.id === 'flameorb') {
this.add('-status', target, 'brn', '[from] item: Flame Orb');
target.m.orbItemStatus = true;
} else if (sourceEffect && sourceEffect.effectType === 'Ability') {
this.add('-status', target, 'brn', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
} else {
this.add('-status', target, 'brn');
}
},
// Damage reduction is handled directly in the sim/battle.js damage function
onResidualOrder: 9,
onResidual(pokemon) {
if (!pokemon.hasAbility('therapeutic')) {
this.damage(pokemon.baseMaxhp / 16);
}
},
},
par: {
name: 'par',
effectType: 'Status',
onStart(target, source, sourceEffect) {
if (sourceEffect && sourceEffect.effectType === 'Ability') {
this.add('-status', target, 'par', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
} else {
this.add('-status', target, 'par');
}
},
onModifySpe(spe, pokemon) {
if (!pokemon.hasAbility(['quickfeet', 'therapeutic'])) {
return this.chainModify(0.5);
}
},
onBeforeMovePriority: 1,
onBeforeMove(pokemon) {
if (!pokemon.hasAbility('therapeutic')) {
if (this.randomChance(1, 4)) {
this.add('cant', pokemon, 'par');
return false;
}
}
},
},
frz: {
name: 'frz',
effectType: 'Status',
onStart(target, source, sourceEffect) {
if (sourceEffect && sourceEffect.effectType === 'Ability') {
this.add('-status', target, 'frz', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
} else {
this.add('-status', target, 'frz');
}
if (target.species.name === 'Shaymin-Sky' && target.baseSpecies.baseSpecies === 'Shaymin') {
target.formeChange('Shaymin', this.effect, true);
}
},
onBeforeMovePriority: 10,
onBeforeMove(pokemon, target, move) {
if (move.flags['defrost']) return;
if (this.randomChance(1, 5)) {
pokemon.cureStatus();
return;
}
if (!pokemon.hasAbility('therapeutic')) {
this.add('cant', pokemon, 'frz');
return false;
}
},
onModifyMove(move, pokemon) {
if (move.flags['defrost']) {
this.add('-curestatus', pokemon, 'frz', '[from] move: ' + move);
pokemon.setStatus('');
}
},
onHit(target, source, move) {
if (move.thawsTarget || move.type === 'Fire' && move.category !== 'Status') {
target.cureStatus();
}
},
},
psn: {
name: 'psn',
effectType: 'Status',
onStart(target, source, sourceEffect) {
if (sourceEffect?.effectType === 'Ability') {
this.add('-status', target, 'psn', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
this.effectState.sourceEffect = sourceEffect.id;
} else {
this.add('-status', target, 'psn');
}
},
onResidualOrder: 9,
onResidual(pokemon) {
if (!pokemon.hasAbility('therapeutic')) {
this.damage(pokemon.baseMaxhp / 8);
}
},
},
tox: {
name: 'tox',
effectType: 'Status',
onStart(target, source, sourceEffect) {
this.effectState.stage = 0;
if (sourceEffect && sourceEffect.id === 'toxicorb') {
this.add('-status', target, 'tox', '[from] item: Toxic Orb');
target.m.orbItemStatus = true;
} else if (sourceEffect && sourceEffect.effectType === 'Ability') {
this.add('-status', target, 'tox', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
} else {
this.add('-status', target, 'tox');
}
},
onSwitchIn() {
this.effectState.stage = 0;
},
onResidualOrder: 9,
onResidual(pokemon) {
if (this.effectState.stage < 15) {
this.effectState.stage++;
}
if (!pokemon.hasAbility('therapeutic')) {
this.damage(this.clampIntRange(pokemon.baseMaxhp / 16, 1) * this.effectState.stage);
}
},
},
};