Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 205 lines (170 sloc) 4.156 kb
477af897 »
2012-03-26 Add the new event documentation.
1 This is a pseudocode overview of how Showdown works - particularly relevant to anyone writing event code.
2
3 (A) = negated by Mold Breaker (and Turboblaze/Teravolt) on abilities only during a move
4 (S) = negated by Sheer Force only during a move with a secondary effect
5 (U) = negated by Substitute
6
7 (Air Lock and Klutz negates every event for the corresponding effect, so don't need to be marked)
8
9 === MOVES ===
10
11 A quick overview of how moves work:
12
13 STEP 1. MOVE PRE-USAGE
14 external execution interruption (flinch, full paralysis)
15 "POKEMON used MOVE!"
16 STEP 2: MOVE USAGE
17 internal execution interruption (charge turn for SolarBeam etc)
18 move start of sub-move (Metronome, Sleep Talk etc)
19 PP deduction
20 STEP 3. MOVE EXECUTION (sub-moves start from here)
21 there is no target
22 internal move failure ("But it failed!")
23 STEP 4. MOVE HIT (happens once per target)
24 move misses
25 external move failure (Protect, Substitute blocked etc)
26 immunity
27 move animation
28 damage
29 other effects
30 secondary effects
31
32 === MAIN LOOP ===
33
34 [BeforeTurn]
35 for every move:
36 [ModifyPriority]
37 move's [BeforeTurn]
38
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
39 runDecision() - runs runSwitch, runAfterSwitch, and runMove in priority order, then residual at end {
40 runSwitch() {
477af897 »
2012-03-26 Add the new event documentation.
41 [BeforeSwitch]
42 switch
43 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
44 runAfterSwitch() - after all pokemon are switched in {
477af897 »
2012-03-26 Add the new event documentation.
45 [Switch]
46 ability's [Start]
47 item's [Start]
48 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
49 runMove() {
477af897 »
2012-03-26 Add the new event documentation.
50 [BeforeMove] (A)
51 -> false => exit runMove
64d876f1 »
2012-04-16 Begone, trailing whitespace!
52
477af897 »
2012-03-26 Add the new event documentation.
53 display "POKEMON used MOVE!"
64d876f1 »
2012-04-16 Begone, trailing whitespace!
54
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
55 useMove() {
477af897 »
2012-03-26 Add the new event documentation.
56 [ModifyMove] (A)
64d876f1 »
2012-04-16 Begone, trailing whitespace!
57
477af897 »
2012-03-26 Add the new event documentation.
58 move's [InterruptMove]
64d876f1 »
2012-04-16 Begone, trailing whitespace!
59
477af897 »
2012-03-26 Add the new event documentation.
60 if no targets:
61 display "But there was no target..." and exit useMove()
64d876f1 »
2012-04-16 Begone, trailing whitespace!
62
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
63 moveHit() - once for each hit of multi-hit move, and also once for secondary hits {
477af897 »
2012-03-26 Add the new event documentation.
64 move's [TryHit], [TryHitSide] or [TryHitField] (A)
65 if hit:
66 [TryHit] (A)
67 -> 0 => skip to SelfHit (used for Substitute)
68 -> null => exit moveHit()
69 -> false => display "But it failed!" and exit moveHit()
70 [Immunity] (A)
71 -> null => exit moveHit()
72 -> false => display "It had no effect!" and exit moveHit()
64d876f1 »
2012-04-16 Begone, trailing whitespace!
73
477af897 »
2012-03-26 Add the new event documentation.
74 move animation
64d876f1 »
2012-04-16 Begone, trailing whitespace!
75
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
76 getDamage() {
477af897 »
2012-03-26 Add the new event documentation.
77 move's [BasePower]
78 [BasePower] (A)
79 move's [Damage]
80 if critical hit:
81 [CriticalHit] (A)
82 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
83 damage() {
477af897 »
2012-03-26 Add the new event documentation.
84 [Damage] (A,U)
85 -> false => exit damage()
86 damage
87 [AfterDamage] (U)
88 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
89 heal() {
477af897 »
2012-03-26 Add the new event documentation.
90 [Heal] (A)
91 -> false => exit heal()
92 heal
93 [AfterHeal]
94 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
95 status() (U) {
477af897 »
2012-03-26 Add the new event documentation.
96 [Status] (A)
97 -> false => exit status()
98 status change
99 status's [Start] (A)
100 -> false => restore previous status and exit status()
101 [AfterStatus]
102 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
103 effect() (U) {
477af897 »
2012-03-26 Add the new event documentation.
104 if effect already exists:
105 effect's [Restart] (A)
106 otherwise:
107 effect change
108 effect's [Start] (A)
109 -> false => remove effect and exit effect()
110 }
64d876f1 »
2012-04-16 Begone, trailing whitespace!
111
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
112 recoil() {
477af897 »
2012-03-26 Add the new event documentation.
113 call damage()
114 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
115 drain() {
477af897 »
2012-03-26 Add the new event documentation.
116 call heal()
117 }
64d876f1 »
2012-04-16 Begone, trailing whitespace!
118
477af897 »
2012-03-26 Add the new event documentation.
119 if hit:
120 [SelfHit] (A)
121 if secondary hit:
122 [SecondarySelfHit] (A)
64d876f1 »
2012-04-16 Begone, trailing whitespace!
123
477af897 »
2012-03-26 Add the new event documentation.
124 if hit:
125 if secondary roll succeeds:
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
126 secondary() (S,U) {
477af897 »
2012-03-26 Add the new event documentation.
127 call moveHit()
128 }
129 }
64d876f1 »
2012-04-16 Begone, trailing whitespace!
130
477af897 »
2012-03-26 Add the new event documentation.
131 [AfterMoveSecondary] (S,U)
132 [AfterMoveSecondarySelf] (S)
64d876f1 »
2012-04-16 Begone, trailing whitespace!
133
477af897 »
2012-03-26 Add the new event documentation.
134 [AfterMove]
4ce2d950 »
2011-12-22 Everything I did before moving to Git
135 }
477af897 »
2012-03-26 Add the new event documentation.
136 pp deducted
137 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
138 runFaint() {
477af897 »
2012-03-26 Add the new event documentation.
139 [Faint]
140 }
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
141 residual() {
477af897 »
2012-03-26 Add the new event documentation.
142 for every effect:
143 if duration = 0:
144 effect's [End]
145 remove effect
146 otherwise:
147 effect's [Residual]
148 }
64d876f1 »
2012-04-16 Begone, trailing whitespace!
149
477af897 »
2012-03-26 Add the new event documentation.
150 choose switch-ins for fainted pokemon
151 => runSwitch() and runAfterSwitch() again
64d876f1 »
2012-04-16 Begone, trailing whitespace!
152
477af897 »
2012-03-26 Add the new event documentation.
153 [Update]
4ce2d950 »
2011-12-22 Everything I did before moving to Git
154 }
155
156
157
477af897 »
2012-03-26 Add the new event documentation.
158 === ISOLATED ===
4ce2d950 »
2011-12-22 Everything I did before moving to Git
159
477af897 »
2012-03-26 Add the new event documentation.
160 These are not part of the main loop, and are only called from inside an event.
4ce2d950 »
2011-12-22 Everything I did before moving to Git
161
477af897 »
2012-03-26 Add the new event documentation.
162 (For instance, eatItem() is usually called from within the Update event of a berry, and weather() is called
163 from the Residual event of a weather condition)
164
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
165 eatItem() {
477af897 »
2012-03-26 Add the new event documentation.
166 [UseItem] (A)
167 -> false => exit EatItem()
168 [EatItem] (A)
169 -> false => exit EatItem()
170 item's [Eat]
171 remove item from pokemon
172 }
4ce2d950 »
2011-12-22 Everything I did before moving to Git
173
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
174 useItem() {
477af897 »
2012-03-26 Add the new event documentation.
175 [UseItem] (A)
176 -> false => exit UseItem()
177 remove item from pokemon
178 }
4ce2d950 »
2011-12-22 Everything I did before moving to Git
179
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
180 takeItem() {
477af897 »
2012-03-26 Add the new event documentation.
181 [TakeItem] (A)
182 -> false => exit TakeItem()
183 remove item from pokemon
184 }
4ce2d950 »
2011-12-22 Everything I did before moving to Git
185
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
186 setItem() {
477af897 »
2012-03-26 Add the new event documentation.
187 set item
188 item's [Start]
189 }
4ce2d950 »
2011-12-22 Everything I did before moving to Git
190
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
191 setAbility() {
477af897 »
2012-03-26 Add the new event documentation.
192 set ability
193 ability's [Start]
194 }
4ce2d950 »
2011-12-22 Everything I did before moving to Git
195
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
196 weather() {
477af897 »
2012-03-26 Add the new event documentation.
197 [Weather]
198 }
4ce2d950 »
2011-12-22 Everything I did before moving to Git
199
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
200 updatePokemon() {
477af897 »
2012-03-26 Add the new event documentation.
201 for every pokemon:
202 [ModifyStats] (A)
203 [ModifyPokemon] (A)
dfca4311 »
2012-04-16 Move braces to the same line as their control statements
204 }
Something went wrong with that request. Please try again.