Skip to content

Commit

Permalink
handle portal coord before tp
Browse files Browse the repository at this point in the history
  • Loading branch information
Neogeekmo committed Jul 17, 2024
1 parent eb04ced commit b379ab1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function AprRC:OnInitialize()
AprRCData.ExtraLineTexts = AprRCData.ExtraLineTexts or {}
AprRCData.QuestLookup = AprRCData.QuestLookup or {}
AprRCData.TaxiLookup = AprRCData.TaxiLookup or {}
AprRCData.BeforePortal = AprRCData.BeforePortal or {}

-- Init module
AprRC.settings:InitializeBlizOptions()
Expand Down
42 changes: 41 additions & 1 deletion Event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ local events = {
buy = "MERCHANT_SHOW",
qpart = "QUEST_WATCH_UPDATE",
loot = "CHAT_MSG_LOOT",
target = "PLAYER_TARGET_CHANGED"
target = "PLAYER_TARGET_CHANGED",
portal = { "PLAYER_LEAVING_WORLD", "PLAYER_ENTERING_WORLD" }
-- warMode = "WAR_MODE_STATUS_UPDATE",
-- vehicle = { "UNIT_ENTERING_VEHICLE", "UNIT_EXITING_VEHICLE" },
}
Expand Down Expand Up @@ -532,6 +533,45 @@ function AprRC.event.functions.pet(event, ...)
AprRC.record:RefreshFrameAnchor()
end

function AprRC.event.functions.portal(event, ...)
if event == "PLAYER_LEAVING_WORLD" then
local step = {}
AprRC:SetStepCoord(step)
AprRCData.BeforePortal.lastStep = AprRC:GetLastStep()
AprRCData.BeforePortal.lastCoord = step
else
local isInitialLogin, isReloadingUi = ...
-- wait 2s si last step = saved last step alors waypoints + text prendre portal -- not skippable waypoints (new option)
-- sinon check IsCurrentStepFarAway si trop loin alors override coord + text prendre portal
-- pour les tp sans portail ni cast => LOSS_OF_CONTROL_ADDED into Zone changed indoors, waypoint update, area pois updated
-- pour les tp avec spell => spell list teleport (sans les spell de class) + unit spellcast-succeeded

if not isInitialLogin and not isReloadingUi then
C_Timer.After(3, function()
local last = AprRC:GetLastStep()
if AprRC:DeepCompare(AprRCData.BeforePortal.lastStep, last) then
local step = {
Waypoint = AprRC:FindClosestIncompleteQuest(),
ExtraLineText = "USE_PORTAL",
Coord = AprRCData.BeforePortal.lastStep.Coord
}
AprRC:NewStep(step)
print("|cff00bfffWaypoint|r Added")
elseif AprRC:IsCurrentStepFarAway() then
local last = AprRC:GetLastStep()
last.Coord = AprRCData.BeforePortal.lastStep.Coord
last.ExtraLineText = "USE_PORTAL"
AprRCData.BeforePortal = {}
print("|cff00bfffLast Step coord updated|r Added")
end
end)
end
if isInitialLogin then
AprRCData.BeforePortal = {}
end
end
end

---------------------
-- V2
---------------------
Expand Down
13 changes: 13 additions & 0 deletions helper/Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ function AprRC:Contains(list, x)
return false
end

function AprRC:DeepCompare(t1, t2)
if t1 == t2 then return true end
if type(t1) ~= "table" or type(t2) ~= "table" then return false end
for k1, v1 in pairs(t1) do
local v2 = t2[k1]
if v2 == nil or not deepCompare(v1, v2) then return false end
end
for k2, v2 in pairs(t2) do
if t1[k2] == nil then return false end
end
return true
end

function AprRC:IsTableEmpty(table)
if (table) then
return next(table) == nil
Expand Down

0 comments on commit b379ab1

Please sign in to comment.