Mechanics Cud Chew behavior

What type of bug are you reporting? Mechanics

What is the bug?
If a pokemon with cud chew eats a berry initially as a result of poison tick damage and not direct damage, then cud chew will not activate the next turn and the berry will not be re eaten

Are you able to replicate it? If so, how?
Original occurrence is here on turn 6, where tauros eats sitrus (it has cudchew, checked with showteam afterwards and also there isn't a randbats set for taurus without cud chew) as a result from poison tick damage after a sludge bomb, wherein the poison brings it below 50%:
https://replay.pokemonshowdown.com/gen9randombattle-2061902690

Replicated it here, turn 2 poison gas brings taurus below 50 and activates sitrus, next turn cud chew does not activate. It functions normally if the mon is poisoned before/after, only seems to affect if it causes the berry to be eaten:
https://replay.pokemonshowdown.com/gen9ou-2061910058
 
Cud Chew uses on onEnd function to delete the Cud Chew volatile flag at the end of the turn. However, poison damage occurs as part of the "residual" event, which occurs after the "end" event.

Karthik - can I have some information regarding the Cud Chew crash fix you did here? I wrote the following fix for this bug report which has worked in testing, but I am not sure if I am reintroducing a crashing bug:

Code:
    cudchew: {
        onEatItem(item, pokemon) {
            if (item.isBerry && pokemon.addVolatile('cudchew')) {
                pokemon.volatiles['cudchew'].berry = item;
            }
        },
        condition: {
            noCopy: true,
            duration: 2,
            onRestart() {
                this.effectState.duration = 2;
            },
            onResidualOrder: 28,
            onResidualSubOrder: 2,
            onResidual(pokemon) {
                if (pokemon.hp) {
                    const item = this.effectState.berry;
                    this.add('-activate', pokemon, 'ability: Cud Chew');
                    this.add('-enditem', pokemon, item.name, '[eat]');
                    if (this.singleEvent('Eat', item, null, pokemon, null, null)) {
                        this.runEvent('EatItem', pokemon, null, null, item);
                    }
                    if (item.onEat) pokemon.ateBerry = true;
                    delete pokemon.volatiles['cudchew'];
                }
            },
        },
        flags: {},
        name: "Cud Chew",
        rating: 2,
        num: 291,
    },
 

Karthik

time heals all
is a Programmeris a Battle Simulator Moderator
Karthik - can I have some information regarding the Cud Chew crash fix you did here? I wrote the following fix for this bug report which has worked in testing, but I am not sure if I am reintroducing a crashing bug:
I don't really remember what the crash was now, that's my fault for not putting it in the pr description. Using onResidual is probably fine, the volatile originally didn't even have the Residual order stuff which is why it was using onEnd.
 
Wonderful - I'll open a PR to fix this now, then.

Edit: I'm going to need someone who can test on-cart behavior of Cud Chew.
1. If Tauros (Cud Chew) eats Sitrus Berry on Turn X, and on Turn X+1 an Unnerve user switches in, does Cud Chew fail? If so, what happens, then, once the Unnerve user switches out?
* If yes to question 1, then I still need to figure something out because my test is failing there.
2. If Tauros (Cud Chew) eats Sitrus Berry on Turn X, and on Turn X+1 a Neutralizing Gas user switches in, does Cud Chew fail? If so, what happens, then, once the Neutralizing Gas user switches out?
* If yes to question 1 and Cud Chew does not activate a second time on NG's switch-out, then simply deleting the Cud Chew volatile in Neutralizing Gas's onPreStart event will solve this (similar to how NG deletes the Slow Start volatile here).
3. If Tauros (Cud Chew) eats Sitrus Berry on Turn X while a Neutralizing Gas user is active, does Cud Chew fail (whether or not NG user is still active on Turn X+1)?
* I expect the answer to be yes - if so, then my fixes are good to go.
 
Last edited:

DaWoblefet

Demonstrably so
is a Battle Simulator Administratoris a Community Leaderis a Programmeris a Community Contributoris a Top Researcheris a Top Tiering Contributoris a Social Media Contributor Alumnus
PS Admin
Wonderful - I'll open a PR to fix this now, then.

Edit: I'm going to need someone who can test on-cart behavior of Cud Chew.
1. If Tauros (Cud Chew) eats Sitrus Berry on Turn X, and on Turn X+1 an Unnerve user switches in, does Cud Chew fail? If so, what happens, then, once the Unnerve user switches out?
* If yes to question 1, then I still need to figure something out because my test is failing there.
2. If Tauros (Cud Chew) eats Sitrus Berry on Turn X, and on Turn X+1 a Neutralizing Gas user switches in, does Cud Chew fail? If so, what happens, then, once the Neutralizing Gas user switches out?
* If yes to question 1 and Cud Chew does not activate a second time on NG's switch-out, then simply deleting the Cud Chew volatile in Neutralizing Gas's onPreStart event will solve this (similar to how NG deletes the Slow Start volatile here).
3. If Tauros (Cud Chew) eats Sitrus Berry on Turn X while a Neutralizing Gas user is active, does Cud Chew fail (whether or not NG user is still active on Turn X+1)?
* I expect the answer to be yes - if so, then my fixes are good to go.
1a) No, Unnerve doesn't prevent Cud Chew from eating Berries.
2a) Correct, Cud Chew won't activate on the turn it would eat its Berry while Neutralizing Gas is on the field.
2b) Yes, Cud Chew eats the Berry the turn after Neutralizing Gas switches out. You can wait multiple turns and it will have the same result as waiting one turn.
3) Cud Chew misses the timing and will not eat a second Berry if Neutralizing Gas was active at the time the Cud Chew Pokemon ate its Berry.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top