diff --git a/scripts/globals/quests.lua b/scripts/globals/quests.lua index 001cf6a617a..1d419138a2f 100644 --- a/scripts/globals/quests.lua +++ b/scripts/globals/quests.lua @@ -69,7 +69,7 @@ xi.quest.id = UNEXPECTED_TREASURE = 70, BLACKMAIL = 71, -- + THE_SETTING_SUN = 72, -- + - DISTANT_LOYALTIES = 74, + DISTANT_LOYALTIES = 74, -- ± Converted THE_RIVALRY = 75, -- ± THE_COMPETITION = 76, -- ± STARTING_A_FLAME = 77, -- ± diff --git a/scripts/quests/sandoria/Distant_Loyalties.lua b/scripts/quests/sandoria/Distant_Loyalties.lua new file mode 100644 index 00000000000..aa693a87ac9 --- /dev/null +++ b/scripts/quests/sandoria/Distant_Loyalties.lua @@ -0,0 +1,172 @@ +----------------------------------- +-- Distant Loyalties +----------------------------------- +-- !addquest 0 74 +-- Southern San 'dOria !zone 230 +-- Femitte: !pos -17.7129 2.1000 10.1636 +-- Bastok Markets !zone 235 +-- Michea: !pos -299.2114 -15.9717 -156.0629 +-- Mythril Ingot !giveitem 653 +----------------------------------- + +local quest = Quest:new(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) + +quest.reward = +{ + fame = 30, + fameArea = xi.fameArea.SANDORIA, + item = xi.item.WHITE_CAPE, +} + +quest.sections = +{ + { + check = function(player, status, vars) + return status == xi.questStatus.QUEST_AVAILABLE and + player:getFameLevel(xi.fameArea.SANDORIA) >= 4 + end, + + [xi.zone.SOUTHERN_SAN_DORIA] = + { + ['Femitte'] = + { + onTrigger = function(player, npc) + return quest:progressEvent(663) + end, + }, + + onEventFinish = + { + [663] = function(player, csid, option, npc) + if option == 0 then + quest:begin(player) + npcUtil.giveKeyItem(player, xi.ki.GOLDSMITHING_ORDER) + quest:setVar(player, 'Prog', 1) + end + end, + }, + }, + }, + + { + check = function(player, status, vars) + return status == xi.questStatus.QUEST_ACCEPTED + end, + + [xi.zone.SOUTHERN_SAN_DORIA] = + { + ['Femitte'] = + { + onTrigger = function(player, npc) + local questProgress = quest:getVar(player, 'Prog') + if + questProgress == 4 and + player:hasKeyItem(xi.ki.MYTHRIL_HEARTS) + then + return quest:progressEvent(665) + end + end, + }, + + -- Dialogue will repeat until the quest is completed. + ['Rouva'] = quest:event(664), + + onEventFinish = + { + [665] = function(player, csid, option, npc) + if quest:complete(player) then + quest:setVar(player, 'finalCS', 1) + player:delKeyItem(xi.ki.MYTHRIL_HEARTS) + end + end, + }, + }, + + [xi.zone.BASTOK_MARKETS] = + { + ['Michea'] = + { + onTrade = function(player, npc, trade) + if + npcUtil.tradeHasExactly(trade, { { xi.item.MYTHRIL_INGOT, 1 } }) and + quest:getVar(player, 'Prog') == 2 + then + return quest:progressEvent(317) + end + end, + + onTrigger = function(player, npc) + local questProgress = quest:getVar(player, 'Prog') + + if + questProgress == 1 and + player:hasKeyItem(xi.ki.GOLDSMITHING_ORDER) + then + return quest:progressEvent(315) + elseif questProgress == 2 then + return quest:event(316) -- Will repeat until the player trades the Myrthil Ingot + elseif + questProgress == 3 and + player:needToZone() + then + return quest:event(320) -- Will repeat until the player zones + elseif + questProgress == 3 and + not player:needToZone() + then + return quest:progressEvent(318) + else + return -- Default action + end + end, + }, + + onEventFinish = + { + [315] = function(player, csid, option, npc) + player:delKeyItem(xi.ki.GOLDSMITHING_ORDER) + quest:setVar(player, 'Prog', 2) + end, + + [317] = function(player, csid, option, npc) + player:confirmTrade() + quest:setVar(player, 'Prog', 3) + player:needToZone(true) + end, + + [318] = function(player, csid, option, npc) + quest:setVar(player, 'Prog', 4) + npcUtil.giveKeyItem(player, xi.ki.MYTHRIL_HEARTS) + end, + }, + }, + }, + + { + check = function(player, status, vars) + return status == xi.questStatus.QUEST_COMPLETED + end, + + [xi.zone.BASTOK_MARKETS] = + { + ['Michea'] = + { + onTrigger = function(player, npc) + if quest:getVar(player, 'finalCS') == 1 then + return quest:progressEvent(319) + end + end, + }, + + onEventFinish = + { + [319] = function(player, csid, option, npc) + player:delKeyItem(xi.ki.GOLDSMITHING_ORDER) + quest:setVar(player, 'finalCS', 0) + end, + }, + }, + }, +} + +return quest diff --git a/scripts/zones/Bastok_Markets/npcs/Michea.lua b/scripts/zones/Bastok_Markets/npcs/Michea.lua index 2cb9cd1e391..d41bf2a41e2 100644 --- a/scripts/zones/Bastok_Markets/npcs/Michea.lua +++ b/scripts/zones/Bastok_Markets/npcs/Michea.lua @@ -9,59 +9,15 @@ local entity = {} entity.onTrade = function(player, npc, trade) - local distantLoyalties = player:getQuestStatus(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) - - -- DISTANT LOYALTIES - if - distantLoyalties == xi.questStatus.QUEST_ACCEPTED and - player:getCharVar('DistantLoyaltiesProgress') == 2 and - npcUtil.tradeHas(trade, xi.item.MYTHRIL_INGOT) - then - player:startEvent(317) - end end entity.onTrigger = function(player, npc) - local distantLoyalties = player:getQuestStatus(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) - local distantLoyaltiesProgress = player:getCharVar('DistantLoyaltiesProgress') - - -- DISTANT LOYALTIES - if - distantLoyalties == xi.questStatus.QUEST_ACCEPTED and - distantLoyaltiesProgress >= 1 and - distantLoyaltiesProgress <= 3 - then - if - distantLoyaltiesProgress == 1 and - player:hasKeyItem(xi.ki.GOLDSMITHING_ORDER) - then - player:startEvent(315) - elseif distantLoyaltiesProgress == 2 then - player:startEvent(316) - elseif distantLoyaltiesProgress == 3 and player:needToZone() then - player:startEvent(317) - elseif distantLoyaltiesProgress == 3 and not player:needToZone() then - player:startEvent(318) - end - end end entity.onEventUpdate = function(player, csid, option, npc) end entity.onEventFinish = function(player, csid, option, npc) - -- DISTANT LOYALTIES - if csid == 315 then - player:delKeyItem(xi.ki.GOLDSMITHING_ORDER) - player:setCharVar('DistantLoyaltiesProgress', 2) - elseif csid == 317 then - player:confirmTrade() - player:setCharVar('DistantLoyaltiesProgress', 3) - player:needToZone(true) - elseif csid == 318 then - player:setCharVar('DistantLoyaltiesProgress', 4) - npcUtil.giveKeyItem(player, xi.ki.MYTHRIL_HEARTS) - end end return entity diff --git a/scripts/zones/Southern_San_dOria/DefaultActions.lua b/scripts/zones/Southern_San_dOria/DefaultActions.lua index 6d561b22e52..e792ff5cebf 100644 --- a/scripts/zones/Southern_San_dOria/DefaultActions.lua +++ b/scripts/zones/Southern_San_dOria/DefaultActions.lua @@ -6,8 +6,10 @@ return { ['Balasiel'] = { event = 667 }, ['Baunise'] = { text = ID.text.NOTHING_TO_REPORT }, ['Cahaurme'] = { text = ID.text.NOTHING_TO_REPORT }, + ['Femitte'] = { event = 661 }, ['Hae_Jakhya'] = { event = 610 }, ['Rosel'] = { text = ID.text.ROSEL_GREETINGS }, + ['Rouva'] = { event = 662 }, ['Sobane'] = { text = ID.text.SOBANE_DIALOG }, ['Valderotaux'] = { event = 58 }, } diff --git a/scripts/zones/Southern_San_dOria/npcs/Femitte.lua b/scripts/zones/Southern_San_dOria/npcs/Femitte.lua index 24076241532..06516390eac 100644 --- a/scripts/zones/Southern_San_dOria/npcs/Femitte.lua +++ b/scripts/zones/Southern_San_dOria/npcs/Femitte.lua @@ -13,8 +13,6 @@ entity.onTrade = function(player, npc, trade) end entity.onTrigger = function(player, npc) - local distantLoyaltiesProgress = player:getCharVar('DistantLoyaltiesProgress') - local distantLoyalties = player:getQuestStatus(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) local wildcatSandy = player:getCharVar('WildcatSandy') if @@ -22,21 +20,8 @@ entity.onTrigger = function(player, npc) not utils.mask.getBit(wildcatSandy, 3) then player:startEvent(807) - elseif - player:getFameLevel(xi.fameArea.SANDORIA) >= 4 and - distantLoyalties == 0 - then - player:startEvent(663) - elseif distantLoyalties == 1 and distantLoyaltiesProgress == 1 then - player:startEvent(664) - elseif - distantLoyalties == 1 and - distantLoyaltiesProgress == 4 and - player:hasKeyItem(xi.ki.MYTHRIL_HEARTS) - then - player:startEvent(665) else - player:startEvent(661) + return end end @@ -46,21 +31,6 @@ end entity.onEventFinish = function(player, csid, option, npc) if csid == 807 then player:setCharVar('WildcatSandy', utils.mask.setBit(player:getCharVar('WildcatSandy'), 3, true)) - elseif csid == 663 and option == 0 then - player:addKeyItem(xi.ki.GOLDSMITHING_ORDER) - player:messageSpecial(ID.text.KEYITEM_OBTAINED, xi.ki.GOLDSMITHING_ORDER) - player:addQuest(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) - player:setCharVar('DistantLoyaltiesProgress', 1) - elseif csid == 665 then - if player:getFreeSlotsCount() == 0 then - player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED, xi.item.WHITE_CAPE) - else - player:delKeyItem(xi.ki.MYTHRIL_HEARTS) - player:addItem(xi.item.WHITE_CAPE, 1) - player:messageSpecial(ID.text.ITEM_OBTAINED, xi.item.WHITE_CAPE) - player:setCharVar('DistantLoyaltiesProgress', 0) - player:completeQuest(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) - end end end diff --git a/scripts/zones/Southern_San_dOria/npcs/Rouva.lua b/scripts/zones/Southern_San_dOria/npcs/Rouva.lua index e2139e3bd29..59dfb35fb7d 100644 --- a/scripts/zones/Southern_San_dOria/npcs/Rouva.lua +++ b/scripts/zones/Southern_San_dOria/npcs/Rouva.lua @@ -19,7 +19,7 @@ entity.onTrigger = function(player, npc) then player:startEvent(808) else - player:startEvent(664) + return end end