Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function AvailableCustomPins()
- local count = 0
- for _, b in pairs(FyrMM.CustomPinList) do
- count = count + #b
- end
- return count
- end
- local function IsCustomPinsLoading()
- for _, b in pairs(FyrMM.LoadingCustomPins) do
- if b then
- return b
- end
- end
- return false
- end
- local function GetQuestFreePinIndex()
- local index = LastQuestPinIndex
- if not tableIsEmpty(FreeQuestPinIndex) then
- index = table.remove(FreeQuestPinIndex)
- return index
- end
- index = index + 1
- LastQuestPinIndex = index
- return index
- end
- function RequestJournalQuestConditionAssistance(questIndex, stepIndex, conditionIndex, assisted)
- local taskId = FyrMM.RequestJournalQuestConditionAssistance(questIndex, stepIndex, conditionIndex, assisted)
- local tag = ZO_MapPin.CreateQuestPinTag(questIndex, stepIndex, conditionIndex)
- local currentTime = GetGameTimeMilliseconds()
- if currentTime - FyrMM.LastQuestPinRequest > FYRMM_QUEST_PIN_REQUEST_MINIMUM_DELAY then
- FyrMM.questPinCount = GetQuestPinCount()
- QuestPinsUpdating = true
- end
- if taskId ~= nil and not FyrMM.Halted then
- FyrMM.LastQuestPinRequest = currentTime
- local currentTask = {}
- currentTask = tag
- currentTask.RequestTimeStamp = FyrMM.LastQuestPinRequest
- currentTask.MapId = CurrentMap.MapId
- currentTask.Fetched = true
- currentTask.ZO_MapVisible = ZO_WorldMap:IsHidden()
- CurrentTasks[taskId] = currentTask
- end
- return taskId
- end
- function CancelRequestJournalQuestConditionAssistance(taskId)
- if taskId ~= nil and CurrentTasks[taskId] and CurrentTasks[taskId].Fetched then
- CurrentTasks[taskId] = nil
- FyrMM.CancelRequestJournalQuestConditionAssistance(taskId)
- end
- end
- function tableIsEmpty(tbl)
- return next(tbl) == nil
- end
- local function CancelUpdates()
- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapDelayedRegister")
- -- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapZoneCheck")
- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapPOIPins")
- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapLocationsPins")
- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapWayshrinesPins")
- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapCustomPins")
- -- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapPOIPinsD")
- -- EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapInitialPreload")
- EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapCustomPinGroupAll")
- FyrMM.UpdatingCustomPins = {}
- FyrMM.LoadingCustomPins = {}
- if PinRef then
- for i, n in pairs(PRCustomPins) do
- if i > MAP_PIN_TYPE_INVALID then
- EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapCustomPinGroup" .. tostring(i))
- end
- end
- end
- end
- local function IsCurrentLocation(pin)
- if not pin then
- return
- end
- local x, y = CurrentMap.PlayerNX, CurrentMap.PlayerNY
- local nX = pin.nX or pin.normalizedX
- local nY = pin.nY or pin.normalizedY
- if not (nX and nY and CurrentMap.TrueMapSize) then
- return false
- end
- local distance = zo_round(CurrentMap.TrueMapSize * math.sqrt((x - nX) ^ 2 + (y - nY) ^ 2) * 7.55) / 10 -- assumed size is 1.325 times larger than approximate effective skill distance in meters.
- local message = zo_strformat(SI_MM_STRING_DISTANCE, distance) .. " m"
- if not InformationTooltip:IsHidden() then
- InformationTooltip:AddLine(message, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
- end
- if not ZO_MapLocationTooltip:IsHidden() then
- ZO_MapLocationTooltip:AddLine(message, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
- end
- return CurrentMap.TrueMapSize * math.sqrt((x - nX) ^ 2 + (y - nY) ^ 2) < 14 -- Approximate distance to use a wayshrine
- end
- local function IsCraftingService(pin)
- if not pin then
- return false
- end
- local tooltipIndex = pin.locationIndex
- if not tooltipIndex then
- return false
- end
- for _, v in pairs(FyrMM.CSProviders) do
- if v then
- for j = 1, GetNumMapLocationTooltipLines(tooltipIndex) do
- local _, tooltipLineText = GetMapLocationTooltipLineInfo(tooltipIndex, j)
- if tooltipLineText:find(v) then
- return true
- end
- end
- end
- end
- return false
- end
- local function SetTooltipMessage(pin)
- if not pin then
- return
- end
- if pin:IsFastTravelWayShrine() then
- local nodeIndex = pin:GetFastTravelNodeIndex()
- local known, name = GetFastTravelNodeInfo(nodeIndex)
- if not known then
- name = name .. " (undiscovered)"
- end
- InformationTooltip:AddLine(zo_strformat(SI_WORLD_MAP_LOCATION_NAME, name), "",
- ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB()) -- Wayshrine name
- if IsCurrentLocation(pin) then
- InformationTooltip:AddLine(GetString(SI_TOOLTIP_WAYSHRINE_CURRENT_LOC), "", ZO_HIGHLIGHT_TEXT:UnpackRGB()) -- Player is near wayshrine
- else
- if IsInAvAZone() then
- InformationTooltip:AddLine(GetString(SI_TOOLTIP_WAYSHRINE_CANT_RECALL_AVA), "",
- ZO_ERROR_COLOR:UnpackRGB()) -- Can't travel to a wayshrine in Cyrodiil
- else
- local _, premiumTimeLeft = GetRecallCooldown()
- if premiumTimeLeft == 0 then
- InformationTooltip:AddLine(GetString(SI_TOOLTIP_WAYSHRINE_CLICK_TO_RECALL), "",
- ZO_HIGHLIGHT_TEXT:UnpackRGB()) -- Recall text line
- local cost = GetRecallCost()
- if cost > 0 then
- if cost <= GetCurrentMoney() then
- ZO_ItemTooltip_AddMoney(InformationTooltip, cost, SI_TOOLTIP_RECALL_COST,
- CURRENCY_HAS_ENOUGH)
- else
- ZO_ItemTooltip_AddMoney(InformationTooltip, cost, SI_TOOLTIP_RECALL_COST,
- CURRENCY_NOT_ENOUGH)
- end
- end
- else
- local cooldownText = zo_strformat(SI_TOOLTIP_WAYSHRINE_RECALL_COOLDOWN, ZO_FormatTimeMilliseconds(
- premiumTimeLeft, TIME_FORMAT_STYLE_DESCRIPTIVE, TIME_FORMAT_PRECISION_SECONDS))
- InformationTooltip:AddLine(cooldownText, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
- end
- end
- end
- else
- local poiIndex = pin:GetPOIIndex()
- local zoneIndex = pin:GetPOIZoneIndex()
- local poiName, _, poiStartDesc, poiFinishedDesc = GetPOIInfo(zoneIndex, poiIndex)
- InformationTooltip:AddLine(zo_strformat(SI_WORLD_MAP_LOCATION_NAME, poiName), "",
- ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB())
- local pinType = select(3, MM_GetPOIMapInfo(zoneIndex, poiIndex))
- if not (ZO_MapPin.POI_PIN_TYPES[pinType]) then
- InformationTooltip:AddLine("(undiscovered)", "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
- end
- if pinType == MAP_PIN_TYPE_POI_COMPLETE then
- if poiFinishedDesc ~= "" then
- InformationTooltip:AddLine(poiFinishedDesc, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
- end
- else
- if poiStartDesc ~= "" then
- InformationTooltip:AddLine(poiStartDesc, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
- end
- end
- end
- end
- function GetCurrentMapTextureFileInfo()
- local tileTexture = (GetMapTileTexture()):lower()
- if tileTexture == nil or tileTexture == "" then
- return "tamriel_0", "tamriel_", "art/maps/tamriel/"
- end
- local pos = select(2, tileTexture:find("maps/([%w%-]+)/"))
- if pos == nil then
- return "tamriel_0", "tamriel_", "art/maps/tamriel/"
- end
- pos = pos + 1
- return string.gsub(string.sub(tileTexture, pos), ".dds", ""),
- string.gsub(string.sub(tileTexture, pos), "0.dds", ""), tileTexture:sub(1, pos - 1)
- end
- local function GetTrueMapSize()
- local currentMapId = CurrentMap.MapId
- local size = FyrMM.MapSizes[currentMapId] or 1
- return currentMapId, size
- end
- local function GetMapTextureFileInfo(mapId)
- local tileTexture = GetMapTileTextureForMapId(mapId, 1)
- if tileTexture == nil or tileTexture == "" then
- return "tamriel_0", "tamriel_", "art/maps/tamriel/"
- end
- local _, pos = tileTexture:find("maps/([%w%-]+)/")
- if not pos then
- return "tamriel_0", "tamriel_", "art/maps/tamriel/"
- end
- return string.gsub(string.sub(tileTexture, pos + 1), ".dds", "")
- end
- function FyrMM.MapHalfDiagonal()
- FyrMM.DiagonalND = math.sqrt((Fyr_MM_Player:GetRight() - Fyr_MM:GetRight()) ^ 2 +
- (Fyr_MM_Player:GetTop() - Fyr_MM:GetTop()) ^ 2)
- return FyrMM.DiagonalND
- end
- local function IsAssisted(pinType)
- if pinType then
- return ASSISTED_PIN_TYPES[pinType] ~= nil -- non-existent key = nil
- end
- return false
- end
- local function IsQuestType(pinType)
- return QUEST_PIN_TYPES[pinType] ~= nil -- non-existent key = nil
- end
- local function valueExists(i, x)
- for j = 1, #x do -- instead of ipairs to avoid overhead
- if x[j] == i then
- return true
- end
- end
- return false
- end
- local function questpinDataExists(pinData, array)
- -- Avoid continuous table lookups localize the values instead
- local questIndex, questName, conditionText, conditionIndex, normX, normY, radius, stepIndex = pinData.questIndex,
- pinData.questName, pinData.conditionText, pinData.conditionIndex, pinData.normalizedX, pinData.normalizedY,
- pinData.radius, pinData.stepIndex
- for i, v in pairs(array) do
- if v.questIndex == questIndex and v.questName == questName and v.conditionText == conditionText and
- v.conditionIndex == conditionIndex and v.normalizedX == normX and v.normalizedY == normY and v.radius ==
- radius and v.stepIndex == stepIndex then
- return i
- end
- end
- return nil
- end
- function FyrMM.SetTargetScale(pin, targetScale)
- if not (pin or targetScale) or (pin.targetScal == targetScale and targetScale == pin:GetScale()) then
- return
- end
- pin.targetScale = targetScale
- local primaryPin, secondaryPin, tertiaryPin = pin.primaryPin, pin.secondaryPin, pin.tertiaryPin
- local newScale
- for i = 1, 10 do
- newScale = zo_deltaNormalizedLerp(pin:GetScale(), pin.targetScale, 0.1 * i)
- zo_callLater(function()
- pin:SetScale(newScale)
- if primaryPin then
- primaryPin:SetScale(newScale)
- end
- if secondaryPin then
- secondaryPin:SetScale(newScale)
- end
- if tertiaryPin then
- tertiaryPin:SetScale(newScale)
- end
- end, i * 50)
- end
- zo_callLater(function()
- pin:SetScale(pin.targetScale)
- if primaryPin then
- primaryPin:SetScale(pin.targetScale)
- end
- if secondaryPin then
- secondaryPin:SetScale(pin.targetScale)
- end
- if tertiaryPin then
- tertiaryPin:SetScale(pin.targetScale)
- end
- pin.targetScale = nil
- end, 550)
- end
- local function WayshrineDistances(nDistance)
- if not (FyrMM.SV.BorderPins and FyrMM.SV.BorderWayshrine) or FyrMM.currentWayshrineCount == 0 then
- return
- end
- if CurrentMap.movedTimeStamp == WayshrineDistancesTimeStamp and WayshrineDistancesTimeStamp ~= 0 then
- return
- end
- WayshrineDistancesTimeStamp = CurrentMap.movedTimeStamp
- local gameTime = GetGameTimeMilliseconds()
- local wDi, wDmi, minWD, owDmi = 1, 1, 1, 1
- if FyrMM.DebugMode then
- CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
- "WayshrineDistances Start:" .. tostring(FyrMM.currentWayshrineCount))
- end
- if FyrMM.currentWayshrineCount == 1 then
- Wayshrines[1].Closest = Wayshrines[1].isRealWayshrine
- return
- end
- EVENT_MANAGER:RegisterForUpdate("OnFyrMiniMapDistances", 100, -- 150 ~8s 50 ~6s -- 100 ~ loads about the same as 50 on initial load.
- function()
- local playerX, playerY = CurrentMap.PlayerNX, CurrentMap.PlayerNY
- if Wayshrines[wDi] and Wayshrines[wDi].isRealWayshrine then
- Wayshrines[wDi].nDistance =
- math.sqrt((playerX - Wayshrines[wDi].nX) ^ 2 + (playerY - Wayshrines[wDi].nY) ^ 2)
- if Wayshrines[wDi].nDistance < minWD then
- minWD = Wayshrines[wDi].nDistance
- wDmi = wDi
- end
- end
- if wDi <= FyrMM.currentWayshrineCount then
- wDi = wDi + 1
- return
- end
- for i, p in pairs(Wayshrines) do
- Wayshrines[i].Closest = (i == wDmi)
- Wayshrines[i].pin.Closest = (i == wDmi)
- end
- if FyrMM.DebugMode then
- CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "WayshrineDistances Done. (" .. tostring(wDmi) .. ") " ..
- tostring(GetGameTimeMilliseconds() - gameTime))
- end
- EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapDistances")
- end)
- end
- local function sort(a, b)
- local typeA, typeB = type(a.index), type(b.index) -- avoid repeated calls to the type function
- if typeA == "number" and typeB == "number" then
- return a.index < b.index
- end
- if typeA == "number" and typeB ~= "number" then
- return true
- end
- if typeA ~= "number" and typeB == "number" then
- return false
- end
- return a.index and b.index and tostring(a.index) < tostring(b.index)
- end
- local function FirstKey(Table, offset)
- if tableIsEmpty(Table) then
- return nil
- end
- if offset == nil then
- offset = 0
- end
- local key = next(Table, offset)
- while key ~= nil do
- if Table[key] ~= nil then
- return key
- end
- key = next(Table, key)
- end
- return nil
- end
- local function QuestGiverDistances()
- if not (FyrMM.SV.BorderPins and FyrMM.SV.BorderQuestGivers) or #FyrMM.AvailableQuestGivers == 0 then
- return
- end
- local gameTime = GetGameTimeMilliseconds()
- local x, y = CurrentMap.PlayerNX, CurrentMap.PlayerNY
- local AQGListFull = {}
- local multiplier = Fyr_MM:GetWidth()
- for _, v in ipairs(FyrMM.AvailableQuestGivers) do
- if v.nX == nil and v.mpin.normalizedX ~= nil then -- workaround just in case
- v.nX = v.mpin.normalizedX
- v.nY = v.mpin.normalizedY
- end
- if v.nX and v.nY then
- v.nDistance = math.sqrt((x - v.nX) * (x - v.nX) + (y - v.nY) * (y - v.nY))
- AQGListFull[#AQGListFull + 1] = {
- index = math.floor(multiplier * v.nDistance),
- data = v
- }
- end
- end
- table.sort(AQGListFull, sort)
- local AQGList = {}
- if FyrMM.ZoneStoryPin then
- AQGList[#AQGList + 1] = FyrMM.ZoneStoryPin
- end
- for i, n in ipairs(AQGListFull) do
- if i > 5 then
- break
- end
- AQGList[#AQGList + 1] = n.data
- end
- if FyrMM.DebugMode then
- CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
- "QuestGiverDistances " .. tostring(GetGameTimeMilliseconds() - gameTime))
- end
- end
- function FyrMM.MenuTooltip(button, message)
- -- Fyr_MM_Menu:SetAlpha(1)
- FyrMM.OverMenu = true
- Fyr_MM_Close:SetAlpha(1)
- if not message or not button then
- return
- end
- InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 38, button:GetTop())
- InformationTooltip:AddLine(message, "", ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB())
- end
- function GetCurrentMapSize()
- return CurrentMap and CurrentMap.TrueMapSize or nil -- Returns assumed calculated map size in feet, returns nil no calculated size or not possible to do so
- end
- local function GetRotatedPosition(x, y) -- Inspired by DeathAngel's RadarMiniMap
- if not CurrentMap.Heading then
- return
- end
- if not (x or CurrentMap.PlayerX) then
- return x, y
- end
- local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
- local ix, iy = (x * mWidth) - CurrentMap.PlayerX, (y * mHeight) - CurrentMap.PlayerY
- local rx = math.cos(-CurrentMap.Heading) * ix - math.sin(-CurrentMap.Heading) * iy
- local ry = math.sin(-CurrentMap.Heading) * ix + math.cos(-CurrentMap.Heading) * iy
- return zo_round(rx), zo_round(ry)
- end
- local function GetNorthFacingPosition(x, y)
- local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
- if x and y then
- return math.floor(mWidth * x), math.floor(mHeight * y) -- math.floor is faster than zo_round
- end
- return x, y
- end
- local function CleanUpPins()
- -- faster ways for cleaning up pins result in occasional pins not removing
- if not tableIsEmpty(PinsList) then
- local cui = 0
- local chunk = FyrMM.SV.ChunkSize or 50
- local delay = FyrMM.SV.ChunkDelay or 50
- if FyrMM.DebugMode then
- CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
- "CleanUpPins Start:" .. tostring(chunk) .. "..." .. tostring(delay))
- end
- EVENT_MANAGER:RegisterForUpdate("FyrMiniMapCleanupPinsTask", delay, function()
- local c = 0
- local k = false
- cui = cui + 1
- local t = GetGameTimeMilliseconds()
- for i, l in pairs(PinsList) do
- c = c + 1
- if c >= chunk then
- if FyrMM.DebugMode then
- CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "CleanUpPins " .. tostring(cui) .. " " ..
- tostring(GetGameTimeMilliseconds() - t))
- end
- return
- end
- if l ~= nil then
- if l.m_PinType ~= nil and l.m_PinType >= MAP_PIN_TYPE_INVALID then -- is custom pin
- RemoveCustomPin(l)
- k = true
- end
- if not k then -- is regular pin
- if l.BorderPin then
- RemoveBorderPin(l.BorderPin)
- end
- l:ClearAnchors()
- l:SetHidden(true)
- l:SetMouseEnabled(false)
- l.nX = nil
- l.nY = nil
- l:ClearAnchors()
- l:SetHidden(true)
- l:SetMouseEnabled(false)
- -- l:SetTexture(nil)
- l:SetDimensions(0, 0)
- l.m_PinTag = nil
- l.m_PinType = nil
- l.m_Pin = nil
- l.IsAvailableQuest = nil
- l.normalizedX = nil
- l.normalizedY = nil
- l.radius = nil
- l.MapId = nil
- l.Index = nil
- l.questName = nil
- l.PinToolTipText = nil
- l.primaryPin = nil
- l.secondaryPin = nil
- l.tertiaryPin = nil
- l.MM_Tag = nil
- l.pinAge = nil
- l.IsTreasure = nil
- l.isDps = nil
- l.isHeal = nil
- l.isTank = nil
- l.ClassId = nil
- l.isLeader = nil
- PinsList[i] = nil
- end
- end
- end
- if tableIsEmpty(PinsList) then
- if FyrMM.DebugMode then
- CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
- "CleanUpPins Done. " .. tostring(GetGameTimeMilliseconds() - t))
- end
- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapCleanupPinsTask")
- CleanUpMisc()
- return
- end
- end)
- else
- FyrMM.Reloading = false
- end
- end
- function FyrMM.playerMoved()
- FyrMM.newPos = {CurrentMap.PlayerNX, CurrentMap.PlayerNY} -- GetMapPlayerPosition("player")
- if rawequal(FyrMM.newPos, FyrMM.oldPos) then
- return false
- end
- FyrMM.oldPos = FyrMM.newPos
- return true
- end
- local function SpeedMeasure()
- local PositionLog3D = PositionLog3D -- cache global table
- FyrMM.WaypointPins()
- local multiplier = FyrMM.GetMapMeasureMultiplier()
- if tableIsEmpty(PositionLog3D) then
- return
- end
- local x13d, y13d, z13d, t1, x12d, y12d = unpack(PositionLog3D[1], 2, 7)
- local x23d, y23d, z23d, t2, x22d, y22d
- local d3d, d2d, v13d, va3d = 0, 0, 0, 0
- local size = FyrMM.MapSizes[CurrentMap.MapId] or FyrMM.currentMap.TrueMapSize
- if IsPlayerMoving() then
- local i = 2
- local PositionLogCounter = PositionLogCounter -- cache global variable
- while i <= PositionLogCounter do
- x23d, y23d, z23d, t2, x22d, y22d = unpack(PositionLog3D[i], 2, 7)
- d3d = math.sqrt((x23d - x13d) ^ 2 + (y23d - y13d) ^ 2 + (z23d - z13d) ^ 2)
- v13d = 0.1487 * d3d / math.abs((t2 - t1) / 1000)
- x13d, y13d, z13d, t1, x12d, y12d = x23d, y23d, z23d, t2, x22d, y22d
- va3d = va3d + v13d
- i = i + 1
- end
- if PositionLogCounter == 0 then
- return
- end
- local nsize = 0.0143 * math.sqrt((x23d - x13d) ^ 2 + (y23d - y13d) ^ 2) /
- math.sqrt((x22d - x12d) ^ 2 + (y22d - y12d) ^ 2)
- if nsize and size and nsize ~= math.huge and size < nsize then
- FyrMM.currentMap.TrueMapSize = nsize
- end
- va3d = va3d / (PositionLogCounter - 1) * multiplier
- end
- local MovementSpeedPrevious = FyrMM.MovementSpeedPrevious -- cache global variable
- if MovementSpeedPrevious ~= nil then
- FyrMM.MovementSpeed = (va3d + MovementSpeedPrevious) / 2
- else
- FyrMM.MovementSpeed = va3d
- end
- if MovementSpeedPrevious ~= FyrMM.MovementSpeed then
- CALLBACK_MANAGER:FireCallbacks("MovementSpeedChanged", va3d)
- FyrMM.MovementSpeedPrevious = FyrMM.MovementSpeed
- end
- if va3d > FyrMM.MovementSpeedMax then
- FyrMM.MovementSpeedMax = va3d
- end
- if FyrMM.SV.ShowSpeed then
- SetSpeedLabel(va3d)
- end
- end
- function FyrMM.PositionUpdate()
- if not FyrMM.Visible or Fyr_MM:IsHidden() or FyrMM.worldMapShowing or not FyrMM.Initialized or
- not Fyr_MM_Scroll_Map_0 or not CurrentMap.Dx then
- return
- end
- if FyrMM.GetMapId() ~= CurrentMap.MapId and not FyrMM.CheckingZone then
- FyrMM.ZoneCheck()
- end
- local a = GetGameTimeMilliseconds()
- local x = CurrentMap.PlayerNX
- local y = CurrentMap.PlayerNY
- local pheading = CurrentMap.PlayerHeading
- if x == nil or pheading == nil then
- x, y, pheading = GetMapPlayerPosition("player")
- end
- local moved = CurrentMap.PlayerMoved
- CurrentMap.CameraHeading = CurrentMap.CameraHeading or GetPlayerCameraHeading()
- local cpheading = FyrMM.SV.RotateMap and math.abs(pheading - pi * 2) + CurrentMap.CameraHeading or
- CurrentMap.CameraHeading
- Fyr_MM_Camera:SetTextureRotation(cpheading)
- local hpos = (x * (Fyr_MM_Scroll_Map_0:GetWidth() * CurrentMap.Dx)) - (Fyr_MM_Scroll:GetWidth() / 2)
- local vpos = (y * (Fyr_MM_Scroll_Map_0:GetHeight() * CurrentMap.Dx)) - (Fyr_MM_Scroll:GetHeight() / 2)
- local heading = pheading
- if FyrMM.SV.PPStyle ~= GetString(SI_MM_STRING_PLAYERANDCAMERA) then
- if FyrMM.SV.Heading == "CAMERA" then
- heading = CurrentMap.CameraHeading
- end
- if not moved and FyrMM.SV.Heading == "MIXED" then
- heading = CurrentMap.CameraHeading
- end
- end
- if moved and FyrMM.SV.ViewRangeFiltering then
- UpdateCustomPinPositions()
- end
- if ((x < 1.2 and x > -0.2) and (y < 1.2 and y > -0.2)) then -- Can't let the scroll go too far outside view (Black map issue)
- if not Fyr_MM:IsHidden() and moved then
- FyrMM.SetMapToPlayerLocation()
- end
- CurrentMap.hpos = hpos
- CurrentMap.vpos = vpos
- if FyrMM.SV.RotateMap then
- Fyr_MM_Scroll:SetHorizontalScroll(0)
- Fyr_MM_Scroll:SetVerticalScroll(0)
- else
- Fyr_MM_Scroll:SetHorizontalScroll(hpos)
- Fyr_MM_Scroll:SetVerticalScroll(vpos)
- end
- if FyrMM.SV.WheelMap then
- FyrMM.WheelScroll(CurrentMap.hpos, CurrentMap.vpos)
- end
- else
- CurrentMap.hpos = hpos
- CurrentMap.vpos = vpos
- if FyrMM.SV.RotateMap then
- Fyr_MM_Scroll:SetHorizontalScroll(0)
- Fyr_MM_Scroll:SetVerticalScroll(0)
- else
- Fyr_MM_Scroll:SetHorizontalScroll(CurrentMap.hpos)
- Fyr_MM_Scroll:SetVerticalScroll(CurrentMap.vpos)
- end
- if FyrMM.SV.WheelMap then
- FyrMM.WheelScroll(CurrentMap.hpos, CurrentMap.vpos)
- end
- end
- FyrMM.UpdateMapTiles(moved) -- can cause tiles not updating but should be fixed by now
- CurrentMap.needRescale = true -- REMOVING THIS CAUSES OCCASIONAL PINS DEPHASING ON ROTATING MAPS
- if FyrMM.SV.RotateMap then
- Fyr_MM_Player:SetTextureRotation(0)
- FyrMM.AxisPins()
- else
- Fyr_MM_Player:SetTextureRotation(heading)
- end
- a = GetGameTimeMilliseconds() - a
- if FyrMM.DebugMode and a > 0 then
- CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.PositionUpdate " .. tostring(a))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement