annotate clojure/com/aurellem/gb/hxc.clj @ 246:921d2277bb57

Got hardcoded move effect data, put it into a map hxc-move-data. Since descriptions are handwritten, they may be buggy.
author Dylan Holmes <ocsenave@gmail.com>
date Mon, 26 Mar 2012 01:56:57 -0500
parents a50faba43967
children 99227bec1123
rev   line source
rlm@218 1 (ns com.aurellem.gb.hxc
rlm@218 2 (:use (com.aurellem.gb assembly characters gb-driver util
rlm@218 3 constants))
rlm@218 4 (:use (com.aurellem.world practice))
rlm@218 5 (:import [com.aurellem.gb.gb_driver SaveState]))
rlm@218 6
rlm@218 7
ocsenave@243 8
ocsenave@243 9 (def pkmn-types
ocsenave@244 10 [:normal
ocsenave@244 11 :fighting
ocsenave@244 12 :flying
ocsenave@244 13 :poison
ocsenave@244 14 :ground
ocsenave@244 15 :rock
ocsenave@245 16 :bird
ocsenave@244 17 :bug
ocsenave@244 18 :ghost
ocsenave@244 19 :A
ocsenave@244 20 :B
ocsenave@244 21 :C
ocsenave@244 22 :D
ocsenave@244 23 :E
ocsenave@244 24 :F
ocsenave@244 25 :G
ocsenave@244 26 :H
ocsenave@244 27 :I
ocsenave@244 28 :J
ocsenave@244 29 :K
ocsenave@244 30 :fire
ocsenave@244 31 :water
ocsenave@244 32 :grass
ocsenave@244 33 :electric
ocsenave@244 34 :psychic
ocsenave@244 35 :ice
ocsenave@244 36 :dragon
ocsenave@244 37 ])
ocsenave@243 38
ocsenave@243 39
ocsenave@246 40 ;; question: when status effects claim to take
ocsenave@246 41 ;; their accuracy from the move accuracy, does
ocsenave@246 42 ;; this mean that the move always "hits" but the
ocsenave@246 43 ;; status effect may not?
ocsenave@246 44
ocsenave@246 45 (def move-effects
ocsenave@246 46 ["normal damage"
ocsenave@246 47 "no damage, just opponent sleep" ;; how many turns? is atk power ignored?
ocsenave@246 48 "0x4C chance of poison"
ocsenave@246 49 "leech half of inflicted damage"
ocsenave@246 50 "0x19 chance of burn"
ocsenave@246 51 "0x19 chance of freeze"
ocsenave@246 52 "0x19 chance of paralyze"
ocsenave@246 53 "user faints; opponent defense halved."
ocsenave@246 54 "leech half of inflicted damage ONLY if sleeping opponent."
ocsenave@246 55 "imitate last attack"
ocsenave@246 56 "user atk +1"
ocsenave@246 57 "user def +1"
ocsenave@246 58 "user spd +1"
ocsenave@246 59 "user spc +1"
ocsenave@246 60 "user acr +1" ;; unused?!
ocsenave@246 61 "user evd +1"
ocsenave@246 62 "get post-battle $ = 2*level*uses"
ocsenave@246 63 "0xFE acr, no matter what."
ocsenave@246 64 "opponent atk -1" ;; acr taken from move acr?
ocsenave@246 65 "opponent def -1" ;;
ocsenave@246 66 "opponent spd -1" ;;
ocsenave@246 67 "opponent spc -1" ;;
ocsenave@246 68 "opponent acr -1";;
ocsenave@246 69 "opponent evd -1"
ocsenave@246 70 "converts user's type to opponent's."
ocsenave@246 71 "(haze)"
ocsenave@246 72 "(bide)"
ocsenave@246 73 "(thrash)"
ocsenave@246 74 "(teleport)"
ocsenave@246 75 "(fury swipes)"
ocsenave@246 76 "attacks 2-5 turns" ;; unused? like rollout?
ocsenave@246 77 "0x19 chance of flinch"
ocsenave@246 78 "opponent sleep for 1-7 turns"
ocsenave@246 79 "0x66 chance of poison"
ocsenave@246 80 "0x4D chance of burn"
ocsenave@246 81 "0x4D chance of freeze"
ocsenave@246 82 "0x4D chance of paralyze"
ocsenave@246 83 "0x4D chance of flinch"
ocsenave@246 84 "one-hit KO"
ocsenave@246 85 "charge one turn, atk next."
ocsenave@246 86 "fixed damage, leaves 1HP." ;; how is dmg determined?
ocsenave@246 87 "fixed damage." ;; cf seismic toss, dragon rage, psywave.
ocsenave@246 88 "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20)
ocsenave@246 89 "charge one turn, atk next. (can't be hit when charging)"
ocsenave@246 90 "atk hits twice."
ocsenave@246 91 "user takes 1 damage if misses."
ocsenave@246 92 "evade status-lowering effects" ;;caused by you or also your opponent?
ocsenave@246 93 "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect"
ocsenave@246 94 "atk causes recoil dmg = 1/4 dmg dealt"
ocsenave@246 95 "confuses opponent" ;; acr taken from move acr
ocsenave@246 96 "user atk +2"
ocsenave@246 97 "user def +2"
ocsenave@246 98 "user spd +2"
ocsenave@246 99 "user spc +2"
ocsenave@246 100 "user acr +2" ;; unused!
ocsenave@246 101 "user evd +2" ;; unused!
ocsenave@246 102 "restores up to half of user's max hp." ;; broken: fails if the difference
ocsenave@246 103 ;; b/w max and current hp is one less than a multiple of 256.
ocsenave@246 104 "(transform)"
ocsenave@246 105 "opponent atk -2"
ocsenave@246 106 "opponent def -2"
ocsenave@246 107 "opponent spd -2"
ocsenave@246 108 "opponent spc -2"
ocsenave@246 109 "opponent acr -2"
ocsenave@246 110 "opponent evd -2"
ocsenave@246 111 "doubles user spc when attacked"
ocsenave@246 112 "doubles user def when attacked"
ocsenave@246 113 "poisons opponent" ;;acr taken from move acr
ocsenave@246 114 "paralyzes opponent" ;;
ocsenave@246 115 "0x19 chance opponent atk -1"
ocsenave@246 116 "0x19 chance opponent def -1"
ocsenave@246 117 "0x19 chance opponent spd -1"
ocsenave@246 118 "0x4C chance opponent spc -1" ;; context suggest chance is 0x19
ocsenave@246 119 "0x19 chance opponent acr -1"
ocsenave@246 120 "0x19 chance opponent evd -1"
ocsenave@246 121 "???" ;; unused? no effect?
ocsenave@246 122 "???" ;; unused? no effect?
ocsenave@246 123 "0x19 chance opponent confused"
ocsenave@246 124 "atk hits twice. 0x33 chance opponent poisioned."
ocsenave@246 125 "broken. crash the game after attack."
ocsenave@246 126 "(substitute)"
ocsenave@246 127 "unless opponent faints, user must recharge after atk. some
ocsenave@246 128 exceptions apply."
ocsenave@246 129 "(rage)"
ocsenave@246 130 "(mimic)"
ocsenave@246 131 "(metronome)"
ocsenave@246 132 "(leech seed)"
ocsenave@246 133 "does nothing (splash)"
ocsenave@246 134 "(disable)"
ocsenave@246 135 ])
ocsenave@246 136
ocsenave@246 137
ocsenave@246 138
ocsenave@246 139
ocsenave@246 140
ocsenave@246 141 (def hxc-items
ocsenave@246 142 "The hardcoded names of the items in memory. List begins at ROM@045B7 "
ocsenave@246 143 (map character-codes->str
ocsenave@246 144 (take-nth 2
ocsenave@246 145 (partition-by #(= % 0x50)
ocsenave@246 146 (take 1200
ocsenave@246 147 (drop 0x45B7 (rom (root))))))))
ocsenave@246 148
ocsenave@246 149 (def hxc-types
ocsenave@246 150 "The hardcoded type names in memory. List begins at ROM@27D99,
ocsenave@246 151 shortly before hxc-titles."
ocsenave@246 152 (map character-codes->str
ocsenave@246 153 (take-nth 2
ocsenave@246 154 (partition-by #(= 0x50 %)
ocsenave@246 155 (take 102
ocsenave@246 156 (drop 0x27D99
ocsenave@246 157 (rom (root))))))))
ocsenave@246 158
ocsenave@246 159 (def hxc-titles
ocsenave@246 160 "The hardcoded names of the trainer titles in memory. List begins at
ocsenave@246 161 ROM@27E77"
ocsenave@246 162 (map character-codes->str
ocsenave@246 163 (take-nth 2
ocsenave@246 164 (partition-by #(= 0x50 %)
ocsenave@246 165 (take 196
ocsenave@246 166 (drop 0x27E77
ocsenave@246 167 (rom (root))))))))
ocsenave@246 168
ocsenave@246 169
ocsenave@246 170 (def hxc-places
ocsenave@246 171 "The hardcoded place names in memory. List begins at
ocsenave@246 172 ROM@71500. Cinnabar Mansion is dynamically calculated."
ocsenave@246 173 (map character-codes->str
ocsenave@246 174 (take-nth 2
ocsenave@246 175 (partition-by #(= % 0x50)
ocsenave@246 176 (take 560
ocsenave@246 177 (drop 0x71500
ocsenave@246 178 (rom (root))))))))
ocsenave@246 179
ocsenave@246 180
ocsenave@246 181 (def hxc-dialog
ocsenave@246 182 "The hardcoded dialogue in memory, including in-game alerts. List begins at ROM@98000."
ocsenave@246 183 (character-codes->str(take 0x0F728
ocsenave@246 184 (drop (+ 0x98000)
ocsenave@246 185 (rom (root))))))
ocsenave@246 186
ocsenave@246 187 (def hxc-pokedex
ocsenave@246 188 "The hardcoded pokedex entries in memory. List begins at
ocsenave@246 189 ROM@B8000, shortly before move names."
ocsenave@246 190 (map character-codes->str
ocsenave@246 191 (take-nth 2
ocsenave@246 192 (partition-by #(= % 0x50)
ocsenave@246 193 (take 14754
ocsenave@246 194 (drop 0xB8000
ocsenave@246 195 (rom (root))))))))
ocsenave@246 196 (def hxc-move-names
ocsenave@246 197 "The hardcoded move names in memory. List begins at ROM@BC000"
ocsenave@246 198 (map character-codes->str
ocsenave@246 199 (take-nth 2
ocsenave@246 200 (partition-by #(= % 0x50)
ocsenave@246 201 (take 1551
ocsenave@246 202 (drop 0xBC000
ocsenave@246 203 (rom (root))))))))
ocsenave@246 204
ocsenave@246 205 (def hxc-move-data
ocsenave@246 206 "The hardcoded (basic (move effects)) in memory. List begins at
ocsenave@246 207 0x38000. Effect descriptions were handwritten and aren't hardcoded."
ocsenave@246 208 (let [names (vec hxc-move-names)
ocsenave@246 209 move-count (count names)
ocsenave@246 210 move-size 6
ocsenave@246 211 format-name (fn [s]
ocsenave@246 212 (keyword (.toLowerCase
ocsenave@246 213 (apply str
ocsenave@246 214 (map #(if (= % \space) "-" %) s)))))
ocsenave@246 215 ]
ocsenave@246 216 (zipmap (map format-name names)
ocsenave@246 217 (map
ocsenave@246 218 (fn [[idx effect power type accuracy pp]]
ocsenave@246 219 {:name (names (dec idx))
ocsenave@246 220 :power power
ocsenave@246 221 :accuracy (hex accuracy)
ocsenave@246 222 :pp pp
ocsenave@246 223 :fx-id (hex effect)
ocsenave@246 224 :fx-txt (get move-effects effect)
ocsenave@246 225 }
ocsenave@246 226 )
ocsenave@246 227
ocsenave@246 228 (partition move-size
ocsenave@246 229 (take (* move-size move-count)
ocsenave@246 230 (drop 0x38000 (rom(root)))))))))
ocsenave@246 231
ocsenave@246 232
ocsenave@246 233
ocsenave@246 234 (def hxc-pokenames
ocsenave@246 235 "The hardcoded names of the 190 species in memory. List begins at ROM@E8000."
ocsenave@246 236 (let [count-species 190
ocsenave@246 237 name-length 10]
ocsenave@246 238 (map character-codes->str
ocsenave@246 239 (partition name-length
ocsenave@246 240 (take (* count-species name-length)
ocsenave@246 241 (drop 0xE8000
ocsenave@246 242 (rom(root))))))))
ocsenave@246 243
ocsenave@246 244
ocsenave@246 245
ocsenave@246 246
ocsenave@246 247
ocsenave@246 248
ocsenave@246 249
ocsenave@246 250
ocsenave@246 251
ocsenave@243 252 (def hxc-advantage
ocsenave@245 253 "The hardcoded type advantages in memory, returned as tuples of [atk-type def-type multiplier]. By default (i.e. if not listed here), the multiplier is 1."
ocsenave@243 254 (map
ocsenave@243 255 (fn [[atk def mult]] [(get pkmn-types atk (hex atk))
ocsenave@243 256 (get pkmn-types def (hex def))
ocsenave@243 257 (/ mult 10)])
ocsenave@243 258 (partition 3
ocsenave@243 259 (take-while (partial not= 0xFF)
ocsenave@243 260 (drop 0x3E62D (rom(root)))))))
ocsenave@243 261
ocsenave@243 262
ocsenave@243 263
ocsenave@243 264
ocsenave@243 265
ocsenave@243 266
ocsenave@243 267
ocsenave@243 268
ocsenave@243 269
ocsenave@243 270
ocsenave@243 271
ocsenave@243 272
ocsenave@243 273
ocsenave@243 274
ocsenave@243 275
ocsenave@246 276 ;; note for later: credits start at F1290
ocsenave@243 277
ocsenave@243 278
ocsenave@243 279
ocsenave@246 280 (comment
ocsenave@243 281
rlm@218 282 (def hxc-later
rlm@218 283 "Running this code produces, e.g. hardcoded names NPCs give
rlm@218 284 their pokemon. Will sort through it later."
rlm@218 285 (print (character-codes->str(take 10000
rlm@218 286 (drop 0x71597
rlm@218 287 (rom (root)))))))
rlm@218 288
rlm@218 289 (let [dex
rlm@218 290 (partition-by #(= 0x50 %)
rlm@218 291 (take 2540
rlm@218 292 (drop 0x40687
rlm@218 293 (rom (root)))))]
rlm@218 294 (def dex dex)
rlm@218 295 (def hxc-species
rlm@218 296 (map character-codes->str
rlm@218 297 (take-nth 4 dex))))
ocsenave@246 298 )