Skip to content

Commit 945f130

Browse files
authored
OMs: Fix innates meant to activate on switch-in (#10976)
* Prevent Toxic Spikes from activating after being absorbed * Fix everything else * OMs: Fix innates meant to activate on switch-in
1 parent 2f0ce9c commit 945f130

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

config/formats.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,8 @@ export const Formats: import('../sim/dex-formats').FormatList = [
803803
let format = this.format;
804804
if (!format.getSharedPower) format = this.dex.formats.get('gen9sharedpower');
805805
for (const ability of format.getSharedPower!(pokemon)) {
806-
const effect = 'ability:' + ability;
807-
pokemon.volatiles[effect] = this.initEffectState({ id: this.toID(effect), target: pokemon });
806+
const effect = 'ability:' + this.toID(ability);
807+
pokemon.volatiles[effect] = this.initEffectState({ id: effect, target: pokemon });
808808
if (!pokemon.m.abils) pokemon.m.abils = [];
809809
if (!pokemon.m.abils.includes(effect)) pokemon.m.abils.push(effect);
810810
}
@@ -1611,8 +1611,8 @@ export const Formats: import('../sim/dex-formats').FormatList = [
16111611
if (pokemon.m.innates) {
16121612
for (const innate of pokemon.m.innates) {
16131613
if (pokemon.hasAbility(innate)) continue;
1614-
const effect = 'ability:' + innate;
1615-
pokemon.volatiles[effect] = this.initEffectState({ id: this.toID(effect), target: pokemon });
1614+
const effect = 'ability:' + this.toID(innate);
1615+
pokemon.volatiles[effect] = this.initEffectState({ id: effect, target: pokemon });
16161616
}
16171617
}
16181618
},
@@ -1805,8 +1805,8 @@ export const Formats: import('../sim/dex-formats').FormatList = [
18051805
if (!pokemon.m.sharedItemsUsed) pokemon.m.sharedItemsUsed = [];
18061806
for (const item of format.getSharedItems!(pokemon)) {
18071807
if (pokemon.m.sharedItemsUsed.includes(item)) continue;
1808-
const effect = 'item:' + item;
1809-
pokemon.volatiles[effect] = this.initEffectState({ id: this.toID(effect), target: pokemon });
1808+
const effect = 'item:' + this.toID(item);
1809+
pokemon.volatiles[effect] = this.initEffectState({ id: effect, target: pokemon });
18101810
}
18111811
},
18121812
},
@@ -2611,8 +2611,8 @@ export const Formats: import('../sim/dex-formats').FormatList = [
26112611
let format = this.format;
26122612
if (!format.getSharedPower) format = this.dex.formats.get('gen9sharedpower');
26132613
for (const ability of format.getSharedPower!(pokemon)) {
2614-
const effect = 'ability:' + ability;
2615-
pokemon.volatiles[effect] = this.initEffectState({ id: this.toID(effect), target: pokemon });
2614+
const effect = 'ability:' + this.toID(ability);
2615+
pokemon.volatiles[effect] = this.initEffectState({ id: effect, target: pokemon });
26162616
if (!pokemon.m.abils) pokemon.m.abils = [];
26172617
if (!pokemon.m.abils.includes(effect)) pokemon.m.abils.push(effect);
26182618
}

data/mods/partnersincrime/scripts.ts

+36
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { Pokemon, Side } from "../../../sim";
2+
import { Field } from "../../../sim/field";
3+
14
export const Scripts: ModdedBattleScriptsData = {
25
gen: 9,
36
inherit: 'gen9',
@@ -64,6 +67,39 @@ export const Scripts: ModdedBattleScriptsData = {
6467
}
6568
}
6669

70+
// effect may have been removed by a prior handler, i.e. Toxic Spikes being absorbed during a double switch
71+
if (handler.state?.target instanceof Pokemon) {
72+
let expectedStateLocation;
73+
if (effect.effectType === 'Ability' && !handler.state.id.startsWith('ability:')) {
74+
expectedStateLocation = handler.state.target.abilityState;
75+
} else if (effect.effectType === 'Item' && !handler.state.id.startsWith('item:')) {
76+
expectedStateLocation = handler.state.target.itemState;
77+
} else if (effect.effectType === 'Status') {
78+
expectedStateLocation = handler.state.target.statusState;
79+
} else {
80+
expectedStateLocation = handler.state.target.volatiles[effect.id];
81+
}
82+
if (expectedStateLocation !== handler.state) {
83+
continue;
84+
}
85+
} else if (handler.state?.target instanceof Side && !handler.state.isSlotCondition) {
86+
if ((handler.state.target.sideConditions[effect.id] !== handler.state)) {
87+
continue;
88+
}
89+
} else if (handler.state?.target instanceof Field) {
90+
let expectedStateLocation;
91+
if (effect.effectType === 'Weather') {
92+
expectedStateLocation = handler.state.target.weatherState;
93+
} else if (effect.effectType === 'Terrain') {
94+
expectedStateLocation = handler.state.target.terrainState;
95+
} else {
96+
expectedStateLocation = handler.state.target.pseudoWeather[effect.id];
97+
}
98+
if (expectedStateLocation !== handler.state) {
99+
continue;
100+
}
101+
}
102+
67103
let handlerEventid = eventid;
68104
if ((handler.effectHolder as Side).sideConditions) handlerEventid = `Side${eventid}`;
69105
if ((handler.effectHolder as Field).pseudoWeather) handlerEventid = `Field${eventid}`;

0 commit comments

Comments
 (0)