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 berries' events and Fix Emergency Exit's interactions with hazards and residuals #10902

Open
wants to merge 94 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8116015
stop
pacmanboss256 May 20, 2021
e72a429
not sure how else to check if a mon hits itself
pacmanboss256 Jun 4, 2021
abc1153
m
pacmanboss256 Jun 4, 2021
3771656
okay should be updated after berry check
pacmanboss256 Jun 4, 2021
d3dcfff
clever solution
pacmanboss256 Jun 7, 2021
44b3b39
fix test
pacmanboss256 Jun 7, 2021
74036d7
whoops need to add this back in in case no damage was dealt
pacmanboss256 Jun 7, 2021
d48244b
Update battle.ts
pacmanboss256 Jun 7, 2021
ed137f9
made sure non hp restoring berries would not be affected
pacmanboss256 Jun 7, 2021
1df721e
rebase
pacmanboss256 Jun 16, 2021
265b300
fix merge conflicts
pacmanboss256 Sep 30, 2021
2edc5ef
fix unnerve interaction
pacmanboss256 Oct 29, 2021
f12b94f
refactor berriesd
pacmanboss256 Nov 1, 2021
c27ba68
fix knock off interactions and activate on residual damage
pacmanboss256 Nov 4, 2021
59317e4
Unnerve fixes
pacmanboss256 Nov 6, 2021
d035e17
final unnerve fixes
pacmanboss256 Nov 6, 2021
2b60963
fix stat pinch berries
pacmanboss256 Nov 6, 2021
9343789
added new event, everything but berserk works
pacmanboss256 Nov 6, 2021
73a6652
fixed berserk
pacmanboss256 Nov 7, 2021
59398c3
fix merge, clear up the test, change the damage indication
pacmanboss256 Jan 23, 2022
575a7cb
revert a change I was working on
pacmanboss256 Jan 23, 2022
bd8644d
remove unneccesary code
pacmanboss256 Apr 24, 2022
9296a02
change event handlers to use effect.id, unsure if a few berries that …
pacmanboss256 Apr 24, 2022
f857ddd
revert unnerve changes, they weren't necessary
pacmanboss256 Apr 24, 2022
48f37dc
final few edits
pacmanboss256 Jul 22, 2022
e35c167
fix formatting
pacmanboss256 Jul 22, 2022
eaa23cb
fix failing tests
pacmanboss256 Jul 22, 2022
c445e2d
clean up
pacmanboss256 Jul 22, 2022
fe1bb8b
clean up one last change
pacmanboss256 Jul 22, 2022
5254721
fix index file formatting
pacmanboss256 Jul 23, 2022
17b4d39
remove unnecessary code
pacmanboss256 Jul 24, 2022
428747c
revert pokemon.ts, fix some formatting
pacmanboss256 Jul 25, 2022
0ad2723
pull from master
pacmanboss256 Jul 30, 2022
d0f42e7
stop
pacmanboss256 May 20, 2021
7f30cb4
not sure how else to check if a mon hits itself
pacmanboss256 Jun 4, 2021
737dd8c
m
pacmanboss256 Jun 4, 2021
0fdd63b
okay should be updated after berry check
pacmanboss256 Jun 4, 2021
5bdf2b9
clever solution
pacmanboss256 Jun 7, 2021
a63ed7b
fix test
pacmanboss256 Jun 7, 2021
0433467
whoops need to add this back in in case no damage was dealt
pacmanboss256 Jun 7, 2021
b3d3ec7
Update battle.ts
pacmanboss256 Jun 7, 2021
4fbc95c
made sure non hp restoring berries would not be affected
pacmanboss256 Jun 7, 2021
972cdaf
rebase
pacmanboss256 Jun 16, 2021
a1ffd45
fix merge conflicts
pacmanboss256 Sep 30, 2021
8ed4c46
fix unnerve interaction
pacmanboss256 Oct 29, 2021
5bc13ed
refactor berriesd
pacmanboss256 Nov 1, 2021
f712362
fix knock off interactions and activate on residual damage
pacmanboss256 Nov 4, 2021
4016f5e
Unnerve fixes
pacmanboss256 Nov 6, 2021
d8fe833
final unnerve fixes
pacmanboss256 Nov 6, 2021
59ebed5
fix stat pinch berries
pacmanboss256 Nov 6, 2021
3e0d9c1
added new event, everything but berserk works
pacmanboss256 Nov 6, 2021
a0a8186
fixed berserk
pacmanboss256 Nov 7, 2021
71947b2
fix merge, clear up the test, change the damage indication
pacmanboss256 Jan 23, 2022
2877af2
revert a change I was working on
pacmanboss256 Jan 23, 2022
98f85eb
remove unneccesary code
pacmanboss256 Apr 24, 2022
802ed54
change event handlers to use effect.id, unsure if a few berries that …
pacmanboss256 Apr 24, 2022
5fa4216
revert unnerve changes, they weren't necessary
pacmanboss256 Apr 24, 2022
7381a8f
final few edits
pacmanboss256 Jul 22, 2022
340575f
fix formatting
pacmanboss256 Jul 22, 2022
fb2949c
fix failing tests
pacmanboss256 Jul 22, 2022
c969be8
clean up
pacmanboss256 Jul 22, 2022
7867930
clean up one last change
pacmanboss256 Jul 22, 2022
19fd397
fix index file formatting
pacmanboss256 Jul 23, 2022
37de20d
remove unnecessary code
pacmanboss256 Jul 24, 2022
199f13d
revert pokemon.ts, fix some formatting
pacmanboss256 Jul 25, 2022
f289aa8
fix merge conflicts
pacmanboss256 Aug 9, 2022
3714686
fix merge conflicts and rebase
pacmanboss256 Aug 9, 2022
32221fe
Merge branch 'master' of https://github.com/smogon/pokemon-showdown i…
pacmanboss256 Aug 10, 2022
d605067
Merge branch 'master' of https://github.com/smogon/pokemon-showdown i…
pacmanboss256 Dec 6, 2022
edf0e44
Fix test RNG Seed so it works again
pacmanboss256 Dec 6, 2022
b133e52
unskip other tests
pacmanboss256 Dec 6, 2022
8eace48
fix merge conflicts and berserk/anger shell
pacmanboss256 Jul 21, 2023
1ee3c41
whoops forgot to stage this
pacmanboss256 Jul 21, 2023
d07dbd9
merge conflicts
pacmanboss256 Jul 21, 2023
2e13ca0
Fix Emergency Exit's interactions with hazards and residuals
andrebastosdias Feb 13, 2025
0ab7d74
Unskip failing test
andrebastosdias Feb 13, 2025
4abb1f9
Fix test message
andrebastosdias Feb 13, 2025
da724f9
ID fix
andrebastosdias Feb 13, 2025
78247e6
Add self confusion test
andrebastosdias Feb 13, 2025
905a816
Fix more things on tests
andrebastosdias Feb 13, 2025
81450f6
Merge remote-tracking branch 'pacmanboss256/confusion-berry-trigger-f…
andrebastosdias Feb 13, 2025
8f6bec9
Fix after merge
andrebastosdias Feb 13, 2025
7bf4c0a
Revert space
andrebastosdias Feb 13, 2025
d02c6c4
Quick fix for Residual SubOrder
andrebastosdias Feb 13, 2025
4274042
Fix remaining test
andrebastosdias Feb 14, 2025
0048f9e
Add comment
andrebastosdias Feb 14, 2025
485bb50
Add tests
andrebastosdias Feb 14, 2025
27a2d60
Dis-refactor switchFlag
andrebastosdias Feb 14, 2025
c9ec912
Final fix
andrebastosdias Feb 14, 2025
2bda281
Fix Gen 3 berries
andrebastosdias Feb 14, 2025
6664318
Merge branch 'master' into emergency-exit
andrebastosdias Feb 16, 2025
7c87d8b
Run before fainted condition
andrebastosdias Feb 16, 2025
dd3cc89
Rename event to AfterDamage
andrebastosdias Feb 17, 2025
6b5fd2a
Merge branch 'master' into emergency-exit
andrebastosdias Feb 17, 2025
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
30 changes: 20 additions & 10 deletions data/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,7 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
}
},
onTryEatItem(item) {
const healingItems = [
'aguavberry', 'enigmaberry', 'figyberry', 'iapapaberry', 'magoberry', 'sitrusberry', 'wikiberry', 'oranberry', 'berryjuice',
];
if (healingItems.includes(item.id)) {
if (item.isBerry || item.id === 'berryjuice') {
return this.effectState.checkedAngerShell;
}
return true;
Expand All @@ -169,6 +166,8 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
const damage = move.multihit ? move.totalDamage : lastAttackedBy.damage;
if (target.hp <= target.maxhp / 2 && target.hp + damage > target.maxhp / 2) {
this.boost({atk: 1, spa: 1, spe: 1, def: -1, spd: -1}, target, target);
const item = target.getItem();
if (item.isBerry || item.id === 'berryjuice') this.runEvent('AfterDamage', target, null, null, damage);
}
},
flags: {},
Expand Down Expand Up @@ -413,10 +412,7 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
}
},
onTryEatItem(item) {
const healingItems = [
'aguavberry', 'enigmaberry', 'figyberry', 'iapapaberry', 'magoberry', 'sitrusberry', 'wikiberry', 'oranberry', 'berryjuice',
];
if (healingItems.includes(item.id)) {
if (item.isBerry || item.id === 'berryjuice') {
return this.effectState.checkedBerserk;
}
return true;
Expand All @@ -429,6 +425,8 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
const damage = move.multihit && !move.smartTarget ? move.totalDamage : lastAttackedBy.damage;
if (target.hp <= target.maxhp / 2 && target.hp + damage > target.maxhp / 2) {
this.boost({spa: 1}, target, target);
const item = target.getItem();
if (item.isBerry || item.id === 'berryjuice') this.runEvent('AfterDamage', target, null, null, damage);
}
},
flags: {},
Expand Down Expand Up @@ -1214,12 +1212,18 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
if (!this.canSwitch(target.side) || target.forceSwitchFlag || target.switchFlag) return;
for (const side of this.sides) {
for (const active of side.active) {
active.switchFlag = false;
if (!active.abilityState.emergencyExiting) {
active.switchFlag = false;
}
}
}
target.switchFlag = true;
this.effectState.emergencyExiting = true;
this.add('-activate', target, 'ability: Emergency Exit');
},
onEnd() {
delete this.effectState.emergencyExiting;
},
flags: {},
name: "Emergency Exit",
rating: 1,
Expand Down Expand Up @@ -5429,12 +5433,18 @@ export const Abilities: import('../sim/dex-abilities').AbilityDataTable = {
if (!this.canSwitch(target.side) || target.forceSwitchFlag || target.switchFlag) return;
for (const side of this.sides) {
for (const active of side.active) {
active.switchFlag = false;
if (!active.abilityState.emergencyExiting) {
active.switchFlag = false;
}
}
}
target.switchFlag = true;
this.effectState.emergencyExiting = true;
this.add('-activate', target, 'ability: Wimp Out');
},
onEnd() {
delete this.effectState.emergencyExiting;
},
flags: {},
name: "Wimp Out",
rating: 1,
Expand Down
145 changes: 117 additions & 28 deletions data/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 80,
type: "Dragon",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -269,9 +275,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 100,
type: "Ground",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -434,7 +446,14 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
fling: {
basePower: 30,
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 2) {
if (this.runEvent('TryHeal', pokemon) && pokemon.useItem()) {
this.heal(20);
}
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 2) {
if (this.runEvent('TryHeal', pokemon, null, this.effect, 20) && pokemon.useItem()) {
this.heal(20);
Expand Down Expand Up @@ -1839,9 +1858,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 80,
type: "Bug",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -2157,9 +2182,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 100,
type: "Ice",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -2613,9 +2644,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 80,
type: "Dark",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -2955,9 +2992,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 100,
type: "Flying",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -3090,9 +3133,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 100,
type: "Grass",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -3386,9 +3435,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 80,
type: "Ghost",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -4043,7 +4098,12 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 80,
type: "Poison",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
Expand Down Expand Up @@ -4183,9 +4243,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 100,
type: "Poison",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -5093,13 +5159,19 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 100,
type: "Fighting",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onEat(pokemon) {
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onEat() {
this.boost({spe: 1});
},
num: 203,
Expand Down Expand Up @@ -5319,7 +5391,12 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 80,
type: "Psychic",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
Expand Down Expand Up @@ -5542,9 +5619,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 100,
type: "Psychic",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down Expand Up @@ -7239,9 +7322,15 @@ export const Items: import('../sim/dex-items').ItemDataTable = {
basePower: 80,
type: "Rock",
},
onUpdate(pokemon) {
onStart(pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
onAfterDamage(damage, pokemon) {
if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 &&
pokemon.hasAbility('gluttony') && pokemon.abilityState.gluttony)) {
pokemon.eatItem();
}
},
Expand Down
Loading