forked from XpRienzo/DragonHeaven
-
Notifications
You must be signed in to change notification settings - Fork 1
/
old-simulator-doc.txt
318 lines (227 loc) · 11.5 KB
/
old-simulator-doc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
Sim events:
Any event that fires on a pokemon also fires on that pokemon's side. So, for instance,
foeModifyMove can be captured by Reflect, a side condition on the foe's side.
Any event that fires on a side also fires on the global battle. So, for instance,
a move's basePower event can be captured by Rain Dance, a weather condition on
the global battle.
=== LIST OF EVENTS ===
beforeMove(user, target) [on move]
beforeMove(user, target, move) [on user]
foeBeforeMove(user, target, move) [on target]
Fired before a pokemon uses a move it chose. Return true to prevent
the move.
Mostly effects that prevent a user from moving, such as paralysis.
Moves not called directly (e.g. moves called by Metronome, Sleep Talk,
or Pursuit) do not fire this event.
examples: [volatile] Flinching, [status] fully paralyzed,
[move] Focus Punch
basePower(user, target) [on move]
basePower(user, target, basePower, move) [on user]
foeBasePower(user, target, basePower, move) [on target]
Fired while calculating a move's base power. Return the modified
base power.
examples: [ability] Technician, [foe side condition] Reflect,
[move] Gyro Ball
beforeTurn(pokemon) [on pokemon]
beforeTurn(user) [on move]
Fired before a turn starts on every active pokemon.
Used for Focus Punch (for the "focusing" message) and Pursuit
(to activate the side condition that listens for the foeSwitchOut
event).
examples: [move] Focus Punch, [move] Pursuit
damage(user, target) [on move]
Fired while calculating a move's damage. Return a damage value in
directly in HP. Bypasses weaknesses and resistances, but not immunities.
examples: [move] Night Shade, [move] Endeavor
modifyMove(user, target, move) [on user]
foeModifyMove(user, target, move) [on target]
Fired before a pokemon uses a move. Return true to prevent the move.
The API is very similar to beforeMove, but the usage is different.
Behavior differences:
1. It is passed a copy of the move object that can be modified.
2. It is fired for moves that bypass beforeMove (moves called by
Metronome, Sleep Talk, or Pursuit switching).
NOTE: Base Power modifications should be handled in basePower, not in
modifyMove. This is because many moves have variable base power.
NOTE: Priority modifications should be handled in movePriority. This is
for performance reasons (there's no need to fire movePriority for
moves that bypass priority, e.g. moves called by Sleep Talk).
examples: [ability] Adaptability, [ability, foe ability] No Guard
modifyPokemon(pokemon) [on pokemon]
Any effect that modifies a pokemon should be applied here.
These are the properties of pokemon you can modify:
- pokemon.stats
- pokemon.weightkg
- pokemon.type
Whenever any effect is added or removed, the pokemon is reset and
modifyPokemon is fired.
examples: [ability] Light Metal, [volatile] Conversion 2, etc
stats(stats, pokemon) [on pokemon]
A shortcut event for modifyPokemon(pokemon) : stats = pokemon.stats.
Stats modifiers should be applied here.
examples: [ability] Swift Swim, [status] Paralysis, etc
type(user, target) [on move]
Fired when calculating a move's type. Returns the move's type, for
the purposes of calculating damage. Not used for the move's type in
any other situation.
Only used for Struggle, which is Normal-type but does ???-type damage.
examples: [move] Struggle
switchIn(pokemon) [on pokemon]
foeSwitchIn(pokemon) [on pokemon's foe's side]
Fired after a pokemon switches in.
If two pokemon switch in at once (first turn, or after two pokemon
faint simultaneously), both switchIn events will fire after both pokemon
have switched in, and the faster pokemon's switchIn event will fire
first.
examples: [ability] Drizzle, [ability] Intimidate, etc
switchOut(pokemon) [on pokemon]
foeSwitchOut(pokemon) [on pokemon's foe's side]
Fired before a pokemon switches out. Return true to interrupt and
prevent the pokemon from switching out.
NOTE: This event fires for (and overrides) Baton Pass and U-Turn and
Pokémon with Shed Shell. DO NOT use it to implement trapping: see the
trapping flag.
NOTE: NOTHING in BW or earlier prevents a pokemon from switching out
at this stage, so you most likely DO NOT want to ever return true.
examples: [foe side condition] Pursuit
immunity(type, target) [on target]
Fired when determining whether or not a pokemon is immune to a move.
Return true if it is immune. Or: 'noMessage' if it is immune - this
suppresses the "It had no effect!" message, so you can replace it with
your own, such as "Motor Drive raised its speed!"
examples: [volatile] Magnet Rise, [ability] Volt Absorb, etc
immunity(effect, target) [on target]
Fired when determining whether or not a pokemon is immune to a non-move
effect, such as status infection or weather damage.
examples: [type] Poison, [ability] Water Veil, [ability] Sand Rush, etc
getHit(target, source, move) [on target]
foeGetHit(target, source, move) [on source]
hit(target, source) [on move]
Fired when a move hits (doesn't miss). Return true to prevent the move's
effects.
Also used for moves whose effects are too complicated to be represented
in any other way.
examples: [foe volatile] Protect, [move] Belly Drum, etc
movePriority(priority, user, target, move) [on user]
foeMovePriority(priority, user, target, move) [on target]
Fired when determining a move's priority. Return the move's priority.
examples: [ability] Prankster
start(pokemon, source) [on status, on volatile]
start(side, source) [on side condition]
start(placeholder, source) [on weather, on field effect]
Fired when an effect starts.
source is the pokemon that inflicted the effect, or null if no such
pokemon did. For instance, if Pikachu uses Toxic, source is Pikachu,
but if you are poisoned by Toxic Spikes, source is null.
Useful for cancelling an effect that fails (e.g. Encore against a newly
switched-in foe), for giving messages that an effect has started, and
for initializing effect data (e.g. Substitute, Wish).
NOTE: Not fired for abilities and items. For abilities and items, see
the switchIn event.
examples: [volatile] Encore, [side condition] Reflect,
[volatile] Substitute
restart(pokemon) [on status, on volatile]
restart(side) [on side condition]
restart() [on weather, on field effect]
Fired when trying to induce an effect that's already active.
Useful for effects that can have multiple "layers".
examples: [side condition] Toxic Spikes, [side condition] Pursuit,
[volatile] Stockpile
end(pokemon) [on status, on volatile, on item, on ability]
end(side) [on side condition]
end() [on weather, on field effect]
Fired when an effect ends naturally, usually because its duration ends.
Return true to stop an effect from ending.
Most ways an effect can end are "natural". The biggest exception is
when a pokemon swiches out. In general, if you would receive a message
when the effect ends, the end event would be fired.
NOTE: NOT fired when a pokemon switches out (see switchOut).
NOTE: If you return true when an event expires from its duration counter
reaching 0, it will never expire unless you reset its duration. To
extend an effect by one turn, simply set its duration counter to 1
before returning true.
Useful for giving messages that an effect has ended.
examples: [volatile] Encore, [side condition] Reflect,
[volatile] Substitute
duration(pokemon, source) [on status, on volatile]
duration(side) [on side condition]
duration() [on weather, on field effect]
Fired while calculating an effect's duration. Returns the duration in
turns, including the current one.
source is the pokemon that inflicted the effect, or null if no such
pokemon did. For instance, if Pikachu uses Toxic, source is Pikachu,
but if you are poisoned by Toxic Spikes, source is null.
For instance, Protect has a duration of 1 turn, and Wish has a duration
of 2 turns. Return 0 to have it never expire.
The effect's residual event is not fired when it expires - instead, its
end event is fired when its residual event would otherwise have fired.
Do not use this for effects that don't expire during a residual. For
instance, sleep expires through a sleep counter that decrements every
beforeMove event, not every residual event.
examples: [weather] Rain Dance, [side condition] Reflect
residual(pokemon) [on status, on volatile, on ability, on item]
residual(side) [on side condition]
residual() [on weather, on field effect]
Fired at the end of each turn, but before fainted pokemon are switched in.
Useful for whatever end-of-turn effects this may have.
The duration counter of each effect is decremented automatically before
this event is fired (see duration for details).
examples: [volatile] Ghost-type Curse, [weather] Sandstorm
=== DETAILED USAGE NOTES ===
In aesoft's unnamed sim, as well as in Pokémon Lab and DougJustDoug's framework,
everything in Pokémon is an effect.
There are 8 types of effects
- move, associated with a pokemon (Grass Knot, Magnitude...)
- status, associated with a pokemon (Sleep, Poison...)
- volatile, associated with a pokemon (Protect, Substitute...)
- ability, associated with a pokemon (Intimidate, Technician...)
- item, associated with a pokemon (Leftovers, Choice Scarf...)
- side condition, associated with a side (Reflect, Tailwind...)
- weather, associated with a battle (Rain Dance, Sunny Day...)
- field effect, associated with a battle (Trick Room...)
Effects associated with a side are also associated with every pokemon on a side,
and effects associated with a battle are associated with every pokemon.
For convenience, every effect has the same ID as the move, ability, or item that
induces it. The only exceptions are effects with many moves associated with them,
such as statuses, and certain volatile statuses (flinch, confusion, locked moves,
and trapping).
Nearly every effect has some sort of event listener, and each action fires an
event.
For instance, here is the Technician ability:
"Technician": {
desc: "When this Pokemon uses an attack that has 60 Base Power or less, the
move's Base Power receives a 50% boost. For example, a move with 60 Base
Power effectively becomes a move with 90 Base Power.",
basePowerCallbackPriority: 10,
basePowerCallback: function(pokemon, target, basePower, move) {
if (basePower <= 60) {
return basePower * 1.5;
}
return basePower;
},
id: "Technician",
name: "Technician",
num: "101"
}
Now, let's work through an example:
> In rain, A Technician Roserade uses Grass Knot against a Vaporen behind Light
> Screen.
This fires the basePower event:
basePower(user, target) [on move]
basePower(user, target, basePower, move) [on user]
foeBasePower(user, target, basePower, move) [on target]
First, the basePower callback on the move is fired.
Grass Knot's basePowerCallback function returns 60 as its Base Power against
Vaporeon.
Next, all basePower callbacks associated with Roserade are fired. This includes
the basePower callbacks of Roserade's effects (its Technician ability), the
basePower callbacks of Roserade's teams's effects (there are none), and the
basePower callbacks of the battle effects (rain).
These callbacks are sorted by their listed priority. The Technician callback
goes first, since it has a priority of 10, and so the attack's new base power is 90.
Then, the rain's callback is called. Since Grass Knot is neither a Water nor a Fire
move, its base power is unchanged.
Finally, all foeBasePower callbacks associated with Vaporeon are fired.
These are also sorted by their listed priority, and then run. With the foeBasePower
callback of Light Screen, we get a final base power of 45, which is then
passed on to the damage formula.