It turns out rules need to be added before sides are initialized,
so that they can hook `ModifySpecies` during side initialization.
The proper way to fix this is pretty complex so this is just a hack.
Specifically, randomized formats will now support Max Team Size, Min Source Gen, Adjust Level, Adjust Level Down, and Force Monotype.
This fixes the issue with randomly-generated Multi Battle teams containing six Pokémon, instead of three as desired.
In format events:
`onFieldTeamPreview` has been renamed back to `onTeamPreview`. It's now
a custom event (like `onBegin`), rather than a field event.
Team Preview data has been entirely moved from `onBegin` into
`onTeamPreview`.
`onFieldStart` for formats/rules now happens after Team Preview, rather
than before. Use `onBegin` for things that happen before Team Preview.
`teamLength`, `maxLevel`, `cupLevelLimit`, and `minSourceGen` no longer
exist as properties of `Format`. Instead, they're value rules that
become properties of `RuleTable`, and can be specified as custom rules
and inherited through rulesets like anything else.
See the PR for a full reckoning of changes:
https://github.com/smogon/pokemon-showdown/pull/8267
* [Gen 1] OU Standard rules, fix validator rule name
erm...
* Fix [Gen 1] Japanese OU & Tradebacks OU
- [Gen 1] Japanese OU shouldn't use the Nintendo Cup 1997 Legality unless you want it to be "RG OU" or something. If so, the name should be changed for accuracy.
- [Gen 1] Tradebacks OU shouldn't complex ban those combinations, the Stadium 2 relearner fixes them all.
* I really did do that huh
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
A few uses of `array.sort()` have been left alone:
- sorting in `data/` because they aren't supposed to import anything
- `set-importer` because I still have no clue what that's for and what
dependencies it is/isn't allowed to have
- `sort()` with no arguments used as a lexical sort (at which point
`sortBy` offers no benefits)
All other cases have been replaced with `Utils.sortBy`, which should
be a massive increase in readability.
Sort orders should be much more readable now, without needing to puzzle
through sign issues. The order is always low-to-high, A-to-Z,
true-to-false.
This is the change that renames:
- `Dex.getMove` -> `Dex.moves.get`
- `Dex.getAbility` -> `Dex.abilities.get`
- `Dex.getItem` -> `Dex.items.get`
- `Dex.getSpecies` -> `Dex.species.get`
- `Dex.getEffect` -> `Dex.conditions.get`
- `Dex.getNature` -> `Dex.natures.get`
- `Dex.getType` -> `Dex.types.get`
- `Dex.getFormat` -> `Dex.formats.get`
In addition, some other APIs have been updated:
- `getByID` methods have also been added to every other table.
- `Dex.moves.all()` now gets an array of all moves
- Plus equivalent methods for `abilities`, `items`, `species`, `formats`, `natures`, `types`
- Note: there's no `Dex.conditions.all()`
- new API: `Dex.stats` for naming/iterating stats
- `Dex.getEffectByID` -> `Dex.conditions.getByID`
- `Dex.getType` -> `Dex.types.get`
- `Dex.data.Formats` -> `Dex.data.Rulesets`
- `Dex.formats` -> now an array `Dex.formats.all()`
- `Dex.getRuleTable` -> `Dex.formats.getRuleTable`
- `Dex.validateFormat` -> `Dex.formats.validate`
Team functions have been split off into a new `sim/teams` package:
- `Dex.packTeam` -> `Teams.pack`
- `Dex.fastUnpackTeam` -> `Teams.unpack`
- `Dex.generateTeam` -> `Teams.generate`
- `Dex.stringifyTeam` -> `Teams.export`
`Teams.export` has also been rewritten to better match how it works in client.
This implements #8178
This involves a huge refactor for how battles are constructed, but
it's totally worth it.
Currently, tournaments, challenges, and laddering are unsupported; only
unrated searches work. But it does work, and it's beautiful.
This doesn't include matchmaking support (which had to be removed
for reworking), but it includes everything else.
Co-authored-by: Spandamn <spandan.punwatkar@gmail.com>
Co-authored-by: MacChaeger <msaimrkon@gmail.com>
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
This introduces a new class, BattleActions, available as `battle.actions`,
moving all functions from `data/scripts.ts` to `sim/battle-actions.ts`.
This makes it so that "go to definition" will now work correctly for
functions previously in scripts; we no longer need UnimplementedError,
and there's now a clean conceptual separation between `battle` and
`battle-actions` (whereas the previous distinction between `battle` and
`scripts` was basically nonexistent).
This will be a difficult migration if you maintain a fork with custom
scripted mods. I'm sorry! Migration instructions are here:
https://github.com/smogon/pokemon-showdown/pull/8138
* Megas for All: Minor Ability polish
* Attribute Arena Rock to the proper source
* Don't always animate delayed moves when the user is KOed
* Add visual indicator of which Pokémon currently has Gravitational Pull
* Damage the correct Pokémon with Stealth Rock and G-Max Steelsurge through Gravitational Pull
* Megas for All: Minor Ability polish
* Don't animate delayed moves through Long Whip unless the user is active - it gets very weird if it tries when the user is absent, because most of the animations bring back the user and then it just hangs out indefinitely behind the other Pokémon and... it's very funny but also not correct
* Megas for All: Slate 30 and balance/bugfixes
Adding all four new Abilities from Slate 30 (Pool Floaties, Red Licorice, Stygian Shades and Long Whip), but also fixing issues with various other Abilities, including minor balance changes to Savage, Heavenly Techniques, Body of Water and Forgery, and bugfixes to Forgery (again), Seismic Scream and Settle.
* Megas for All: Slate 30 ability (Long Whip)
This is so convoluted, but it has to be able to stack with itself as many as five times over, so I hope this is okay. Let me know if there's a way to streamline this! (and same for Settle, for that matter)
* Megas for All: Slate 30
* Megas for All: Add slate 30 stones
* Megas for All: Update Court Change
* Megas for All: Add slate 30 Mega Evolutions
* Megas for All: Slate 30 and balance changes
Forgery can no longer fake a Z-Crystal, so the entire section dedicated to making that work is no longer necessary. However, there's a new form of non-groundedness that needs to be added (the new 'poolfloaties' volatile), and I also modified the damage section slightly because Settle and Body of Water have some weird interactions, and this was the best way I could find to handle them with perfect accuracy. (For reference, Settle is meant to use the user's physical Attack stat without actually becoming a physical move for any other intents or purposes, while Body of Water is now about halfway to the Body Press effect but keeps the user's offensive stat changes rather than its defensive ones.)
* Megas for All: Add two new move modifiers
* Megas for All: Add missing trailing comma
* Megas for All: Improve Red Licorice ability
* Update abilities.ts
Okay I do think this was at least part of the problem so I'm gonna address that first
* Update scripts.ts
* Megas for All: Fix Cinccino and Falinks
Just fixing two minor errors that came up since the last time I touched this patch
* Update data/mods/megasforall/abilities.ts
Co-authored-by: Annika <annika0uwu@gmail.com>
* Megas for All: Define bladeMoves only once
(okay I was so tired when I worked on this code and I'm actually very embarrassed to see that there are three of these in quick succession and I only changed two of them ._.
so uh! clearly Annika's suggestion not to define it three separate times in the first place is the right call XP)
* Update data/mods/megasforall/abilities.ts
Co-authored-by: Annika <annika0uwu@gmail.com>
* Update scripts.ts
* Megas for All: Abilities for slate 31 and bugfixes
* Revise some shortDescs so they can fit better
* Accommodate for Illusion in some messages (previously, they gave away the Pokémon's real name)
* Revise Forgery (again) - it can no longer copy Mega Stones, and it no longer wears off when the user is hit
* Improve the functionality of Clairvoyance (for consistency with Future Sight and other delayed moves)
* Preserve type change indicators for SOS and Stance Change (established convention is for every Mega in the mod to have these regardless of whether it has changed type, but they disappear when changing form)
* Make sure Sticky Gel doesn't ignite more than once at a time (has been happening)
* Add an activation message to Stygian Shades to reduce confusion
* Overhaul Long Whip (now compatible with the varying base powers of Triple Axel and Triple Kick; now decides accuracy at the start and guarantees that every subsequent hit will land; now persists after the source faints and behaves more similarly to other delayed moves)
* Add new Abilities from slate 31, the very over-the-top complicated Gravitational Pull and the refreshingly simple Chakra Lock
* Megas for All: Improve functionality of Long Whip
* Megas for All: Slate 31
* Megas for All: Slate 31 stones
* Megas for All: Slate 31 compatibility
Modify all entry hazards to account for Gravitational Pull and Triple Axel and Triple Kick to account for Long Whip
* Megas for All: Add slate 31 forms
Add Mega Torterra, Mega Infernape and Mega Empoleon and revise Mega Zoroark's stats
* Megas for All: Slate 31 moves and balance changes
* Megas for All: Minor Ability corrections
* Megas for All: longWhipBoost
* Update moves.ts
* Megas for All: Fix Long Whip
* Megas for All: Fix Alchemist
SHOOT sorry I skipped over this
Meant to do it in the same commit
That was just a copying error
* Apply suggestions from code review
Aaaaa thank you so much! ;u;
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Megas for All: Condense Long Whip conditions
WOW this saves so much space I never knew you could do that
* Update conditions.ts
Co-authored-by: Annika <annika0uwu@gmail.com>
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Megas for All: Fix three abilities
This changes Blackmail primarily just to be more realistic, but there are also more important bugfixes to Forgery and Masquerade.
The previous version of Masquerade would activate the acquired Ability twice if, as in the case of Intimidate, it was supposed to activate on entry. This is because the Ability was replaced while the Pokémon was still starting, so it activated once when it was acquired (as it would by Skill Swap) and again as the Pokémon was still "entering." This fix makes it so such Abilities only activate once; it's also much neater and easier to edit than the messy version I had before.
The previous version of Forgery had problems whenever the Pokémon's item was consumed at the same time it was hit with a move; it would replace its item with Zoroarkite, then consume the Zoroarkite and be itemless, which in turn left it unable to activate the Ability.
I fixed this by making it acquire the item later on (after it would be consumed), and I also made the Ability itself check for a specific species instead of a specific item at the start, so it should still function in case Zoroarkite is ever not properly replaced (though it's also way more consistent at that now than before).
Let me know if there's anything else I should change about these! After testing, I think they work a lot better now than before, though. C:
* Megas for All: fix Unaware
The custom Ability Body of Water can give the effect of Body Press to special moves, so Unaware needs to ignore an attacker's Special Defense boosts when being attacked.
* Update data/mods/megasforall/abilities.ts
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Update data/mods/megasforall/abilities.ts
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Update abilities.ts
* Megas for All: Add slate 29 abilities
* Megas for All: Add slate 29 stones
* Megas for All: Add slate 29 forms
(That's a lot of fish)
* Megas for All: Add slate 29 moves
and keep Alolan Dugtrio incompatible with Dugtrionite
* Megas for All: Shorten overlong line
* Apply suggestions from code review
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Correct variable name after code review
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Update formats.ts
Ban Dragonitite in Megas for All in line with latest update
* Update abilities.ts
Megas for All: add slate 28 Abilities (Everlasting Winter, Forgery, Clairvoyance and Sleight of Hand)
* Update items.ts
Megas for All: add slate 28 Mega Stones (Ninetalesite, Zoroarkite and Delphoxite)
* Update pokedex.ts
Megas for All: add slate 29 Mega Evolutions (Ninetales-Alola, Zoroark, Delphox); buff Thievul; add battleOnly for Mega Evolutions with multiple base forms (this was causing issues before)
* Update scripts.ts
Megas for All: add new moves to Thievul, Delphox; add form requirement for Mega Ninetales; add compatibility with Mega Zoroark to Mega Evolution and Z-Move scripts
* Update items.ts
Megas for All: rename Delphoxite -> Delphite
* Update pokedex.ts
Megas for All: rename Delphoxite -> Delphite
* Update abilities.ts
Megas for All: correct line length and trailing spaces
* Update items.ts
Megas for All: correcting species string (caught by npm test)
* Update abilities.ts
* Update scripts.ts
* Update abilities.ts
Megas for All: improve Everlasting Winter
(It feels remiss of me not to specify this - Ninetales gets Rain Dance itself, so it would be awkward if it was that easy to overwrite Everlasting Hail even if no one would do it in a serious environment)
I just tested and can confirm this fix works more properly!
* Update data/mods/megasforall/abilities.ts
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Update data/mods/megasforall/abilities.ts
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
* Update data/mods/megasforall/items.ts
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
This is required to add support for Stadium in unit tests. A lot of the
codebase assumes that all mods start with "gen" followed by a number,
but I don't want to touch the others at the moment.
Patch notes (2/13/21):
-Prevent Virizion with 1 attack by preventing Coaching from generating with any other setup move.
-Prevent First Impression from generating with any setup move, for Sirfetch'd.
-Reject Protect if Belly Drum is in the movepool but hasn't been rolled, in an attempt to prevent Belly Drum-less Eiscue.
-Fix post-refactor bug causing heavy-duty boots to generate where it shouldn't
-Glastrier: Icicle Crash over Avalanche
-Keldeo: Muddy Water over Hydro Pump and Scald, added Air Slash.
-Regieleki: Electroweb over Eerie Impulse
-Various level balancing. Pokemon above 56.00% win rate nerfed. Pokemon below 46.00% win rate buffed. Highlights: Moltres-Galar, Regidrago, Calyrex-Shadow, Zacian-C down again, Maractus, Toxapex, Shuckle, etc. up. See pull request for full list of level changes.
Gen 7 Random Doubles: Remove Protect from Typhlosion to prevent Choice Scarf Protect.
This PR
- Brings all Random Battles code up to the standard 120-charaacter line length limit
- Improves readability for all Random Battles code
- Refactors current-gen Random Battles team generation to be more modular and readable
Documentation thanks to @ACakeWearingAHat!
- Various movepool improvements
- Prevent Toxic with setup or Trick Room
- Prevent Rain Dance with RestTalk
- Force Seed Flare and Horn Leech
- Reject Keen Eye
- Reject Intimidate so Shed Skin is rolled
- Fix Toxic/Flame Orb selection
- Improve Leftovers and Life Orb selection
- Various movepool adjustments
- Prevent Substitute + Circle Throw (Poliwrath)
- Improve Protect rejection
- Prevent Water Spout outside of Choice sets (Kyogre)
- Prevent Ice Punch with RestTalk (optimizes Throh and Muk)
- Make RestTalk Throh have Guts
- Make Gardevoir have Trace
- Fix Tinted Lens rejection (Venomoth)
- Improve Gem selection with Unburden
- Increase the bulk cut-off for Focus Sash
- Allow Sturdy leads to roll Custap Berry (Golem)
This was a minor mistake when I was writing this thing up. Since Desync Clause isn't something you replicate in RBY, it is more accurate to describe it as a Mod, in line with the ADV Switch thing.