forked from XpRienzo/DragonHeaven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulator-doc.txt
196 lines (164 loc) · 3.96 KB
/
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
This is a pseudocode overview of how Pokémon Showdown works - particularly relevant to anyone writing event code.
(A) = negated by Mold Breaker (and Turboblaze/Teravolt) on abilities only during a move
(S) = negated by Sheer Force only during a move with a secondary effect
(U) = negated by Substitute
(Air Lock and Klutz negates every event for the corresponding effect, so don't need to be marked)
=== MOVES ===
A quick overview of how moves work:
STEP 1. MOVE PRE-USAGE
external execution interruption (flinch, full paralysis)
"POKEMON used MOVE!"
STEP 2: MOVE USAGE
internal execution interruption (charge turn for SolarBeam etc)
move start of sub-move (Metronome, Sleep Talk etc)
PP deduction
STEP 3. MOVE EXECUTION (sub-moves start from here)
there is no target
internal move failure ("But it failed!")
STEP 4. MOVE HIT (happens once per target)
move misses
external move failure (Protect, Substitute blocked etc)
immunity
move animation
damage
other effects
secondary effects
=== MAIN LOOP ===
[BeforeTurn]
for every move:
[ModifyPriority]
move's [BeforeTurn]
runDecision() - runs runSwitch, runAfterSwitch, and runMove in priority order, then residual at end {
runSwitch() {
[BeforeSwitch]
switch
}
runAfterSwitch() - after all pokemon are switched in {
[Switch]
ability's [Start]
item's [Start]
}
runMove() {
[BeforeMove] (A)
-> false => exit runMove
display "POKEMON used MOVE!"
useMove() {
[ModifyMove] (A)
if no targets:
display "But there was no target..." and exit useMove()
moveHit() - once for each hit of multi-hit move, and also once for secondary hits {
move's [TryHit], [TryHitSide] or [TryHitField] (A)
if hit:
[TryHit] (A)
-> 0 => skip to SelfHit (used for Substitute)
-> null => exit moveHit()
-> false => display "But it failed!" and exit moveHit()
[Immunity] (A)
-> null => exit moveHit()
-> false => display "It had no effect!" and exit moveHit()
move animation
getDamage() {
move's [BasePower]
[BasePower] (A)
move's [Damage]
if critical hit:
[CriticalHit] (A)
}
damage() {
[Damage] (A,U)
-> false => exit damage()
damage
[AfterDamage] (U)
}
heal() {
[Heal] (A)
-> false => exit heal()
heal
[AfterHeal]
}
status() (U) {
[Status] (A)
-> false => exit status()
status change
status's [Start] (A)
-> false => restore previous status and exit status()
[AfterStatus]
}
effect() (U) {
if effect already exists:
effect's [Restart] (A)
otherwise:
effect change
effect's [Start] (A)
-> false => remove effect and exit effect()
}
recoil() {
call damage()
}
drain() {
call heal()
}
if hit:
[SelfHit] (A)
if secondary hit:
[SecondarySelfHit] (A)
if hit:
if secondary roll succeeds:
secondary() (S,U) {
call moveHit()
}
}
[AfterMoveSecondary] (S,U)
[AfterMoveSecondarySelf] (S)
[AfterMove]
}
pp deducted
}
runFaint() {
[Faint]
}
residual() {
for every effect:
if duration = 0:
effect's [End]
remove effect
otherwise:
effect's [Residual]
}
choose switch-ins for fainted pokemon
=> runSwitch() and runAfterSwitch() again
[Update]
}
=== ISOLATED ===
These are not part of the main loop, and are only called from inside an event.
(For instance, eatItem() is usually called from within the Update event of a berry, and weather() is called
from the Residual event of a weather condition)
eatItem() {
[UseItem] (A)
-> false => exit EatItem()
[EatItem] (A)
-> false => exit EatItem()
item's [Eat]
remove item from pokemon
}
useItem() {
[UseItem] (A)
-> false => exit UseItem()
remove item from pokemon
}
takeItem() {
[TakeItem] (A)
-> false => exit TakeItem()
remove item from pokemon
}
setItem() {
set item
item's [Start]
}
setAbility() {
set ability
ability's [Start]
}
weather() {
[Weather]
}