aaaaaa123456789

Pokemon ROM hacking - Fossil script

Jun 25th, 2015
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 KB | None | 0 0
  1. /*
  2. FOSSIL SCRIPT
  3. by aaaaaa123456789, 2015-06-25
  4. This script is hereby released to the public domain.
  5.  
  6. This script controls the NPC that revives fossils in Devon Corporation. It
  7. is meant as a replacement for the current script at 0x082118f1.
  8.  
  9. Variables used:
  10. 0x4001: parameter to an external call
  11. 0x40c4: fossil revival status (0: ready, 1: waiting, 2: done)
  12. [this variable is changed externally from 1 to 2]
  13. 0x40c5: species that is waiting for revival
  14. 0x8000: parameter 1
  15. 0x8001: parameter 2, temporary
  16. 0x8002: pure temporary
  17. 0x800d: (alias: LASTRESULT) result of the last call
  18.  
  19. Flags affected:
  20. 0x10b: something was revived (write-only)
  21.  
  22. Externals referenced:
  23. 0x08273374: string: rename this Pokemon (parameters: [buffer1]: species)
  24. 0x082723dd: procedure: rename Pokemon in party (parameters: 0x8004: ID)
  25. 0x0827378b: procedure: get last ID in party (return value in 0x8004)
  26. 0x08273797: procedure: rename last deposited Pokemon
  27. 0x082737a0: procedure: show deposit message (shows a message indicating
  28. that the recently received Pokemon was deposited) (parameters:
  29. 0x4001: species)
  30. 0x08273811: procedure: no room for Pokemon (shows an error message stating
  31. there is no room for an extra Pokemon in the party and exits)
  32.  
  33. Notes:
  34. 1) This script requires a #dynamic directive to be placed before it.
  35. 2) The instructions to modify the script to allow for new or different
  36. fossils and Pokemon are placed at the end, where the corresponding
  37. primitives are located.
  38. */
  39.  
  40. #org @fossil_main
  41. lock
  42. faceplayer
  43. compare 0x40c4 2
  44. if 1 goto @fossil_revival_done
  45. compare 0x40c4 1
  46. if 1 goto @fossil_revival_waiting
  47. msgbox @fossil_str0 4
  48. call @fossil_count_fossils
  49. compare LASTRESULT 1
  50. if 2 goto @fossil_many_fossils
  51. compare LASTRESULT 1
  52. if 1 goto @fossil_one_fossil
  53. release
  54. end
  55.  
  56. #org @fossil_revival_done
  57. compare 0x40c5 0
  58. if 1 goto @fossil_revival_nothing
  59. bufferpokemon 1 0x40c5
  60. msgbox @fossil_str8 4
  61. givepokemon 0x40c5 20 0 0 0 0
  62. bufferpokemon 0 0x40c5
  63. copyvar 0x4001 0x40c5
  64. compare LASTRESULT 0
  65. if 1 goto @fossil_done_no_deposit
  66. compare LASTRESULT 1
  67. if 1 goto @fossil_done_with_deposit
  68. goto 0x8273811
  69.  
  70. #org @fossil_done_no_deposit
  71. call @fossil_show_received
  72. msgbox 0x8273374 5
  73. compare LASTRESULT 0
  74. if 1 goto @fossil_done_end
  75. call 0x827378b
  76. call 0x82723dd
  77. goto @fossil_done_end
  78.  
  79. #org @fossil_done_with_deposit
  80. call @fossil_show_received
  81. msgbox 0x8273374 5
  82. compare LASTRESULT 0
  83. if 1 goto @fossil_show_deposit
  84. call 0x8273797
  85. goto @fossil_show_deposit
  86.  
  87. #org @fossil_show_deposit
  88. call 0x82737a0
  89. goto @fossil_done_end
  90.  
  91. #org @fossil_done_end
  92. setvar 0x40c4 0
  93. setflag 0x10b
  94. release
  95. end
  96.  
  97. #org @fossil_show_received
  98. fanfare 0x172
  99. preparemsg @fossil_str10
  100. waitmsg
  101. waitfanfare
  102. return
  103.  
  104. #org @fossil_revival_nothing
  105. msgbox @fossil_str9 4
  106. setvar 0x40c4 0
  107. release
  108. end
  109.  
  110. #org @fossil_revival_waiting
  111. msgbox @fossil_str7 4
  112. release
  113. end
  114.  
  115. #org @fossil_count_fossils
  116. setvar 0x8002 0
  117. setvar 0x8000 0
  118. call @fossil_add_next_fossil
  119. copyvar LASTRESULT 0x8002
  120. return
  121.  
  122. #org @fossil_add_next_fossil
  123. call @fossil_get_fossil_by_ID
  124. copyvar 0x8001 LASTRESULT
  125. compare 0x8001 0
  126. if 1 goto @fossil_return
  127. addvar 0x8000 1
  128. checkitem 0x8001 1
  129. compare LASTRESULT 1
  130. if 0 goto @fossil_add_next_fossil
  131. addvar 0x8002 1
  132. goto @fossil_add_next_fossil
  133.  
  134. #org @fossil_many_fossils
  135. call @fossil_found_fossil
  136. compare LASTRESULT 0
  137. if 1 goto @fossil_turned_down
  138. msgbox @fossil_str4 4
  139. setvar 0x8000 0
  140. call @fossil_find_next_fossil
  141. copyvar 0x8000 LASTRESULT
  142. call @fossil_get_fossil_by_ID
  143. copyvar 0x8001 LASTRESULT
  144. compare 0x8001 0
  145. if 1 goto @fossil_close
  146. call @fossil_ask_fossil_1
  147. compare LASTRESULT 1
  148. if 1 goto @fossil_revival_chosen
  149. addvar 0x8000 1
  150. goto @fossil_try_next_fossil
  151.  
  152. #org @fossil_try_next_fossil
  153. call @fossil_find_next_fossil
  154. copyvar 0x8000 LASTRESULT
  155. call @fossil_get_fossil_by_ID
  156. copyvar 0x8001 LASTRESULT
  157. compare 0x8001 0
  158. if 1 goto @fossil_turned_down
  159. call @fossil_ask_fossil_2
  160. compare LASTRESULT 1
  161. if 1 goto @fossil_revival_chosen
  162. addvar 0x8000 1
  163. goto @fossil_try_next_fossil
  164.  
  165. #org @fossil_ask_fossil_1
  166. bufferitem 0 0x8001
  167. msgbox @fossil_str5 5
  168. return
  169.  
  170. #org @fossil_ask_fossil_2
  171. bufferitem 0 0x8001
  172. msgbox @fossil_str6 5
  173. return
  174.  
  175. #org @fossil_one_fossil
  176. setvar 0x8000 0
  177. call @fossil_find_next_fossil
  178. copyvar 0x8000 LASTRESULT
  179. call @fossil_get_fossil_by_ID
  180. copyvar 0x8001 LASTRESULT
  181. compare 0x8001 0
  182. if 1 goto @fossil_close
  183. call @fossil_found_fossil
  184. compare LASTRESULT 0
  185. if 1 goto @fossil_turned_down
  186. goto @fossil_revival_chosen
  187.  
  188. #org @fossil_revival_chosen
  189. bufferitem 0 0x8001
  190. msgbox @fossil_str3 4
  191. removeitem 0x8001 1
  192. call @fossil_get_pokemon_by_ID
  193. copyvar 0x40c5 LASTRESULT
  194. setvar 0x40c4 1
  195. release
  196. end
  197.  
  198. #org @fossil_find_next_fossil
  199. call @fossil_get_fossil_by_ID
  200. copyvar 0x8002 LASTRESULT
  201. compare 0x8002 0
  202. if 1 goto @fossil_return_current_fossil
  203. checkitem 0x8002 1
  204. compare LASTRESULT 1
  205. if 1 goto @fossil_return_current_fossil
  206. addvar 0x8000 1
  207. goto @fossil_find_next_fossil
  208.  
  209. #org @fossil_return_current_fossil
  210. copyvar LASTRESULT 0x8000
  211. return
  212.  
  213. #org @fossil_return
  214. return
  215.  
  216. #org @fossil_close
  217. release
  218. end
  219.  
  220. #org @fossil_found_fossil
  221. closeonkeypress
  222. sound 0x15
  223. applymovement 5 @fossil_move0
  224. waitmovement 0
  225. applymovement 5 @fossil_move1
  226. waitmovement 0
  227. msgbox @fossil_str1 5
  228. return
  229.  
  230. #org @fossil_turned_down
  231. msgbox @fossil_str2 4
  232. release
  233. end
  234.  
  235.  
  236. // Strings
  237. #org @fossil_str0
  238. = I've been trying to develop a device\nthat resurrects POKéMON from fossils[.]\pAnd, it's working!
  239. #org @fossil_str1
  240. = Wait! That thing you have there[.]\nIs that a POKéMON fossil?\pWould you like to bring that POKéMON\nback to life?\pI can with my newly developed\nFOSSIL REGENERATOR.
  241. #org @fossil_str2
  242. = Oh, is that so?\pDEVON's technological expertise\nis outstanding, I tell you.
  243. #org @fossil_str3
  244. = Excellent!\nLet's do this right away.\p[player] handed the [buffer1] to\nthe DEVON RESEARCHER.
  245. #org @fossil_str4
  246. = Oh, now that's a surprise!\nYou have not one, but many, fossils?\pUnfortunately, my machine can only\nregenerate one POKéMON at a time.
  247. #org @fossil_str5
  248. = You will have to pick one of your\nfossils. Should we begin with the\l[buffer1]?
  249. #org @fossil_str6
  250. = How about the [buffer1]?
  251. #org @fossil_str7
  252. = The FOSSIL REGENERATOR, which I made,\nis incredible.\pBut it has one drawback--it takes\na long time to work.\pSo, uh[.] How about you go for a stroll\nand look around for a while?
  253. #org @fossil_str8
  254. = Thanks for waiting!\pYour fossilized POKéMON has been\nbrought back to life!\pThe fossil was an ancient POKéMON.\n[buffer2], it was!
  255. #org @fossil_str9
  256. = Thanks for waiting!\pUnfortunately, your fossil turned\nout to be just a bunch of old\lrocks. Nothing came out of it.\pIf you find any more fossils,\nbring them to me and I'll try to\lrevive them.
  257. #org @fossil_str10
  258. = [player] received [buffer1] from\nthe DEVON RESEARCHER.
  259.  
  260.  
  261. // Movements
  262. #org @fossil_move0
  263. #raw 0x56 0xfe
  264. #org @fossil_move1
  265. #raw 0x14 0x14 0x14 0xfe
  266.  
  267.  
  268. // Modifiable primitives
  269. #org @fossil_get_fossil_by_ID
  270. /*
  271. This primitive returns the various items that are acknowledged as fossils.
  272. For each one of them, add the following lines of code:
  273. setvar LASTRESULT <item number>
  274. compare 0x8000 <ID>
  275. if 1 goto @fossil_return
  276. where <item number> is the fossil's item number, and <ID> is an incrementing
  277. ID (0 for the first one, 1 for the second one, and so on). There must be at
  278. least two fossils for the script to work properly.
  279. */
  280. setvar LASTRESULT 0x11e
  281. compare 0x8000 0
  282. if 1 goto @fossil_return
  283. setvar LASTRESULT 0x11f
  284. compare 0x8000 1
  285. if 1 goto @fossil_return
  286. // fossil list ends here. Do not modify the following lines.
  287. setvar LASTRESULT 0
  288. return
  289.  
  290. #org @fossil_get_pokemon_by_ID
  291. /*
  292. This primitive returns the Pokemon that are revived by each fossil. For each
  293. one of them, add the following lines of code:
  294. setvar LASTRESULT <pokemon number>
  295. compare 0x8000 <ID>
  296. if 1 goto @fossil_return
  297. where <pokemon number> is the internal number for the Pokemon, and <ID> is
  298. the same ID number that was set for the corresponding fossil in the previous
  299. primitive. The IDs for the fossils and the Pokemon must match.
  300. If a Pokemon number is set to 0, the fossil will be a dud/fake fossil (i.e.,
  301. will not contain a Pokemon when revived).
  302. */
  303. setvar LASTRESULT 0x184
  304. compare 0x8000 0
  305. if 1 goto @fossil_return
  306. setvar LASTRESULT 0x186
  307. compare 0x8000 1
  308. if 1 goto @fossil_return
  309. // Pokemon list ends here. Do not modify the following lines.
  310. setvar LASTRESULT 0
  311. return
Add Comment
Please, Sign In to add comment