Skip to content

Commit

Permalink
[Quest]Distant Loyalties and associated quests
Browse files Browse the repository at this point in the history
[Quest]Distant Loyalties and associated quests
  • Loading branch information
hooksta4 committed May 8, 2024
1 parent 2309bb1 commit e1f5fbe
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 83 deletions.
4 changes: 3 additions & 1 deletion scripts/quests/bastok/Father_Figure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ quest.sections =
check = function(player, status, vars)
return status == xi.questStatus.QUEST_AVAILABLE and
player:hasCompletedQuest(xi.questLog.BASTOK, xi.quest.id.bastok.THE_ELVAAN_GOLDSMITH) and
player:getFameLevel(xi.fameArea.BASTOK) >= 2
player:getFameLevel(xi.fameArea.BASTOK) >= 2 and
player:getQuestStatus(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) ~= xi.questStatus.QUEST_ACCEPTED
-- quest is blocked if Distant Loyalties is active.
end,

[xi.zone.BASTOK_MARKETS] =
Expand Down
7 changes: 5 additions & 2 deletions scripts/quests/bastok/The_Elvaan_Goldsmith.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ quest.sections =
{
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_AVAILABLE
return status == xi.questStatus.QUEST_AVAILABLE and
player:getQuestStatus(xi.questLog.SANDORIA, xi.quest.id.sandoria.DISTANT_LOYALTIES) ~= xi.questStatus.QUEST_ACCEPTED
--quest is blocked if Distant Loyalties is started
end,

[xi.zone.BASTOK_MARKETS] =
Expand All @@ -40,7 +42,8 @@ quest.sections =
(
status == xi.questStatus.QUEST_COMPLETED and
player:getFameLevel(xi.fameArea.BASTOK) == 1 and
not quest:getMustZone(player)
not quest:getMustZone(player) or
player:hasCompletedQuest(xi.questLog.BASTOK, xi.quest.id.bastok.THE_RETURN_OF_THE_ADVENTURER) -- allows repeat only after this quest is completed.
)
end,

Expand Down
161 changes: 161 additions & 0 deletions scripts/quests/sandoria/Distant_Loyalties.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
-----------------------------------
-- Distant Loyalties
-----------------------------------
-- !addquest 0 74
-- Femitte: !gotoid 17719491
-- Michea: !gotoid 17739820
-----------------------------------

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'] = quest:progressEvent(663),

onEventFinish =
{
[663] = function(player, csid, option, npc)
if option == 0 then
quest:begin(player)
npcUtil.giveKeyItem(player, xi.ki.GOLDSMITHING_ORDER)
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 player:hasKeyItem(xi.ki.GOLDSMITHING_ORDER) then
return quest:event(661)
elseif
questProgress == 3 and
player:hasKeyItem(xi.ki.MYTHRIL_HEARTS)
then
return quest:progressEvent(665)
end
end,
},
['Rouva'] =
{
onTrigger = function(player, npc)
if player:hasKeyItem(xi.ki.GOLDSMITHING_ORDER) then
return quest:event(664)
end
end,
},

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) and
quest:getVar(player, 'Prog') == 1
then
return quest:progressEvent(317)
end
end,

onTrigger = function(player, npc)
local questProgress = quest:getVar(player, 'Prog')

if player:hasKeyItem(xi.ki.GOLDSMITHING_ORDER) then
return quest:progressEvent(315)
elseif questProgress == 1 then
return quest:event(316)
elseif
questProgress == 2 and
not player:needToZone()
then
return quest:progressEvent(318)
end
end,
},

onEventFinish =
{
[315] = function(player, csid, option, npc)
player:delKeyItem(xi.ki.GOLDSMITHING_ORDER)
quest:setVar(player, 'Prog', 1)
end,

[317] = function(player, csid, option, npc)
player:confirmTrade()
quest:setVar(player, 'Prog', 2)
player:needToZone(true)
end,

[318] = function(player, csid, option, npc)
quest:setVar(player, 'Prog', 3)
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
44 changes: 0 additions & 44 deletions scripts/zones/Bastok_Markets/npcs/Michea.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,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
1 change: 1 addition & 0 deletions scripts/zones/Southern_San_dOria/DefaultActions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ return {
['Cahaurme'] = { text = ID.text.NOTHING_TO_REPORT },
['Hae_Jakhya'] = { event = 610 },
['Rosel'] = { text = ID.text.ROSEL_GREETINGS },
['HRouva'] = { event = 662 },
['Sobane'] = { text = ID.text.SOBANE_DIALOG },
['Valderotaux'] = { event = 58 },
}
34 changes: 0 additions & 34 deletions scripts/zones/Southern_San_dOria/npcs/Femitte.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,19 @@
-- Involved in Quest: Lure of the Wildcat (San d'Oria), Distant Loyalties
-- !pos -17 2 10 230
-----------------------------------
local ID = zones[xi.zone.SOUTHERN_SAN_DORIA]
-----------------------------------
local entity = {}

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
player:getQuestStatus(xi.questLog.SANDORIA, xi.quest.id.sandoria.LURE_OF_THE_WILDCAT) == xi.questStatus.QUEST_ACCEPTED and
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)
end
end

Expand All @@ -45,21 +26,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

Expand Down
2 changes: 0 additions & 2 deletions scripts/zones/Southern_San_dOria/npcs/Rouva.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ entity.onTrigger = function(player, npc)
not utils.mask.getBit(wildcatSandy, 2)
then
player:startEvent(808)
else
player:startEvent(664)
end
end

Expand Down

0 comments on commit e1f5fbe

Please sign in to comment.