Advertisement
Guest User

bcnm.lua

a guest
Jul 21st, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.49 KB | None | 0 0
  1. require("scripts/globals/status")
  2. require("scripts/globals/keyitems")
  3. require("scripts/globals/missions")
  4. require("scripts/globals/quests")
  5.  
  6. -- NEW SYSTEM BCNM NOTES
  7. -- The "core" functions TradeBCNM EventUpdateBCNM EventTriggerBCNM EventFinishBCNM all return TRUE if the action performed is covered by the function.
  8. -- This means all the old code will still be executed if the new functions don't support it. This means that there is effectively 'backwards compatibility' with the old system.
  9.  
  10. -- array to map (for each zone) the item id of the valid trade item with the bcnmid in the database
  11. -- e.g. zone, {itemid, bcnmid, itemid, bcnmid, itemid, bcnmid}
  12. -- DO NOT INCLUDE MAAT FIGHTS
  13.  
  14. --[ZoneId]={[ItemId]={bcnmid}}
  15. itemid_bcnmid_map =
  16. {
  17. [139]= -- Horlais Peak
  18. { --itemid bcnmid
  19. [1130]={ 2, 14}, -- dismemberment_brigade, shots_in_the_dark
  20. [1131]={ 1, 12}, -- tails_of_woe, under_observation
  21. [1175]={ 15}, -- double_dragonian
  22. [1177]={ 4, 13}, -- hostile_herbivores, eye_of_the_tiger
  23. [1178]={ 16}, -- todays_horoscope
  24. [1180]={ 17}, -- contaminated_colosseum
  25. [1551]={ 9}, -- shooting_fish
  26. [1552]={ 8, 10}, -- carapace_combatants, dropping_like_flies
  27. [1553]={ 11} -- horns_of_war
  28. },
  29. [140]= -- Ghelsba Outpost
  30. { --itemid bcnmid
  31. [1551]={ 34}, -- wings_of_fury
  32. [1552]={ 35, 36} -- petrifying_pair, toadal_recall
  33. },
  34. [144]= -- Waughroon Shrine
  35. { --itemid bcnmid
  36. [1130]={ 66, 79}, -- grimshell_shocktroopers, up_in_arms
  37. [1131]={ 65, 77}, -- worms_turn, royal_jelly
  38. [1166]={ 68}, -- thief_in_norg
  39. [1175]={ 80}, -- copycat
  40. [1177]={ 69, 78}, -- 3_2_1, final_bout
  41. [1178]={ 81}, -- operation_desert_swarm
  42. [1180]={ 82}, -- prehistoric_pigeons
  43. [1551]={ 74}, -- crustacean_conundrum
  44. [1552]={ 73, 75}, -- birds_of_a_feather, grove_guardians
  45. [1553]={ 76} -- hills_are_alive
  46. },
  47. [146]= -- Balgas Dias
  48. { --itemid bcnmid
  49. [1130]={ 98, 110}, -- divine_punishers, wild_wild_whiskers
  50. [1131]={ 97, 108}, -- steamed_sprouts, royal_succession
  51. [1175]={ 111}, -- seasons_greetings
  52. [1177]={ 100, 109}, -- treasures_and_tribulations, rapid_raptors
  53. [1178]={ 112}, -- royale_ramble
  54. [1180]={ 113}, -- moa_constrictors
  55. [1551]={ 105}, -- charming_trio
  56. [1552]={ 104, 106}, -- creeping_doom, harem_scarem
  57. [1553]={ 107} -- early_bird_catches_the_wyrm
  58. },
  59. [163]= -- Sacrificial Chamber
  60. { --itemid bcnmid
  61. [1130]={ 129, 130} -- jungle_boogymen, amphibian_assault
  62. },
  63. [168]= -- Chamber of Oracles
  64. { --itemid bcnmid
  65. [1130]={ 193}, -- legion_xi_comitatensis
  66. [1175]={ 197}, -- cactuar_suave
  67. [1178]={ 198}, -- eye_of_the_storm
  68. [1180]={ 199} -- scarlet_king
  69. },
  70. [180]= -- LaLoff Amphitheater
  71. { --itemid bcnmid
  72. [1550]={ 293} -- divine_might
  73. },
  74. [201]= -- Cloister of Gales
  75. { --itemid bcnmid
  76. [1174]={ 417}, -- carbuncle_debacle
  77. [1546]={ 418} -- trial-size_trial_by_wind
  78. },
  79. [202]= -- Cloister of Storms
  80. { --itemid bcnmid
  81. [1172]={ 449}, -- carbuncle_debacle
  82. [1548]={ 450} -- trial-size_trial_by_lightning
  83. },
  84. [203]= -- Cloister of Frost
  85. { --itemid bcnmid
  86. [1171]={ 481}, -- class_reunion
  87. [1545]={ 482} -- trial-size_trial_by_ice
  88. },
  89. [206]= -- Qu'Bia Arena
  90. { --itemid bcnmid
  91. [1130]={ 520, 523, 528}, -- demolition_squad, brothers_d_aurphe, celery
  92. [1131]={ 524, 525}, -- undying_promise, factory_rejects
  93. [1175]={ 513}, -- come_into_my_parlor
  94. [1177]={ 526, 527}, -- idol_thoughts, awful_autopsy
  95. [1178]={ 514}, -- e-vase-ive_action
  96. [1180]={ 515}, -- infernal_swarm
  97. [1552]={ 521, 522} -- die_by_the_sword, let_sleeping_dogs_die
  98. },
  99. [207]= -- Cloister of Flames
  100. { --itemid bcnmid
  101. [1544]={ 545}, -- trial-size_trial_by_fire
  102. },
  103. [209]= -- Cloister of Tremors
  104. { --itemid bcnmid
  105. [1169]={ 577}, -- puppet_master
  106. [1547]={ 578} -- trial-size_trial_by_earth
  107. },
  108. [211]= -- Cloister of Tides
  109. { --itemid bcnmid
  110. [1549]={ 609} -- trial-size_trial_by_water
  111. }
  112. };
  113.  
  114. -- [zoneId] = {bcnm, ids, in, order}
  115. battlefield_bitmask_map =
  116. {
  117. [6] = {640, 641, 642, 643, 644},
  118. [8] = {672, 673, 674, 675, 676, 677, 678, 679},
  119. [10] = {704, 705, 706},
  120. [13] = {736, 737, 738, 739, 740, 741},
  121. [17] = {768, 769, 770},
  122. [19] = {800,801,802},
  123. [21] = {832,833,834},
  124. [23] = {864,865,866},
  125. [29] = {896,897},
  126. [30] = {928},
  127. [31] = {960,961,962,963,964,965,966,967},
  128. [32] = {992,993},
  129. [35] = {1024},
  130. [36] = {1056,1057},
  131. [37] = {1298,1299,1300,1301,1302,1303,1304,1305,1306,1307},
  132. [38] = {1290,1291,1292,1293,1294,1295,1296,1297},
  133. [39] = {1286},
  134. [40] = {1287},
  135. [41] = {1288},
  136. [42] = {1289},
  137. [57] = {1088,1089,1090,1091,1092},
  138. [64] = {1120,1121,1122,1123,1124},
  139. [67] = {1152,1153,1154,1155,1156},
  140. [78] = {1184},
  141. [186] = {1280},
  142. [185] = {1281},
  143. [187] = {1282},
  144. [188] = {1283},
  145. [134] = {1284},
  146. [135] = {1285},
  147. [139] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
  148. [140] = {32,33,34,35,36,37},
  149. [144] = {64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85},
  150. [146] = {96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116},
  151. [156] = {352,353,354},
  152. [163] = {128,129,130,131,132},
  153. [165] = {160,161,162,163,164},
  154. [168] = {192,193,194,195,196,197,198,199,200,201},
  155. [170] = {224,225,226,227},
  156. [179] = {256,257,258,259,260,261,262},
  157. [180] = {288,289,290,291,292,293},
  158. [181] = {320},
  159. [182] = {385},
  160. [201] = {416,417,418,419,420},
  161. [202] = {448,449,450,451,452},
  162. [203] = {480,481,482,483,484},
  163. [206] = {512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533},
  164. [207] = {544,545,546,547},
  165. [209] = {576,577,578,579,580},
  166. [211] = {608,609,610,611},
  167. };
  168.  
  169. -- Call this onTrade for burning circles
  170. function TradeBCNM(player, zone, trade, npc)
  171. if (trade == nil) then
  172. print("TradeBCNM was sent a nil trade!\n\t Player: "..player:getName().."\n\t zone: "..zone.."\n")
  173. return false
  174. end
  175.  
  176. if (player:hasStatusEffect(EFFECT_BATTLEFIELD)) then -- cant start a new bc
  177. player:messageBasic(94, 0, 0)
  178. return false
  179. elseif (player:hasWornItem(trade:getItemId())) then -- If already used orb or testimony
  180. player:messageBasic(56, 0, 0) -- i need correct dialog
  181. return false
  182. end
  183.  
  184. if (CheckMaatFights(player, zone, trade, npc)) then -- This function returns true for maat fights
  185. return true
  186. end
  187. -- the following is for orb battles, etc
  188. local item = trade:getItemId()
  189. local questTimelineOK = 0
  190. -- Job/lvl condition for smn battle lvl20
  191. if (item >= 1544 and item <= 1549 and player:getMainJob() == JOBS.SMN and player:getMainLvl() >= 20) then
  192. questTimelineOK = 1
  193. elseif (item == 1166 and player:getVar("aThiefinNorgCS") == 6) then -- AF3 SAM condition
  194. questTimelineOK = 1
  195. elseif (item == 1551) then -- BCNM20
  196. questTimelineOK = 1
  197. elseif (item == 1552) then -- BCNM30
  198. questTimelineOK = 1
  199. elseif (item == 1131) then -- BCNM40
  200. questTimelineOK = 1
  201. elseif (item == 1177) then -- BCNM50
  202. questTimelineOK = 1
  203. elseif (item == 1130) then -- BCNM60
  204. questTimelineOK = 1
  205. elseif (item == 1175) then -- KSNM30
  206. questTimelineOK = 1
  207. elseif (item == 1178) then -- KSNM30
  208. questTimelineOK = 1
  209. elseif (item == 1180) then -- KSNM30
  210. questTimelineOK = 1
  211. elseif (item == 1553) then -- KSNM99
  212. questTimelineOK = 1
  213. elseif (item == 1550 and (player:getQuestStatus(OUTLANDS, DIVINE_MIGHT) == QUEST_ACCEPTED or player:getQuestStatus(OUTLANDS, DIVINE_MIGHT_REPEAT) == QUEST_ACCEPTED)) then -- Divine Might
  214. questTimelineOK = 1
  215. elseif (item == 1169 and player:getVar("ThePuppetMasterProgress") == 2) then -- The Puppet Master
  216. questTimelineOK = 1
  217. elseif (item == 1171 and player:getVar("ClassReunionProgress") == 5) then -- Class Reunion
  218. questTimelineOK = 1
  219. elseif (item == 1172 and player:getVar("CarbuncleDebacleProgress") == 3) then -- Carbuncle Debacle (Gremlims)
  220. questTimelineOK = 1
  221. elseif (item == 1174 and player:getVar("CarbuncleDebacleProgress") == 6) then -- Carbuncle Debacle (Ogmios)
  222. questTimelineOK = 1
  223. end
  224.  
  225. if (questTimelineOK == 1) then
  226. local id = ItemToBCNMID(player, zone, trade)
  227.  
  228. if (id == -1) then -- no valid BCNMs with this item
  229. -- todo: display message based on zone text offset
  230. player:setVar("trade_bcnmid", 0)
  231. player:setVar("trade_itemid", 0)
  232. return false
  233. else -- a valid BCNM with this item, start it.
  234. player:setVar("trade_bcnmid", id[1])
  235. player:setVar("trade_itemid", item)
  236. mask = GetBattleBitmask(id, zone, 3)
  237.  
  238. if (mask == -1) then -- Cannot resolve this BCNMID to an event number, edit bcnmid_param_map!
  239. print("Item is for a valid BCNM but cannot find the event parameter to display to client.")
  240. player:setVar("trade_bcnmid", 0)
  241. player:setVar("trade_itemid", 0)
  242. return false
  243. end
  244. if (player:isBcnmsFull() == 1) then -- temp measure, this will precheck the instances
  245. print("all bcnm instances are currently occupied.")
  246. npc:messageBasic(246, 0, 0) -- this wont look right in other languages!
  247. return true
  248. end
  249. player:startEvent(32000, 0, 0, 0, mask, 0, 0, 0, 0)
  250. return true
  251. end
  252. end
  253. end
  254.  
  255. function EventTriggerBCNM(player, npc)
  256. player:setVar("trade_bcnmid", 0)
  257. player:setVar("trade_itemid", 0)
  258.  
  259. if (player:hasStatusEffect(EFFECT_BATTLEFIELD)) then
  260. if (player:isInBcnm() == 1) then
  261. player:startEvent(32003) -- Run Away or Stay menu
  262. else -- You're not in the BCNM but you have the Battlefield effect. Think: non-trader in a party
  263. status = player:getStatusEffect(EFFECT_BATTLEFIELD)
  264. playerbcnmid = status:getPower()
  265. playermask = GetBattleBitmask(playerbcnmid, player:getZoneID(), 1)
  266. if (playermask~=-1) then
  267. -- This gives players who did not trade to go in the option of entering the fight
  268. player:startEvent(32000, 0, 0, 0, playermask, 0, 0, 0, 0)
  269. else
  270. player:messageBasic(94, 0, 0)
  271. end
  272. end
  273. return true
  274. else
  275. if (checkNonTradeBCNM(player, npc)) then
  276. return true
  277. end
  278. end
  279.  
  280. return false
  281. end
  282.  
  283. function EventUpdateBCNM(player, csid, option, entrance)
  284. local id = player:getVar("trade_bcnmid") -- this is 0 if the bcnm isnt handled by new functions
  285. local skip = CutsceneSkip(player, npc)
  286. local zone = player:getZoneID()
  287. print("UPDATE csid "..csid.." option "..option)
  288. -- seen: option 2, 3, 0 in that order
  289. if (csid == 32003 and option == 2) then -- leaving a BCNM the player is currently in.
  290. player:updateEvent(3)
  291. return true
  292. elseif (csid == 32003 and option == 3) then -- leaving a BCNM the player is currently in.
  293. player:updateEvent(0)
  294. return true
  295. end
  296. if (option == 255 and csid == 32000) then -- Ignore packet type 0x05B 255 does not tell us which battlefield was selected.
  297. return true
  298. elseif (option > 0 and csid == 32000) then -- Requesting a Battlefield Instance
  299. -- The client will send a total of THREE EventUpdate packets for each one of the free instances.
  300. -- If the first instance is free, it should respond to the first packet
  301. -- If the second instance is free, it should respond to the second packet, etc
  302. local id = battlefield_bitmask_map[zone][bit.rshift(option, 4) + 1] -- Get Battlefield Requested
  303. local instreq = bit.band(option, 0x000F) -- Get Instance Requested
  304. if (player:hasStatusEffect(EFFECT_BATTLEFIELD)) then
  305. inst = player:getBattlefieldID()-- You're entering a bcnm but you already had the battlefield effect, so you want to go to the
  306. player:setVar("bcnm_instanceid", inst) -- instance that your battlefield effect represents.
  307. else
  308. inst = player:bcnmRegister(id)
  309. player:setVar("trade_bcnmid", id)
  310. end
  311. if (inst > 0) then
  312. player:setVar("bcnm_instanceid", inst)
  313. player:updateEvent(0, GetBattleBitmask(id, player:getZoneID(), 1), 0, 0, 5, 0)
  314.  
  315. if (entrance ~= nil and player:getBattlefield() ~= nil) then
  316. player:getBattlefield():setEntrance(entrance)
  317. end
  318. -- player:tradeComplete()
  319. else
  320. -- no free battlefields at the moment!
  321. print("no free instances")
  322. player:setVar("bcnm_instanceid", 255)
  323. end
  324.  
  325. if (inst == instreq) then
  326. -- respond to this packet
  327. local mask = GetBattleBitmask(id, player:getZoneID(), 2)
  328. local status = player:getStatusEffect(EFFECT_BATTLEFIELD)
  329. local playerbcnmid = status:getPower()
  330. local battlefield = player:getBattlefield()
  331. local name = 'None';
  332. local partySize = 5;
  333. local clearTime = 260;
  334. print(mask)
  335. print(playerbcnmid)
  336.  
  337. if battlefield then
  338. local record = battlefield:getRecord()
  339. name = record.name
  340. partySize = record.partySize
  341. clearTime = record.clearTime
  342. end
  343.  
  344. if (mask < playerbcnmid) then
  345. mask = GetBattleBitmask(playerbcnmid, player:getZoneID(), 2)
  346. player:updateEvent(2, mask - 1, 0, clearTime, partySize, skip) -- Add mask number for the correct entering CS
  347. player:updateEventString(name);
  348. player:bcnmEnter(id)
  349. -- print("mask is "..mask)
  350. -- print("playerbcnmid is "..playerbcnmid)
  351.  
  352. elseif (mask >= playerbcnmid) then
  353. mask = GetBattleBitmask(id, player:getZoneID(), 2)
  354. player:updateEvent(2, mask - 1, 0, clearTime, partySize, skip) -- Add mask number for the correct entering CS
  355. player:updateEventString(name);
  356. player:bcnmEnter(id)
  357. -- print("mask2 is "..mask)
  358. -- print("playerbcnmid2 is "..playerbcnmid)
  359. end
  360.  
  361. if (entrance ~= nil and player:getBattlefield() ~= nil) then
  362. player:getBattlefield():setEntrance(entrance)
  363. end
  364.  
  365. elseif (player:getVar("bcnm_instanceid") == 255) then -- none free
  366. -- print("nfa")
  367. -- player:updateEvent(2, 5, 0, 0, 1, 0) -- @cs 32000 0 0 0 0 0 0 0 2
  368. -- param1
  369. -- 2=generic enter cs
  370. -- 3=spam increment instance requests
  371. -- 4=cleared to enter but cant while ppl engaged
  372. -- 5=dont meet req, access denied.
  373. -- 6=room max cap
  374. -- param2 alters the eventfinish option (offset)
  375. -- param7/8 = does nothing??
  376. end
  377. -- !pos -517 159 -209
  378. -- !pos -316 112 -103
  379. -- player:updateEvent(msgid, bcnmFight, 0, record, numadventurers, skip) skip=1 to skip anim
  380. -- msgid 1=wait a little longer, 2=enters
  381. end
  382. return true
  383. end
  384.  
  385. function EventFinishBCNM(player, csid, option)
  386. print("FINISH csid "..csid.." option "..option)
  387.  
  388. if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then -- Temp condition for normal bcnm (started with onTrigger)
  389. return false
  390. else
  391. local id = player:getVar("trade_bcnmid")
  392. local item = player:getVar("trade_itemid")
  393.  
  394. if (id == 68 or id == 418 or id == 450 or id == 482 or id == 545 or id == 578 or id == 609 or id == 293) then
  395. player:tradeComplete() -- Removes the item
  396. elseif ((item >= 1426 and item <= 1440) or item == 1130 or item == 1131 or item == 1175 or item == 1177 or item == 1180 or item == 1178 or item == 1551 or item == 1552 or item == 1553) then -- Orb and T$
  397. player:createWornItem(item)
  398. end
  399.  
  400. if csid == 32003 and option == 4 then
  401. if player:getBattlefield() then
  402. player:bcnmLeave(1);
  403. end
  404. end
  405. return true
  406. end
  407.  
  408. end
  409.  
  410. -- Returns TRUE if you're trying to do a maat fight, regardless of outcome e.g. if you trade testimony on wrong job, this will return true in order to prevent further execution of TradeBCNM. Returns FALSE if yo$
  411. function CheckMaatFights(player, zone, trade, npc)
  412. player:setVar("trade_bcnmid", 0)
  413. player:setVar("trade_itemid", 0)
  414. -- check for maat fights (one maat fight per zone in the db, but >1 mask entries depending on job, so we
  415. -- need to choose the right one depending on the players job, and make sure the right testimony is traded,
  416. -- and make sure the level is right!
  417. local itemid = trade:getItemId()
  418. local job = player:getMainJob()
  419. local lvl = player:getMainLvl()
  420.  
  421. if (itemid >= 1426 and itemid <= 1440) then -- The traded item IS A TESTIMONY
  422. if (lvl < 66) then
  423. return true
  424. end
  425.  
  426. if (player:isBcnmsFull() == 1) then -- temp measure, this will precheck the instances
  427. print("all bcnm instances are currently occupied.")
  428. npc:messageBasic(246, 0, 0)
  429. return true
  430. end
  431.  
  432. -- Zone, {item, job, menu, bcnmid, ...}
  433. maatList =
  434. {
  435. 139, {1426, 1, 32, 5, 1429, 4, 64, 6, 1436, 11, 128, 7}, -- Horlais Peak [WAR BLM RNG]
  436. 144, {1430, 5, 64, 70, 1431, 6, 128, 71, 1434, 9, 256, 72}, -- Waughroon Shrine [RDM THF BST]
  437. 146, {1427, 2, 32, 101, 1428, 3, 64, 102, 1440, 15, 128, 103}, -- Balga's Dais [MNK WHM SMN]
  438. 168, {1437, 12, 4, 194, 1438, 13, 8, 195, 1439, 14, 16, 196}, -- Chamber of Oracles [SAM NIN DRG]
  439. 206, {1432, 7, 32, 517, 1433, 8, 64, 518, 1435, 10, 128, 519} -- Qu'Bia Arena [PLD DRK BRD]
  440. }
  441.  
  442. for nb = 1, #maatList, 2 do
  443. if (maatList[nb] == zone) then
  444. for nbi = 1, #maatList[nb + 1], 4 do
  445. if (itemid == maatList[nb + 1][nbi] and job == maatList[nb + 1][nbi + 1]) then
  446. player:startEvent(32000, 0, 0, 0, maatList[nb + 1][nbi + 2], 0, 0, 0, 0)
  447. player:setVar("trade_bcnmid", maatList[nb + 1][nbi + 3])
  448. player:setVar("trade_itemid", maatList[nb + 1][nbi])
  449. break
  450. end
  451. end
  452. end
  453. end
  454.  
  455. return true
  456. end
  457. -- if it got this far then its not a testimony
  458. return false
  459. end
  460.  
  461. function GetBattleBitmask(bcnmid, zone, mode)
  462. -- normal sweep for NON MAAT FIGHTS
  463. local mask = 0;
  464. if (battlefield_bitmask_map[zone] ~= null) then
  465. for index = 1, #battlefield_bitmask_map[zone] do
  466. if (mode == 3) then -- array input mode!
  467. for id = 1, #bcnmid do
  468. if(battlefield_bitmask_map[zone][index] == bcnmid[id]) then
  469. mask = mask + math.pow(2, index -1)
  470. end
  471. end
  472. elseif (battlefield_bitmask_map[zone][index] == bcnmid) then
  473. if(mode == 1) then
  474. return math.pow(2, index - 1);
  475. else
  476. return index;
  477. end
  478. end
  479. end
  480. return mask;
  481. else
  482. printf("[bcnm] unable to get bitmask for battlefield: %u, zone: %u", id, zone);
  483. return -1;
  484. end
  485. end
  486.  
  487. function ItemToBCNMID(player, zone, trade)
  488. local item = trade:getItemId()
  489. if ( itemid_bcnmid_map[zone][item] ~= nil) then
  490. item_to_bcnm = {}
  491. for id = 1, #itemid_bcnmid_map[zone][item] do -- loop bcnms matching item/zone
  492. item_to_bcnm[id]=itemid_bcnmid_map[zone][item][id] --add them to array
  493. end
  494. return item_to_bcnm; --return array
  495. else
  496. return -1 -- item not found for zone
  497. end
  498. end
  499.  
  500. -- E.g. mission checks go here, you must know the right bcnmid for the mission you want to code.
  501. -- You also need to know the bitmask (event param) which should be put in bcnmid_param_map
  502.  
  503. function checkNonTradeBCNM(player, npc, mode)
  504. local mask = 0
  505. local Zone = player:getZoneID()
  506. mode = mode or 2;
  507.  
  508. local checks =
  509. {
  510. [6] = {
  511. [640] = function() return (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") == 6) end, -- flames_for_the_dead
  512. [643] = function() return (player:hasKeyItem(ZEPHYR_FAN)) end, -- Brothers ENM
  513. },
  514. [8] = {
  515. [672] = function() return (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") == 5) end, -- head_wind
  516. [673] = function() return (player:hasKeyItem(MIASMA_FILTER)==true) end,
  517. },
  518. [10] = {
  519. [704] = function() return (player:getCurrentMission(COP) == DARKNESS_NAMED and player:getVar("PromathiaStatus") == 2) end,-- DARKNESS_NAMED
  520. [706] = function() return (player:hasKeyItem(VIAL_OF_DREAM_INCENSE)==true) end, -- waking_dreams (diabolos avatar quest)
  521. },
  522. [13] = {
  523. [736] = function() return (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Louverance_s_Path") == 5) end, -- century_of_hardship
  524. },
  525. [17] = {
  526. [768] = function() return (player:getCurrentMission(COP) == BELOW_THE_ARKS and player:getVar("PromathiaStatus") ==1 ) or
  527. (player:getCurrentMission(COP) == THE_MOTHERCRYSTALS and player:hasKeyItem(LIGHT_OF_HOLLA) == false) end, -- light of holla
  528. },
  529. [19] = {
  530. [800] = function() return (player:getCurrentMission(COP) == BELOW_THE_ARKS and player:getVar("PromathiaStatus") ==1 ) or
  531. (player:getCurrentMission(COP) == THE_MOTHERCRYSTALS and player:hasKeyItem(LIGHT_OF_DEM) == false) end, -- light of dem
  532. },
  533. [21] = {
  534. [832] = function() return (player:getCurrentMission(COP) == BELOW_THE_ARKS and player:getVar("PromathiaStatus") ==1 ) or
  535. (player:getCurrentMission(COP) == THE_MOTHERCRYSTALS and player:hasKeyItem(LIGHT_OF_MEA) == false) end, -- light of mea
  536. },
  537. [23] = {
  538. [864] = function() return (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus")==8) end, -- desires of emptiness
  539. },
  540. [29] = {
  541. [896] = function() return (player:getQuestStatus(JEUNO,STORMS_OF_FATE) == QUEST_ACCEPTED and player:getVar('StormsOfFate') == 2) end, -- Storms of Fate BCNM
  542. },
  543. [31] = {
  544. [960] = function() return (player:getCurrentMission(COP) == ANCIENT_VOWS and player:getVar("PromathiaStatus") == 2) end, -- Ancient Vows bcnm
  545. [961] = function() return (player:getCurrentMission(COP) == THE_SAVAGE and player:getVar("PromathiaStatus") == 1) end,
  546. },
  547. [32] = {
  548. [992] = function() return (player:getCurrentMission(COP) == ONE_TO_BE_FEARED and player:getVar("PromathiaStatus")==2) end, -- one_to_be_feared
  549. [993] = function() return (player:getCurrentMission(COP) == THE_WARRIOR_S_PATH) end, -- warriors_path
  550. },
  551. [35] = {
  552. [1024] = function() return (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus")==4) end, -- when_angels_fall
  553. },
  554. [36] = {
  555. [1056] = function() return (player:getCurrentMission(COP) == DAWN and player:getVar("PromathiaStatus")==2) end, -- dawn
  556. },
  557. [57] = {
  558. [1092] = function() return (player:getCurrentMission(TOAU) == LEGACY_OF_THE_LOST) end, -- TOAU-35 Legacy of the Lost
  559. },
  560. [64] = {
  561. [1124] = function() return (player:getCurrentMission(TOAU) == SHIELD_OF_DIPLOMACY and player:getVar("AhtUrganStatus")==2) end, -- TOAU-22 shield of diplomacy
  562. },
  563. [67] = {
  564. [1156] = function() return (player:getCurrentMission(TOAU) == PUPPET_IN_PERIL and player:getVar("AhtUrganStatus")==1) end, -- TOAU-29 Puppet in Peril
  565. },
  566. [139] = {
  567. [0] = function()
  568. return ((player:getCurrentMission(BASTOK) == THE_EMISSARY_SANDORIA2 or
  569. player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_SANDORIA2) and player:getVar("MissionStatus") == 9)
  570. end, -- Mission 2-3
  571. [3] = function() return (player:getCurrentMission(SANDORIA) == THE_SECRET_WEAPON and player:getVar("SecretWeaponStatus") == 2) end,
  572. },
  573. [140] = {
  574. [32] = function()
  575. local MissionStatus = player:getVar("MissionStatus");
  576. local sTcCompleted = player:hasCompletedMission(SANDORIA, SAVE_THE_CHILDREN);
  577. return (player:getCurrentMission(SANDORIA) == SAVE_THE_CHILDREN and (sTcCompleted and MissionStatus <= 2 or sTcCompleted == false and MissionStatus == 2))
  578. end, -- Sandy Mission 1-3
  579. [33] = function() return (player:hasKeyItem(DRAGON_CURSE_REMEDY)) end, -- DRG Flag Quest
  580. },
  581. [144] = {
  582. [64] = function() return ((player:getCurrentMission(SANDORIA) == JOURNEY_TO_BASTOK2 or
  583. player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_BASTOK2) and player:getVar("MissionStatus") == 10) end, -- Mission 2-3
  584. [67] = function() return ((player:getCurrentMission(BASTOK) == ON_MY_WAY) and (player:getVar("MissionStatus") == 2)) end,
  585. },
  586. [146] = {
  587. [96] = function() return (player:hasKeyItem(DARK_KEY)) end, -- Mission 2-3
  588. [99] = function() return ((player:getCurrentMission(WINDURST) == SAINTLY_INVITATION) and (player:getVar("MissionStatus") == 1)) end, -- Mission 6-2
  589. },
  590. [163] = {
  591. [128] = function() return (player:getCurrentMission(ZILART) == THE_TEMPLE_OF_UGGALEPIH) end, -- Zilart Mission 4
  592. },
  593. [165] = {
  594. [160] = function() return (player:getCurrentMission(player:getNation()) == 15 and player:getVar("MissionStatus") == 3) end, -- Mission 5-2
  595. [161] = function() return (player:getCurrentMission(BASTOK) == WHERE_TWO_PATHS_CONVERGE and player:getVar("BASTOK92") == 1) end, -- bastok 9-2
  596. },
  597. [168] = {
  598. [192] = function() return (player:getCurrentMission(ZILART) == THROUGH_THE_QUICKSAND_CAVES or player:getCurrentMission(ZILART) == THE_CHAMBER_OF_ORACLES) end, -- Zilart Mission 6
  599. },
  600. [170] = {
  601. [224] = function() return (player:hasKeyItem(MOON_BAUBLE)) end, -- The Moonlit Path
  602. [225] = function() return ((player:getCurrentMission(WINDURST) == MOON_READING) and player:getVar("MissionStatus") == 2) end, -- Windurst 9-2
  603. },
  604. [179] = {
  605. [256] = function() return (player:getCurrentMission(ZILART) == RETURN_TO_DELKFUTTS_TOWER and player:getVar("ZilartStatus") == 3) end, -- Zilart Mission 8
  606. },
  607. [180] = {
  608. [288] = function() return (player:getCurrentMission(ZILART) == ARK_ANGELS and player:getVar("ZilartStatus") == 1 and npc:getID() == 17514791 and player:hasKeyItem(SHARD_OF_APATHY) == false) $
  609. [289] = function() return (player:getCurrentMission(ZILART) == ARK_ANGELS and player:getVar("ZilartStatus") == 1 and npc:getID() == 17514792 and player:hasKeyItem(SHARD_OF_COWARDICE) == fals$
  610. [290] = function() return (player:getCurrentMission(ZILART) == ARK_ANGELS and player:getVar("ZilartStatus") == 1 and npc:getID() == 17514793 and player:hasKeyItem(SHARD_OF_ENVY) == false) e$
  611. [291] = function() return (player:getCurrentMission(ZILART) == ARK_ANGELS and player:getVar("ZilartStatus") == 1 and npc:getID() == 17514794 and player:hasKeyItem(SHARD_OF_ARROGANCE) == fals$
  612. [292] = function() return (player:getCurrentMission(ZILART) == ARK_ANGELS and player:getVar("ZilartStatus") == 1 and npc:getID() == 17514795 and player:hasKeyItem(SHARD_OF_RAGE) == false) e$
  613. },
  614. [181] = {
  615. [320] = function() return (player:getCurrentMission(ZILART) == THE_CELESTIAL_NEXUS) end, -- Zilart Mission 16
  616. },
  617. [201] = {
  618. [416] = function() return (player:hasKeyItem(TUNING_FORK_OF_WIND)) end, -- Trial by Wind
  619. [420] = function() return (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_EMERALD_SEAL)) end,
  620. },
  621. [202] = {
  622. [448] = function() return (player:hasKeyItem(TUNING_FORK_OF_LIGHTNING)) end, -- Trial by Lightning
  623. [452] = function() return (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_VIOLET_SEAL)) end,
  624. },
  625. [203] = {
  626. [480] = function() return (player:hasKeyItem(TUNING_FORK_OF_ICE)) end, -- Trial by Ice
  627. [484] = function() return (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_AZURE_SEAL)) end,
  628. },
  629. [206] = {
  630. [512] = function() return (player:getCurrentMission(player:getNation()) == 14 and player:getVar("MissionStatus") == 11) end, -- Mission 5-1
  631. [516] = function() return (player:getCurrentMission(SANDORIA) == THE_HEIR_TO_THE_LIGHT and player:getVar("MissionStatus") == 3) end, -- sando 9-2
  632. --[[
  633. Temp disabled pending BCNM mob fixes
  634. [532] = function() return (player:getCurrentMission(ACP) >= THOSE_WHO_LURK_IN_SHADOWS_III and player:hasKeyItem(MARK_OF_SEED)) end, -- ACP Mission 7
  635. ]]
  636. },
  637. [207] = {
  638. [544] = function() return (player:hasKeyItem(TUNING_FORK_OF_FIRE)) end, -- Trial by Fire
  639. [547] = function() return (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_SCARLET_SEAL)) end,
  640. },
  641. [209] = {
  642. [576] = function() return (player:hasKeyItem(TUNING_FORK_OF_EARTH)) end, -- Trial by Earth
  643. [580] = function() return (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_AMBER_SEAL)) end,
  644. },
  645. [211] = {
  646. [608] = function() return (player:hasKeyItem(TUNING_FORK_OF_WATER)) end, -- Trial by Water
  647. [611] = function() return (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_CERULEAN_SEAL)) end,
  648. },
  649. }
  650.  
  651. for keyid, condition in pairs(checks[Zone]) do
  652. if condition() and GetBattleBitmask(keyid, Zone, mode) ~= -1 then
  653. mask = mask + GetBattleBitmask(keyid, Zone, mode);
  654. if mode == 2 then
  655. player:setVar("trade_bcnmid", keyid);
  656. end
  657. -- todo: multiple choice bcnms
  658. break;
  659. end;
  660. end;
  661.  
  662. if mode == 2 then
  663. player:startEvent(32000, 0, 0, 0, mask, 0, 0, 0, 0);
  664. end
  665. return mask;
  666. end
  667.  
  668. function CutsceneSkip(player, npc)
  669.  
  670. local skip = 0
  671. local Zone = player:getZoneID()
  672.  
  673. if (Zone == 6) then -- Bearclaw Pinnacle
  674. if ((player:hasCompletedMission(COP, THREE_PATHS)) or (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") > 6)) then -- flames_for_the_dead
  675. skip = 1
  676. end
  677. elseif (Zone == 8) then -- Boneyard Gully
  678. if ((player:hasCompletedMission(COP, THREE_PATHS)) or (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") > 5)) then -- head_wind
  679. skip = 1
  680. end
  681. elseif (Zone == 10) then -- The_Shrouded_Maw
  682. if ((player:hasCompletedMission(COP, DARKNESS_NAMED)) or (player:getCurrentMission(COP) == DARKNESS_NAMED and player:getVar("PromathiaStatus") > 2)) then -- DARKNESS_NAMED
  683. skip = 1
  684. elseif ((player:hasCompletedQuest(WINDURST, WAKING_DREAMS)) or (player:hasKeyItem(WHISPER_OF_DREAMS))) then -- waking_dreams (diabolos avatar quest)
  685. skip = 1
  686. end
  687. elseif (Zone == 13) then -- Mine Shaft 2716
  688. if ((player:hasCompletedMission(COP, THREE_PATHS)) or (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Louverance_s_Path") > 5)) then -- century_of_hardship
  689. skip = 1
  690. end
  691. elseif (Zone == 17) then -- Spire of Holla
  692. if ((player:hasCompletedMission(COP, THE_MOTHERCRYSTALS)) or (player:hasKeyItem(LIGHT_OF_HOLLA))) then -- light of holla
  693. skip = 1
  694. end
  695. elseif (Zone == 19) then -- Spire of Dem
  696. if ((player:hasCompletedMission(COP, THE_MOTHERCRYSTALS)) or (player:hasKeyItem(LIGHT_OF_DEM))) then -- light of dem
  697. skip = 1
  698. end
  699. elseif (Zone == 21) then -- Spire of Mea
  700. if ((player:hasCompletedMission(COP, THE_MOTHERCRYSTALS)) or (player:hasKeyItem(LIGHT_OF_MEA))) then -- light of mea
  701. skip = 1
  702. end
  703. elseif (Zone == 23) then -- Spire of Vahzl
  704. if ((player:hasCompletedMission(COP, DESIRES_OF_EMPTINESS)) or (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus") > 8)) then -- desires of emptiness
  705. skip = 1
  706. end
  707. elseif (Zone == 29) then -- Riverne Site #B01
  708. if ((player:getQuestStatus(JEUNO,STORMS_OF_FATE) == QUEST_COMPLETED) or (player:getQuestStatus(JEUNO,STORMS_OF_FATE) == QUEST_ACCEPTED and player:getVar("StormsOfFate") > 2)) then -- Storms of Fate
  709. skip = 1
  710. end
  711. elseif (Zone == 31) then -- Monarch Linn
  712. if (player:hasCompletedMission(COP, ANCIENT_VOWS)) then -- Ancient Vows
  713. skip = 1
  714. elseif ((player:hasCompletedMission(COP, THE_SAVAGE)) or (player:getCurrentMission(COP) == THE_SAVAGE and player:getVar("PromathiaStatus") > 1)) then
  715. skip = 1
  716. end
  717. elseif (Zone == 32) then -- Sealion's Den
  718. if (player:hasCompletedMission(COP, ONE_TO_BE_FEARED)) then -- one_to_be_feared
  719. skip = 1
  720. elseif (player:hasCompletedMission(COP, THE_WARRIOR_S_PATH)) then -- warriors_path
  721. skip = 1
  722. end
  723. elseif (Zone == 35) then -- The Garden of RuHmet
  724. if ((player:hasCompletedMission(COP, WHEN_ANGELS_FALL)) or (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus") > 4)) then -- when_angels_fall
  725. skip = 1
  726. end
  727. elseif (Zone == 36) then -- Empyreal Paradox
  728. if ((player:hasCompletedMission(COP, DAWN)) or (player:getCurrentMission(COP) == DAWN and player:getVar("PromathiaStatus") > 2)) then -- dawn
  729. skip = 1
  730. end
  731. elseif (Zone == 139) then -- Horlais Peak
  732. if ((player:hasCompletedMission(BASTOK, THE_EMISSARY_SANDORIA2) or player:hasCompletedMission(WINDURST, THE_THREE_KINGDOMS_SANDORIA2)) or
  733. ((player:getCurrentMission(BASTOK) == THE_EMISSARY_SANDORIA2 or player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_SANDORIA2) and player:getVar("MissionStatus") > 9)) then -- Mission 2-3
  734. skip = 1
  735. elseif ((player:hasCompletedMission(SANDORIA, THE_SECRET_WEAPON)) or (player:getCurrentMission(SANDORIA) == THE_SECRET_WEAPON and player:getVar("SecretWeaponStatus") > 2)) then
  736. skip = 1
  737. end
  738. elseif (Zone == 140) then -- Ghelsba Outpost
  739. if ((player:hasCompletedMission(SANDORIA, SAVE_THE_CHILDREN)) or (player:getCurrentMission(SANDORIA) == SAVE_THE_CHILDREN and player:getVar("MissionStatus") > 2)) then -- Sandy Mission 1-3
  740. skip = 1
  741. elseif (player:hasCompletedQuest(SANDORIA, THE_HOLY_CREST)) then -- DRG Flag Quest
  742. skip = 1
  743. end
  744. elseif (Zone == 144) then -- Waughroon Shrine
  745. if ((player:hasCompletedMission(SANDORIA, JOURNEY_TO_BASTOK2) or player:hasCompletedMission(WINDURST, THE_THREE_KINGDOMS_BASTOK2)) or
  746. ((player:getCurrentMission(SANDORIA) == JOURNEY_TO_BASTOK2 or player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_BASTOK2) and player:getVar("MissionStatus") > 10)) then -- Mission 2-3
  747. skip = 1
  748. elseif ((player:hasCompletedMission(BASTOK, ON_MY_WAY)) or (player:getCurrentMission(BASTOK) == ON_MY_WAY and player:getVar("MissionStatus") > 2)) then
  749. skip = 1
  750. end
  751. elseif (Zone == 146) then -- Balga's Dais
  752. if ((player:hasCompletedMission(SANDORIA, JOURNEY_TO_WINDURST2) or player:hasCompletedMission(BASTOK, THE_EMISSARY_WINDURST2)) or
  753. ((player:getCurrentMission(SANDORIA) == JOURNEY_TO_WINDURST2 or player:getCurrentMission(BASTOK) == THE_EMISSARY_WINDURST2) and player:getVar("MissionStatus") > 8)) then -- Mission 2-3
  754. skip = 1
  755. elseif ((player:hasCompletedMission(WINDURST, SAINTLY_INVITATION)) or (player:getCurrentMission(WINDURST) == SAINTLY_INVITATION and player:getVar("MissionStatus") > 1)) then -- Mission 6-2
  756. skip = 1
  757. end
  758. elseif (Zone == 165) then -- Throne Room
  759. if ((player:hasCompletedMission(player:getNation(), 15)) or (player:getCurrentMission(player:getNation()) == 15 and player:getVar("MissionStatus") > 3)) then -- Mission 5-2
  760. skip = 1
  761. end
  762. elseif (Zone == 168) then -- Chamber of Oracles
  763. if (player:hasCompletedMission(ZILART, THROUGH_THE_QUICKSAND_CAVES)) then -- Zilart Mission 6
  764. skip = 1
  765. end
  766. elseif (Zone == 170) then -- Full Moon Fountain
  767. if ((player:hasCompletedQuest(WINDURST, THE_MOONLIT_PATH)) or (player:hasKeyItem(WHISPER_OF_THE_MOON))) then -- The Moonlit Path
  768. skip = 1
  769. elseif ((player:hasCompletedMission(WINDURST, MOON_READING)) or (player:getCurrentMission(WINDURST) == MOON_READING and player:getVar("MissionStatus") > 2)) then
  770. skip = 1
  771. end
  772. elseif (Zone == 179) then -- Stellar Fulcrum
  773. if (player:hasCompletedMission(ZILART, RETURN_TO_DELKFUTTS_TOWER)) then -- Zilart Mission 8
  774. skip = 1
  775. end
  776. elseif (Zone == 180) then -- La'Loff Amphitheater
  777. if (player:hasCompletedMission(ZILART, ARK_ANGELS)) then
  778. skip = 1
  779. end
  780. elseif (Zone == 181) then -- The Celestial Nexus
  781. if (player:hasCompletedMission(ZILART, THE_CELESTIAL_NEXUS)) then -- Zilart Mission 16
  782. skip = 1
  783. end
  784. elseif (Zone == 201) then -- Cloister of Gales
  785. if ((player:hasCompletedQuest(OUTLANDS, TRIAL_BY_WIND)) or (player:hasKeyItem(WHISPER_OF_GALES))) then -- Trial by Wind
  786. skip = 1
  787. end
  788. elseif (Zone == 202) then -- Cloister of Storms
  789. if ((player:hasCompletedQuest(OTHER_AREAS_LOG, TRIAL_BY_LIGHTNING)) or (player:hasKeyItem(WHISPER_OF_STORMS))) then -- Trial by Lightning
  790. skip = 1
  791. end
  792. elseif (Zone == 203) then -- Cloister of Frost
  793. if ((player:hasCompletedQuest(SANDORIA, TRIAL_BY_ICE)) or (player:hasKeyItem(WHISPER_OF_FROST))) then -- Trial by Ice
  794. skip = 1
  795. end
  796. elseif (Zone == 206) then -- Qu'Bia Arena
  797. if ((player:hasCompletedMission(player:getNation(), 14)) or (player:getCurrentMission(player:getNation()) == 14 and player:getVar("MissionStatus") > 11)) then -- Mission 5-1
  798. skip = 1
  799. elseif ((player:hasCompletedMission(player:getNation(), 23)) or (player:getCurrentMission(player:getNation()) == 23 and player:getVar("MissionStatus") > 4)) then -- Mission 9-2
  800. skip = 1
  801. end
  802. elseif (Zone == 207) then -- Cloister of Flames
  803. if ((player:hasCompletedQuest(OUTLANDS, TRIAL_BY_FIRE)) or (player:hasKeyItem(WHISPER_OF_FLAMES))) then -- Trial by Fire
  804. skip = 1
  805. end
  806. elseif (Zone == 209) then -- Cloister of Tremors
  807. if ((player:hasCompletedQuest(BASTOK, TRIAL_BY_EARTH)) or (player:hasKeyItem(WHISPER_OF_TREMORS))) then -- Trial by Earth
  808. skip = 1
  809. end
  810. elseif (Zone == 211) then -- Cloister of Tides
  811. if ((player:hasCompletedQuest(OUTLANDS, TRIAL_BY_WATER)) or (player:hasKeyItem(WHISPER_OF_TIDES))) then -- Trial by Water
  812. skip = 1
  813. end
  814. end
  815. return skip
  816. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement