Thread Tools Display Modes
06/02/16, 11:58 PM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
[outdated] hudtelvarmeter.lua changes reflecting new features

Something like this adapted to your code :






Lua Code:
  1. function ZO_HUDTelvarMeter:UpdateMultiplier()
  2.    
  3.     local baseMultiplier = GetTelvarStoneMultiplier(self.telvarStoneThreshold)
  4.     local realMultiplier
  5.    
  6.     if GetCurrentMapIndex() then -- Sewers returns nil
  7.         realMultiplier = baseMultiplier + (self.actualDistrictBonus / 100) * baseMultiplier
  8.     else
  9.         realMultiplier = baseMultiplier
  10.     end
  11.    
  12.     local wholePart = zo_floor(realMultiplier)
  13.     local fractionalPart = zo_round(zo_mod(realMultiplier, 1.0)*100)
  14.     HUD_TELVAR_METER.multiplierWholePart:SetText(zo_strformat(SI_TELVAR_HUD_MULTIPLIER_VALUE_WHOLE, wholePart))
  15.     HUD_TELVAR_METER.multiplierFractionalPart:SetText(zo_strformat(SI_TELVAR_HUD_MULTIPLIER_VALUE_FRACTION, string.format("%02d", fractionalPart)))
  16.  
  17.    
  18. end
  19.  
  20. local function OnPlayerActivated()
  21.  
  22.     if IsInImperialCity() then
  23.        
  24.         self.actualDistrictBonus = 0
  25.         for keepId in pairs(ICKeeps) do
  26.             local owningAlliance = GetKeepAlliance(keepId, BGQUERY_LOCAL)
  27.             if owningAlliance == self.playerAlliance then
  28.                 self.actualDistrictBonus = self.actualDistrictBonus + GetDistrictOwnershipTelVarBonusPercent(keepId, BGQUERY_LOCAL)
  29.             end
  30.             ICKeeps[keepId] = owningAlliance
  31.         end
  32.        
  33.         self:UpdateMultiplier()
  34.    
  35.     end
  36.  
  37. end
  38.  
  39. local function OnObjectiveControlState(_, objectiveKeepId, _, _, _, _, objectiveControlEvent, _, objectiveParam1)
  40.    
  41.     if IsInImperialCity() then
  42.         if objectiveControlEvent == OBJECTIVE_CONTROL_EVENT_CAPTURED or objectiveControlEvent == OBJECTIVE_CONTROL_EVENT_RECAPTURED then
  43.             if objectiveParam1 == self.playerAlliance then
  44.                 self.actualDistrictBonus = self.actualDistrictBonus + GetDistrictOwnershipTelVarBonusPercent(objectiveKeepId, BGQUERY_LOCAL)
  45.             elseif ICKeeps[objectiveKeepId] == playerAlliance then
  46.                 self.actualDistrictBonus = self.actualDistrictBonus - GetDistrictOwnershipTelVarBonusPercent(objectiveKeepId, BGQUERY_LOCAL)
  47.             end
  48.            
  49.             ICKeeps[objectiveKeepId] = objectiveParam1
  50.             self:UpdateMultiplier()
  51.            
  52.         end
  53.     end
  54.    
  55. end
  56.  
  57.  
  58. ZO_HUDTelvarMeter:Initialize(control)
  59.  
  60.     self.actualDistrictBonus = 0
  61.     self.playerAlliance = GetUnitAlliance("player")
  62.     self.ICKeeps = {
  63.         [141] = true,
  64.         [142] = true,
  65.         [143] = true,
  66.         [146] = true,
  67.         [147] = true,
  68.         [148] = true,
  69.     }
  70.    
  71.     control:RegisterForEvent(EVENT_PLAYER_ACTIVATED, OnPlayerActivated)
  72.     control:RegisterForEvent(EVENT_OBJECTIVE_CONTROL_STATE, OnObjectiveControlState)
  73.      
  74.     ...

Last edited by Ayantir : 06/03/16 at 12:40 AM.
 
06/03/16, 04:03 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
I consider this a bug and have already reported it on the pts. Maybe I'll add it to Medic.
 

ESOUI » Developer Discussions » Wish List » [outdated] hudtelvarmeter.lua changes reflecting new features

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off