Something like this adapted to your code :
Lua Code:
function ZO_HUDTelvarMeter:UpdateMultiplier()
local baseMultiplier = GetTelvarStoneMultiplier(self.telvarStoneThreshold)
local realMultiplier
if GetCurrentMapIndex() then -- Sewers returns nil
realMultiplier = baseMultiplier + (self.actualDistrictBonus / 100) * baseMultiplier
else
realMultiplier = baseMultiplier
end
local wholePart = zo_floor(realMultiplier)
local fractionalPart = zo_round(zo_mod(realMultiplier, 1.0)*100)
HUD_TELVAR_METER.multiplierWholePart:SetText(zo_strformat(SI_TELVAR_HUD_MULTIPLIER_VALUE_WHOLE, wholePart))
HUD_TELVAR_METER.multiplierFractionalPart:SetText(zo_strformat(SI_TELVAR_HUD_MULTIPLIER_VALUE_FRACTION, string.format("%02d", fractionalPart)))
end
local function OnPlayerActivated()
if IsInImperialCity() then
self.actualDistrictBonus = 0
for keepId in pairs(ICKeeps) do
local owningAlliance = GetKeepAlliance(keepId, BGQUERY_LOCAL)
if owningAlliance == self.playerAlliance then
self.actualDistrictBonus = self.actualDistrictBonus + GetDistrictOwnershipTelVarBonusPercent(keepId, BGQUERY_LOCAL)
end
ICKeeps[keepId] = owningAlliance
end
self:UpdateMultiplier()
end
end
local function OnObjectiveControlState(_, objectiveKeepId, _, _, _, _, objectiveControlEvent, _, objectiveParam1)
if IsInImperialCity() then
if objectiveControlEvent == OBJECTIVE_CONTROL_EVENT_CAPTURED or objectiveControlEvent == OBJECTIVE_CONTROL_EVENT_RECAPTURED then
if objectiveParam1 == self.playerAlliance then
self.actualDistrictBonus = self.actualDistrictBonus + GetDistrictOwnershipTelVarBonusPercent(objectiveKeepId, BGQUERY_LOCAL)
elseif ICKeeps[objectiveKeepId] == playerAlliance then
self.actualDistrictBonus = self.actualDistrictBonus - GetDistrictOwnershipTelVarBonusPercent(objectiveKeepId, BGQUERY_LOCAL)
end
ICKeeps[objectiveKeepId] = objectiveParam1
self:UpdateMultiplier()
end
end
end
ZO_HUDTelvarMeter:Initialize(control)
self.actualDistrictBonus = 0
self.playerAlliance = GetUnitAlliance("player")
self.ICKeeps = {
[141] = true,
[142] = true,
[143] = true,
[146] = true,
[147] = true,
[148] = true,
}
control:RegisterForEvent(EVENT_PLAYER_ACTIVATED, OnPlayerActivated)
control:RegisterForEvent(EVENT_OBJECTIVE_CONTROL_STATE, OnObjectiveControlState)
...