From d92e47ac582e89405c359e23b19689ca71416a38 Mon Sep 17 00:00:00 2001 From: slashtangent <78345197+slashtangent@users.noreply.github.com> Date: Sun, 16 Mar 2025 23:53:23 -0500 Subject: [PATCH] [lua] [SQL] Convert Quest "The Missing Piece" to IF --- scripts/globals/quests.lua | 2 +- scripts/quests/outlands/The_Missing_Piece.lua | 157 ++++++++++++++++++ .../Northern_San_dOria/npcs/Charlaimagnat.lua | 50 ------ .../zones/Quicksand_Caves/DefaultActions.lua | 1 + scripts/zones/Quicksand_Caves/npcs/qm5.lua | 52 ------ scripts/zones/Rabao/IDs.lua | 1 + scripts/zones/Rabao/npcs/Alfesar.lua | 46 ----- sql/npc_list.sql | 2 +- 8 files changed, 161 insertions(+), 150 deletions(-) create mode 100644 scripts/quests/outlands/The_Missing_Piece.lua delete mode 100644 scripts/zones/Northern_San_dOria/npcs/Charlaimagnat.lua delete mode 100644 scripts/zones/Quicksand_Caves/npcs/qm5.lua delete mode 100644 scripts/zones/Rabao/npcs/Alfesar.lua diff --git a/scripts/globals/quests.lua b/scripts/globals/quests.lua index 8cb7aa14842..56a51d735f2 100644 --- a/scripts/globals/quests.lua +++ b/scripts/globals/quests.lua @@ -602,7 +602,7 @@ xi.quest.id = -- Rabao (192-201) DONT_FORGET_THE_ANTIDOTE = 192, -- ± - THE_MISSING_PIECE = 193, -- ± + THE_MISSING_PIECE = 193, -- ± Converted TRIAL_BY_WIND = 194, -- ± THE_KUFTAL_TOUR = 195, THE_IMMORTAL_LU_SHANG = 196, -- ± diff --git a/scripts/quests/outlands/The_Missing_Piece.lua b/scripts/quests/outlands/The_Missing_Piece.lua new file mode 100644 index 00000000000..702e1738c8b --- /dev/null +++ b/scripts/quests/outlands/The_Missing_Piece.lua @@ -0,0 +1,157 @@ +----------------------------------- +-- The Missing Piece +----------------------------------- +-- !addquest 5 193 +-- Alfesar : !pos 23.193 8.818 38.985 +-- qm5 + -- Possible Positions: + -- !pos 770, 0, -419 + -- !pos 657, 0, -537 + -- !pos 749, 0, -573 + -- !pos 451, -16, -739 + -- !pos 787, -16, -819 +-- Charlaimagnat : !pos 124.560 6.500 111.787 +----------------------------------- +local rabaoID = zones[xi.zone.RABAO] +----------------------------------- + +local quest = Quest:new(xi.questLog.OUTLANDS, xi.quest.id.outlands.THE_MISSING_PIECE) + +local positionTable = +{ + [1] = { 770, 0, -419 }, + [2] = { 657, 0, -537 }, + [3] = { 759, 0, -573 }, + [4] = { 451, -16, -739 }, + [5] = { 787, -16, -819 }, +} + +quest.reward = +{ + item = xi.item.SCROLL_OF_TELEPORT_ALTEP, +} + +quest.sections = +{ + { + check = function(player, status, vars) + return status == xi.questStatus.QUEST_AVAILABLE and + player:getFameLevel(xi.fameArea.SELBINA_RABAO) >= 4 and + player:getMainLvl() >= 10 + end, + + [xi.zone.RABAO] = + { + ['Alfesar'] = quest:progressEvent(6, xi.ki.ANCIENT_TABLET_FRAGMENT), + + onEventFinish = + { + [6] = function(player, csid, option, npc) + quest:begin(player) + end, + }, + }, + }, + + { + check = function(player, status, vars) + return status == xi.questStatus.QUEST_ACCEPTED + end, + + [xi.zone.RABAO] = + { + ['Alfesar'] = + { + onTrigger = function(player, npc) + local progress = quest:getVar(player, 'Prog') + + if progress == 0 then + return quest:event(7, xi.ki.ANCIENT_TABLET_FRAGMENT) -- Reminder to get KI + elseif progress == 1 then + return quest:progressEvent(8, xi.ki.ANCIENT_TABLET_FRAGMENT) -- Player has returned with KI + elseif progress == 2 then + return quest:event(9, 0, xi.ki.ANCIENT_TABLET_FRAGMENT) -- Reminder to go to Sandy + end + end, + }, + + onEventFinish = + { + [8] = function(player, csid, option, npc) + player:delKeyItem(xi.ki.ANCIENT_TABLET_FRAGMENT) + player.addKeyItem(player, xi.ki.TABLET_OF_ANCIENT_MAGIC) + player.addKeyItem(player, xi.ki.LETTER_FROM_ALFESAR) + quest:setVar(player, 'Prog', 2) + player:messageSpecial(rabaoID.text.ACCEPTED_KEYITEM, 0, xi.ki.TABLET_OF_ANCIENT_MAGIC, xi.ki.LETTER_FROM_ALFESAR) + end, + }, + }, + + [xi.zone.QUICKSAND_CAVES] = + { + ['qm5'] = + { + onTrigger = function(player, npc) + if quest:getVar(player, 'Prog') == 0 then + quest:setVar(player, 'Prog', 1) + local newPosition = npcUtil.pickNewPosition(npc:getID(), positionTable) + npc:setPos(newPosition.x, newPosition.y, newPosition.z) + return quest:keyItem(xi.ki.ANCIENT_TABLET_FRAGMENT) + end + end, + }, + }, + + [xi.zone.NORTHERN_SAN_DORIA] = + { + ['Charlaimagnat'] = + { + onTrigger = function(player, npc) + local progress = quest:getVar(player, 'Prog') + + if progress == 2 then + return quest:progressEvent(703) -- Player has turned in the KIs from Alfesar + elseif + progress == 3 and + os.time() < quest:getVar(player, 'Wait') + then + return quest:event(704) -- Player has not waited a game day + elseif + progress == 3 and + os.time() >= quest:getVar(player, 'Wait') + then + return quest:progressEvent(705) -- Player has waited a game day. Quest Finished + end + end, + }, + + onEventFinish = + { + [703] = function(player, csid, option, npc) + quest:setVar(player, 'Wait', os.time() + 60) + player:addTitle(xi.title.ACQUIRER_OF_ANCIENT_ARCANUM) + player:delKeyItem(xi.ki.TABLET_OF_ANCIENT_MAGIC) + player:delKeyItem(xi.ki.LETTER_FROM_ALFESAR) + quest:setVar(player, 'Prog', 3) + end, + + [705] = function(player, csid, option, npc) + quest:complete(player) + end, + }, + }, + }, + + { + check = function(player, status, vars) + return status == xi.questStatus.QUEST_COMPLETED + end, + + [xi.zone.RABAO] = + { + ['Alfesar'] = quest:event(11):replaceDefault(), + }, + }, +} + +return quest diff --git a/scripts/zones/Northern_San_dOria/npcs/Charlaimagnat.lua b/scripts/zones/Northern_San_dOria/npcs/Charlaimagnat.lua deleted file mode 100644 index b502080cb43..00000000000 --- a/scripts/zones/Northern_San_dOria/npcs/Charlaimagnat.lua +++ /dev/null @@ -1,50 +0,0 @@ ------------------------------------ --- Area: Northern San d'Oria --- NPC: Charlaimagnat ------------------------------------ -local ID = zones[xi.zone.NORTHERN_SAN_DORIA] ------------------------------------ ----@type TNpcEntity -local entity = {} - -entity.onTrigger = function(player, npc) - local theMissingPiece = player:getQuestStatus(xi.questLog.OUTLANDS, xi.quest.id.outlands.THE_MISSING_PIECE) - - if - theMissingPiece == xi.questStatus.QUEST_ACCEPTED and - player:hasKeyItem(xi.ki.TABLET_OF_ANCIENT_MAGIC) and - player:hasKeyItem(xi.ki.LETTER_FROM_ALFESAR) - then - player:startEvent(703) -- Continuing the Quest - elseif - theMissingPiece == xi.questStatus.QUEST_ACCEPTED and - os.time() < player:getCharVar('TheMissingPiece_date') - then - player:startEvent(704) -- didn't wait a day yet - elseif - theMissingPiece == xi.questStatus.QUEST_ACCEPTED and - os.time() >= player:getCharVar('TheMissingPiece_date') - then - player:startEvent(705) -- Quest Completed - end -end - -entity.onEventFinish = function(player, csid, option, npc) - if csid == 703 then - player:setCharVar('TheMissingPiece_date', os.time() + 60) - player:addTitle(xi.title.ACQUIRER_OF_ANCIENT_ARCANUM) - player:delKeyItem(xi.ki.TABLET_OF_ANCIENT_MAGIC) - player:delKeyItem(xi.ki.LETTER_FROM_ALFESAR) - elseif csid == 705 then - if player:getFreeSlotsCount() == 0 then -- does the player have space - player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED, xi.item.SCROLL_OF_TELEPORT_ALTEP) - else -- give player teleport-altep - player:addItem(xi.item.SCROLL_OF_TELEPORT_ALTEP) - player:messageSpecial(ID.text.ITEM_OBTAINED, xi.item.SCROLL_OF_TELEPORT_ALTEP) - player:addFame(xi.fameArea.SELBINA_RABAO, 30) - player:completeQuest(xi.questLog.OUTLANDS, xi.quest.id.outlands.THE_MISSING_PIECE) - end - end -end - -return entity diff --git a/scripts/zones/Quicksand_Caves/DefaultActions.lua b/scripts/zones/Quicksand_Caves/DefaultActions.lua index 1daab89ee77..083fe406800 100644 --- a/scripts/zones/Quicksand_Caves/DefaultActions.lua +++ b/scripts/zones/Quicksand_Caves/DefaultActions.lua @@ -5,6 +5,7 @@ return { ['qm2'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY }, ['qm3'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY }, ['qm4'] = { messageSpecial = ID.text.YOU_FIND_NOTHING_OUT }, + ['qm5'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY }, ['qm6'] = { messageSpecial = ID.text.ANCIENT_LETTERS_UNREAD }, ['qm7'] = { messageSpecial = ID.text.SOMETHING_IS_BURIED }, ['Fountain_of_Kings'] = { messageSpecial = ID.text.POOL_OF_WATER }, diff --git a/scripts/zones/Quicksand_Caves/npcs/qm5.lua b/scripts/zones/Quicksand_Caves/npcs/qm5.lua deleted file mode 100644 index 94d0d302a5d..00000000000 --- a/scripts/zones/Quicksand_Caves/npcs/qm5.lua +++ /dev/null @@ -1,52 +0,0 @@ ------------------------------------ --- Area: Quicksand Caves --- NPC: ??? (qm5) --- Involved in Quest: The Missing Piece --- positions: --- 1: !pos 770 0 -419 --- 2: !pos 657 0 -537 --- 3: !pos 749 0 -573 --- 4: !pos 451 -16 -739 --- 5: !pos 787 -16 -819 --- spawn in npc_list is 770 0 -419 ------------------------------------ -local ID = zones[xi.zone.QUICKSAND_CAVES] ------------------------------------ ----@type TNpcEntity -local entity = {} - -entity.onTrigger = function(player, npc) - local theMissingPiece = player:getQuestStatus(xi.questLog.OUTLANDS, xi.quest.id.outlands.THE_MISSING_PIECE) - local hasAncientFragment = player:hasKeyItem(xi.ki.ANCIENT_TABLET_FRAGMENT) - local hasAncientTablet = player:hasKeyItem(xi.ki.TABLET_OF_ANCIENT_MAGIC) - - -- Need to make sure the quest is flagged the player is no further along in the quest - if - theMissingPiece == xi.questStatus.QUEST_ACCEPTED and - not hasAncientTablet and - not hasAncientFragment and - player:getTitle() ~= xi.title.ACQUIRER_OF_ANCIENT_ARCANUM - then - npcUtil.giveKeyItem(player, xi.ki.ANCIENT_TABLET_FRAGMENT) - - -- move the ??? to a random location - local i = math.random(0, 100) - if i >= 0 and i < 20 then - npc:setPos(770, 0, -419, 0) - elseif i >= 20 and i < 40 then - npc:setPos(657, 0, -537, 0) - elseif i >= 40 and i < 60 then - npc:setPos(749, 0, -573, 0) - elseif i >= 60 and i < 80 then - npc:setPos(451, -16, -739, 0) - elseif i >= 80 and i <= 100 then - npc:setPos(787, -16, -819, 0) - else - npc:setPos(787, -16, -819, 0) - end - else - player:messageSpecial(ID.text.NOTHING_OUT_OF_ORDINARY) - end -end - -return entity diff --git a/scripts/zones/Rabao/IDs.lua b/scripts/zones/Rabao/IDs.lua index 859e4af49e9..e2419efbff8 100644 --- a/scripts/zones/Rabao/IDs.lua +++ b/scripts/zones/Rabao/IDs.lua @@ -25,6 +25,7 @@ zones[xi.zone.RABAO] = HUNT_RECORDED = 6907, -- You record your hunt. OBTAIN_SCYLDS = 6909, -- You obtain [scyld/scylds]! Current balance: [scyld/scylds]. HUNT_CANCELED = 6913, -- Hunt canceled. + ACCEPTED_KEYITEM = 10003, -- Accepted Key Items: and . PAKHI_DELIVERY_DIALOG = 10045, -- When your pack is fit to burrrst, send your non-essential items to your delivery box and bam, prrroblem solved! SPIRIT_DELIVERY_DIALOG = 10046, -- We can deliver goods to your residence or to the residences of your friends. SHINY_TEETH_SHOP_DIALOG = 10050, -- Well met, adventurer. If you're looking for a weapon to carve through those desert beasts, you've come to the right place. diff --git a/scripts/zones/Rabao/npcs/Alfesar.lua b/scripts/zones/Rabao/npcs/Alfesar.lua deleted file mode 100644 index 16e1b4aa846..00000000000 --- a/scripts/zones/Rabao/npcs/Alfesar.lua +++ /dev/null @@ -1,46 +0,0 @@ ------------------------------------ --- Area: Rabao --- NPC: Alfesar ---Starts The Missing Piece ------------------------------------ ----@type TNpcEntity -local entity = {} - -entity.onTrigger = function(player, npc) - local theMissingPiece = player:getQuestStatus(xi.questLog.OUTLANDS, xi.quest.id.outlands.THE_MISSING_PIECE) - local fame = player:getFameLevel(xi.fameArea.SELBINA_RABAO) - - if theMissingPiece == xi.questStatus.QUEST_AVAILABLE and fame >= 4 then -- start quest - player:startEvent(6) - elseif - theMissingPiece == xi.questStatus.QUEST_ACCEPTED and - not player:hasKeyItem(xi.ki.ANCIENT_TABLET_FRAGMENT) - then - -- talk to again with quest activated - player:startEvent(7) - elseif - theMissingPiece == xi.questStatus.QUEST_ACCEPTED and - player:hasKeyItem(xi.ki.ANCIENT_TABLET_FRAGMENT) - then - -- successfully retrieve key item - player:startEvent(8) - elseif - theMissingPiece == xi.questStatus.QUEST_ACCEPTED and - player:hasKeyItem(xi.ki.TABLET_OF_ANCIENT_MAGIC) - then - -- They got their Key items. tell them to goto sandy - player:startEvent(9) - end -end - -entity.onEventFinish = function(player, csid, option, npc) - if csid == 6 then - player:addQuest(xi.questLog.OUTLANDS, xi.quest.id.outlands.THE_MISSING_PIECE) - elseif csid == 8 then -- give the player the key items he needs to complete the quest - player:delKeyItem(xi.ki.ANCIENT_TABLET_FRAGMENT) - npcUtil.giveKeyItem(player, xi.ki.TABLET_OF_ANCIENT_MAGIC) - npcUtil.giveKeyItem(player, xi.ki.LETTER_FROM_ALFESAR) - end -end - -return entity diff --git a/sql/npc_list.sql b/sql/npc_list.sql index 8ecb4710525..4c1571e0bbb 100644 --- a/sql/npc_list.sql +++ b/sql/npc_list.sql @@ -24019,7 +24019,7 @@ INSERT INTO `npc_list` VALUES (17629732,'_5sp','',0,816.750,-8.312,-743.250,1,40 INSERT INTO `npc_list` VALUES (17629733,'qm4','???',64,-533.065,-0.851,-414.969,1,40,40,0,0,0,0,3,0x0000340000000000000000000000000000000000,0,NULL,0); INSERT INTO `npc_list` VALUES (17629734,'Zeid','Zeid',0,0.000,0.000,0.000,0,40,40,0,0,0,6,27,0x00003E0300000000000000000000000000000000,32,NULL,1); INSERT INTO `npc_list` VALUES (17629735,'Fountain_of_Kings','Fountain of Kings',249,571.283,20.000,-938.480,32769,40,40,0,0,0,0,3,0x0000340000000000000000000000000000000000,0,NULL,1); -INSERT INTO `npc_list` VALUES (17629736,'qm5','???',173,771.331,-0.996,-419.256,7,40,40,0,0,0,0,3,0x0000340000000000000000000000000000000000,0,NULL,0); +INSERT INTO `npc_list` VALUES (17629736,'qm5','???',173,771.331,-0.996,-419.256,7,40,40,0,0,8,0,3,0x0000660500000000000000000000000000000000,0,NULL,0); INSERT INTO `npc_list` VALUES (17629737,'blank','',0,0.000,0.000,0.000,1,50,50,0,0,0,2,2051,0x0000320000000000000000000000000000000000,0,NULL,1); INSERT INTO `npc_list` VALUES (17629738,'NPC[1d]','',0,0.000,0.000,0.000,0,50,50,0,0,0,2,3,0x0000320000000000000000000000000000000000,0,NULL,1); INSERT INTO `npc_list` VALUES (17629739,'Moogle','Moogle',0,0.000,0.000,0.000,0,40,40,0,0,0,2,4194307,0x0000520000000000000000000000000000000000,0,NULL,0);