quest_utils.py 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # SPDX-FileCopyrightText: Copyright (C) 2022-2023 MH3SP Server Project
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. """Quest utils module."""
  6. from os import path
  7. import struct
  8. from other.utils import pad
  9. from mh.equipment_utils import create_arena_equipment_set
  10. class Enum(object):
  11. def __getitem__(self, idx):
  12. return getattr(self, idx)
  13. class WaveType(Enum):
  14. none = 0
  15. monster = 1
  16. item = 2
  17. unknown = 3
  18. class LocationType(Enum):
  19. QUEST_LOCATION_NONE = 0
  20. QUEST_LOCATION_D_ISLAND = 1
  21. QUEST_LOCATION_SANDY_PLAINS = 2
  22. QUEST_LOCATION_FLOODED_FOR = 3
  23. QUEST_LOCATION_TUNDRA = 4
  24. QUEST_LOCATION_VOLCANO = 5
  25. QUEST_LOCATION_GRT_DESERT = 6
  26. QUEST_LOCATION_UW_RUIN = 7
  27. QUEST_LOCATION_LAND_ARENA_1 = 8
  28. QUEST_LOCATION_LAND_ARENA_2 = 9
  29. QUEST_LOCATION_WATER_ARENA_1 = 10
  30. QUEST_LOCATION_SACRED_LAND = 11
  31. QUEST_LOCATION_WATER_ARENA_2 = 12
  32. LocationType = LocationType()
  33. LOCATION_SIZE = {
  34. LocationType.QUEST_LOCATION_NONE: 0,
  35. LocationType.QUEST_LOCATION_D_ISLAND: 13,
  36. LocationType.QUEST_LOCATION_SANDY_PLAINS: 12,
  37. LocationType.QUEST_LOCATION_FLOODED_FOR: 11,
  38. LocationType.QUEST_LOCATION_TUNDRA: 10,
  39. LocationType.QUEST_LOCATION_VOLCANO: 11,
  40. LocationType.QUEST_LOCATION_GRT_DESERT: 3,
  41. LocationType.QUEST_LOCATION_UW_RUIN: 4,
  42. LocationType.QUEST_LOCATION_LAND_ARENA_1: 2,
  43. LocationType.QUEST_LOCATION_LAND_ARENA_2: 2,
  44. LocationType.QUEST_LOCATION_WATER_ARENA_1: 2,
  45. LocationType.QUEST_LOCATION_SACRED_LAND: 2,
  46. LocationType.QUEST_LOCATION_WATER_ARENA_2: 2,
  47. }
  48. class Monster(Enum):
  49. none = 0
  50. rathian = 1
  51. rathalos = 2
  52. qurupeco = 3
  53. gigginox = 4
  54. barioth = 5
  55. diablos = 6
  56. deviljho = 7
  57. barroth = 8
  58. uragaan = 9
  59. jaggi = 10
  60. jaggia = 11
  61. great_jaggi = 12
  62. baggi = 13
  63. great_baggi = 14
  64. lagiacrus = 15
  65. royal_ludroth = 16
  66. ludroth = 17
  67. gobul = 18
  68. agnaktor = 19
  69. ceadeus = 20
  70. uroktor = 21
  71. delex = 22
  72. epioth = 23
  73. alatreon = 24
  74. jhen_mohran = 25
  75. giggi = 26
  76. aptonoth = 27
  77. popo = 28
  78. rhenoplos = 29
  79. felyne = 30
  80. melynx = 31
  81. fish = 32
  82. altaroth = 33
  83. kelbi = 34
  84. bnahabra1 = 35 # Gigginox Egg
  85. bnahabra2 = 36 # Bnahabra (Blue Wing)
  86. bnahabra3 = 37 # Bnahabra (Orange Wing)
  87. bnahabra4 = 38 # Bnahabra (Green Wing)
  88. brd_wyv = 39 # Bnahabra (Red Wing)
  89. fly_wyv = 40 # ---- INVALID AS AN IN-QUEST MONSTER ---
  90. brt_wyv = 41 # ---- INVALID AS AN IN-QUEST MONSTER ---
  91. psc_wyv = 42 # ---- INVALID AS AN IN-QUEST MONSTER ---
  92. levthn = 43 # ---- INVALID AS AN IN-QUEST MONSTER ---
  93. elddrg = 44 # ---- INVALID AS AN IN-QUEST MONSTER ---
  94. lynian = 45 # ---- INVALID AS AN IN-QUEST MONSTER ---
  95. herbvr = 46 # ---- INVALID AS AN IN-QUEST MONSTER ---
  96. nptron = 47 # ---- INVALID AS AN IN-QUEST MONSTER ---
  97. unk = 48 # ---- INVALID AS AN IN-QUEST MONSTER ---
  98. Monster = Monster()
  99. class QuestRankType(Enum):
  100. none = 0
  101. star_1 = 1
  102. star_2 = 2
  103. star_3 = 3
  104. star_4 = 4
  105. star_5 = 5
  106. urgent = 6
  107. QuestRankType = QuestRankType()
  108. class ItemsType(Enum):
  109. none = 0
  110. barrel_bomb_s = 1
  111. barrel_bomb_l = 2
  112. pitfall_trap = 3
  113. shock_trap = 4
  114. flash_bomb = 5
  115. oxygen_supply = 6
  116. sonic_bomb = 7
  117. throwing_knife = 8
  118. poison_knife = 9
  119. sleep_knife = 10
  120. paralysis_knife = 11
  121. tranq_knife = 12
  122. potion = 13
  123. mega_potion = 14
  124. dash_juice = 15
  125. mega_dash_juice = 16
  126. antidote = 17
  127. demondrug = 18
  128. mega_demondrug = 19
  129. might_pill = 20
  130. armorskin = 21
  131. mega_armorskin = 22
  132. adamant_pill = 23
  133. cool_drink = 24
  134. hot_drink = 25
  135. well_done_steak = 26
  136. rare_steak = 27
  137. burnt_meat = 28
  138. raw_meat = 29
  139. poisoned_meat = 30
  140. tinged_meat = 31
  141. druged_meat = 32
  142. paintball = 33
  143. old_pickaxe = 34
  144. iron_pickaxe = 35
  145. mega_pickaxe = 36
  146. old_bug_net = 37
  147. bug_net = 38
  148. mega_bug_net = 39
  149. bbq_spit = 40
  150. great_jagi_head = 41
  151. map = 42
  152. torch = 43
  153. first_aid_med = 44
  154. ration = 45
  155. mini_oxy_supply = 46
  156. portable_spit = 47
  157. mini_whetstone = 48
  158. ez_shock_trap = 49
  159. ez_flash_bomb = 50
  160. max_potion = 51
  161. barrel_bomb_l_plus = 52
  162. normal_s_lv1 = 53
  163. normal_s_lv2 = 54
  164. normal_s_lv3 = 55
  165. pierce_s_lv1 = 56
  166. pierce_s_lv2 = 57
  167. pierce_s_lv3 = 58
  168. pellet_s_lv1 = 59
  169. pellet_s_lv2 = 60
  170. pellet_s_lv3 = 61
  171. crag_s_lv1 = 62
  172. crag_s_lv2 = 63
  173. crag_s_lv3 = 64
  174. clust_s_lv1 = 65
  175. clust_s_lv2 = 66
  176. clust_s_lv3 = 67
  177. flaming_s = 68
  178. water_s = 69
  179. thunder_s = 70
  180. freeze_s = 71
  181. dragon_s = 72
  182. recov_s_lv1 = 73
  183. recov_s_lv2 = 74
  184. poison_s_lv1 = 75
  185. poison_s_lv2 = 76
  186. para_s_lv1 = 77
  187. para_s_lv2 = 78
  188. sleep_s_lv1 = 79
  189. sleep_s_lv2 = 80
  190. tranq_s = 81
  191. paint_s = 82
  192. demon_s_i = 83
  193. demon_s_ii = 84
  194. armor_s_i = 85
  195. armor_s_ii = 86
  196. sub_s_lv1 = 87
  197. sub_s_lv2 = 88
  198. exhaust_s = 89
  199. err89 = 90
  200. slicing_s = 91
  201. wyvernfire_lv1 = 92
  202. wyvernfire_lv2 = 93
  203. wyvernfire_lv3 = 94
  204. binoculars = 95
  205. tranq_bomb = 96
  206. stone = 97
  207. whetstone = 98
  208. iron_ore = 99
  209. earth_crystal = 100
  210. machalite_ore = 101
  211. dragonite_ore = 102
  212. carbalite_ore = 103
  213. pelagicite_ore = 104
  214. bathycite_ore = 105
  215. firestone = 106
  216. ice_crystal = 107
  217. lightcrystal = 108
  218. sharq_ticket = 109
  219. rustshard = 110
  220. ancient_shard = 111
  221. isisium = 112
  222. gracium = 113
  223. err113 = 114
  224. godbug = 115
  225. bitterbug = 116
  226. flashbug = 117
  227. thunderbug = 118
  228. gluehopper = 119
  229. killer_beetle = 120
  230. rare_scarab = 121
  231. royal_rhino = 122
  232. herb = 123
  233. antidote_herb = 124
  234. sleep_herb = 125
  235. fire_herb = 126
  236. sap_plant = 127
  237. paintberry = 128
  238. needleberry = 129
  239. huskberry = 130
  240. scatternut = 131
  241. bomberry = 132
  242. ivy = 133
  243. might_seed = 134
  244. adamant_seed = 135
  245. hot_pepper = 136
  246. cactus_flower = 137
  247. airweed = 138
  248. wyvern_eg = 139
  249. unknown_skull = 140
  250. honey = 141
  251. blue_mushroom = 142
  252. choice_mushroom = 143
  253. unique_mushroom = 144
  254. exciteshroom = 145
  255. parashroom = 146
  256. nitroshroom = 147
  257. err147 = 148
  258. black_pearl = 149
  259. jumbo_pearl = 150
  260. broken_shell = 151
  261. dragonbone_relic = 152
  262. monster_bone_s = 153
  263. monster_bone_m = 154
  264. monster_bone_l = 155
  265. err155 = 156
  266. eldest_saturnian = 157
  267. err157 = 158
  268. err158 = 159
  269. err159 = 160
  270. err160 = 161
  271. err161 = 162
  272. err162 = 163
  273. hercudrome = 164
  274. err164 = 165
  275. chilled_meat = 166
  276. hot_meat = 167
  277. err167 = 168
  278. rathian_scale_plus = 169
  279. rathian_carapace = 170
  280. rath_medulla = 171
  281. rathian_spike_plus = 172
  282. rathian_ruby = 173
  283. rathalos_ruby = 174
  284. inferno_sac = 175
  285. rathalos_scale_plus = 176
  286. rathaloscarapace = 177
  287. qurupeco_scale_plus = 178
  288. err178 = 179
  289. wonderful_beak = 180
  290. unnerving_talon = 181
  291. fearsome_maw = 182
  292. wyvern_stone = 183
  293. freezer_sac = 184
  294. wyvrnhide_ticket = 185
  295. black_gem_ticket = 186
  296. flabby_hide_plus = 187
  297. uncanny_hide_plus = 188
  298. toxin_sac = 189
  299. unnerving_talon_plus = 190
  300. stunning_quill = 191
  301. pittance_fang = 192
  302. vermilion_scale = 193
  303. fishing_harpoon = 194
  304. insect_husk = 195
  305. bone = 196
  306. dung = 197
  307. spider_web = 198
  308. bomb_casing = 199
  309. small_barrel = 200
  310. large_barrel = 201
  311. cricket = 202
  312. worm = 203
  313. firefly = 204
  314. mega_fishing_fly = 205
  315. frog = 206
  316. whetfish = 207
  317. sushifish = 208
  318. pin_tuna = 209
  319. popfish = 210
  320. sleepyfish = 211
  321. burst_arowana = 212
  322. bomb_arowana = 213
  323. glutton_tuna = 214
  324. scatterfish = 215
  325. small_goldenfish = 216
  326. goldenfish = 217
  327. err217 = 218
  328. beautiful_scale = 219
  329. giant_skull = 220
  330. pirate_booty = 221
  331. net = 222
  332. no_item = 223
  333. shroom_germ = 224
  334. bugmaker_pro = 225
  335. bizzy_bees = 226
  336. saturnian = 227
  337. fortune_fang = 228
  338. shining_starfish = 229
  339. mystic_narwhal = 230
  340. atlantis_crab = 231
  341. gold_needle = 232
  342. armorfish_morsel = 233
  343. fish_finder = 234
  344. treasure_tracker = 235
  345. spare_spear = 236
  346. perfect_paddle = 237
  347. shroom_germ_plus = 238
  348. pink_liver = 239
  349. ethnic_wyvrnmeat = 240
  350. ancient_skin_oil = 241
  351. queens_spirit = 242
  352. err242 = 243
  353. funky_pheromones = 244
  354. saturnian_trap = 245
  355. err245 = 246
  356. super_sized_dung = 247
  357. fine_pelt = 248
  358. moonlight_fang = 249
  359. queen_needle = 250
  360. power_paddle = 251
  361. curved_fang = 252
  362. flamboyant_quill = 253
  363. glittering_scale = 254
  364. sea_kings_scale = 255
  365. wyverngold = 256
  366. err256 = 257
  367. err257 = 258
  368. err258 = 259
  369. err259 = 260
  370. err260 = 261
  371. err261 = 262
  372. err262 = 263
  373. felvine_bomb = 264
  374. double_bbq_spit = 265
  375. dragonbone_piece = 266
  376. abalone_piece = 267
  377. fossil_piece = 268
  378. odd_eg = 269
  379. mystery_bone = 270
  380. err270 = 271
  381. err271 = 272
  382. herbal_medicine = 273
  383. rathian_scale = 274
  384. rathian_shell = 275
  385. rathian_webbing = 276
  386. rathian_spike = 277
  387. rathian_plate = 278
  388. flame_sac = 279
  389. wyvern_tear = 280
  390. rathalos_scale = 281
  391. rathalos_shell = 282
  392. rathalos_webbing = 283
  393. rath_marrow = 284
  394. rathalos_plate = 285
  395. rathalos_tail = 286
  396. qurupeco_scale = 287
  397. qurupeco_feather = 288
  398. vivid_feather = 289
  399. strange_beak = 290
  400. flabby_hide = 291
  401. uncanny_hide = 292
  402. poison_sac = 293
  403. pale_extract = 294
  404. diablos_fang = 295
  405. diablos_shell = 296
  406. diablos_ridge = 297
  407. diablos_tailcase = 298
  408. barroth_shell = 299
  409. barroth_ridge = 300
  410. barroth_claw = 301
  411. barroth_tail = 302
  412. barroth_scalp = 303
  413. bird_wyvern_fang = 304
  414. jagi_hide = 305
  415. jagi_scale = 306
  416. great_jagi_claw = 307
  417. great_jagi_hide = 308
  418. screamer = 309
  419. lagiacrus_hide = 310
  420. lagiacrus_scale = 311
  421. lagiacrus_claw = 312
  422. shell_shocker_plus = 313
  423. lagiacrus_tail = 314
  424. lagiacrus_plate = 315
  425. spongy_hide = 316
  426. r_ludroth_scale = 317
  427. r_ludroth_claw = 318
  428. r_ludroth_tail = 319
  429. dash_extract = 320
  430. hydro_hide = 321
  431. immature_sponge = 322
  432. gobul_spike = 323
  433. gobul_hide = 324
  434. paralysis_sac = 325
  435. gobul_fin = 326
  436. armor_sphere = 327
  437. armor_sphere_plus = 328
  438. gobul_lantern = 329
  439. warm_pelt = 330
  440. nutrients = 331
  441. mega_nutrients = 332
  442. dragon_toadstool = 333
  443. immunizer = 334
  444. catalyst = 335
  445. bomb_sac = 336
  446. kelbi_horn = 337
  447. blue_kelbi_horn = 338
  448. bnahabra_shell = 339
  449. bnahabra_wing = 340
  450. monster_fluid = 341
  451. bone_husk_s = 342
  452. bone_husk_l = 343
  453. toadstool = 344
  454. smoke_bomb = 345
  455. poison_smoke_bmb = 346
  456. dung_bomb = 347
  457. gunpowder = 348
  458. trap_tool = 349
  459. yambug = 350
  460. tuna_bait = 351
  461. bughopper = 352
  462. arowana_bait = 353
  463. snakebee_larva = 354
  464. goldenfish_bait = 355
  465. antiseptic_stone = 356
  466. wyvern_fang = 357
  467. lifecrystals = 358
  468. wyvern_claw_ = 359
  469. lifepowder = 360
  470. hunting_horn = 361
  471. health_horn = 362
  472. antidote_horn = 363
  473. demon_horn = 364
  474. armor_horn = 365
  475. farcaster = 366
  476. tranquilizer = 367
  477. dragonfell_berry = 368
  478. err368 = 369
  479. err369 = 370
  480. err370 = 371
  481. err371 = 372
  482. err372 = 373
  483. energy_drink = 374
  484. cleanser = 375
  485. garbage = 376
  486. ancient_potion = 377
  487. psychoserum = 378
  488. agnaktor_coin = 379
  489. ballista_ammo = 380
  490. cannon_ammo = 381
  491. powderstone = 382
  492. anti_dragon_bomb = 383
  493. ballista_binder = 384
  494. rath_talon = 385
  495. twisted_horn = 386
  496. majestic_horn = 387
  497. mega_harpoon = 388
  498. whetfish_bait = 389
  499. sushifish_bait = 390
  500. firedouse_berry = 391
  501. waterblock_seed = 392
  502. icethaw_pellet = 393
  503. stormsender_seed = 394
  504. herbivore_eg = 395
  505. crystal_bone = 396
  506. golden_bone = 397
  507. air_philter = 398
  508. mega_air_philter = 399
  509. altaroth_stomach = 400
  510. altaroth_jaw = 401
  511. ripened_mushroom = 402
  512. r_ludroth_crest = 403
  513. barioth_shell = 404
  514. barioth_pelt = 405
  515. amber_tusks = 406
  516. barioth_claw = 407
  517. barioth_spike = 408
  518. frost_sac = 409
  519. uragaan_shell = 410
  520. uragaan_scute = 411
  521. uragaan_marrow = 412
  522. uragaan_jaw = 413
  523. agnaktor_shell = 414
  524. agnaktor_hide = 415
  525. agnaktor_fin = 416
  526. agnaktor_claw = 417
  527. agnaktor_scale = 418
  528. agnaktor_beak = 419
  529. kings_frill = 420
  530. fertile_mud = 421
  531. gobul_whisker = 422
  532. shell_shocker = 423
  533. lagiacrus_horn = 424
  534. flintstone = 425
  535. barioth_tail = 426
  536. bloodstone = 427
  537. paw_pass_ticket = 428
  538. monster_guts = 429
  539. red_coral_stone = 430
  540. voucher = 431
  541. gourmet_voucher = 432
  542. alatreon_scute = 433
  543. alatreon_plate = 434
  544. alatreon_talon = 435
  545. azure_dragongem = 436
  546. skypiercer = 437
  547. bbq_with_mask = 438
  548. no_mask = 439
  549. mystery_charm = 440
  550. shining_charm = 441
  551. timeworn_charm = 442
  552. armor_stone = 443
  553. adv_armor_sphere = 444
  554. hrd_armor_sphere = 445
  555. hvy_armor_sphere = 446
  556. aquaglow_jewel = 447
  557. sunspire_jewel = 448
  558. bloodrun_jewel = 449
  559. lazurite_jewel = 450
  560. barioth_carapace = 451
  561. barioth_pelt_plus = 452
  562. amber_tusks_plus = 453
  563. barioth_claw_plus = 454
  564. diablos_marrow = 455
  565. diablos_carapace = 456
  566. diablos_ridge = 457
  567. stout_horn = 458
  568. ceadeus_hide = 459
  569. ceadeus_scale = 460
  570. ceadeus_fur = 461
  571. ceadeus_tail = 462
  572. luminous_organ = 463
  573. deep_dragongem = 464
  574. crooked_horn = 465
  575. elderdragonblood = 466
  576. mohran_shell = 467
  577. mohran_brace = 468
  578. mohran_scale = 469
  579. sturdy_fang = 470
  580. earth_dragongem = 471
  581. mohran_carapace = 472
  582. mohran_scale_plus = 473
  583. sturdy_fang_plus = 474
  584. mohran_brace_plus = 475
  585. barroth_carapace = 476
  586. barroth_ridge_plus = 477
  587. barroth_claw_plus = 478
  588. uragaan_scale = 479
  589. uragaan_scale_plus = 480
  590. uragaan_ruby = 481
  591. uragaan_carapace = 482
  592. deviljho_hide = 483
  593. deviljho_scale = 484
  594. deviljho_talon = 485
  595. deviljho_fang = 486
  596. deviljho_gem = 487
  597. deviljho_scalp = 488
  598. deviljho_tail = 489
  599. quality_sponge = 490
  600. spongy_hide_plus = 491
  601. r_ludroth_scale_plus = 492
  602. r_ludroth_claw_plus = 493
  603. r_ludroth_crest_plus = 494
  604. gobul_spike_plus = 495
  605. gobul_hide_plus = 496
  606. gobul_lantern_plus = 497
  607. gobul_fin_plus = 498
  608. lagiacrus_hide_plus = 499
  609. lagiacrus_scale_plus = 500
  610. lagiacrus_claw_plus = 501
  611. lagiacrus_horn_plus = 502
  612. lagia_sapphire = 503
  613. agnaktor_tail = 504
  614. agnaktorcarapace = 505
  615. agnaktor_hide_plus = 506
  616. agnaktor_fin_plus = 507
  617. agnaktor_claw_plus = 508
  618. firecell_stone = 509
  619. brkn_skypiercer = 510
  620. alatreon_tail = 511
  621. alatreon_webbing = 512
  622. kelbi_horn_objet = 513
  623. twstd_horn_objet = 514
  624. mohranfang_objet = 515
  625. pigie = 516
  626. egie_pigie = 517
  627. rath_pigie = 518
  628. sandstone_plant = 519
  629. marshland_plant = 520
  630. snowflake_plant = 521
  631. prismshroom_lamp = 522
  632. qurupeco_lamp = 523
  633. sirensea_lamp = 524
  634. oceanic_fountain = 525
  635. bubbly_fountain = 526
  636. magma_fountain = 527
  637. iron_figure = 528
  638. machalite_figure = 529
  639. dragonite_figure = 530
  640. model_sandskiff = 531
  641. model_airship = 532
  642. model_pigieship = 533
  643. guildie_red = 534
  644. guildie_green = 535
  645. guildie_blue = 536
  646. great_pigie = 537
  647. qurupeco_wing = 538
  648. jagi_hide_plus = 539
  649. lightning_ticket = 540
  650. great_bagi_claw = 541
  651. high_qualty_pelt = 542
  652. popo_tongue = 543
  653. rhenoplos_shell = 544
  654. rhenoplos_scalp = 545
  655. rheno_carapace = 546
  656. bnahabracarapace = 547
  657. monster_broth = 548
  658. quality_sac = 549
  659. sleep_sac = 550
  660. coma_sac = 551
  661. bagi_hide = 552
  662. bagi_scale = 553
  663. great_bagi_hide = 554
  664. leaders_crest = 555
  665. bird_wyvern_gem = 556
  666. uroktor_scale = 557
  667. smiths_notebook = 558
  668. bird_wyvern_bone = 559
  669. big_fin = 560
  670. quality_fin = 561
  671. sharpened_fang = 562
  672. velvety_hide = 563
  673. gigi_stinger = 564
  674. commendation = 565
  675. bird_wyvern_claw = 566
  676. barrel_bomb_s_plus = 567
  677. felvine = 568
  678. steel_eg = 569
  679. silver_eg = 570
  680. golden_eg = 571
  681. incomplete_crown = 572
  682. crowns_gemstone = 573
  683. dazzling_crown = 574
  684. book_of_combos_1 = 575
  685. book_of_combos_2 = 576
  686. book_of_combos_3 = 577
  687. book_of_combos_4 = 578
  688. book_of_combos_5 = 579
  689. organizer_guide = 580
  690. pack_rat_guide = 581
  691. ez_barrel_bomb_l = 582
  692. uw_ballista_ammo = 583
  693. rathalos_coin = 584
  694. gobul_coin = 585
  695. barioth_coin = 586
  696. hunter_king_coin = 587
  697. diablos_coin = 588
  698. deviljho_coin = 589
  699. hellhunter_tag = 590
  700. dark_metal = 591
  701. incomplete_plans = 592
  702. lion_kings_seal = 593
  703. soulhunter_tag = 594
  704. monster_bone_plus = 595
  705. powercharm = 596
  706. powertalon = 597
  707. armorcharm = 598
  708. armortalon = 599
  709. bounce_bomb = 600
  710. bounce_bomb_plus = 601
  711. sharqskin = 602
  712. conquerors_seal = 603
  713. golden_medallion = 604
  714. prize_gold_sword = 605
  715. great_jagi_coin = 606
  716. qurupeco_coin = 607
  717. barroth_coin = 608
  718. r_ludroth_coin = 609
  719. rathian_coin = 610
  720. lagiacrus_coin = 611
  721. uragaan_coin = 612
  722. wyvern_lord_coin = 613
  723. sea_lord_coin = 614
  724. pinnacle_coin = 615
  725. antidote_jewel = 616
  726. antidote_jewel_plus = 617
  727. paralysis_jewel = 618
  728. paralysis_jewel_plus = 619
  729. pep_jewel = 620
  730. pep_jewel_plus = 621
  731. steadfast_jewel = 622
  732. steadfast_jewel_plus = 623
  733. weather_jewel = 624
  734. weather_jewel_plus = 625
  735. ninja_jewel = 626
  736. vitality_jewel = 627
  737. recovery_jewel = 628
  738. resurgence_jewel = 629
  739. razor_jewel = 630
  740. cutter_jewel = 631
  741. handicraft_jewel = 632
  742. architect_jewel = 633
  743. fencer_jewel = 634
  744. swordsman_jewel = 635
  745. expert_jewel = 636
  746. master_jewel = 637
  747. hermit_jewel = 638
  748. grinder_jewel = 639
  749. stone_wall_jewel = 640
  750. iron_wall_jewel = 641
  751. shield_jewel = 642
  752. aegis_jewel = 643
  753. quickload_jewel = 644
  754. flashload_jewel = 645
  755. absorber_jewel = 646
  756. flinchfree_jewel = 647
  757. forceshot_jewel = 648
  758. forceshot_jewel_plus = 649
  759. pierce_jewel = 650
  760. pierce_jewel_plus = 651
  761. pellet_jewel = 652
  762. pellet_jewel_plus = 653
  763. shotplus_jewel = 654
  764. shotplus_jewel_plus = 655
  765. piercplus_jewel = 656
  766. piercplus_jewel_plus = 657
  767. pelletplus_jewel = 658
  768. cragplus_jewel = 659
  769. clustplus_jewel = 660
  770. disabler_jewel = 661
  771. disabler_jewel_plus = 662
  772. element_jewel = 663
  773. element_jewel_plus = 664
  774. bombardier_jewel = 665
  775. lite_eater_jewel = 666
  776. hungerless_jewel = 667
  777. metabolism_jewel = 668
  778. attack_jewel = 669
  779. assault_jewel = 670
  780. onslaught_jewel = 671
  781. defense_jewel = 672
  782. turtle_jewel = 673
  783. protection_jewel = 674
  784. asylum_jewel = 675
  785. earplug_jewel = 676
  786. silencer_jewel = 677
  787. alarm_jewel = 678
  788. friendship_jewel = 679
  789. alliance_jewel = 680
  790. transportr_jewel = 681
  791. crimson_jewel = 682
  792. torrent_jewel = 683
  793. storm_jewel = 684
  794. glacier_jewel = 685
  795. dragonbane_jewel = 686
  796. breeze_jewel = 687
  797. warmth_jewel = 688
  798. sandbag_jewel = 689
  799. anchor_jewel = 690
  800. map_jewel = 691
  801. gathering_jewel = 692
  802. spree_jewel = 693
  803. blessing_jewel = 694
  804. fate_jewel = 695
  805. destiny_jewel = 696
  806. fisher_jewel = 697
  807. psychic_jewel = 698
  808. medicine_jewel = 699
  809. panacea_jewel = 700
  810. professor_jewel = 701
  811. factory_jewel = 702
  812. evade_jewel = 703
  813. lightfoot_jewel = 704
  814. crisis_jewel = 705
  815. peril_jewel = 706
  816. enduring_jewel = 707
  817. sprinter_jewel = 708
  818. marathon_jewel = 709
  819. chamber_jewel = 710
  820. magazine_jewel = 711
  821. sniper_jewel = 712
  822. gobbler_jewel = 713
  823. voracious_jewel = 714
  824. carver_jewel = 715
  825. looter_jewel = 716
  826. footing_jewel = 717
  827. tectonic_jewel = 718
  828. bbq_jewel = 719
  829. jumping_jewel = 720
  830. leaping_jewel = 721
  831. draw_jewel = 722
  832. critical_jewel = 723
  833. trapmaster_jewel = 724
  834. workout_jewel = 725
  835. physique_jewel = 726
  836. tranq_jewel = 727
  837. capture_jewel = 728
  838. perception_jewel = 729
  839. charger_jewel = 730
  840. dynamo_jewel = 731
  841. fresh_air_jewel = 732
  842. upstream_jewel = 733
  843. swimmer_jewel = 734
  844. diver_jewel = 735
  845. gambit_jewel = 736
  846. checkmate_jewel = 737
  847. resistor_jewel = 738
  848. release_jewel = 739
  849. catalyst_jewel = 740
  850. guts_jewel = 741
  851. fortitude_jewel = 742
  852. salvo_jewel = 743
  853. fusillade_jewel = 744
  854. dung_jewel = 745
  855. torchlight_jewel = 746
  856. ItemsType = ItemsType()
  857. class ResourcesType(Enum):
  858. low_rank = 0x0000
  859. high_rank = 0x0001
  860. arena = 0x0002
  861. ResourcesType = ResourcesType()
  862. class StartingPositionType(Enum):
  863. camp = 0x00
  864. random = 0x01
  865. shrine = 0x02
  866. StartingPositionType = StartingPositionType()
  867. class QuestRestrictionType(Enum):
  868. RESTRICTION_NONE = 0
  869. RESTRICTION_9_JOIN = 1
  870. RESTRICTION_18_JOIN = 2
  871. RESTRICTION_31_JOIN = 3
  872. RESTRICTION_40_JOIN = 4
  873. RESTRICTION_51_JOIN = 5
  874. RESTRICTION_100_JOIN = 6
  875. RESTRICTION_9_INITJOIN = 7
  876. RESTRICTION_18_INITJOIN = 8
  877. RESTRICTION_31_INITJOIN = 9
  878. RESTRICTION_40_INITJOIN = 10
  879. RESTRICTION_51_INITJOIN = 11
  880. RESTRICTION_100_INITJOIN = 12
  881. RESTRICTION_1_8_INITJOIN = 13
  882. RESTRICTION_1_17_INITJOIN = 14
  883. RESTRICTION_1_30_INITJOIN = 15
  884. RESTRICTION_31_39_INITJOIN = 16
  885. RESTRICTION_31_50_INITJOIN = 17
  886. RESTRICTION_MEN_ONLY = 18
  887. RESTRICTION_LADIES_ONLY = 19
  888. RESTRICTION_NO_ARMOR = 20
  889. RESTRICTION_CHACHA = 21
  890. RESTRICTION_5_JOIN = 22
  891. RESTRICTION_14_JOIN = 23
  892. RESTRICTION_27_JOIN = 24
  893. RESTRICTION_35_JOIN = 25
  894. RESTRICTION_46_JOIN = 26
  895. QuestRestrictionType = QuestRestrictionType()
  896. def make_monster_quest_type(monster_type, starting_area, boss_id, spawn_count, level,
  897. min, size, max):
  898. data = b""
  899. # - id: monster_type
  900. # type: u1
  901. # enum: Monster
  902. data += struct.pack(">B", monster_type)
  903. # - id: boss_id
  904. # type: u2
  905. data += struct.pack(">B", starting_area)
  906. data += struct.pack(">B", boss_id)
  907. # - id: spawn_count
  908. # type: u1
  909. data += struct.pack(">B", spawn_count)
  910. # - id: level
  911. # type: u1
  912. data += struct.pack(">B", level)
  913. # - id: min
  914. # type: u1
  915. data += struct.pack(">B", min)
  916. # - id: size
  917. # type: u1
  918. data += struct.pack(">B", size)
  919. # - id: max
  920. # type: u1
  921. data += struct.pack(">B", max)
  922. return data
  923. def make_quest_properties_type(type, objective_type, objective_count):
  924. data = b""
  925. # - id: type
  926. # type: u4
  927. data += struct.pack(">I", type)
  928. # - id: objective_type
  929. # type: u2
  930. data += struct.pack(">h", objective_type)
  931. # - id: objective_count
  932. # type: u2
  933. data += struct.pack(">h", objective_count)
  934. return data
  935. def make_reward_type(item, amount, percent):
  936. data = b""
  937. # - id: item
  938. # type: u2
  939. # enum: item_type
  940. data += struct.pack(">h", item)
  941. # - id: amount
  942. # type: u1
  943. data += struct.pack(">B", amount)
  944. # - id: percent
  945. # type: u1
  946. data += struct.pack(">B", percent)
  947. return data
  948. def generate_rewards(rewards):
  949. data = b""
  950. i = -1
  951. for i, reward in enumerate(rewards):
  952. data += make_reward_type(reward[0], reward[1], reward[2])
  953. if i == 10:
  954. break
  955. data += b'\0' * (4 * (10-i))
  956. return data
  957. def make_binary_event_quest(quest_data):
  958. """
  959. 'quest_info': {
  960. 'quest_id': quest_id,
  961. 'name': name,
  962. 'client': client,
  963. 'description': description,
  964. 'details': details,
  965. # Usually "Complete the Main Quest."
  966. 'success_message': success_message,
  967. 'flags': flags,
  968. 'penalty_per_cart': penalty_per_cart,
  969. 'quest_fee': quest_fee,
  970. 'time_limit': time_limit,
  971. 'main_monster_1': main_monster1,
  972. 'main_monster_2': main_monster2,
  973. 'location': location,
  974. 'quest_rank': quest_rank,
  975. 'hrp_restriction': hrp_restriction,
  976. 'resources': resources,
  977. 'supply_set_number': supply_set_number,
  978. 'starting_position': starting_position,
  979. 'general_enemy_level': general_enemy_level,
  980. 'summon': summon,
  981. 'wave_1_transition_type': wave_1_transition_type,
  982. 'wave_1_transition_target': wave_1_transition_target,
  983. 'wave_1_transition_quantity': wave_1_transition_quantity,
  984. 'wave_2_transition_type': wave_2_transition_type,
  985. 'wave_2_transition_target': wave_2_transition_target,
  986. 'wave_2_transition_quantity': wave_2_transition_quantity,
  987. 'smallmonster_data_file': smallmonster_data (or None),
  988. },
  989. """
  990. quest_info = quest_data['quest_info']
  991. """
  992. 'large_monsters': {
  993. 'monster_1': {
  994. 'type': monsterType1,
  995. 'boss_id': monsterType1_bossid,
  996. 'enabled': monsterType1_enabled,
  997. 'level': monsterType1_level, # 0x01 through 0x3c
  998. 'size': monsterType1_size,
  999. # 0: fixed, 1: spread of 5, 2: spread of 3
  1000. 'hp_spread': monsterType1_min,
  1001. # Controls the spread of size but details unknown
  1002. 'size_spread': monsterType1_max
  1003. },
  1004. 'monster_2': {
  1005. 'type': monsterType2,
  1006. 'boss_id': monsterType2_bossid,
  1007. 'enabled': monsterType2_enabled,
  1008. 'level': monsterType2_level, # 0x01 through 0x3c
  1009. 'size': monsterType2_size,
  1010. # 0: fixed, 1: spread of 5, 2: spread of 3
  1011. 'hp_spread': monsterType2_min,
  1012. # Controls the spread of size but details unknown
  1013. 'size_spread': monsterType2_max
  1014. },
  1015. 'monster_3': {
  1016. 'type': monsterType3,
  1017. 'boss_id': monsterType3_bossid,
  1018. 'enabled': monsterType3_enabled,
  1019. 'level': monsterType3_level, # 0x01 through 0x3c
  1020. 'size': monsterType3_size,
  1021. # 0: fixed, 1: spread of 5, 2: spread of 3
  1022. 'hp_spread': monsterType3_min,
  1023. # Controls the spread of size but details unknown
  1024. 'size_spread': monsterType3_max
  1025. }
  1026. },
  1027. """
  1028. large_monsters = quest_data['large_monsters']
  1029. monster_1 = large_monsters['monster_1']
  1030. monster_2 = large_monsters['monster_2']
  1031. monster_3 = large_monsters['monster_3']
  1032. """
  1033. 'objective_details': {
  1034. 'main_quest': {
  1035. 'type': mainquest_type,
  1036. 'objective_type': mainquest_objectivetype,
  1037. 'objective_num': mainquest_objectivenum,
  1038. 'zenny_reward': main_reward,
  1039. 'hrp_reward': hunter_rank_points,
  1040. 'rewards_row_1': mainquest_rewards1,
  1041. 'rewards_row_2': mainquest_rewards2,
  1042. }
  1043. 'subquest_1': {
  1044. 'description': subquest1_description,
  1045. 'type': subquest1_type,
  1046. 'objective_type': subquest1_objectivetype,
  1047. 'objective_num': subquest1_objectivenum,
  1048. 'zenny_reward': sub_quest_1_reward,
  1049. 'hrp_reward': subquest1_hrp,
  1050. 'rewards_row_1': sq1_rewards,
  1051. }
  1052. 'subquest_2': {
  1053. 'description': subquest2_description,
  1054. 'type': subquest2_type,
  1055. 'objective_type': subquest2_objectivetype,
  1056. 'objective_num': subquest2_objectivenum,
  1057. 'zenny_reward': sub_quest_2_reward,
  1058. 'hrp_reward': subquest2_hrp,
  1059. 'rewards_row_1': sq2_rewards,
  1060. }
  1061. },
  1062. """
  1063. objective_details = quest_data['objective_details']
  1064. main_quest = objective_details['main_quest']
  1065. subquest_1 = objective_details['subquest_1']
  1066. subquest_2 = objective_details['subquest_2']
  1067. """
  1068. 'unknown': {
  1069. 'unk_12': unk_12,
  1070. 'unk_4': unk_4,
  1071. 'unk_5': unk_5,
  1072. 'unk_6': unk_6,
  1073. 'unk_7': unk_7,
  1074. 'unk_9': unk_9,
  1075. 'unk_10': unk_10,
  1076. 'unk_11': unk_11,
  1077. }
  1078. """
  1079. unknown = quest_data['unknown']
  1080. # TOOO: Remove encode("ascii") and use bytes instead
  1081. data = b""
  1082. # - id: name
  1083. # type: str
  1084. # size: 44
  1085. # offset: 0x0000
  1086. data += pad(quest_info['name'].encode("ascii"), 40) # Size 0x28
  1087. data += struct.pack(">I", 0x00000000)
  1088. # - id: quest_id
  1089. # type: u2
  1090. # offset: 0x002C
  1091. data += struct.pack(">H", quest_info['quest_id'])
  1092. # - id: description
  1093. # type: str
  1094. # size: 92
  1095. # offset: 0x002E
  1096. data += pad(quest_info['description'].encode("ascii"), 80)
  1097. data += b'\0' * 0xC # Padding
  1098. # - id: quest_rank
  1099. # type: u1
  1100. # enum: QuestRankType
  1101. # offset: 0x008A
  1102. data += struct.pack(">B", quest_info['quest_rank'])
  1103. # - id: location
  1104. # type: u1
  1105. # enum: LocationType
  1106. # offset: 0x008B
  1107. data += struct.pack(">B", quest_info['location']) # Offset 0x8C
  1108. # - id: sub_quest_1_title
  1109. # type: str
  1110. # size: 41
  1111. # offset: 0x008C
  1112. data += pad(
  1113. objective_details['subquest_1']['description'].encode("ascii"),
  1114. 0x29
  1115. )
  1116. # - id: sub_quest_2_title
  1117. # type: str
  1118. # size: 41
  1119. # offset: 0x00B5
  1120. data += pad(
  1121. objective_details['subquest_2']['description'].encode("ascii"),
  1122. 0x29
  1123. )
  1124. # - id: sucess_message
  1125. # type: str
  1126. # size: 92
  1127. # offset: 0x00DE
  1128. data += pad(quest_info['success_message'].encode("ascii"), 0x5C)
  1129. # - id: time_limit
  1130. # type: u2
  1131. # offset: 0x013A
  1132. data += struct.pack(">h", quest_info['time_limit'])
  1133. # - id: failure_message
  1134. # type: str
  1135. # size: 92
  1136. # Presently hardcoded
  1137. # offset: 0x013C
  1138. data += pad(b"Reward hits 0, or time\nexpires.", 0x5C)
  1139. # - id: hunter_rank_point_restriction
  1140. # type: u2
  1141. # offset: 0x0198
  1142. data += struct.pack(">h", quest_info['hrp_restriction'])
  1143. # - id: client
  1144. # type: str
  1145. # size: 41
  1146. # offset: 0x019A
  1147. data += pad(quest_info['client'].encode("ascii"), 0x29)
  1148. # - id: unk2
  1149. # size: 6
  1150. # offset: 0x01C3
  1151. data += b'\0' * 0x06
  1152. # - id: details
  1153. # type: str
  1154. # size: 256
  1155. # offset: 0x01C9
  1156. data += pad(quest_info['details'].encode("ascii"), 0x100) # b'\0' * 0x100
  1157. # - id: unk1
  1158. # size: 61
  1159. # offset: 0x02C9
  1160. data += b'\0' * 0x3D
  1161. # - id: minion_unsure
  1162. # size: 3
  1163. # offset: 0x0306
  1164. data += b'\0' * 0x03
  1165. # - id: quest_flags_unsure
  1166. # size: 3
  1167. # offset: 0x0309
  1168. data += b'\0' * 0x03
  1169. # - id: monster_1
  1170. # type: u1
  1171. # enum: Monster
  1172. # Offset 0x30C ("Main monsters" 1)
  1173. data += struct.pack(">B", quest_info['main_monster_1'])
  1174. # - id: monster_2
  1175. # type: u1
  1176. # enum: Monster
  1177. # Offset 0x30D ("Main monsters" 2)
  1178. data += struct.pack(">B", quest_info['main_monster_2'])
  1179. # - id: unk3
  1180. # size: 2
  1181. # offset: 0x030E
  1182. data += b'\0' * 0x02 # Padding
  1183. # - id: flags
  1184. # type: u4
  1185. # offset: 0x0310
  1186. data += struct.pack(">I", generate_flags(*(quest_info['flags']))) # Offset 0x310
  1187. # - id: monsters
  1188. # type: monster_quest_type
  1189. # repeat: expr
  1190. # repeat-expr: 3
  1191. # # offset: 0x0314
  1192. if monster_1['type'] != 0:
  1193. data += make_monster_quest_type(
  1194. monster_type=monster_1['type'],
  1195. starting_area=monster_1['starting_area'],
  1196. boss_id=monster_1['boss_id'],
  1197. spawn_count=monster_1['spawn_count'],
  1198. level=monster_1['level'],
  1199. min=monster_1['hp_spread'],
  1200. size=monster_1['size'],
  1201. max=monster_1['size_spread']
  1202. ) # size: 0x08
  1203. else:
  1204. data += b'\0' * 0x08
  1205. # offset: 0x031C
  1206. if monster_2['type'] != 0:
  1207. data += make_monster_quest_type(
  1208. monster_type=monster_2['type'],
  1209. starting_area=monster_2['starting_area'],
  1210. boss_id=monster_2['boss_id'],
  1211. spawn_count=monster_2['spawn_count'],
  1212. level=monster_2['level'],
  1213. min=monster_2['hp_spread'],
  1214. size=monster_2['size'],
  1215. max=monster_2['size_spread']
  1216. ) # size: 0x08
  1217. else:
  1218. data += b'\0' * 0x08
  1219. # offset: 0x0324
  1220. if monster_3['type'] != 0:
  1221. data += make_monster_quest_type(
  1222. monster_type=monster_3['type'],
  1223. starting_area=monster_3['starting_area'],
  1224. boss_id=monster_3['boss_id'],
  1225. spawn_count=monster_3['spawn_count'],
  1226. level=monster_3['level'],
  1227. min=monster_3['hp_spread'],
  1228. size=monster_3['size'],
  1229. max=monster_3['size_spread']
  1230. ) # size: 0x08
  1231. else:
  1232. data += b'\0' * 0x08
  1233. # SUMMON / (INVADER?)
  1234. # - id: unk5
  1235. # type: u4
  1236. # offset: 0x032C
  1237. data += struct.pack(">I", quest_info['summon'])
  1238. # - id: quests_properties
  1239. # type: quest_properties_type
  1240. # repeat: expr
  1241. # repeat-expr: 3
  1242. # "Hunt 8 jaggia:"
  1243. # mainquest_type = 0x00008101,
  1244. # mainquest_objectivetype=0x000b,
  1245. # mainquest_objectivecount=0x0008
  1246. # "Hunt 12 jaggi:"
  1247. # mainquest_type = 0x00000101,
  1248. # mainquest_objectivetype=0x000a,
  1249. # mainquest_objectivecount=0x000c
  1250. # "Hunt a Great Jaggi:"
  1251. # mainquest_type = 0x00000001,
  1252. # mainquest_objectivetype=0x000c,
  1253. # mainquest_objectivecount=0x0001
  1254. # "Wound Great Jaggi's Head:"
  1255. # quest_type = 0x00000204,
  1256. # quest_objectivetype=0x000c,
  1257. # quest_objectivecount=0x0001
  1258. # "Stun Great Jaggi:"
  1259. # quest_type = 0x00001000,
  1260. # quest_objectivetype=0x000c,
  1261. # quest_objectivecount=0x0003
  1262. # offset: 0x0330
  1263. data += make_quest_properties_type(
  1264. main_quest['type'],
  1265. main_quest['objective_type'],
  1266. main_quest['objective_num']
  1267. )
  1268. # offset: 0x0338
  1269. if subquest_1['type'] is not None:
  1270. data += make_quest_properties_type(
  1271. subquest_1['type'],
  1272. subquest_1['objective_type'],
  1273. subquest_1['objective_num']
  1274. )
  1275. else:
  1276. data += b"\0" * 0x08
  1277. # offset: 0x0340
  1278. if subquest_2['type'] is not None:
  1279. data += make_quest_properties_type(
  1280. subquest_2['type'],
  1281. subquest_2['objective_type'],
  1282. subquest_2['objective_num']
  1283. )
  1284. else:
  1285. data += b"\0" * 0x08
  1286. # - id: contract_fee
  1287. # type: u4
  1288. # offset: 0x0348
  1289. data += struct.pack(">I", quest_info['quest_fee'])
  1290. # - id: main_objective_reward
  1291. # type: u4
  1292. # offset: 0x034C
  1293. data += struct.pack(">I", main_quest['zenny_reward'])
  1294. # - id: sub_objective_a_reward
  1295. # type: u4
  1296. # offset: 0x0350
  1297. data += struct.pack(">I", subquest_1['zenny_reward'])
  1298. # - id: sub_objective_b_reward
  1299. # type: u4
  1300. # offset: 0x0354
  1301. data += struct.pack(">I", subquest_2['zenny_reward'])
  1302. # - id: death_reduction
  1303. # type: u4
  1304. # offset: 0x0358
  1305. data += struct.pack(">I", quest_info['penalty_per_cart'])
  1306. # - id: hunter_rank_points
  1307. # type: u4
  1308. # offset: 0x035C
  1309. data += struct.pack(">I", main_quest['hrp_reward'])
  1310. # - id: unk7
  1311. # type: u4
  1312. # 0x0000000f for the great jaggi quest/(all quests?)
  1313. # offset: 0x0360
  1314. data += struct.pack(">I", 0x0000000f)
  1315. # - id: unk8
  1316. # type: u1
  1317. # offset: 0x0364
  1318. data += b'\0' * 0x01
  1319. # - id: gather_rank (wrong)
  1320. # type: u1
  1321. # offset: 0x0365
  1322. data += b'\0' * 0x01
  1323. # - id: unk9
  1324. # type: u1
  1325. # offset: 0x0366
  1326. data += b'\0' * 0x01
  1327. # - id: unk10
  1328. # type: u1
  1329. # offset: 0x0367
  1330. data += struct.pack(">B", subquest_1['hrp_reward'])
  1331. # - id: supply_set (wrong)
  1332. # type: u4
  1333. # offset: 0x0368
  1334. data += struct.pack(">I", subquest_2['hrp_reward'])
  1335. # - id: Unknown 4
  1336. # type: u1
  1337. # offset: 0x036C
  1338. data += struct.pack(">B", unknown['unk_4'])
  1339. # - id: supply_type (0x00: low rank, 0x01: high rank, 0x02: arena)
  1340. # type: u1
  1341. # offset: 0x036D
  1342. data += struct.pack(">B", quest_info['resources'])
  1343. # - id: unk11
  1344. # size: 2
  1345. # type: u1
  1346. # offset: 0x036E
  1347. data += struct.pack(">B", unknown['unk_5'])
  1348. # type: u1
  1349. # offset: 0x036F
  1350. data += struct.pack(">B", unknown['unk_6'])
  1351. # - id: supply_set_number
  1352. # type: u4
  1353. # 0x00000011 for the great jaggi quest
  1354. # offset: 0x0370
  1355. data += struct.pack(">I", quest_info['supply_set_number'])
  1356. # - id: unk12
  1357. # type: u4
  1358. # offset: 0x0374
  1359. data += struct.pack(">I", unknown['unk_7'])
  1360. # - id: unk13
  1361. # type: u2
  1362. # offset: 0x0378
  1363. data += b'\0' * 0x02
  1364. # - id: type_flag (STARTING POSITION, 0x0000: basecamp,
  1365. # 0x0001:random, 0x0002: shrine)
  1366. # type: u2
  1367. # offset: 0x037A
  1368. data += struct.pack(">h", quest_info['starting_position'])
  1369. # UNK
  1370. # offset: 0x037C
  1371. data += b'\0' * 0x02
  1372. # - id: small_monster_data_location
  1373. # type: u2
  1374. # offset: 0x037E
  1375. data += struct.pack(">h", 0x04b8)
  1376. # - id: type_amount
  1377. # type: u2
  1378. # offset: 0x0380
  1379. data += b'\0' * 0x02
  1380. # - id: general_enemy_level
  1381. # type: u2
  1382. # offset: 0x0382
  1383. data += struct.pack(">h", quest_info['general_enemy_level'])
  1384. # - id: wave_1_transition_type
  1385. # type: u2
  1386. # offset: 0x0384
  1387. data += struct.pack(">h", quest_info['wave_1_transition_type'])
  1388. # - id: wave_1_transition_target
  1389. # type: u2
  1390. # offset: 0x0386
  1391. data += struct.pack(">h", quest_info['wave_1_transition_target'])
  1392. # - id: wave_1_transition_quantity
  1393. # type: u2
  1394. # offset: 0x0388
  1395. data += struct.pack(">h", quest_info['wave_1_transition_quantity'])
  1396. # - id: wave_2_transition_type
  1397. # type: u2
  1398. # offset: 0x038A
  1399. data += struct.pack(">h", quest_info['wave_2_transition_type'])
  1400. # - id: wave_2_transition_target
  1401. # type: u2
  1402. # offset: 0x038C
  1403. data += struct.pack(">h", quest_info['wave_2_transition_target'])
  1404. # - id: wave_2_transition_quantity
  1405. # type: u2
  1406. # offset: 0x038E
  1407. data += struct.pack(">h", quest_info['wave_2_transition_quantity'])
  1408. # Unknown 12 (0x00000002 for large monster hunting quests,
  1409. # 0x00000003 for small monster & gathering quests,
  1410. # 0x00000005 for Jhen & Alatreon)
  1411. # offset: 0x0390
  1412. data += struct.pack(">I", unknown['unk_12'])
  1413. # offset: 0x0394
  1414. data += make_quest_properties_type(main_quest['type'],
  1415. main_quest['objective_type'],
  1416. main_quest['objective_num'])
  1417. # - id: main_objective_rewards
  1418. # type: reward_type
  1419. # repeat: expr
  1420. # repeat-expr: 11
  1421. # offset: 0x039C
  1422. data += generate_rewards(main_quest['rewards_row_1'])
  1423. # - id: main_objective_additional_rewards
  1424. # type: reward_type
  1425. # repeat: expr
  1426. # repeat-expr: 11
  1427. # offset: 0x03C8
  1428. data += generate_rewards(main_quest['rewards_row_2'])
  1429. # SUBQUEST 1 REWARDS
  1430. # offset: 0x03F4
  1431. if subquest_1['type'] is not None:
  1432. data += make_quest_properties_type(subquest_1['type'],
  1433. subquest_1['objective_type'],
  1434. subquest_1['objective_num'])
  1435. data += generate_rewards(subquest_1['rewards_row_1'])
  1436. else:
  1437. data += b"\0" * 0x08
  1438. data += b'\0' * (4 * 11)
  1439. # offset: 0x0428
  1440. data += b'\0' * (4 * 11)
  1441. # SUBQUEST 2 REWARDS
  1442. # offset: 0x0454
  1443. if subquest_2['type'] is not None:
  1444. data += make_quest_properties_type(subquest_2['type'],
  1445. subquest_2['objective_type'],
  1446. subquest_2['objective_num'])
  1447. data += generate_rewards(subquest_2['rewards_row_1'])
  1448. else:
  1449. data += b"\0" * 0x08
  1450. data += b'\0' * (4 * 11)
  1451. # offset: 0x0488
  1452. data += b'\0' * (4 * 11)
  1453. assert len(data) == 0x4B4
  1454. # Add 2-byte tail between the main quest info and the small monster data
  1455. # that describes how many bytes total the quest takes up before the
  1456. # optional arena equipment data
  1457. tail = 0x4B4 + 4
  1458. if 'smallmonster_data_file' in quest_info:
  1459. # Read small monster data from hex string file
  1460. sm_data = read_quest_sm_data(quest_info['smallmonster_data_file'])
  1461. if sm_data is not None:
  1462. tail += len(sm_data) - 4
  1463. data += struct.pack(">I", tail)
  1464. data += sm_data[4:]
  1465. else:
  1466. data += struct.pack(">I", tail)
  1467. else:
  1468. # Create new small monster data from parameters
  1469. """
  1470. 'small_monsters': [
  1471. [
  1472. {
  1473. 'type': monsterType,
  1474. 'variant': variant,
  1475. 'room': room,
  1476. 'quantity': quantity,
  1477. 'unk1': unk1,
  1478. 'pos_x': pos_x,
  1479. 'pos_y': pos_y,
  1480. 'pos_z': pos_z,
  1481. 'rot_x': rot_x,
  1482. 'rot_y': rot_y,
  1483. 'rot_z': rot_z,
  1484. 'unk2': unk2, # Usually 0xFF
  1485. }
  1486. ] * number of waves * number of areas
  1487. ]
  1488. """
  1489. sm_data = b""
  1490. small_monsters = quest_data['small_monsters']
  1491. location_size = LOCATION_SIZE[quest_info['location']]
  1492. assert len(small_monsters) % location_size == 0
  1493. num_waves = int(len(small_monsters) / location_size)
  1494. assert num_waves <= 3
  1495. # Pre-preamble: Establishing the locations of each of the waves' preambles
  1496. sm_data += struct.pack('>I', 0x0000000C)
  1497. sm_data += struct.pack('>I', 0x0000000C + 8*location_size)
  1498. if num_waves < 3:
  1499. sm_data += struct.pack('>I', 0xCCCCCCCC)
  1500. else:
  1501. sm_data += struct.pack('>I', 0x0000000C + 2*8*location_size)
  1502. monster_data = b""
  1503. # Preamble: Establishing the location and length of each of the
  1504. # small monster areas
  1505. current_sm_index = 0x0C + 8*len(small_monsters)
  1506. for entry, monster_list in enumerate(quest_data['small_monsters']):
  1507. sm_data += struct.pack(">I", current_sm_index)
  1508. area = entry % location_size
  1509. area_monster_data = b""
  1510. for monster in monster_list:
  1511. assert monster['room'] == area
  1512. new_monster_data = b""
  1513. new_monster_data += struct.pack(">I", monster['type'])
  1514. new_monster_data += 3* b"\0"
  1515. new_monster_data += struct.pack(">b", monster['quantity'])
  1516. new_monster_data += struct.pack(">B", monster['unk2'])
  1517. new_monster_data += struct.pack(">B", monster['room'])
  1518. new_monster_data += struct.pack(">B", monster['unk1'])
  1519. new_monster_data += struct.pack(">B", monster['variant'])
  1520. new_monster_data += struct.pack(">I", 0x00000000)
  1521. new_monster_data += struct.pack(">f", monster['pos_x'])
  1522. new_monster_data += struct.pack(">f", monster['pos_y'])
  1523. new_monster_data += struct.pack(">f", monster['pos_z'])
  1524. new_monster_data += struct.pack('>i', int(180.05 * monster['rot_x']))
  1525. new_monster_data += struct.pack('>i', int(180.05 * monster['rot_y']))
  1526. new_monster_data += struct.pack('>i', int(180.05 * monster['rot_z']))
  1527. new_monster_data += struct.pack('>I', 0xFF000000)
  1528. new_monster_data += struct.pack('>I', 0x00000000)
  1529. assert len(new_monster_data) == 0x30
  1530. area_monster_data += new_monster_data
  1531. area_monster_data += 0x30 * b'\0'
  1532. sm_data += struct.pack(">I", len(area_monster_data))
  1533. current_sm_index += len(area_monster_data)
  1534. monster_data += area_monster_data
  1535. # Main small monster data
  1536. sm_data += monster_data
  1537. tail += len(sm_data)
  1538. data += struct.pack(">I", tail)
  1539. data += sm_data
  1540. # If there is arena equipment data, add it to the end of the quest binary
  1541. if 'arena_equipment' in quest_data:
  1542. assert 0xEA60 <= quest_info['quest_id'] <= 0xEA6B, \
  1543. "Invalid arena quest ID: {:#x}".format(quest_info['quest_id'])
  1544. data += create_arena_equipment_set(quest_data['arena_equipment'])
  1545. return data
  1546. # FLAGS INFO:
  1547. # (Arena quests have bytes in "QUEST_FLAG_ARENA = 0b10000" set)
  1548. # byte 1: Boss Order 1 (
  1549. # +0x1000000: Unknown1
  1550. # +0x2000000: All At Once(CombineSubquestsRequireMQAndFirstSubquest)
  1551. # +0x4000000: Marathon (CombineSubquestsRequireMQAndBothSubquests)
  1552. # +0x8000000: Unknown4
  1553. # +0x10000000: Unknown5
  1554. # +0x20000000: Unknown6
  1555. # +0x40000000: Unknown7
  1556. # +0x80000000: CombineMainAndSubquests
  1557. # )
  1558. # byte 2: Boss Order 2 (
  1559. # +0x10000: Unknown1
  1560. # +0x20000: Unknown2
  1561. # +0x40000: RequireMQAndBothSubquests
  1562. # +0x80000: Unknown4
  1563. # +0x100000: QualifyingTime
  1564. # +0x200000: DontAnnounceSubquestCompletion
  1565. # +0x400000: Unknown7
  1566. # +0x800000: ElderDragonLeftWounded
  1567. # )
  1568. # byte 3: Boss Order 3 (
  1569. # +0x100(256): 2Mon_NoSubs_ReqSub1_Unstable
  1570. # +0x200(512): Unknown2
  1571. # +0x400(1024): Unknown3
  1572. # +0x800(2048): BanjoMusic
  1573. # +0x1000(4096): Unknown5
  1574. # +0x2000(8192): Unknown6
  1575. # +0x4000(16384): Unknown7
  1576. # +0x8000(32768): Unknown8
  1577. # )
  1578. # byte 4: Quest Flags (
  1579. # +1: Slay
  1580. # +2: Deliver
  1581. # +4: Capture
  1582. # +8: Defend
  1583. # +0x10(16): ArenaQuest
  1584. # +0x20(32): Unknown2
  1585. # +0x40(64): Repel(EndAtMainQuest)
  1586. # +0x80(128): Unknown3
  1587. # )
  1588. def generate_flags(byte1, byte2, byte3, byte4):
  1589. res = 0x00000000
  1590. curr = 0x00
  1591. for i in range(8):
  1592. curr += byte1[i] * 2**i
  1593. res += curr * 16**6
  1594. curr = 0x00
  1595. for i in range(8):
  1596. curr += byte2[i] * 2**i
  1597. res += curr * 16**4
  1598. curr = 0x00
  1599. for i in range(8):
  1600. curr += byte3[i] * 2**i
  1601. res += curr * 16**2
  1602. curr = 0x00
  1603. for i in range(8):
  1604. curr += byte4[i] * 2**i
  1605. res += curr * 16**0
  1606. return res
  1607. def read_quest_sm_data(fname):
  1608. data_path = path.join("event", fname)
  1609. if not path.exists(data_path):
  1610. return None
  1611. with open(data_path, 'r') as f:
  1612. data = f.read()
  1613. return bytearray.fromhex(data.replace(" ", "").replace("\n", ""))
  1614. def make_event_slot(event):
  1615. return (make_binary_event_quest(event), event)
  1616. def byteify(input):
  1617. if isinstance(input, dict):
  1618. return {byteify(key): byteify(value)
  1619. for key, value in input.items()}
  1620. elif isinstance(input, list):
  1621. return [byteify(element) for element in input]
  1622. elif isinstance(input, str):
  1623. return input
  1624. else:
  1625. return input
  1626. def is_arena_quest(flags):
  1627. return ((1 * 2**4) * 16**0) & flags > 0
  1628. class QuestLoader:
  1629. def __init__(self, file_loc='event/quest_rotation.json'):
  1630. self.version = 0
  1631. self.version_incrementer = 28
  1632. self.file_loc = file_loc
  1633. self.load_quests()
  1634. self.version = 0
  1635. def load_quests(self):
  1636. import json
  1637. self.version += self.version_incrementer
  1638. quest_list = []
  1639. with open(self.file_loc, 'r') as f:
  1640. quests_json = byteify(json.load(f))
  1641. for day in quests_json:
  1642. curr_quest_list = []
  1643. for quest_file in day:
  1644. with open(quest_file, 'r') as ff:
  1645. curr_quest = byteify(json.load(ff))
  1646. curr_quest = make_event_slot(curr_quest)
  1647. curr_quest_list.append(curr_quest)
  1648. quest_list.append(curr_quest_list)
  1649. self.quests = quest_list
  1650. def get_quest_dicts(self, idx):
  1651. # Get quest dicts for the day
  1652. true_idx = idx - 1
  1653. return [quest[1] for _, quest in enumerate(self.quests[true_idx])]
  1654. def get_separated_quest_dicts(self, idx):
  1655. # Get quest dicts for the day separated by event and arena
  1656. quest_list = []
  1657. arena_list = []
  1658. for quest in self.get_quest_dicts(idx):
  1659. if quest is None:
  1660. continue
  1661. if is_arena_quest(generate_flags(*(quest['quest_info']['flags']))):
  1662. arena_list.append(quest)
  1663. else:
  1664. quest_list.append(quest)
  1665. return quest_list, arena_list
  1666. def __len__(self):
  1667. # Get number of days
  1668. return len(self.quests)
  1669. def __getitem__(self, idx):
  1670. # Get quests for the day
  1671. true_idx = idx - self.version - 1
  1672. return [quest[0] for _, quest in enumerate(self.quests[true_idx])]