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

Refactor Chloroblast recoil #10501

Open
wants to merge 6 commits into
base: master
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
2 changes: 1 addition & 1 deletion config/formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ export const Formats: import('../sim/dex-formats').FormatList = [
move.critRatio = (move.critRatio || 1) + (forte.critRatio || 1) - 1;
const VALID_PROPERTIES = [
'alwaysHit', 'basePowerCallback', 'breaksProtect', 'drain', 'forceSTAB', 'forceSwitch', 'hasCrashDamage', 'hasSheerForce',
'ignoreAbility', 'ignoreAccuracy', 'ignoreDefensive', 'ignoreEvasion', 'ignoreImmunity', 'mindBlownRecoil', 'noDamageVariance',
'ignoreAbility', 'ignoreAccuracy', 'ignoreDefensive', 'ignoreEvasion', 'ignoreImmunity', 'mindBlownRecoil', 'chloroblastRecoil', 'noDamageVariance',
'ohko', 'overrideDefensivePokemon', 'overrideDefensiveStat', 'overrideOffensivePokemon', 'overrideOffensiveStat', 'pseudoWeather',
'recoil', 'selfdestruct', 'selfSwitch', 'sleepUsable', 'smartTarget', 'stealsBoosts', 'thawsTarget', 'volatileStatus', 'willCrit',
] as const;
Expand Down
2 changes: 1 addition & 1 deletion data/mods/gen9ssb/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ export const Scripts: ModdedBattleScriptsData = {
this.battle.add('-hitcount', targets[0], hit - 1);
}

if ((move.recoil || move.id === 'chloroblast') && move.totalDamage) {
if ((move.recoil || move.chloroblastRecoil) && move.totalDamage) {
const hpBeforeRecoil = pokemon.hp;
this.battle.damage(this.calcRecoilDamage(move.totalDamage, move, pokemon), pokemon, pokemon, 'recoil');
if (pokemon.hp <= pokemon.maxhp / 2 && hpBeforeRecoil > pokemon.maxhp / 2) {
Expand Down
4 changes: 2 additions & 2 deletions data/moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,7 @@ export const Moves: import('../sim/dex-moves').MoveDataTable = {
pp: 5,
priority: 0,
flags: {protect: 1, mirror: 1, metronome: 1},
// Recoil implemented in battle-actions.ts
chloroblastRecoil: [1, 2],
secondary: null,
target: "normal",
type: "Grass",
Expand Down Expand Up @@ -19036,7 +19036,7 @@ export const Moves: import('../sim/dex-moves').MoveDataTable = {
} else {
this.add('-activate', target, 'move: Substitute', '[damage]');
}
if (move.recoil || move.id === 'chloroblast') {
if (move.recoil || move.chloroblastRecoil) {
this.damage(this.actions.calcRecoilDamage(damage, move, source), source, target, 'recoil');
}
if (move.drain) {
Expand Down
4 changes: 2 additions & 2 deletions sim/battle-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ export class BattleActions {
this.battle.add('-hitcount', targets[0], hit - 1);
}

if ((move.recoil || move.id === 'chloroblast') && move.totalDamage) {
if ((move.recoil || move.chloroblastRecoil) && move.totalDamage) {
const hpBeforeRecoil = pokemon.hp;
this.battle.damage(this.calcRecoilDamage(move.totalDamage, move, pokemon), pokemon, pokemon, 'recoil');
if (pokemon.hp <= pokemon.maxhp / 2 && hpBeforeRecoil > pokemon.maxhp / 2) {
Expand Down Expand Up @@ -1403,7 +1403,7 @@ export class BattleActions {
}

calcRecoilDamage(damageDealt: number, move: Move, pokemon: Pokemon): number {
if (move.id === 'chloroblast') return Math.round(pokemon.maxhp / 2);
if (move.chloroblastRecoil) return Math.round(pokemon.maxhp * move.chloroblastRecoil[0] / move.chloroblastRecoil[1]);
return this.battle.clampIntRange(Math.round(damageDealt * move.recoil![0] / move.recoil![1]), 1);
}

Expand Down
1 change: 1 addition & 0 deletions sim/dex-moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export interface MoveData extends EffectData, MoveEventMethods, HitEffect {
recoil?: [number, number];
drain?: [number, number];
mindBlownRecoil?: boolean;
chloroblastRecoil?: [number, number];
stealsBoosts?: boolean;
struggleRecoil?: boolean;
secondary?: SecondaryEffect | null;
Expand Down
Loading