Skip to content

Commit

Permalink
finalize bequeather reset logic and translations
Browse files Browse the repository at this point in the history
  • Loading branch information
g4m3r7ag committed Feb 12, 2022
1 parent f3c68ec commit 0a1bb0f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 53 deletions.
13 changes: 1 addition & 12 deletions PolloxsDailyQuestTracker/DailyQuestTracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,20 +472,9 @@ end
function Main.OnAddOnLoaded(event, addonName)
-- The event fires each time *any* addon loads - but we only care about when our own addon loads
if addonName == Main.name then

EVENT_MANAGER:UnregisterForEvent(Main.name, EVENT_ADD_ON_LOADED)

SecurePostHook(INTERACTION, "UpdateShadowyConnectionsOnTimeComplete", function()
local timeRemaining = GetTimeToShadowyConnectionsResetInSeconds()
if timeRemaining <= 0 then
d("UpdateShadowyConnectionsOnTimeComplete")
end
end)
SecurePostHook(INTERACTION, "UpdateShadowyConnectionsChatterOption", function()
local timeRemaining = GetTimeToShadowyConnectionsResetInSeconds()
if timeRemaining <= 0 then
d("UpdateShadowyConnectionsChatterOption")
end
end)

EVENT_MANAGER:RegisterForEvent(Main.name, EVENT_QUEST_ADDED, Main.onQuestAdded)
EVENT_MANAGER:RegisterForEvent(Main.name, EVENT_QUEST_COMPLETE, Main.onQuestComplete)
Expand Down
1 change: 1 addition & 0 deletions PolloxsDailyQuestTracker/lang/de.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ L.SI_DQT_OTHER_TIMERS = "Other Timers"
L.SI_DQT_RANDOM_DUNGEON = "Random Dungeon"
L.SI_DQT_RANDOM_BATTLEGROUNDS = "Random Battlegrounds"
L.SI_DQT_MOUNT_TRAINING = "Mount Training"
L.SI_DQT_BEQUEATHER = "verhüllter Versorger"
L.SI_DQT_ELSWEYR_PROLOGUE = "Elsweyr Prologue"
L.SI_DQT_ELSWEYR = "Elsweyr"
L.SI_DQT_DRAGONHOLD = "Dragonhold" -- Added by DarkPhalanx
Expand Down
1 change: 1 addition & 0 deletions PolloxsDailyQuestTracker/lang/fr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ L.SI_DQT_OTHER_TIMERS = "Other Timers"
L.SI_DQT_RANDOM_DUNGEON = "Random Dungeon"
L.SI_DQT_RANDOM_BATTLEGROUNDS = "Random Battlegrounds"
L.SI_DQT_MOUNT_TRAINING = "Mount Training"
L.SI_DQT_BEQUEATHER = "Fournisseur des ombres"
L.SI_DQT_ELSWEYR_PROLOGUE = "Elsweyr Prologue"
L.SI_DQT_ELSWEYR = "Elsweyr"
L.SI_DQT_DRAGONHOLD = "Dragonhold" -- Added by DarkPhalanx
Expand Down
1 change: 1 addition & 0 deletions PolloxsDailyQuestTracker/lang/jp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ L.SI_DQT_OTHER_TIMERS = "その他の時間"
L.SI_DQT_RANDOM_DUNGEON = "ランダム ダンジョン"
L.SI_DQT_RANDOM_BATTLEGROUNDS = "ランダム バトルグラウンド"
L.SI_DQT_MOUNT_TRAINING = "マウント トレーニング"
L.SI_DQT_BEQUEATHER = "Shadowy Supplier"
L.SI_DQT_ELSWEYR_PROLOGUE = "Elsweyr Prologue"
L.SI_DQT_ELSWEYR = "Elsweyr"
L.SI_DQT_DRAGONHOLD = "Dragonhold" -- Added by DarkPhalanx
Expand Down
1 change: 1 addition & 0 deletions PolloxsDailyQuestTracker/lang/ru.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ L.SI_DQT_OTHER_TIMERS = "Other Timers"
L.SI_DQT_RANDOM_DUNGEON = "Random Dungeon"
L.SI_DQT_RANDOM_BATTLEGROUNDS = "Random Battlegrounds"
L.SI_DQT_MOUNT_TRAINING = "Mount Training"
L.SI_DQT_BEQUEATHER = "Теневой поставщик"
L.SI_DQT_ELSWEYR_PROLOGUE = "Elsweyr Prologue"
L.SI_DQT_ELSWEYR = "Elsweyr"
L.SI_DQT_DRAGONHOLD = "Dragonhold" -- Added by DarkPhalanx
Expand Down
98 changes: 57 additions & 41 deletions PolloxsDailyQuestTracker/timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ local TIMER_TYPE = {

Timer.TIMER_TYPE = TIMER_TYPE

local DQTName = DQT.Main.name

function Timer:init()
self.questTimers = DQT.SV:getForChar(GetCurrentCharacterId()).questTimers

Expand All @@ -20,9 +22,10 @@ function Timer:init()
self:resetMountTraining()
self:resetBequeatherTimer()

EVENT_MANAGER:RegisterForEvent(DQT.Main.name, EVENT_ACTIVITY_FINDER_ACTIVITY_COMPLETE, Timer.onActivityFinderActivityComplete)
EVENT_MANAGER:RegisterForEvent(DQT.Main.name, EVENT_BATTLEGROUND_STATE_CHANGED, Timer.onBattlegroundStateChanged)
EVENT_MANAGER:RegisterForEvent(DQT.Main.name, EVENT_RIDING_SKILL_IMPROVEMENT, Timer.onRidingSkillImprovement)
EVENT_MANAGER:RegisterForEvent(DQTName, EVENT_ACTIVITY_FINDER_ACTIVITY_COMPLETE, Timer.onActivityFinderActivityComplete)
EVENT_MANAGER:RegisterForEvent(DQTName, EVENT_BATTLEGROUND_STATE_CHANGED, Timer.onBattlegroundStateChanged)
EVENT_MANAGER:RegisterForEvent(DQTName, EVENT_RIDING_SKILL_IMPROVEMENT, Timer.onRidingSkillImprovement)
EVENT_MANAGER:RegisterForEvent(DQTName, EVENT_PLAYER_ACTIVATED, Timer.playerActivated)
end

--[[
Expand Down Expand Up @@ -55,50 +58,63 @@ function Timer.onRidingSkillImprovement(eventCode, ridingSkillType, previous, cu
end
end

--[[
function Timer:resetBequeatherTimer()
if IsSkillAbilityPurchased(5, 1, 4) ~= true then
self.questTimers[TIMER_TYPE.BEQUEATHER] = "na"
else
SecurePostHook(INTERACTION, "UpdateShadowyConnectionsChatterOption", function(selfInteraction, control, data)
local timeRemaining = GetTimeToShadowyConnectionsResetInSeconds()
if timeRemaining ~= 0 and not data.optionUsable then
self:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
end
end)

function Timer:resetBequeatherTimer(eventCode)
EVENT_MANAGER:UnregisterForEvent(DQTName, EVENT_CHATTER_END)
--Check if Shadowy Supplier passive is purchased, if not set timer to na, else reset timer.
local clientlang = GetCVar("language.2")
if clientlang == "ru" then
if IsSkillAbilityPurchased(5, 6, 4) ~= true then
self.questTimers[TIMER_TYPE.BEQUEATHER] = "na"
else
Timer:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
end
elseif clientlang == "en" then
if IsSkillAbilityPurchased(5, 1, 4) ~= true then
self.questTimers[TIMER_TYPE.BEQUEATHER] = "na"
else
Timer:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
end
elseif clientlang == "de" then
if IsSkillAbilityPurchased(5, 2, 4) ~= true then
self.questTimers[TIMER_TYPE.BEQUEATHER] = "na"
else
Timer:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
end
elseif clientlang == "fr" then
if IsSkillAbilityPurchased(5, 1, 4) ~= true then
self.questTimers[TIMER_TYPE.BEQUEATHER] = "na"
else
Timer:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
end
end
end
--]]
function Timer:resetBequeatherTimer()
if IsSkillAbilityPurchased(5, 1, 4) ~= true then
self.questTimers[TIMER_TYPE.BEQUEATHER] = "na"

--[[Use player activated event to determine if in outlaw zone when changing zones for Shadowy Supplier reset
If in outlaw zone regester EVENT_CHATTER_BEGIN to call next function]]
function Timer.playerActivated(eventCode, initial)
if IsInOutlawZone() then
EVENT_MANAGER:RegisterForEvent(DQTName, EVENT_CHATTER_BEGIN, Timer.OnChatterRegister)
else
-- Timer:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
d("GetTimeToShadowyConnectionsResetInSeconds")
EVENT_MANAGER:UnregisterForEvent(DQTName, EVENT_CHATTER_BEGIN)
end
end

--[[
function Timer:resetBequeatherTimer()
if IsSkillAbilityPurchased(5, 1, 4) ~= true then
self.questTimers[TIMER_TYPE.BEQUEATHER] = "na"
elseif GetTimeToShadowyConnectionsResetInSeconds() ~= 0 then
self:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
else
SecurePostHook(INTERACTION, "UpdateShadowyConnectionsChatterOption", function(selfInteraction, control, data)
local timeRemaining = GetTimeToShadowyConnectionsResetInSeconds()
local bequeatherdelays = {5, 10, 20}
if timeRemaining ~= 0 then
self:resetTimer(TIMER_TYPE.BEQUEATHER, GetTimeToShadowyConnectionsResetInSeconds())
else
for _, delay in ipairs(bequeatherdelays) do
zo_callLater(function() Timer:resetBequeatherTimer() end, 1000 * delay)
end
end
end)
--[[Check if NPC is Remains-Silent on chatter begin
If so then register EVENT_CHATTER_END to call timer reset when interaction ends]]
function Timer.OnChatterRegister(eventCode, optionCount)
local interactableName = select(2, GetGameCameraInteractableActionInfo())
local RemainsSilent={
["Schweigt-still"]=true,
["Remains-Silent"]=true,
["Хранит-Молчание"]=true,
["Garde-le-Silence"]=true
}
if RemainsSilent[interactableName] then
EVENT_MANAGER:RegisterForEvent(DQTName, EVENT_CHATTER_END, Timer.resetBequeatherTimer)
end
end
--]]

--[[
There seems to be a slight delay between when EVENT_ACTIVITY_FINDER_ACTIVITY_COMPLETE fires,
and when GetLFGCooldownTimeRemainingSeconds is actually updated. I have not found a reliable
Expand Down Expand Up @@ -132,12 +148,12 @@ function Timer.onBattlegroundStateChanged(eventCode, previousState, currentState
Timer:resetBattlegroundsTimer()

-- try to reset timer again after they leave the battleground
EVENT_MANAGER:RegisterForEvent(DQT.Main.Name, EVENT_PLAYER_ACTIVATED, Timer.onBattlegroundLeft)
EVENT_MANAGER:RegisterForEvent(DQTName.."_Battleground_Player_Activated", EVENT_PLAYER_ACTIVATED, Timer.onBattlegroundLeft)
end
end

function Timer.onBattlegroundLeft(eventCode, initial)
EVENT_MANAGER:UnregisterForEvent(DQT.Main.Name, EVENT_PLAYER_ACTIVATED)
EVENT_MANAGER:UnregisterForEvent(DQTName.."_Battleground_Player_Activated", EVENT_PLAYER_ACTIVATED)
Timer:resetBattlegroundsTimer()
end

Expand Down

0 comments on commit 0a1bb0f

Please sign in to comment.