Skip to content

Commit

Permalink
[Quest] Convert Distant Loyalties to IF
Browse files Browse the repository at this point in the history
* Converted Distant Loyalties to IF
* Added Default Action for Rouva
* Added Default Action for Femitte
* Removed Quest code from Rouva, Michea, and Femitte NPC lua

Co-Authored-By: hooksta4 <13935086+hooksta4@users.noreply.github.com>
  • Loading branch information
slashtangent and hooksta4 committed Dec 11, 2024
1 parent 1bd4fc5 commit ab2afc8
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 77 deletions.
2 changes: 1 addition & 1 deletion scripts/globals/quests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, -- ±
Expand Down
172 changes: 172 additions & 0 deletions scripts/quests/sandoria/Distant_Loyalties.lua
Original file line number Diff line number Diff line change
@@ -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
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 @@ -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
2 changes: 2 additions & 0 deletions scripts/zones/Southern_San_dOria/DefaultActions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
}
32 changes: 1 addition & 31 deletions scripts/zones/Southern_San_dOria/npcs/Femitte.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,15 @@ 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)
return
end
end

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/zones/Southern_San_dOria/npcs/Rouva.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ entity.onTrigger = function(player, npc)
then
player:startEvent(808)
else
player:startEvent(664)
return
end
end

Expand Down

0 comments on commit ab2afc8

Please sign in to comment.