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
  • Loading branch information
claywar committed Sep 2, 2024
1 parent 8ee48ac commit e13e814
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 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
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/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
11 changes: 5 additions & 6 deletions scripts/specs/types/Quest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
---@meta

-- Definitions for quest.sections{}
---@class TQuestSectionList : TQuestZoneSection[]
---@alias TQuestSectionList TQuestSection[]

---@class TQuestSection
---@class TQuestSection : { [xi.zone] : TQuestZoneSection }
---@field check fun(player: CBaseEntity, status: { [integer]: xi.questStatus }, vars: { [string]: integer }): boolean
---@field [xi.zone] TQuestZoneSection

-- TODO: Below here, we can most likely be generic and reuse these definitions for Hidden Quests, Missions,
-- and perhaps Battlefields as well
---@class TQuestZoneSection
---@field onZoneIn? TQuestOnZoneIn
---@field onZoneOut? TQuestOnZoneFunction
---@field afterZoneIn? TQuestOnZoneFunction
---@field [string]? TQuestZoneEntity
---@field [string]? TQuestZoneEntity|QuestReturnType
---@field onEventUpdate? TQuestEventSection
---@field onEventFinish? TQuestEventSection
---@field onTriggerAreaEnter? TQuestTriggerAreaSection
Expand All @@ -33,10 +32,10 @@

---@class TQuestZoneEntity
---@field onTrade? fun(player: CBaseEntity, npc: CBaseEntity, trade: CTradeContainer): QuestReturnType
---@field onTrigger? fun(player: CBaseEntity, npc: CBaseEntity): QuestReturnType
---@field onTrigger? QuestReturnType|fun(player: CBaseEntity, npc: CBaseEntity): QuestReturnType
---@field onMobDeath? fun(mob: CBaseEntity, player: CBaseEntity, optParams: { isKiller: boolean, noKiller: boolean, isWeaponSkillKill: boolean, weaponskillUsed: xi.weaponskill, weaponskillDamage: integer })

---@class TQuestEventSection
---@field [integer] fun(player: CBaseEntity, csid: integer, option: integer, npc: CBaseEntity)

---@alias QuestReturnType TInteractionEvent|TInteractionKeyItem|TInteractionMessage|TInteractionSequence|TInteractionNoAction?
---@alias QuestReturnType TInteractionEvent|TInteractionKeyItem|TInteractionMessage|TInteractionSequence|TInteractionAction|TInteractionNoAction?

0 comments on commit e13e814

Please sign in to comment.