Commit Graph

998 Commits

Author SHA1 Message Date
pyuk-bot
fa974427ef
Migrate terrains from onTerrain to onResidual (#8232) 2021-04-25 13:00:37 -07:00
Guangcong Luo
f9fdc73133
Support per-pokemon Residual handlers in Side/Field conditions (#8222)
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
2021-04-25 10:55:54 -07:00
pyuk-bot
66c547432b
Fix Parental Bond to modify damage, not base power (#8226) 2021-04-25 12:06:27 -04:00
InAShellnut
9ab4c86fe3
Add Stadium 2, Nintendo Cup 1997, and Nintendo Cup 2000 (#8195)
An implementation of Nintendo Cup 1997, Nintendo Cup 2000, and Pokemon Stadium 2, for Pokemon Showdown. The only thing which has not been implemented was showing the exact health of both Pokemon in Pokemon Stadium 2, however implementing that requires changes to the showdown client. The Nintendo Cup 1997 code was done by Enigami, and the rest was by myself (Shellnuts).

This should fulfill the requirements asked by the following accepted suggestions:
https://www.smogon.com/forums/threads/please-add-a-pok%C3%A9mon-stadium-2-simulator-in-showdown.3679486/
https://www.smogon.com/forums/threads/add-nintendo-cup-1997-and-2000-as-challenge-only-formats.3653454/
2021-04-22 00:54:14 -07:00
pyuk-bot
3639079d1f
Protective Pads should not apply to Gulp Missile (#8207)
Co-authored-by: Leonard Craft III <leonardcraft64@gmail.com>
2021-04-19 12:39:33 -04:00
Leonard Craft III
4818c50374
Fix Transform source Ability leak (#8204) 2021-04-17 15:06:40 -07:00
Kris Johnson
fc60b76c48 Add new Pet Mod of the Season 2021-04-13 20:55:47 -06:00
Annika
a59296cbbb Fix crash in simulator runner 2021-04-11 23:31:58 -07:00
Guangcong Luo
5c3d0f5eae Fix deterministic speed ties
We have apparently been sorting everything by switch-in order this
entire time, not just move redirection. This appears to be a mistake
in #5216

The actual bug fix is just the single line in `comparePriority`,
everything else is just documentation, and a bit of optimization of
how speed ties are resolved.

Fixes #6319
2021-04-10 09:41:22 -07:00
Leonard Craft III
f8cfe3a242 Validator: Don't enforce 3 IV minimum in Hackmons 2021-04-09 23:40:16 -05:00
Leonard Craft III
ba66ffde0f Validator: Fix Behemoth moves 2021-04-09 21:10:38 -05:00
Guangcong Luo
9ee76d7415 Fix crash in FFA forfeiting before Team Preview 2021-04-09 06:13:20 -07:00
Guangcong Luo
6658d65c40 Properly fix Keldeo-R 2021-04-08 14:48:03 -04:00
Guangcong Luo
1ae9f90393 Possibly fix a format corruption issue 2021-04-08 08:07:30 -07:00
Guangcong Luo
73353990ad Add some safety for formats
A weird bug with OU lacking Team Preview might be caused by this.
2021-04-08 07:23:15 -07:00
Guangcong Luo
fc2c43e1ea Fix crash when forfeiting before battle start 2021-04-08 07:13:31 -07:00
Guangcong Luo
5233559183 Refactor Dex types 2021-04-08 07:08:56 -07:00
Guangcong Luo
34880b65e1 Sim: Revert AfterBoost event change
It turns out I accidentally had whole word matching turned on when
I searched the codebase for `AfterBoost`, so I missed all the
`onAfterBoost` uses. :[
2021-04-08 06:22:31 -07:00
Guangcong Luo
2a5c80e707 Sim: Only run AfterBoost when boosts succeed 2021-04-08 06:08:43 -07:00
Guangcong Luo
05e28925a7 Fix Mega Rayquaza and Keldeo-R validation 2021-04-08 06:02:43 -07:00
Guangcong Luo
53924a9ca5 Fix Pokébilities and Shared Power
This fixes `pokemon.addVolatile('ability:intimidate')` to be able to
add abilities as volatile statuses, for use in OMs that want to have
more than one ability at a time.

Items are now also supported, for instance as
`pokemon.addVolatile('item:choiceband')`.

As usual, abilities and items are not written with this functionality
in mind, so it's the OM's job to fix any crashes caused by
abilities/items not expecting to be used as volatiles.
2021-04-08 05:38:36 -07:00
Guangcong Luo
13189fdb02
Update Dex API (#8181)
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
2021-04-08 03:00:37 -07:00
pyuk-bot
636ebdd7f8
FFA: Apply GMax side conditions to all foes' sides (#8184)
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2021-04-06 20:55:43 -07:00
pyuk-bot
912a2c6677
Send ally request data in multi battles (#8175) 2021-04-03 23:02:44 -07:00
Guangcong Luo
7072a87010 Fix canceling in 4-player games 2021-04-03 19:14:09 -07:00
pyuk-bot
817addfd62
Fix Follow Me, etc. in FFA (#8173) 2021-04-03 15:16:27 -07:00
HoeenHero
47d8bd4d82
Fix hazards not applying if the target side is fainted (#8171)
Co-authored-by: pyuk-bot <msaimrkon@gmail.com>
2021-04-03 15:15:13 -07:00
pyuk-bot
2b9bb1c4c4
Multi Battle: Run residuals on p3 and p4 (#8170) 2021-04-03 02:44:38 -07:00
pyuk-bot
19111bda58
FFA: Don't retarget from a fainted target (#8166) 2021-04-03 01:50:00 -07:00
pyuk-bot
956daf89b6
FFA: Properly set hazards against all foes' sides (#8165) 2021-04-02 23:15:19 -07:00
Guangcong Luo
ef16d0f4d4 Fix FFA games not ending on some forfeits 2021-04-03 02:02:40 -04:00
Guangcong Luo
694e79eea8 Add form for inviting players
(This makes it so you don't need to use console commands)
2021-04-02 23:00:30 -07:00
urkerab
d4e6fb227c
Fix Aromatherapy failing if the right slot has a Substitute (#8151) 2021-04-02 17:35:04 -04:00
Guangcong Luo
1acffa98b3 Fix forfeiting in FFA 2021-04-01 14:46:00 -07:00
Guangcong Luo
86df524adc Support forfeiting in free-for-all battles
I honestly don't understand HOW it works, but it definitely works.
2021-04-01 04:44:16 -07:00
Guangcong Luo
44ef998ecc Implement free-for-all
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.
2021-04-01 04:44:16 -07:00
Guangcong Luo
622645cd04 Fix crash in addSideCondition 2021-03-31 22:38:24 -07:00
Spandan Punwatkar
b77d6cb20f
Add simulator support for multi battle (#7929)
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>
2021-03-31 22:22:25 -07:00
Guangcong Luo
39f5717c25 Fix repeate mega evolution bug 2021-03-31 22:16:06 -07:00
Guangcong Luo
3b5e8cbfc2
Refactor for multi battles (#8152) 2021-03-31 20:27:07 -07:00
Guangcong Luo
46ad7ad716 Add some basic documentation on team formats 2021-03-30 18:47:02 -07:00
Guangcong Luo
d4b6ba4c0f Allow passing teams to random formats
The team validator will now complain if try to bring a team to a random
format. Also, if you bypass the validator (such as with
`/importinputlog` or using the JS API directly), you can now use custom
teams in random formats.

Fixes #8144
2021-03-29 10:28:00 -07:00
Guangcong Luo
d18c0a4e1f Refactor more things to use pokemon.allies/foes
(This will make multi battles easier to implement.)
2021-03-28 20:06:18 -07:00
Guangcong Luo
ed454ef76a
Refactor scripts to battle-actions (#8138)
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
2021-03-28 12:01:38 -07:00
Marty-D
afb15b82f0 Validator: Fix blank mismatched forme message 2021-03-26 16:29:34 -04:00
urkerab
82b8b90038
Make Scalemons apply before Tier Shift when they are mashed up (#8051) 2021-03-23 23:17:08 -06:00
Kris Johnson
5e6c259dec
Gen 3/4: Remove HAs in getSpecies (#8134) 2021-03-23 10:19:50 -07:00
HematiteH2O
654a106df4
Megas for All: Slates 30 and 31, balance/bugfixes (#8114)
* 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>
2021-03-23 02:34:41 -06:00
ACakeWearingAHat
333371b709
Add [Gen 8] Random Battle (No Dynamax) (#8111) 2021-03-10 17:19:50 -08:00
Marty-D
d1c80dc60f Validator: Fix Diancie exception
Thanks Anubis!
2021-03-08 12:57:53 -05:00