Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lls] Annotate mission scripts, correct issues identified #6225

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 23 additions & 3 deletions scripts/globals/interaction/mission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
-----------------------------------
require('scripts/globals/interaction/container')
-----------------------------------

---@see TInteractionContainer
---@class TMission : TInteractionContainer
---@field areaId integer
---@field missionId integer
Mission = setmetatable({ areaId = -1 }, { __index = Container })
Mission.__index = Mission

---@diagnostic disable-next-line: duplicate-set-field
Mission.__eq = function(m1, m2)
return m1.areaId == m2.areaId and m1.missionId == m2.missionId
end

---@type rewardParam
Mission.reward = {}

---@diagnostic disable-next-line: duplicate-set-field
---@type TMissionSection[]
Mission.sections = {}

---@nodiscard
---@param areaId integer
---@param missionId integer
---@return TMission
function Mission:new(areaId, missionId)
local obj = Container:new(Mission.getVarPrefix(areaId, missionId))
setmetatable(obj, self)
Expand All @@ -23,10 +32,17 @@ function Mission:new(areaId, missionId)
return obj
end

---@nodiscard
---@param areaId integer
---@param missionId integer
---@return string
function Mission.getVarPrefix(areaId, missionId)
return string.format('Mission[%d][%d]', areaId, missionId)
end

---@nodiscard
---@param player CBaseEntity
---@return table<integer>
function Mission:getCheckArgs(player)
return { player:getCurrentMission(self.areaId), player:getMissionStatus(self.areaId) }
end
Expand All @@ -35,10 +51,14 @@ end
-- Mission operations
-----------------------------------

---@param player CBaseEntity
---@return nil
function Mission:begin(player)
player:addMission(self.areaId, self.missionId)
end

---@param player CBaseEntity
---@return boolean
function Mission:complete(player)
local didComplete = npcUtil.completeMission(player, self.areaId, self.missionId, self.reward)
if didComplete then
Expand Down
6 changes: 4 additions & 2 deletions scripts/globals/interaction/quest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require('scripts/globals/interaction/container')
Quest = setmetatable({ areaId = 0 }, { __index = Container })
Quest.__index = Quest

---@diagnostic disable-next-line: duplicate-set-field
Quest.__eq = function(q1, q2)
return q1.areaId == q2.areaId and q1.questId == q2.questId
end
Expand All @@ -21,6 +20,7 @@ Quest.reward = {}
---@type TQuestSection[]
Quest.sections = {}

---@nodiscard
---@param areaId xi.questLog
---@param questId integer
---@return TQuest
Expand All @@ -32,15 +32,17 @@ function Quest:new(areaId, questId)
return obj
end

---@nodiscard
---@param areaId xi.questLog
---@param questId integer
---@return string
function Quest.getVarPrefix(areaId, questId)
return string.format('Quest[%d][%d]', areaId, questId)
end

---@nodiscard
---@param player CBaseEntity
---@return { [integer]: xi.questStatus }
---@return table<xi.questStatus>
function Quest:getCheckArgs(player)
return { player:getQuestStatus(self.areaId, self.questId) }
end
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/acp/01_A_Crystalline_Prophecy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- !addmission 9 0
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.ACP, xi.mission.id.acp.A_CRYSTALLINE_PROPHECY)

mission.reward =
Expand Down
21 changes: 12 additions & 9 deletions scripts/missions/amk/01_A_Moogle_Kupo_dEtat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-- !addmission 10 0
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.A_MOOGLE_KUPO_DETAT)

mission.reward =
Expand All @@ -14,16 +15,18 @@ mission.reward =
-- Since there are so many zones with interactions:
-- Populate each by hand
mission.sections = {}
mission.sections[1] = {} -- REMEMBER: Lua is 1-indexed!

mission.sections[1].check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId and
xi.settings.main.ENABLE_AMK == 1 and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getMainLvl() >= 10 and
player:getCharVar('HQuest[moghouseExpo]notSeen') == 0
end
mission.sections[1] = -- REMEMBER: Lua is 1-indexed!
{
check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId and
xi.settings.main.ENABLE_AMK == 1 and
xi.moghouse.isInMogHouseInHomeNation(player) and
player:getMainLvl() >= 10 and
player:getCharVar('HQuest[moghouseExpo]notSeen') == 0
end,
}

---@type ZoneSection
local moogleTriggerEvent =
{
-- TODO: Does there need to be onZoneIn here?
Expand Down
15 changes: 9 additions & 6 deletions scripts/missions/amk/02_Drenched_It_Began_with_a_Raindrop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-- YAGUDO_CAULK : !additem 2759
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.DRENCHED_IT_BEGAN_WITH_A_RAINDROP)

mission.reward =
Expand All @@ -17,13 +18,15 @@ mission.reward =
-- Since there are so many zones with interactions:
-- Populate each by hand
mission.sections = {}
mission.sections[1] = {} -- REMEMBER: Lua is 1-indexed!

mission.sections[1].check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId and
xi.moghouse.isInMogHouseInHomeNation(player)
end
mission.sections[1] = -- REMEMBER: Lua is 1-indexed!
{
check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId and
xi.moghouse.isInMogHouseInHomeNation(player)
end,
}

---@type ZoneSection
local moogleTriggerEvent =
{
['Moogle'] =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/amk/03_Hasten_In_a_Jam_in_Jeuno.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- Inconspicuous Door : !pos -15 1.300 68 244
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.HASTEN_IN_A_JAM_IN_JEUNO)

mission.reward =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-- Like in: scripts\quests\adoulin\Flavors_of_Our_Lives.lua
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.WELCOME_TO_MY_DECREPIT_DOMICILE)

mission.reward =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- Shantotto : !pos 122 -2 112 239
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.CURSES_A_HORRIFICALLY_HARROWING_HEX)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/amk/06_An_Errand_The_Professors_Price.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
local horutotoID = zones[xi.zone.OUTER_HORUTOTO_RUINS]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.AN_ERRAND_THE_PROFESSORS_PRICE)

mission.reward =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-- MOLDY_WORM_EATEN_CHEST : !addkeyitem 1144
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.SHOCK_ARRANT_ABUSE_OF_AUTHORITY)

mission.reward =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-- Inconspicuous Door : !pos -15 1.300 68 244
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.LENDER_BEWARE_READ_THE_FINE_PRINT)

mission.reward =
Expand Down
6 changes: 4 additions & 2 deletions scripts/missions/amk/09_Rescue_A_Moogles_Labor_of_Love.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
local ID = zones[xi.zone.QUICKSAND_CAVES]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.RESCUE_A_MOOGLES_LABOR_OF_LOVE)

mission.reward =
Expand Down Expand Up @@ -121,15 +122,16 @@ mission.sections =
end

-- Determine if QM triggered is in markerset
local keyItem = 0
---@type xi.keyItem
local keyItem
for idx, markerIdIndex in ipairs(markerSets[amkMarkerSet]) do
if npc:getID() == ID.npc.QM_AMK[markerIdIndex] then
keyItem = xi.ki.STONE_OF_SURYA + idx - 1
end
end

-- Give KI if QM is correct
if keyItem ~= 0 and not player:hasKeyItem(keyItem) then
if keyItem and not player:hasKeyItem(keyItem) then
player:addKeyItem(keyItem)
return mission:messageSpecial(ID.text.KEYITEM_OBTAINED, keyItem)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-- !addmission 10 9
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.ROAR_A_CAT_BURGLAR_BARES_HER_FANGS)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/amk/11_Relief_A_Triumphant_Return.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- Inconspicuous Door : !pos -15 1.300 68 244
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.RELIEF_A_TRIUMPHANT_RETURN)

mission.reward =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-- !addmission 10 11
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.JOY_SUMMONED_TO_A_FABULOUS_FETE)

mission.reward =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
-- Craggy Pillar 4 : !pos -236 -52 103 162
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.A_CHALLENGE_YOU_COULD_BE_A_WINNER)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/amk/14_Smash_A_Malevolent_Menace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-- !addmission 10 13
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.AMK, xi.mission.id.amk.SMASH_A_MALEVOLENT_MENACE)

mission.reward =
Expand Down
4 changes: 3 additions & 1 deletion scripts/missions/asa/01_A_Shantotto_Ascension.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- !addmission 11 0
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.ASA, xi.mission.id.asa.A_SHANTOTTO_ASCENSION)

mission.reward =
Expand Down Expand Up @@ -35,7 +36,8 @@ mission.sections =
onEventFinish =
{
[510] = function(player, csid, option, npc)
return mission:event(514)
-- TODO: This is most likely a pos change, followed by onZoneIn event
player:startEvent(514)
end,

[514] = function(player, csid, option, npc)
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/asa/02_Burgeoning_Dread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- !addmission 11 1
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.ASA, xi.mission.id.asa.BURGEONING_DREAD)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/asa/03_That_Which_Curdles_Blood.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
-- Trodden Snow : !pos -19.7 -17.3 104.4 126
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.ASA, xi.mission.id.asa.THAT_WHICH_CURDLES_BLOOD)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/asa/04_Sugar-Coated_Directive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local tidesID = zones[xi.zone.CLOISTER_OF_TIDES]
local tremorsID = zones[xi.zone.CLOISTER_OF_TREMORS]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.ASA, xi.mission.id.asa.SUGAR_COATED_DIRECTIVE)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/asa/05_Enemy_Of_The_Empire_I.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
local norgID = zones[xi.zone.NORG]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.ASA, xi.mission.id.asa.ENEMY_OF_THE_EMPIRE_I)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/bastok/1_1_The_Zeruhn_Report.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local portBastokID = zones[xi.zone.PORT_BASTOK]
local zeruhnID = zones[xi.zone.ZERUHN_MINES]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.BASTOK, xi.mission.id.bastok.THE_ZERUHN_REPORT)

local handleAcceptMission = function(player, csid, option, npc)
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/bastok/1_2_A_Geological_Survey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local metalworksID = zones[xi.zone.METALWORKS]
local portBastokID = zones[xi.zone.PORT_BASTOK]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.BASTOK, xi.mission.id.bastok.GEOLOGICAL_SURVEY)

local handleAcceptMission = function(player, csid, option, npc)
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/bastok/1_3_Fetichism.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local metalworksID = zones[xi.zone.METALWORKS]
local portBastokID = zones[xi.zone.PORT_BASTOK]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.BASTOK, xi.mission.id.bastok.FETICHISM)

-- npcUtil.completeMission will only award rank if less than player's current rank in
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/bastok/2_1_The_Crystal_Line.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local metalworksID = zones[xi.zone.METALWORKS]
local portBastokID = zones[xi.zone.PORT_BASTOK]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.BASTOK, xi.mission.id.bastok.THE_CRYSTAL_LINE)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/bastok/2_2_Wading_Beasts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local metalworksID = zones[xi.zone.METALWORKS]
local portBastokID = zones[xi.zone.PORT_BASTOK]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.BASTOK, xi.mission.id.bastok.WADING_BEASTS)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/bastok/2_3_0_The_Emissary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local metalworksID = zones[xi.zone.METALWORKS]
local portBastokID = zones[xi.zone.PORT_BASTOK]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.BASTOK, xi.mission.id.bastok.THE_EMISSARY)

mission.reward =
Expand Down
1 change: 1 addition & 0 deletions scripts/missions/bastok/2_3_1_The_Emissary_Sandoria.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local chateauID = zones[xi.zone.CHATEAU_DORAGUILLE]
local northernSandoriaID = zones[xi.zone.NORTHERN_SAN_DORIA]
-----------------------------------

---@type TMission
local mission = Mission:new(xi.mission.log_id.BASTOK, xi.mission.id.bastok.THE_EMISSARY_SANDORIA)

mission.reward = {}
Expand Down
Loading
Loading