Skip to content

Commit

Permalink
Merge pull request #4 from ACastanza/FindMyEmp
Browse files Browse the repository at this point in the history
Add Icon to Current Emperor in KillFeed and ReticleOver
  • Loading branch information
ACastanza authored Dec 26, 2023
2 parents b96eb04 + a27c954 commit 3982567
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 35 deletions.
92 changes: 63 additions & 29 deletions PvpAlerts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ local PVP_BRIGHT_AD_COLOR = PVP:GetGlobal('PVP_BRIGHT_AD_COLOR')
local PVP_BRIGHT_EP_COLOR = PVP:GetGlobal('PVP_BRIGHT_EP_COLOR')
local PVP_BRIGHT_DC_COLOR = PVP:GetGlobal('PVP_BRIGHT_DC_COLOR')


local emperorAlliance, emperorRawName, emperorAccName

function PVP:RemoveDuplicateNames() -- // a clean-up function for various arrays containing information about players nearby //
local function ClearId(id)
PVP.playerSpec[PVP.idToName[id]] = nil
Expand Down Expand Up @@ -206,6 +207,11 @@ function PVP.OnUpdate() -- // main loop of the addon, is called each 250ms //
-- PVP:TestThisScale()
end

function PVP:updateCampaignEmperor(eventCode, campaignId)
if not campaignId == GetCurrentCampaignId() then return end
emperorAlliance, emperorRawName, emperorAccName = GetCampaignEmperorInfo(campaignId)
end

local lastcount, lastcountAcc
function PVP:RefreshStoredNumbers(currentTime) -- // output of the number of stored accounts/players //
PVP.reportTimer = currentTime
Expand Down Expand Up @@ -861,7 +867,11 @@ function PVP:OnZoneChange(_, zoneName, newZone)

if not self.SV.unlocked and self.SV.showCaptureFrame then PVP:SetupCurrentObjective(zoneText) end

PVP:UpdateNearbyKeepsAndPOIs(nil, true)
PVP:UpdateNearbyKeepsAndPOIs(nil, true)
local currentCampaignId = GetCurrentCampaignId()
if currentCampaignId ~= 0 then
self:updateCampaignEmperor(nil, currentCampaignId)
end
end

function PVP:OnOwnerOrUnderAttackChanged(zoneText, keepIdToUpdate, updateType)
Expand Down Expand Up @@ -1617,6 +1627,10 @@ function PVP:OnKillfeed(_, killLocation, killerPlayerDisplayName, killerPlayerCh
local playerActionKilledToken = self:Colorize("You killed", messageColor)

local importantToken, isKOS = GetImportantIcon(targetValidName)
local isVictimEmperor = PVP:IsEmperor(targetValidName, emperorRawName)
if isVictimEmperor then
importantToken = PVP:GetEmperorIcon(32, allianceColor) .. importantToken
end
local victimPlayerToken
local victimNameToken = targetPlayer

Expand Down Expand Up @@ -1652,14 +1666,22 @@ function PVP:OnKillfeed(_, killLocation, killerPlayerDisplayName, killerPlayerCh
sourceValidName, sourceName, sourceAllianceColor, killLocation)
local text
local messageColor = "AF7500"

local killerImportantToken = GetImportantIcon(sourceValidName)
local isKillerEmperor = PVP:IsEmperor(sourceValidName, emperorRawName)
if isKillerEmperor then
killerImportantToken = PVP:GetEmperorIcon(32, sourceAllianceColor) .. killerImportantToken
end
local killerPlayerToken
local killerNameToken = PVP:GetFormattedClassNameLink(sourceValidName, sourceAllianceColor)

local actionToken = PVP:Colorize("killed", messageColor)

local victimImportantToken = GetImportantIcon(targetValidName)
local victimImportantToken = GetImportantIcon(targetValidName)
local isVictimEmperor = PVP:IsEmperor(targetValidName, emperorRawName)
if isVictimEmperor then
victimImportantToken = PVP:GetEmperorIcon(32, allianceColor) .. victimImportantToken
end
local victimPlayerToken
local victimNameToken = targetPlayer
local withToken = self:Colorize("with", messageColor)
Expand Down Expand Up @@ -1707,6 +1729,10 @@ function PVP:OnKillfeed(_, killLocation, killerPlayerDisplayName, killerPlayerCh
local playerActionDiedToken = PVP:Colorize("You were killed by", messageColor)

local importantToken = GetImportantIcon(sourceValidName)
local isKillerEmperor = PVP:IsEmperor(sourceValidName, emperorRawName)
if isKillerEmperor then
importantToken = PVP:GetEmperorIcon(32, sourceAllianceColor) .. importantToken
end
local killerPlayerToken
local killedByNameToken = PVP:GetFormattedClassNameLink(sourceValidName, sourceAllianceColor)

Expand Down Expand Up @@ -2132,7 +2158,8 @@ function PVP:GetTargetChar(playerName, isTargetFrame)
end

local formattedName
local KOSOrFriend = self:IsKOSOrFriend(playerName)
local KOSOrFriend = self:IsKOSOrFriend(playerName)
local isEmperor = PVP:IsEmperor(playerName, emperorRawName)

local statusIcon, isDeadOrResurrect = FindInNames(playerName)

Expand All @@ -2157,26 +2184,29 @@ function PVP:GetTargetChar(playerName, isTargetFrame)
end
end


if isDeadOrResurrect then
formattedName = self:GetFormattedClassNameLink(playerName, nameColor, false, isDeadOrResurrect, true,
not isTargetFrame)
else
formattedName = self:GetFormattedClassNameLink(playerName, nameColor, nil, nil, true, not isTargetFrame)
end

-- if KOSOrFriend then
if KOSOrFriend == "KOS" then
formattedName = formattedName .. self:GetKOSIcon(not isTargetFrame and 45 or nil)
elseif KOSOrFriend == "friend" then
formattedName = formattedName .. self:GetFriendIcon(not isTargetFrame and 35 or 19)
elseif KOSOrFriend == "cool" then
formattedName = formattedName .. self:GetCoolIcon(not isTargetFrame and 35 or 19)
elseif KOSOrFriend == "groupleader" then
formattedName = formattedName .. self:GetGroupLeaderIcon(not isTargetFrame and 45 or nil)
elseif KOSOrFriend == "group" then
formattedName = formattedName .. self:GetGroupIcon(not isTargetFrame and 45 or nil)
if isEmperor then
formattedName = self:GetEmperorIcon(not isTargetFrame and 45 or nil,
PVP:GetTrueAllianceColorsHex(emperorAlliance)) .. formattedName
end
-- if KOSOrFriend then
if KOSOrFriend == "KOS" then
formattedName = formattedName .. self:GetKOSIcon(not isTargetFrame and 45 or nil)
elseif KOSOrFriend == "friend" then
formattedName = formattedName .. self:GetFriendIcon(not isTargetFrame and 35 or 19)
elseif KOSOrFriend == "cool" then
formattedName = formattedName .. self:GetCoolIcon(not isTargetFrame and 35 or 19)
elseif KOSOrFriend == "groupleader" then
formattedName = formattedName .. self:GetGroupLeaderIcon(not isTargetFrame and 45 or nil)
elseif KOSOrFriend == "group" then
formattedName = formattedName .. self:GetGroupIcon(not isTargetFrame and 45 or nil)
end

if isTargetFrame then
formattedName = formattedName .. statusIcon
Expand Down Expand Up @@ -2496,7 +2526,9 @@ function PVP:OnOff()
EVENT_MANAGER:RegisterForUpdate(self.name, 250, PVP.OnUpdate)
DEATH_FRAGMENT:RegisterCallback("StateChange", OnDeathFragmentStateChange)
PVP_SCOREBOARD_FRAGMENT:RegisterCallback("StateChange", ScoreboardFragmentCallback)
CALLBACK_MANAGER:RegisterCallback("OnWorldMapChanged", OnWorldMapChangedCallback)
CALLBACK_MANAGER:RegisterCallback("OnWorldMapChanged", OnWorldMapChangedCallback)
EVENT_MANAGER:RegisterForUpdate(self.name, EVENT_CAMPAIGN_EMPEROR_CHANGED,
function(...) self:updateCampaignEmperor(...) end)
end
self:InitEnabledAddon()
else
Expand All @@ -2516,7 +2548,8 @@ function PVP:OnOff()
EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_MEDAL_AWARDED)
EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_ALLIANCE_POINT_UPDATE)
EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_ACTION_SLOT_ABILITY_USED)
EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_LEADER_UPDATE)
EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_LEADER_UPDATE)
EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_CAMPAIGN_EMPEROR_CHANGED)
EVENT_MANAGER:UnregisterForUpdate(self.name)
DEATH_FRAGMENT:UnregisterCallback("StateChange", OnDeathFragmentStateChange)
PVP_SCOREBOARD_FRAGMENT:UnregisterCallback("StateChange", ScoreboardFragmentCallback)
Expand Down Expand Up @@ -2713,9 +2746,10 @@ function PVP:GetAllianceCountPlayers()
end

if playerName ~= self.playerName then
local KOSOrFriend = self:IsKOSOrFriend(playerName)
local KOSOrFriend = self:IsKOSOrFriend(playerName)
local statusIcon, isResurrect, isDead = FindInNames(playerName)
local addStatus
local addStatus

if statusIcon == "" then addStatus = true end
if KOSOrFriend then
if KOSOrFriend == "KOS" then
Expand Down Expand Up @@ -2815,11 +2849,11 @@ function PVP:GetAllianceCountPlayers()
for k, v in pairs(self.playerAlliance) do
local playerName = self.idToName[k]
local formattedName
local KOSOrFriend = self:IsKOSOrFriend(playerName)

local KOSOrFriend = self:IsKOSOrFriend(playerName)
local statusIcon, isResurrect, isDead = FindInNames(playerName)
local addStatus
if statusIcon == "" then addStatus = true end
if statusIcon == "" then addStatus = true end

if isDead or isResurrect then
formattedName = self:GetFormattedClassNameLink(playerName,
self:GetTimeFadedColor(self:NameToAllianceColor(playerName, true), k, currentTime), false, true, k,
Expand Down Expand Up @@ -2911,11 +2945,11 @@ function PVP:GetAllianceCountPlayers()

for k, _ in pairs(self.playerNames) do
if not foundNames[k] then
local playerName = k
local playerName = k
local formattedName
local nameLength = string.len(zo_strformat(SI_UNIT_NAME, playerName))
local KOSOrFriend = self:IsKOSOrFriend(playerName)

local nameLength = string.len(zo_strformat(SI_UNIT_NAME, playerName))
local KOSOrFriend = self:IsKOSOrFriend(playerName)
local statusIcon, isResurrect, isDead = FindInNames(playerName)

if (not isDead) and (not isResurrect) then
Expand Down Expand Up @@ -3160,7 +3194,7 @@ function PVP:PopulateReticleOverNamesBuffer()
if playerName then
local iconsCount = 0
local formattedName = ""
KOSOrFriend = self:IsKOSOrFriend(playerName)
KOSOrFriend = self:IsKOSOrFriend(playerName)
if KOSOrFriend then
iconsCount = iconsCount + 1
if KOSOrFriend == "KOS" then
Expand Down
5 changes: 4 additions & 1 deletion PvpAlerts_Init_Globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ PVP.globalConstants = {
['PVP_FIGHT_EPDC'] = "/esoui/art/mappins/ava_ebonheartvdaggerfall.dds",

['PVP_ATTACKER'] = "/esoui/art/compass/ava_returnpoint_ebonheart.dds",

['PVP_RESURRECT'] = "/esoui/art/compass/ava_flagcarrier_neutral.dds",

['PVP_6STAR'] = "PvpAlerts/textures/6star1.dds",

['PVP_EMPEROR'] = "/esoui/art/campaign/overview_indexicon_emperor_up.dds",

['PVP_AP'] = "esoui/art/currency/alliancepoints_32.dds",

['PVP_NAME_FONT'] = "$(BOLD_FONT)|29|thick-outline",
Expand Down
10 changes: 10 additions & 0 deletions PvpAlerts_KOS_System.lua
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,16 @@ function PVP:IsKOSOrFriend(playerName)
return false
end

function PVP:IsEmperor(playerName, emperorRawName)
if emperorRawName == "" or emperorRawName == nil then return false end
if playerName == "" or playerName == nil then return false end
playerName = tostring(playerName)
emperorRawName = tostring(emperorRawName)
local playerRootName = PVP:GetRootNames(playerName)
local emperorRootName = PVP:GetRootNames(emperorRawName)
return playerRootName == emperorRootName
end

function PVP:IsNameInKOS(playerName)
local dbRecord, accName
dbRecord = self.SV.playersDB[playerName]
Expand Down
23 changes: 18 additions & 5 deletions PvpAlerts_Utility_Functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local PVP_IMPORTANT_ICON = PVP:GetGlobal('PVP_IMPORTANT_ICON')
local PVP_EYE_ICON = PVP:GetGlobal('PVP_EYE_ICON')
local PVP_KILLING_BLOW = PVP:GetGlobal('PVP_KILLING_BLOW')
local PVP_ATTACKER = PVP:GetGlobal('PVP_ATTACKER')
local PVP_EMPEROR = PVP:GetGlobal('PVP_EMPEROR')
local PVP_RESURRECT = PVP:GetGlobal('PVP_RESURRECT')
local PVP_6STAR = PVP:GetGlobal('PVP_6STAR')

Expand Down Expand Up @@ -551,6 +552,12 @@ function PVP:GetAttackerIcon(dimension, color)
return self:Colorize(zo_iconFormatInheritColor(PVP_ATTACKER, dimension, dimension), color)
end

function PVP:GetEmperorIcon(dimension, color)
dimension = dimension or 20
color = color or "FFFFFF"
return self:Colorize(zo_iconFormatInheritColor(PVP_EMPEROR, dimension, dimension), color)
end

-- function PVP:GetTargetIcon(dimension, color)
-- dimension = dimension or 22
-- color = color or "FFFFFF"
Expand Down Expand Up @@ -760,12 +767,18 @@ function PVP:IsMalformedName(name)
end

function PVP:GetValidName(name)
if not name or name == '' then return end
if not PVP:IsMalformedName(name) then return name end
-- if not PVP.bgNames then return end
if not name or name == '' then return end
if not PVP:IsMalformedName(name) then return name end
-- if not PVP.bgNames then return end

if PVP.bgNames and PVP.bgNames[name .. '^Mx'] then return name .. '^Mx' end
if PVP.bgNames and PVP.bgNames[name .. '^Fx'] then return name .. '^Fx' end
end

if PVP.bgNames and PVP.bgNames[name .. '^Mx'] then return name .. '^Mx' end
if PVP.bgNames and PVP.bgNames[name .. '^Fx'] then return name .. '^Fx' end
function PVP:GetRootNames(name)
if not name or name == '' then return "" end
local rootName = name:gsub("%s*%^[MF]x%s*$", "")
return rootName or ""
end

function PVP:BgAllianceToHexColor(bgAlliance)
Expand Down

0 comments on commit 3982567

Please sign in to comment.