Commit Graph

158 Commits

Author SHA1 Message Date
Guangcong Luo
3b4d8b3ff0 Split random-teams.js out of scripts.js
Random team generation scripts are no longer in scripts.js, but instead
in a new file random-teams.js.

The scripts are now also no longer run from inside battles, but in a
new team generator object. This makes it easier for external scripts
to generate random teams by running Dex.generateTeam(format).
2017-07-25 02:59:59 -04:00
Guangcong Luo
22186f1903 Improve TypeScript typing
sim/dex.js and sim/prng.js are now valid strict TypeScript! Also they
have slightly less "any" use than before.
2017-05-08 02:58:55 -05:00
Guangcong Luo
6dd58b40d3 Refactor simulator into new sim/ directory
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.

In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
  in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`

In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
2017-05-05 16:48:38 -05:00
Guangcong Luo
d7f180954f Comment out unused Gen 1 setupType 2017-02-23 05:24:45 -06:00
xCrystal
2abd1dbef5 Gen 1 Random Battles: Improve movesets and balance (#3210) 2017-02-22 16:46:32 -06:00
xCrystal
64e742ab9d Gen I: Fix three minor bugs (#3222)
Fix being put to sleep not clearing recharge condition

Fix Supersonic clearing last stored damage

Fix Substitute HP
- In RBY, a Substitute is only knocked out when its HP underflows, but remains alive at 0 HP. Therefore, it's effectively as if the Substitute had 1 more HP than the amount of HP lost in order to set it up.
2017-02-14 21:10:15 -05:00
Guernouille
9c1c4b64e6 Gen I: Fix Challenge Cup DVs (#3059)
SpA and SpD use the same DV, and HP DV is calculated using the 4 other DVs.
In-game, the DV range is [0;15], each point giving 2 points in the stats, so to simulate that we make every DV a multiple of 2 in the [0;30] range.
2017-01-02 14:35:36 -05:00
Guangcong Luo
bf4e3df3b8 Deprecate decision.targetSide/targetPosition
These are no longer used; we now only use targetLoc.
2016-12-26 17:12:40 -05:00
Guangcong Luo
9f4613ea1e Don't use tradeback moves in Gen 1 CC 2016-12-23 12:59:08 -08:00
Ivo Julca
b684db5a81
Gen 1: Improve comments and refactor out volatile data for trap PP rollover 2016-09-17 15:51:05 -05:00
Guangcong Luo
2a90611718 Optimize Gen 1 boostBy 2016-08-18 16:15:09 -05:00
Marty-D
6953200e62 Gen I: Fix boosting resulting in a neutral stat stage 2016-08-18 16:10:15 -04:00
Marty-D
fc86e0ef0a Prevent confusion damage from being a critical hit 2016-05-05 23:44:58 -04:00
Ivo Julca
0281176fd1 Remove usage of Array|Object methods implemented by Sugar.js
Adds a dependency to shim Object.values until it's natively available.
2016-03-09 16:55:34 -05:00
Guangcong Luo
cc7ccd2efe Stop unnecessarily calling update()
pokemon.update() used to be called after pretty much everything, but
now that we've refactored pretty much everything out of it, it's no
longer necessary for most of the situations we call it for.

It currently only updates pokemon.speed, so I've renamed it updateSpeed
for clarity.

We now only update pokemon.speed on switch-in, right before the
residual event, and at the beginning of every turn. This gives
something like a 30% speed-up.
2016-02-17 01:07:22 -06:00
Marty-D
635123c5e2 Gen I: Fix partial-trapping PP display 2016-01-31 15:54:06 -05:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Guangcong Luo
94a67eb243 Fix inaccurate PP use tracking in gen 1 2015-12-19 04:12:31 -05:00
Juanma Serrano
7a8b033bf5 Gen 1 RandBat: Fix teams having 5 mons sometimes
Very small chance that happened in very specific scenarios.
2015-12-17 16:24:56 +01:00
r0730
4dcc422a07 Gen 1: Reduce occurrence of extremely weak team
You won't get more UU if you already have handicapMons, however if you get a lot UU first, you could still get handicapMons.
This fix make sure you wont get handicapMons once you have at least 2 NU/worse (which is already bad enough)
2015-11-18 18:11:34 +08:00
r0730
680a3f3d04 prevent getting >1 handicapMons
NU is worse than UU, so if UU pokemons will be skipped, NU should certainly be skipped as well.
2015-11-14 23:18:24 +08:00
Marty-D
be670b0a68 Gen I: Fix Random Battle set generator
Previously, it would reject every move until there were 4 left in the pool.
2015-11-09 23:13:56 -05:00
Ivo Julca
04c64c143e Cleanup: remove several unused variables 2015-11-07 17:34:21 -05:00
Ivo Julca
90973d5c0c Style fixes
- Cut down excessive spacing
- Add braces to missing conditionals
2015-11-07 17:08:09 -05:00
Ivo Julca
2c2a3bdf58 Fix misplaced cases in random sets generators 2015-11-07 16:50:51 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Juanma Serrano
9cace281b5 Gen 1: Remove Rage accuracy bug, it's not real
Read: http://www.smogon.com/forums/threads/gen-1-and-tradebacks-dev-post-bugs-here.3524844/page-9#post-6416886
2015-09-16 11:55:12 +02:00
Guangcong Luo
5d3cd8263c More updates to Endless Battle Clause
- Gen 1 PP overflow makes a Pokemon stale
- Staleness warnings now specify the staleness source
- Half-staleness also warns, if another pokemon is already stale

Warning on half-staleness helps remind people who seem to think
they've beaten Endless Battle Clause after 5-ish turns, when it
takes 10-20 turns for some staleness verdics, especially if
there's a lot of switching going on.
2015-07-24 03:33:28 -04:00
Ivo Julca
15b925f7e4 RBY-GSC Randbats: Fix high incidence of later gen Pokémon 2015-07-16 13:33:42 -05:00
Ivo Julca
baadd0a92f Overhaul old-gen random team builders
Mainly follow-up for 1deedc595, but also fixes a few bugs.
- BW/GSC/RBY - randomSet: fixed and renamed slot argument.
- BW - randomTeam: crashlogger relative path was set incorrectly.
- BW - randomTeam: PotD Magikarp and Delibird used outdated randomBattleMoves data format.
- RBY - randomTeam: builder was too reject-happy regarding weaknesses (counters prematurely updated).

An improvement of 130% more op/s is observed for RBY randomCCTeam,
with no significative performance regression for randomTeam in any gen.
2015-07-16 12:03:14 -05:00
Marty-D
0f7f238a10 Gen I: Prevent Cosplay Pikachu from appearing in Challenge Cup 2015-07-08 20:27:09 -04:00
Ivo Julca
f18eef39ca Fix Travis build 2015-06-12 03:41:22 -05:00
The Immortal
a4a09021b2 Gen 1: Fix Wrap deducting extra PP
It currently deducts an extra PP on a switch. According to the comment,
PP is not deducted earlier, which is why it was being deducted here.
But this is incorrect. PP is deducted earlier on a switch.
2015-06-09 19:12:43 +04:00
Juanma Serrano
3a4abaf0fc Gen 1: Implement NU listing
Where as SmogDex does not list the NU tier, it is been a long-standing existing tier within Smogon and rby2k10 communities.
The NU tiering serves for Random Battle balance purposes mainly, as there is no UU format.
One could use the change to build a Gen 1 NU tier or similar, though.
2015-06-09 13:42:36 +02:00
Marty-D
29e56b1043 Fix confusion timing after rampage moves
- Gen 1, 2, 5, and 6 cause confusion immediately after the move on the
last turn
- Gen 3 and 4 cause confusion at the end of the turn on the last turn
2015-06-04 09:55:30 -04:00
Juanma Serrano
98dcac1d8b Gen 1: Fix (de)boost behaviour
The routine for burn and para drops is checked after applying boosts to the Pokémon whose turn is not, regardless of the target of the move, when a Pokémon uses a move that results in a stat change.
2015-05-26 18:12:06 +02:00
Juanma Serrano
825fc4b92e Gen 1: Fix bug with stat modifiers over +2 2015-05-26 17:58:37 +02:00
Marty-D
1e5b241c0d Gen I, II: Fix rampage moves
- The lock starts even if the move is blocked by Protect, misses, or the
target is immune
- The lock ends without causing confusion whenever the move cannot be
executed
- When the lock ends normally, confusion begins even if the user is
already confused, and there is no indication that confusion has started
- In Gen 1 the duration is 3-4 turns
2015-05-22 14:30:44 -04:00
SolarisFox
29b961ff69 Style fix: indexOf() comparisons 2015-05-18 15:55:57 -07:00
Juanma Serrano
9e119fa279 Gen 1: Fix status and stats interaction
Stats are recalculated from 0 with a boost, status ignored.
Status drops only applied if status is successfully set.
2015-05-14 10:47:24 +02:00
Juanma Serrano
124ffd0ab0 Gen 1: Implement Rage bug properly 2015-05-13 11:05:44 +02:00
Joimer
ede8c2da7c Fix crash in Gen 1 2015-05-12 18:57:09 +02:00
Juanma Serrano
14cc0ce5fb Gen 1: Refactor stat calculation
In order to emulate Gen 1 perfectly and to let the metagame adapt to the correct mechanics, stat calculation has been refactored.
Burn and Paralyse drop are applied whenever a Pokémon switches in with the status.
Also whenever a Pokémon gets a stat boost, if the Pokémon whose turn is not has the status.
Stat boosts recalculate that stat, minus burn and para drops (that's why Agility ignores para drop and Rest keeps drops).
Additionally, Reflect and Light Screen are only calculated in damage calculation.

Part of this code has been added to battle-engine.js with a gen === 1 conditional to avoid a ton of code repetition that would have been necessary otherwise.
Keep in mind that .modifiedStats for a BattlePokemon and the modifyStat function must only be available for gen 1 games.
2015-05-12 17:58:00 +02:00
Konrad Borowski
2e8e0e0620 Disallow Fissure with Horn Drill in Gen1 randbats. 2015-05-10 18:25:26 +02:00
Marty-D
dca8a8c81a Gen I: Fix explosions on subs with immunity 2015-05-05 16:56:26 -04:00
Juanma Serrano
125144e07e Gen 1: Fix self-destructing moves on immunity
Forgot to mention this change for c53d022e4b
2015-05-05 10:48:56 +02:00
Marty-D
c53d022e4b Fix OHKO moves
- Fix Gen 1/Stadium's accuracy and immunity order
- Fix OHKO moves ignoring Phantom Force
- Add OHKO messages
2015-04-30 13:06:45 -04:00
Kevin Lau
b6808d4476 Fix ignoreImmunity crashes in earlier gens
Unlike battle-engine.js, old gens did not check if move.ignoreImmunity was
undefined/false in their getDamage functions, causing crashes when numbers
were passed in to the function.
2015-04-14 15:22:06 -07:00
Kevin Lau
2e56120ad9 Move refactor: affectedByImmunities -> ignoreImmunity
While move.affectedByImmunities was always a Boolean value to denote if
the move was affected by immunities, move.ignoreImmunity can be a Boolean
value if it ignores or is affected by all type immunities, but also can
act as an object such that !!move.ignoreImmunity[type] means it ignores
immunities of that type.
2015-04-08 00:17:12 -07:00
Juanma Serrano
9c0288a2f3 Gen 1: Fix Counter interaction with residuals
Residual damages do not clear previous direct damage, so Counter still works as intended.
2015-04-06 13:52:11 +02:00