rlm@247
|
1 (ns com.aurellem.run.bootstrap-0
|
rlm@277
|
2 (:use (com.aurellem.gb gb-driver vbm characters money))
|
rlm@250
|
3 (:use (com.aurellem.run title save-corruption))
|
rlm@264
|
4 (:use (com.aurellem.exp item-bridge))
|
rlm@264
|
5 (:import [com.aurellem.gb.gb_driver SaveState]))
|
rlm@247
|
6
|
rlm@250
|
7 (defn-memo boot-root []
|
rlm@255
|
8 [ [] (root)])
|
rlm@247
|
9
|
rlm@255
|
10 (defn-memo to-rival-name
|
rlm@255
|
11 ([] (to-rival-name (boot-root)))
|
rlm@255
|
12 ([script]
|
rlm@255
|
13 (-> script
|
rlm@255
|
14 title
|
rlm@255
|
15 oak
|
rlm@255
|
16 name-entry-rlm
|
rlm@255
|
17 scroll-text
|
rlm@255
|
18 scroll-text
|
rlm@255
|
19 scroll-text
|
rlm@255
|
20 scroll-text
|
rlm@274
|
21 scroll-text)))
|
rlm@247
|
22
|
rlm@255
|
23 (defn-memo name-rival-bootstrap
|
rlm@255
|
24 ([] (name-rival-bootstrap (to-rival-name)))
|
rlm@255
|
25 ([script]
|
rlm@255
|
26 (->> script
|
rlm@255
|
27 (advance [] [:a])
|
rlm@255
|
28 (advance [] [:r] DE)
|
rlm@255
|
29 (play-moves
|
rlm@255
|
30 [[]
|
rlm@255
|
31 [:r] [] [:r] [] [:r] [] [:r] []
|
rlm@255
|
32 [:r] [] [:r] [] [:r] [] [:d] []
|
rlm@255
|
33 [:d] [:a] ;; space
|
rlm@255
|
34 [:l] [] [:d] [:a] ;; [PK]
|
rlm@255
|
35 [:u] [] [:u] [] [:u] [] [:l] [:a] ;; G
|
rlm@255
|
36 [:d] [] [:d] [] [:d] [] [:r] [:a] ;; [PK]
|
rlm@255
|
37 [:u] [] [:u] [] [:u] [] [:l] [:a] ;; G
|
rlm@255
|
38 [:d] [] [:d] [] [:d] [] [:r] [:a] ;; [PK]
|
rlm@247
|
39
|
rlm@255
|
40 [:d] [] [:r] [:a] ;; finish
|
rlm@255
|
41 ]))))
|
rlm@255
|
42
|
rlm@255
|
43 (defn walk
|
rlm@255
|
44 "Move the character along the given directions."
|
rlm@255
|
45 [directions script]
|
rlm@255
|
46 (reduce (fn [script direction]
|
rlm@255
|
47 (move direction script))
|
rlm@255
|
48 script directions))
|
rlm@255
|
49
|
rlm@255
|
50 (def ↑ [:u])
|
rlm@255
|
51 (def ↓ [:d])
|
rlm@255
|
52 (def ← [:l])
|
rlm@255
|
53 (def → [:r])
|
rlm@255
|
54
|
rlm@255
|
55 (defn-memo leave-house
|
rlm@255
|
56 ([] (leave-house (name-rival-bootstrap)))
|
rlm@255
|
57 ([script]
|
rlm@255
|
58 (->> script
|
rlm@255
|
59 finish-title
|
rlm@255
|
60 start-walking
|
rlm@255
|
61 walk-to-stairs
|
rlm@255
|
62 walk-to-door
|
rlm@255
|
63 (walk [↓ ↓]))))
|
rlm@255
|
64
|
rlm@255
|
65 (defn-memo to-pallet-town-edge
|
rlm@255
|
66 ([] (to-pallet-town-edge (leave-house)))
|
rlm@255
|
67 ([script]
|
rlm@255
|
68 (->> script
|
rlm@255
|
69 start-walking
|
rlm@255
|
70 (walk [→ → → → →
|
rlm@255
|
71 ↑ ↑ ↑ ↑ ↑ ↑]))))
|
rlm@255
|
72
|
rlm@257
|
73 (defn end-text [script]
|
rlm@257
|
74 (->> script
|
rlm@257
|
75 (scroll-text)
|
rlm@257
|
76 (play-moves [[] [:a]])))
|
rlm@257
|
77
|
rlm@257
|
78 (defn-memo start-pikachu-battle
|
rlm@257
|
79 ([] (start-pikachu-battle
|
rlm@257
|
80 (to-pallet-town-edge)))
|
rlm@257
|
81 ([script]
|
rlm@257
|
82 (->> script
|
rlm@257
|
83 (advance [:b] [:b :a] DE)
|
rlm@257
|
84 (scroll-text)
|
rlm@257
|
85 (play-moves [[:b]])
|
rlm@257
|
86 (scroll-text)
|
rlm@257
|
87 (end-text) ;; battle begins
|
rlm@257
|
88 (scroll-text))))
|
rlm@257
|
89
|
rlm@257
|
90 (defn-memo capture-pikachu
|
rlm@257
|
91 ([] (capture-pikachu (start-pikachu-battle)))
|
rlm@257
|
92 ([script]
|
rlm@257
|
93 (->> script
|
rlm@257
|
94 (scroll-text 2)
|
rlm@257
|
95 (end-text))))
|
rlm@257
|
96
|
rlm@257
|
97 (defn-memo go-to-lab
|
rlm@257
|
98 ([] (go-to-lab (capture-pikachu)))
|
rlm@257
|
99 ([script]
|
rlm@257
|
100 (->> script
|
rlm@257
|
101 (scroll-text 5)
|
rlm@257
|
102 (end-text)
|
rlm@257
|
103 (scroll-text)
|
rlm@257
|
104 (end-text)
|
rlm@257
|
105 (scroll-text 8)
|
rlm@257
|
106 (end-text)
|
rlm@257
|
107 (scroll-text)
|
rlm@257
|
108 (end-text))))
|
rlm@257
|
109
|
rlm@257
|
110 (defn-memo obtain-pikachu
|
rlm@257
|
111 ([] (obtain-pikachu (go-to-lab)))
|
rlm@257
|
112 ([script]
|
rlm@257
|
113 (->> script
|
rlm@257
|
114 (scroll-text)
|
rlm@257
|
115 (play-moves
|
rlm@257
|
116 (concat
|
rlm@257
|
117 (repeat 51 [])
|
rlm@257
|
118 [[:a] []]))
|
rlm@257
|
119 (walk [↓ ↓ → → ↑])
|
rlm@258
|
120 (play-moves
|
rlm@258
|
121 (concat [[] [:a]]
|
rlm@258
|
122 (repeat 100 [])))
|
rlm@258
|
123 (scroll-text 9)
|
rlm@258
|
124 (end-text)
|
rlm@258
|
125 (scroll-text 7)
|
rlm@258
|
126
|
rlm@258
|
127 (play-moves
|
rlm@258
|
128 (concat
|
rlm@258
|
129 (repeat 42 [])
|
rlm@260
|
130 [[:b] [:b] [:b] [:b]])))))
|
rlm@258
|
131
|
rlm@258
|
132 (defn-memo begin-battle-with-rival
|
rlm@258
|
133 ([] (begin-battle-with-rival
|
rlm@258
|
134 (obtain-pikachu)))
|
rlm@258
|
135 ([script]
|
rlm@258
|
136 (->> script
|
rlm@260
|
137 (walk [↓ ↓ ↓ ↓])
|
rlm@260
|
138 (scroll-text 3)
|
rlm@260
|
139 (end-text)
|
rlm@260
|
140 (scroll-text))))
|
rlm@260
|
141
|
rlm@260
|
142 (defn search-string
|
rlm@260
|
143 [array string]
|
rlm@260
|
144 (let [codes
|
rlm@260
|
145 (str->character-codes string)
|
rlm@260
|
146 codes-length (count codes)
|
rlm@260
|
147 mem (vec array)
|
rlm@260
|
148 mem-length (count mem)]
|
rlm@260
|
149 (loop [idx 0]
|
rlm@260
|
150 (if (< (- mem-length idx) codes-length)
|
rlm@260
|
151 nil
|
rlm@260
|
152 (if (= (subvec mem idx (+ idx codes-length))
|
rlm@260
|
153 codes)
|
rlm@260
|
154 idx
|
rlm@260
|
155 (recur (inc idx)))))))
|
rlm@260
|
156
|
rlm@260
|
157 (defn critical-hit
|
rlm@260
|
158 "Put the cursor over the desired attack. This program will
|
rlm@260
|
159 determine the appropriate amount of blank frames to
|
rlm@260
|
160 insert before pressing [:a] to ensure that the attack is
|
rlm@260
|
161 a critical hit."
|
rlm@260
|
162 [script]
|
rlm@260
|
163 (loop [blanks 6]
|
rlm@260
|
164 (let [new-script
|
rlm@260
|
165 (->> script
|
rlm@260
|
166 (play-moves
|
rlm@260
|
167 (concat (repeat blanks [])
|
rlm@260
|
168 [[:a][]])))]
|
rlm@260
|
169 (if (let [future-state
|
rlm@260
|
170 (run-moves (second new-script)
|
rlm@260
|
171 (repeat 400 []))
|
rlm@260
|
172
|
rlm@260
|
173 result (search-string (memory future-state)
|
rlm@260
|
174 "Critical")]
|
rlm@260
|
175 (if result
|
rlm@260
|
176 (println "critical hit with" blanks "blank frames"))
|
rlm@260
|
177 result)
|
rlm@260
|
178 new-script
|
rlm@260
|
179 (recur (inc blanks))))))
|
rlm@260
|
180
|
rlm@260
|
181 (defn-memo battle-with-rival
|
rlm@260
|
182 ([] (battle-with-rival
|
rlm@260
|
183 (begin-battle-with-rival)))
|
rlm@260
|
184 ([script]
|
rlm@260
|
185 (->> script
|
rlm@260
|
186 (play-moves (repeat 381 []))
|
rlm@260
|
187 (play-moves [[:a]])
|
rlm@260
|
188 (critical-hit)
|
rlm@260
|
189 (play-moves (repeat 100 []))
|
rlm@260
|
190 (scroll-text)
|
rlm@258
|
191 (play-moves
|
rlm@260
|
192 (concat (repeat 275 []) [[:a]]))
|
rlm@260
|
193 (critical-hit)
|
rlm@260
|
194 (play-moves (repeat 100 []))
|
rlm@260
|
195 (scroll-text)
|
rlm@258
|
196 (play-moves
|
rlm@260
|
197 (concat (repeat 270 []) [[:a]]))
|
rlm@260
|
198 (play-moves [[][][][][][][][][:a]]))))
|
rlm@260
|
199
|
rlm@260
|
200 (defn-memo finish-rival-text
|
rlm@260
|
201 ([] (finish-rival-text
|
rlm@260
|
202 (battle-with-rival)))
|
rlm@260
|
203 ([script]
|
rlm@260
|
204 (->> script
|
rlm@260
|
205 (scroll-text 2)
|
rlm@260
|
206 (end-text)
|
rlm@260
|
207 (scroll-text 9)
|
rlm@260
|
208 (end-text))))
|
rlm@260
|
209
|
rlm@262
|
210 (defn do-nothing [n script]
|
rlm@262
|
211 (->> script
|
rlm@262
|
212 (play-moves
|
rlm@262
|
213 (repeat n []))))
|
rlm@260
|
214
|
rlm@262
|
215 (defn-memo pikachu-comes-out
|
rlm@262
|
216 ([] (pikachu-comes-out
|
rlm@262
|
217 (finish-rival-text)))
|
rlm@262
|
218 ([script]
|
rlm@262
|
219 (->> script
|
rlm@262
|
220 (do-nothing 177)
|
rlm@262
|
221 (end-text)
|
rlm@262
|
222 (scroll-text 7)
|
rlm@262
|
223 (end-text))))
|
rlm@260
|
224
|
rlm@262
|
225 (defn-memo leave-oaks-lab
|
rlm@262
|
226 ([] (leave-oaks-lab
|
rlm@262
|
227 (pikachu-comes-out)))
|
rlm@262
|
228 ([script]
|
rlm@262
|
229 (->> script
|
rlm@262
|
230 (walk [← ← ↓ ↓ ↓ ↓ ↓ ↓]))))
|
rlm@257
|
231
|
rlm@271
|
232 (defn-memo oaks-lab->pallet-town-edge
|
rlm@262
|
233 ([] (oaks-lab->pallet-town-edge
|
rlm@262
|
234 (leave-oaks-lab)))
|
rlm@262
|
235 ([script]
|
rlm@262
|
236 (->> script
|
rlm@262
|
237 (walk [← ← ← ←
|
rlm@262
|
238 ↑ ↑ ↑ ↑
|
rlm@262
|
239 ↑ ↑ ↑ ↑ ↑ ↑
|
rlm@262
|
240 → ↑]))))
|
rlm@264
|
241
|
rlm@264
|
242 (defn move-thru-grass
|
rlm@264
|
243 [direction script]
|
rlm@264
|
244 (loop [blanks 0]
|
rlm@264
|
245 (let [new-script
|
rlm@264
|
246 (->> script
|
rlm@264
|
247 (play-moves (repeat blanks []))
|
rlm@264
|
248 (move direction))
|
rlm@264
|
249
|
rlm@264
|
250 future-state
|
rlm@264
|
251 (run-moves (second new-script)
|
rlm@264
|
252 (repeat 600 []))
|
rlm@264
|
253
|
rlm@264
|
254 result (search-string (memory future-state)
|
rlm@264
|
255 "Wild")]
|
rlm@264
|
256 (if (nil? result)
|
rlm@278
|
257 (do
|
rlm@278
|
258 (if (< 0 blanks)
|
rlm@278
|
259 (do(println "avoided pokemon with" blanks "blank frames")))
|
rlm@278
|
260 new-script)
|
rlm@264
|
261 (recur (inc blanks))))))
|
rlm@264
|
262
|
rlm@264
|
263 (defn walk-thru-grass
|
rlm@264
|
264 [directions script]
|
rlm@264
|
265 (reduce (fn [script direction]
|
rlm@264
|
266 (move-thru-grass direction script))
|
rlm@264
|
267 script directions))
|
rlm@264
|
268
|
rlm@264
|
269 (defn-memo pallet-edge->viridian-mart
|
rlm@271
|
270 ([] (pallet-edge->viridian-mart true
|
rlm@264
|
271 (oaks-lab->pallet-town-edge)))
|
rlm@271
|
272 ([dodge-stupid-guy? script]
|
rlm@271
|
273 (let [dodge-1 (if dodge-stupid-guy?
|
rlm@271
|
274 [→ →]
|
rlm@271
|
275 [→])
|
rlm@271
|
276 dodge-2 (if dodge-stupid-guy?
|
rlm@271
|
277 [↑ ↑ ←]
|
rlm@271
|
278 [↑ ↑ ←])]
|
rlm@271
|
279
|
rlm@271
|
280 (->> script
|
rlm@264
|
281 ;; leave straight grass
|
rlm@264
|
282 (walk-thru-grass
|
rlm@264
|
283 [↑ ↑ ↑ ↑ ↑])
|
rlm@264
|
284
|
rlm@264
|
285 (walk [↑ ↑ ↑ ↑])
|
rlm@264
|
286
|
rlm@264
|
287 (walk-thru-grass
|
rlm@264
|
288 [← ← ↑])
|
rlm@264
|
289 (walk [↑ ↑ ↑ ↑ → → → ])
|
rlm@264
|
290
|
rlm@264
|
291 (walk-thru-grass
|
rlm@264
|
292 [→ ↑ ↑ ←])
|
rlm@264
|
293
|
rlm@264
|
294 (walk
|
rlm@264
|
295 [← ←
|
rlm@264
|
296 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
rlm@264
|
297 → → → → ])
|
rlm@264
|
298
|
rlm@271
|
299 ;; this part is dependent on that
|
rlm@266
|
300 ;; stupid NPC in the grass patch
|
rlm@264
|
301 (walk-thru-grass
|
rlm@271
|
302 (concat dodge-1
|
rlm@271
|
303 [↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ]))
|
rlm@271
|
304
|
rlm@264
|
305 (walk
|
rlm@271
|
306 (concat
|
rlm@271
|
307 dodge-2
|
rlm@271
|
308 [← ← ←
|
rlm@271
|
309 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
rlm@271
|
310 ← ←
|
rlm@271
|
311 ↑ ↑ ↑ ↑
|
rlm@271
|
312 → → → → → → → → → →
|
rlm@271
|
313 ↑ ↑ ↑ ↑ ↑ ↑ ↑]))))))
|
rlm@264
|
314
|
rlm@266
|
315 (defn-memo get-oaks-parcel
|
rlm@266
|
316 ([] (get-oaks-parcel
|
rlm@266
|
317 (pallet-edge->viridian-mart)))
|
rlm@266
|
318 ([script]
|
rlm@266
|
319 (->> script
|
rlm@266
|
320 (end-text)
|
rlm@266
|
321 (scroll-text 3)
|
rlm@266
|
322 (do-nothing 197)
|
rlm@266
|
323 (play-moves [[:a] []])
|
rlm@266
|
324 (walk [↓ ↓ → ↓]))))
|
rlm@266
|
325
|
rlm@269
|
326 (defn-memo viridian-store->oaks-lab
|
rlm@269
|
327 ([] (viridian-store->oaks-lab
|
rlm@269
|
328 (get-oaks-parcel)))
|
rlm@269
|
329 ([script]
|
rlm@269
|
330 (->> script
|
rlm@269
|
331 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
332 ← ← ← ← ← ← ← ← ← ←
|
rlm@269
|
333 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
334 ← ←
|
rlm@269
|
335 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
336 ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
337 → → → → → → → →
|
rlm@269
|
338 ↓ ↓ ↓ ↓
|
rlm@269
|
339 ← ← ← ← ←
|
rlm@269
|
340 ↓ ↓ ↓ ↓])
|
rlm@266
|
341
|
rlm@269
|
342 (walk-thru-grass
|
rlm@269
|
343 [↓ ↓ ↓ ↓ ↓ ↓ ↓])
|
rlm@269
|
344
|
rlm@269
|
345 (walk [↓ ↓ ← ↓ ↓ ↓ ←
|
rlm@269
|
346 ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
347 → → → ↑]))))
|
rlm@269
|
348
|
rlm@269
|
349 (defn-memo viridian-store->oaks-lab-like-a-boss
|
rlm@269
|
350 ([] (viridian-store->oaks-lab-like-a-boss
|
rlm@269
|
351 (get-oaks-parcel)))
|
rlm@269
|
352 ([script]
|
rlm@269
|
353 (->> script
|
rlm@269
|
354 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
355 ← ← ← ← ← ← ← ← ← ←
|
rlm@269
|
356 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])
|
rlm@269
|
357
|
rlm@269
|
358 (walk-thru-grass
|
rlm@269
|
359 [↓ ↓ ↓ ↓ ↓])
|
rlm@269
|
360
|
rlm@269
|
361 (walk
|
rlm@269
|
362 [↓ ↓ ← ↓
|
rlm@269
|
363 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
364 → →])
|
rlm@269
|
365
|
rlm@269
|
366 (walk-thru-grass
|
rlm@269
|
367 [→ ↓ ↓ ↓])
|
rlm@269
|
368
|
rlm@269
|
369 (walk [↓ ← ← ↓ ↓ ↓ ↓ ↓ ↓])
|
rlm@269
|
370
|
rlm@269
|
371 (walk-thru-grass
|
rlm@269
|
372 [↓ ↓ ↓ ↓ ↓ ↓ ↓])
|
rlm@269
|
373
|
rlm@269
|
374 (walk [↓ ↓ ← ↓ ↓ ↓ ←
|
rlm@269
|
375 ↓ ↓ ↓ ↓ ↓
|
rlm@269
|
376 → → → ↑]))))
|
rlm@270
|
377
|
rlm@270
|
378 (defn-memo deliver-oaks-parcel
|
rlm@270
|
379 ([] (deliver-oaks-parcel
|
rlm@270
|
380 (viridian-store->oaks-lab-like-a-boss)))
|
rlm@270
|
381 ([script]
|
rlm@270
|
382 (->> script
|
rlm@270
|
383 (walk [↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑])
|
rlm@270
|
384 (play-moves [[:a]])
|
rlm@270
|
385 (scroll-text 11)
|
rlm@270
|
386 (end-text)
|
rlm@270
|
387 (end-text)
|
rlm@270
|
388 (do-nothing 200)
|
rlm@270
|
389 (end-text)
|
rlm@270
|
390 (scroll-text 3)
|
rlm@270
|
391 (end-text)
|
rlm@270
|
392 (scroll-text 2)
|
rlm@270
|
393 (end-text)
|
rlm@270
|
394 (scroll-text 5)
|
rlm@270
|
395 (end-text)
|
rlm@270
|
396 (scroll-text 2)
|
rlm@270
|
397 (end-text)
|
rlm@270
|
398 (scroll-text 9)
|
rlm@270
|
399 (end-text)
|
rlm@270
|
400 (scroll-text 7)
|
rlm@270
|
401 (end-text)
|
rlm@271
|
402 (walk [← ← ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓]))))
|
rlm@271
|
403
|
rlm@271
|
404 (defn-memo return-to-viridian-mart
|
rlm@271
|
405 ([] (return-to-viridian-mart
|
rlm@271
|
406 (deliver-oaks-parcel)))
|
rlm@271
|
407 ([script]
|
rlm@271
|
408 (->> script
|
rlm@271
|
409 oaks-lab->pallet-town-edge
|
rlm@274
|
410 (pallet-edge->viridian-mart false))))
|
rlm@274
|
411
|
rlm@274
|
412 (defn-memo walk-to-counter
|
rlm@274
|
413 ([] (walk-to-counter
|
rlm@274
|
414 (return-to-viridian-mart)))
|
rlm@274
|
415 ([script]
|
rlm@274
|
416 (->> script
|
rlm@274
|
417 (walk [↑ ↑ ← ←]))))
|
rlm@275
|
418
|
rlm@275
|
419 (defn buy-item
|
rlm@275
|
420 "Assumes that the main item-screen is up, and buys
|
rlm@275
|
421 quantity of the nth item in the list, assuming that you
|
rlm@275
|
422 have enough money."
|
rlm@275
|
423 [n quantity script]
|
rlm@275
|
424 (if (= 0 quantity)
|
rlm@275
|
425 script
|
rlm@275
|
426 (let [after-initial-pause
|
rlm@275
|
427 (do-nothing 20 script)
|
rlm@275
|
428 move-to-item
|
rlm@275
|
429 (reduce (fn [script _]
|
rlm@275
|
430 (->> script
|
rlm@275
|
431 (play-moves [[:d]])
|
rlm@275
|
432 (do-nothing 3)))
|
rlm@275
|
433 after-initial-pause
|
rlm@275
|
434 (range n))
|
rlm@275
|
435 select-item
|
rlm@275
|
436 (play-moves [[:a]] move-to-item)
|
rlm@275
|
437 request-items
|
rlm@275
|
438 (reduce (fn [script _]
|
rlm@275
|
439 (->> script
|
rlm@275
|
440 (play-moves [[:u]])
|
rlm@275
|
441 (do-nothing 1)))
|
rlm@275
|
442 select-item
|
rlm@275
|
443 (range (dec quantity)))
|
rlm@275
|
444 buy-items
|
rlm@275
|
445 (->> request-items
|
rlm@275
|
446 (do-nothing 3)
|
rlm@275
|
447 (play-moves [[:a]])
|
rlm@275
|
448 (scroll-text)
|
rlm@275
|
449 (scroll-text)
|
rlm@275
|
450 (play-moves [[:a]])
|
rlm@275
|
451 (scroll-text))]
|
rlm@275
|
452 buy-items)))
|
rlm@275
|
453
|
rlm@275
|
454
|
rlm@275
|
455 (defn buy-items
|
rlm@275
|
456 "Given a list of [item-no quantity], buys the quantity
|
rlm@275
|
457 from the shop's list. Assumes that the item list is
|
rlm@275
|
458 already up."
|
rlm@275
|
459 [item-pairs script]
|
rlm@275
|
460 (let [item-lookup (into {0 0 1 0 2 0 3 0 4 0} item-pairs)
|
rlm@275
|
461 initial-purchase
|
rlm@275
|
462 (->> script
|
rlm@275
|
463 (buy-item 0 (item-lookup 0))
|
rlm@275
|
464 (buy-item 1 (item-lookup 1))
|
rlm@275
|
465 (buy-item 2 (item-lookup 2)))]
|
rlm@275
|
466 (cond
|
rlm@275
|
467 (and
|
rlm@275
|
468 (not= 0 (item-lookup 3))
|
rlm@275
|
469 (not= 0 (item-lookup 4)))
|
rlm@275
|
470 (->> initial-purchase
|
rlm@275
|
471 (do-nothing 20)
|
rlm@275
|
472 (play-moves [[:d]])
|
rlm@275
|
473 (do-nothing 3)
|
rlm@275
|
474 (play-moves [[:d]])
|
rlm@275
|
475 (do-nothing 3)
|
rlm@275
|
476 (play-moves [[:d]])
|
rlm@275
|
477 (do-nothing 10)
|
rlm@275
|
478 (buy-item 0 (item-lookup 3))
|
rlm@275
|
479 (do-nothing 20)
|
rlm@275
|
480 (play-moves [[:d]])
|
rlm@275
|
481 (do-nothing 3)
|
rlm@275
|
482 (play-moves [[:d]])
|
rlm@275
|
483 (do-nothing 3)
|
rlm@275
|
484 (play-moves [[:d]])
|
rlm@275
|
485 (do-nothing 10)
|
rlm@275
|
486 (buy-item 0 (item-lookup 4)))
|
rlm@275
|
487 (and (= 0 (item-lookup 3))
|
rlm@275
|
488 (not= 0 (item-lookup 4)))
|
rlm@275
|
489 (->> initial-purchase
|
rlm@275
|
490 (do-nothing 20)
|
rlm@275
|
491 (play-moves [[:d]])
|
rlm@275
|
492 (do-nothing 3)
|
rlm@275
|
493 (play-moves [[:d]])
|
rlm@275
|
494 (do-nothing 3)
|
rlm@275
|
495 (play-moves [[:d]])
|
rlm@275
|
496 (do-nothing 10)
|
rlm@275
|
497 (play-moves [[:d]])
|
rlm@275
|
498 (do-nothing 10)
|
rlm@275
|
499 (buy-item 0 (item-lookup 4)))
|
rlm@275
|
500 (and (not= 0 (item-lookup 3))
|
rlm@275
|
501 (= 0 (item-lookup 4)))
|
rlm@275
|
502 (->> initial-purchase
|
rlm@275
|
503 (do-nothing 20)
|
rlm@275
|
504 (play-moves [[:d]])
|
rlm@275
|
505 (do-nothing 3)
|
rlm@275
|
506 (play-moves [[:d]])
|
rlm@275
|
507 (do-nothing 3)
|
rlm@275
|
508 (play-moves [[:d]])
|
rlm@275
|
509 (do-nothing 10)
|
rlm@275
|
510 (buy-item 0 (item-lookup 3))))))
|
rlm@275
|
511
|
rlm@275
|
512
|
rlm@275
|
513 (defn test-buy-items
|
rlm@277
|
514 ([] (test-buy-items
|
rlm@274
|
515 (walk-to-counter)))
|
rlm@274
|
516 ([script]
|
rlm@275
|
517 (->> [(first script) (set-money (second script)
|
rlm@275
|
518 999999)]
|
rlm@274
|
519 (play-moves
|
rlm@274
|
520 [[] [:a] []])
|
rlm@274
|
521 (scroll-text)
|
rlm@274
|
522 (do-nothing 100)
|
rlm@274
|
523 (play-moves [[:a]])
|
rlm@274
|
524 (do-nothing 100)
|
rlm@275
|
525 (buy-items
|
rlm@275
|
526 [[0 1]
|
rlm@275
|
527 [1 15]
|
rlm@275
|
528 [2 1]
|
rlm@275
|
529 [3 20]
|
rlm@275
|
530 [4 95]
|
rlm@275
|
531 ]))))
|
rlm@275
|
532
|
rlm@275
|
533 (defn-memo buy-initial-items
|
rlm@275
|
534 ([] (buy-initial-items
|
rlm@275
|
535 (walk-to-counter)))
|
rlm@275
|
536 ([script]
|
rlm@275
|
537 (->> script
|
rlm@275
|
538 (play-moves
|
rlm@275
|
539 [[] [:a] []])
|
rlm@274
|
540 (scroll-text)
|
rlm@274
|
541 (do-nothing 100)
|
rlm@274
|
542 (play-moves [[:a]])
|
rlm@274
|
543 (do-nothing 100)
|
rlm@275
|
544 (buy-items
|
rlm@275
|
545 [[0 1]
|
rlm@275
|
546 [1 1]
|
rlm@275
|
547 [2 1]
|
rlm@275
|
548 [3 1]
|
rlm@279
|
549 [4 1]])
|
rlm@279
|
550 (do-nothing 100)
|
rlm@279
|
551 (play-moves [[:b]])
|
rlm@279
|
552 (do-nothing 100)
|
rlm@279
|
553 (play-moves [[:b]])
|
rlm@279
|
554 (do-nothing 100)
|
rlm@279
|
555 (play-moves [[:b] []]))))
|
rlm@274
|
556
|
rlm@274
|
557
|
rlm@280
|
558 (defn-memo do-save-corruption
|
rlm@279
|
559 ([] (do-save-corruption
|
rlm@279
|
560 (buy-initial-items)))
|
rlm@279
|
561 ([script]
|
rlm@279
|
562 (->> script
|
rlm@280
|
563 (advance [:b] [:b :start])
|
rlm@280
|
564 (advance [] [:d])
|
rlm@280
|
565 (play-moves [[] [] [] [:d]
|
rlm@280
|
566 [] [] [] [:d]
|
rlm@280
|
567 [] [] [] [:d]
|
rlm@280
|
568 [] [] [:a]])
|
rlm@280
|
569 scroll-text
|
rlm@280
|
570 (play-moves
|
rlm@280
|
571 ;; this section is copied from speedrun-2942 and corrupts
|
rlm@280
|
572 ;; the save so that the end-of-list marker for the pokemon
|
rlm@280
|
573 ;; roster is destroyed, but the save is still playable.
|
rlm@280
|
574 [[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
|
rlm@280
|
575 [] [] [] [] [] [] [] [] [] [] [] [:select] [:restart]])
|
rlm@280
|
576 (title)
|
rlm@280
|
577 (advance [] [:start])
|
rlm@280
|
578 (advance [] [:a])
|
rlm@280
|
579 (advance [:a] [:a :start]))))
|
rlm@280
|
580
|
rlm@280
|
581
|
rlm@280
|
582 (defn viridian-store->viridian-poke-center
|
rlm@280
|
583 []
|
rlm@280
|
584 ;; leave store
|
rlm@280
|
585 ;;(walk [↓ ↓
|
rlm@280
|
586 ;; → ↓ ↓])
|
rlm@280
|
587 )
|
rlm@274
|
588
|