Skip to content

Commit

Permalink
Fix issues identified from TQuest definition
Browse files Browse the repository at this point in the history
Fix Quest definitions to properly represent heirarchy

f

Add additional definition types, fixes

Make onTrigger function def return optional
  • Loading branch information
claywar committed Sep 2, 2024
1 parent 8ee48ac commit 788188a
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 89 deletions.
12 changes: 6 additions & 6 deletions scripts/quests/ahtUrhgan/Olduum.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ local keyItems =
xi.ki.ELECTROLOCOMOTIVE,
}

quest.hasKeyItem = function(player)
for i, v in pairs(keyItems) do
local hasQuestKeyItem = function(player)
for _, v in pairs(keyItems) do
if player:hasKeyItem(v) then
return true
end
Expand Down Expand Up @@ -68,7 +68,7 @@ quest.sections =
['Dkhaaya'] =
{
onTrigger = function(player, npc)
if quest.hasKeyItem(player) then
if hasQuestKeyItem(player) then
return quest:progressEvent(6)
else
return quest:event(5)
Expand All @@ -94,7 +94,7 @@ quest.sections =
onTrade = function(player, npc, trade)
if
not player:hasItem(xi.item.OLDUUM_RING) and
not quest.hasKeyItem(player) and
not hasQuestKeyItem(player) and
npcUtil.tradeHasExactly(trade, xi.item.PICKAXE)
then
if math.random(1, 10) > 5 then
Expand Down Expand Up @@ -135,7 +135,7 @@ quest.sections =
['Dkhaaya'] =
{
onTrigger = function(player, npc)
if quest.hasKeyItem(player) then
if hasQuestKeyItem(player) then
return quest:progressEvent(8)
elseif
player:hasItem(xi.item.OLDUUM_RING) or
Expand Down Expand Up @@ -202,7 +202,7 @@ quest.sections =
onTrade = function(player, npc, trade)
if
not player:hasItem(xi.item.OLDUUM_RING) and
not quest.hasKeyItem(player) and
not hasQuestKeyItem(player) and
npcUtil.tradeHasExactly(trade, xi.item.PICKAXE)
then
if math.random(1, 10) > 5 then
Expand Down
5 changes: 3 additions & 2 deletions scripts/quests/ahtUrhgan/Three_Men_and_a_Closet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ quest.sections =
-- Section: Begin quest
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_AVAILABLE and player:getQuestStatus(xi.questLog.AHT_URHGAN, xi.quest.id.ahtUrhgan.GOT_IT_ALL) == xi.questStatus.QUEST_COMPLETED
return status == xi.questStatus.QUEST_AVAILABLE and
player:getQuestStatus(xi.questLog.AHT_URHGAN, xi.quest.id.ahtUrhgan.GOT_IT_ALL) == xi.questStatus.QUEST_COMPLETED
end,

[xi.zone.AHT_URHGAN_WHITEGATE] =
{
['Kubhe_Ijyuhla'] =
{
onTrigger = function(player, npc)
return quest:progressEvent(player, 836)
return quest:progressEvent(836)
end
},

Expand Down
2 changes: 1 addition & 1 deletion scripts/quests/bastok/A_Question_of_Faith.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ quest.sections =
{
[6] = function(player, csid, option, npc)
player:delKeyItem(xi.ki.DAWN_TALISMAN)
return quest:messageSpecial(ID.text.WAS_TAKEN_FROM_YOU, 0, xi.ki.DAWN_TALISMAN)
player:messageSpecial(ID.text.WAS_TAKEN_FROM_YOU, 0, xi.ki.DAWN_TALISMAN)
end,
},
},
Expand Down
3 changes: 3 additions & 0 deletions scripts/quests/bastok/Lure_of_the_Wildcat_Bastok.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ local wildcatNpcData =
['Vaghron'] = { 19, 503 }, -- !pos -39.162 -1 -92.147 234
}

---@param player CBaseEntity
---@param npc CBaseEntity
---@return QuestReturnType?
local wildcatOnTrigger = function(player, npc)
local npcData = wildcatNpcData[npc:getName()]

Expand Down
17 changes: 10 additions & 7 deletions scripts/quests/bastok/Teak_Me_to_the_Stars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ quest.sections =

[xi.zone.METALWORKS] =
{
onTrigger = function(player, npc)
local option = 0
if player:hasCompletedMission(xi.mission.id.cop.THE_CALL_OF_THE_WYRMKING) then
option = 2 -- additional dialogue regarding Crystal propulsion unit and hooded scientists as mentioned in cop wyrmking mission
end
['Raibaht'] =
{
onTrigger = function(player, npc)
local option = 0
if player:hasCompletedMission(xi.mission.log_id.COP, xi.mission.id.cop.THE_CALL_OF_THE_WYRMKING) then
option = 2 -- additional dialogue regarding Crystal propulsion unit and hooded scientists as mentioned in cop wyrmking mission
end

return quest:progressEvent(864, 0, xi.item.GARHADA_TEAK_LUMBER, 0, 0, 0, 0, option)
end,
return quest:progressEvent(864, 0, xi.item.GARHADA_TEAK_LUMBER, 0, 0, 0, 0, option)
end,
},

onEventFinish =
{
Expand Down
4 changes: 4 additions & 0 deletions scripts/quests/crystalWar/The_Price_of_Valor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ quest.sections =
elseif questProgress == 5 then
if quest:getLocalVar(player, 'nmDefeated') == 0 then
local zoneObj = player:getZone()
if not zoneObj then
return
end

local mobObj = zoneObj:queryEntitiesByName('Madthrasher_Zradbodd')[1]

if not mobObj:isSpawned() then
Expand Down
4 changes: 3 additions & 1 deletion scripts/quests/jeuno/Chocobos_Wounds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ quest.sections =
quest:setVar(player, 'Timer', os.time() + 45)
quest:setVar(player, 'Prog', 4)

return quest:event(99)
-- TODO: This needs retail verification to confirm no zoning
-- event has occurred
player:startEvent(99)
end,

[60] = function(player, csid, option, npc)
Expand Down
6 changes: 4 additions & 2 deletions scripts/quests/otherAreas/A_Hard_Days_Knight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@ quest.sections =
{
[631] = function(player, csid, option, npc)
if quest:getVar(player, 'Prog') == 2 then
return quest:progressEvent(632)
-- TODO: This is most likely not retail accurate, and need to check captures
-- for forced zoning events.
player:startEvent(632)
end
end,

[632] = function(player, csid, option, npc)
player:confirmTrade()
quest:setVar(player, 'Prog', 0)
return quest:keyItem(xi.ki.TEMPLE_KNIGHT_KEY)
npcUtil.giveKeyItem(player, xi.ki.TEMPLE_KNIGHT_KEY)
end
},
},
Expand Down
38 changes: 22 additions & 16 deletions scripts/quests/otherAreas/Give_a_Moogle_a_Break.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ quest.reward =
-- Since there are so many zones with interactions:
quest.sections = {}

quest.sections[1] = {}
quest.sections[1].check = function(player, status, vars)
local bedPlacedTime = quest:getVar(player, 'bedPlacedTime')

return status == xi.questStatus.QUEST_AVAILABLE and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getFameLevel(player:getNation()) >= 3 and
not quest:getMustZone(player) and
quest:getLocalVar(player, 'questSeen') == 0 and
bedPlacedTime ~= 0 and
os.time() > bedPlacedTime + 60
end
quest.sections[1] =
{
check = function(player, status, vars)
local bedPlacedTime = quest:getVar(player, 'bedPlacedTime')

return status == xi.questStatus.QUEST_AVAILABLE and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getFameLevel(player:getNation()) >= 3 and
not quest:getMustZone(player) and
quest:getLocalVar(player, 'questSeen') == 0 and
bedPlacedTime ~= 0 and
os.time() > bedPlacedTime + 60
end
}

---@type TQuestZoneSection
local questAvailable =
{
['Moogle'] =
Expand All @@ -50,11 +53,14 @@ local questAvailable =
},
}

quest.sections[2] = {}
quest.sections[2].check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end
quest.sections[2] =
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end
}

---@type TQuestZoneSection
local questAccepted =
{
['Moogle'] =
Expand Down
10 changes: 5 additions & 5 deletions scripts/quests/otherAreas/Knocking_on_Forbidden_Doors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ quest.sections =
{
['Chemioue'] =
{
onTrigger = function(player, csid, option, npc)
onTrigger = function(player, npc)
if quest:getVar(player, 'Prog') == 0 then
return quest:progressEvent(536)
end
Expand Down Expand Up @@ -141,13 +141,13 @@ quest.sections =
quest:getVar(player, 'Prog') == 3 and
npcUtil.popFromQM(player, npc, misareauxID.mob.ALSHA, { claim = true, hide = 0 })
then
return quest:messageSpecial(misareauxID.text.FOUL_STENCH)
player:messageSpecial(misareauxID.text.FOUL_STENCH)
end
end,

[558] = function(player, csid, option, npc)
quest:setVar(player, 'Prog', 5)
return quest:keyItem(xi.ki.BETTER_HUMES_AND_MANNEQUINS)
npcUtil.giveKeyItem(player, xi.ki.BETTER_HUMES_AND_MANNEQUINS)
end,
},
},
Expand All @@ -156,7 +156,7 @@ quest.sections =
{
['Fyi_Chalmwoh'] =
{
onTrigger = function(player, csid, option, npc)
onTrigger = function(player, npc)
if quest:getVar(player, 'Prog') == 5 then
return quest:progressEvent(321, { [0] = 704,
[1] = xi.mannequin.getMannequins(player),
Expand Down Expand Up @@ -189,7 +189,7 @@ quest.sections =
{
['Fyi_Chalmwoh'] =
{
onTrigger = function(player, csid, option, npc)
onTrigger = function(player, npc)
return quest:progressEvent(321, { [1] = xi.mannequin.getMannequins(player),
[2] = xi.mannequin.cost.PURCHASE,
[3] = xi.mannequin.cost.TRADE,
Expand Down
40 changes: 23 additions & 17 deletions scripts/quests/otherAreas/Moogles_in_the_Wild.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ quest.reward =
-- Since there are so many zones with interactions:
quest.sections = {}

quest.sections[1] = {}
quest.sections[1].check = function(player, status, vars)
local bedPlacedTime = quest:getVar(player, 'bedPlacedTime')

return status == xi.questStatus.QUEST_AVAILABLE and
player:hasCompletedQuest(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.THE_MOOGLE_PICNIC) and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getFameLevel(player:getNation()) >= 7 and
not quest:getMustZone(player) and
quest:getLocalVar(player, 'questSeen') == 0 and
bedPlacedTime ~= 0 and
os.time() > bedPlacedTime + 60
end
quest.sections[1] =
{
check = function(player, status, vars)
local bedPlacedTime = quest:getVar(player, 'bedPlacedTime')

return status == xi.questStatus.QUEST_AVAILABLE and
player:hasCompletedQuest(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.THE_MOOGLE_PICNIC) and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getFameLevel(player:getNation()) >= 7 and
not quest:getMustZone(player) and
quest:getLocalVar(player, 'questSeen') == 0 and
bedPlacedTime ~= 0 and
os.time() > bedPlacedTime + 60
end
}

---@type TQuestZoneSection
local questAvailable =
{
['Moogle'] =
Expand All @@ -51,11 +54,14 @@ local questAvailable =
},
}

quest.sections[2] = {}
quest.sections[2].check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end
quest.sections[2] =
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end
}

---@type TQuestZoneSection
local questAccepted =
{
['Moogle'] =
Expand Down
2 changes: 1 addition & 1 deletion scripts/quests/otherAreas/RQ4_His_Name_is_Valgeir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ quest.sections =
if
player:hasKeyItem(xi.ki.ARAGONEU_PIZZA) and -- No free ride after delivering Pizza.
player:getZPos() > 38.5 and -- Pos check.
quest:setVar(player, 'Prog') == 0 -- Hasn't taken the free ride.
quest:getVar(player, 'Prog') == 0 -- Hasn't taken the free ride.
then
return quest:progressEvent(230) -- Free ride. 1 time only. Non-Mandatory step.
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/quests/otherAreas/Test_My_Mettle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ quest.sections =
quest:setVar(player, 'Reward', betAmount * rewardMultiplier[vanaHoursRemaining])
quest:begin(player)
else
return quest:messageSpecial(selbinaID.text.DONT_HAVE_ENOUGH_GIL)
player:messageSpecial(selbinaID.text.DONT_HAVE_ENOUGH_GIL)
end
end
end,
Expand Down
40 changes: 23 additions & 17 deletions scripts/quests/otherAreas/The_Moogles_Picnic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ quest.reward =
-- Since there are so many zones with interactions:
quest.sections = {}

quest.sections[1] = {}
quest.sections[1].check = function(player, status, vars)
local bedPlacedTime = quest:getVar(player, 'bedPlacedTime')

return status == xi.questStatus.QUEST_AVAILABLE and
player:hasCompletedQuest(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.GIVE_A_MOOGLE_A_BREAK) and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getFameLevel(player:getNation()) >= 5 and
not quest:getMustZone(player) and
quest:getLocalVar(player, 'questSeen') == 0 and
bedPlacedTime ~= 0 and
os.time() > bedPlacedTime + 60
end
quest.sections[1] =
{
check = function(player, status, vars)
local bedPlacedTime = quest:getVar(player, 'bedPlacedTime')

return status == xi.questStatus.QUEST_AVAILABLE and
player:hasCompletedQuest(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.GIVE_A_MOOGLE_A_BREAK) and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getFameLevel(player:getNation()) >= 5 and
not quest:getMustZone(player) and
quest:getLocalVar(player, 'questSeen') == 0 and
bedPlacedTime ~= 0 and
os.time() > bedPlacedTime + 60
end
}

---@type TQuestZoneSection
local questAvailable =
{
['Moogle'] =
Expand All @@ -51,11 +54,14 @@ local questAvailable =
},
}

quest.sections[2] = {}
quest.sections[2].check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end
quest.sections[2] =
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end
}

---@type TQuestZoneSection
local questAccepted =
{
['Moogle'] =
Expand Down
2 changes: 1 addition & 1 deletion scripts/quests/sandoria/The_Pickpocket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ quest.sections =
{
['Esca'] =
{
onTrigger = function(player, npc, trade)
onTrigger = function(player, npc)
if player:hasItem(xi.item.GILT_GLASSES) then
return quest:event(123)
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/quests/windurst/Overnight_Delivery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ quest.sections =
[346] = function(player, csid, option, npc)
player:delQuest(quest.areaId, quest.questId)
player:delKeyItem(xi.ki.SMALL_BAG)
quest:setVar('dueDate', 0)
quest:setVar(player, 'dueDate', 0)
quest:setVar(player, 'Prog', 256)
end,

Expand Down
Loading

0 comments on commit 788188a

Please sign in to comment.