View Single Post
07-14-23, 03:36 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I figured it out by updating the pre-assigned zone and subzone lists, which were using whatever was assigned during initial login, which is probably either nil. I'll clean up the code, but here are the fixed lines.
Lua Code:
  1. -- Sholazar Basin has three possible zone factions; some DF subzones have two; retun factionID based on player's quest progress
  2. function RepByZone:GetMultiRepIDsForZones()
  3.     -- Sholazar Basin
  4.     local newSholazarRepID
  5.     local frenzyHeartStanding = select(3, GetFactionInfoByID(1104))
  6.     local oraclesStanding = select(3, GetFactionInfoByID(1105))
  7.  
  8.     if frenzyHeartStanding <= 3 then
  9.         newSholazarRepID = 1105 -- Frenzyheart hated, return Oracles
  10.     elseif oraclesStanding <= 3 then
  11.         newSholazarRepID = 1104 -- Oracles hated, return Frenzyheart
  12.     elseif (frenzyHeartStanding == 0) or (oraclesStanding == 0) then
  13.         newSholazarRepID = db.watchedRepID or self.racialRepID
  14.     end
  15.  
  16.     if newSholazarRepID ~= self.sholazarRepID then
  17.         self.sholazarRepID = newSholazarRepID
  18.         -- self:SwitchedZones()
  19.     end
  20.  
  21.     -- Wrathion or Sabellian in Dragonflight
  22.     local newDragonFlightRepID = 2510 -- start with Valdrakken Accord
  23.     self.dragonflightRepID = 2510 -- start with Valdrakken Accord
  24.     local wrathionFriendshipInfo = C_GossipInfo.GetFriendshipReputation(2517)
  25.     local sabellionFriendshipInfo = C_GossipInfo.GetFriendshipReputation(2518)
  26.  
  27.     local wrathionRankInfo = C_GossipInfo.GetFriendshipReputationRanks(2517)
  28.     local sabellionRankInfo = C_GossipInfo.GetFriendshipReputationRanks(2518)
  29.  
  30.     local wrathionMaxRep = wrathionFriendshipInfo and wrathionFriendshipInfo.maxRep or 0 -- use 0 instead of possible nil
  31.     local sabellionMaxRep = sabellionFriendshipInfo and sabellionFriendshipInfo.maxRep or 0 -- use 0 instead of possible nil
  32.    
  33.     local wrathionNextThreshold = wrathionFriendshipInfo and wrathionFriendshipInfo.nextThreshold or 0 -- use 0 instead of possible nil
  34.     local sabellionNextThreshold = sabellionFriendshipInfo and sabellionFriendshipInfo.nextThreshold or 0 -- use 0 instead of possible nil
  35.  
  36.     local wrathionCurrentRepAmount = wrathionMaxRep % wrathionNextThreshold
  37.     local sabellionCurrentRepAmount = sabellionMaxRep % sabellionNextThreshold
  38.  
  39.     if (wrathionRankInfo and wrathionRankInfo.currentLevel) > (sabellionRankInfo and sabellionRankInfo.currentLevel) then
  40.         newDragonFlightRepID = 2517 -- Wrathion is higher
  41.         self:Print("Wrathion rank is higher, newDragonFlightRepID is", newDragonFlightRepID)
  42.     elseif (sabellionRankInfo and sabellionRankInfo.currentLevel) > (wrathionRankInfo and wrathionRankInfo.currentLevel) then
  43.         newDragonFlightRepID = 2518 -- Sabellian is higher
  44.         self:Print("Sabellian rank is higher, newDragonFlightRepID is", newDragonFlightRepID)
  45.     elseif (wrathionRankInfo and wrathionRankInfo.currentLevel) == (sabellionRankInfo and sabellionRankInfo.currentLevel) then
  46.         -- they are the same rank or the factions are unknown, verify
  47.         if wrathionCurrentRepAmount > sabellionCurrentRepAmount then
  48.             newDragonFlightRepID = 2517 -- Wrathion is higher
  49.             self:Print("Dragon ranks are the same, Wrathion progress is higher, newDragonFlightRepID is", newDragonFlightRepID)
  50.         elseif sabellionCurrentRepAmount > wrathionCurrentRepAmount then
  51.             newDragonFlightRepID = 2518 -- Sabellian is higher
  52.             self:Print("Dragon ranks are the same, Sabellian progress is higher, newDragonFlightRepID is", newDragonFlightRepID)
  53.         end
  54.     end
  55.     self:Print("newDragonFlightRepID is", newDragonFlightRepID)
  56.  
  57.     if newDragonFlightRepID ~= self.dragonflightRepID then
  58.         self.dragonflightRepID = newDragonFlightRepID
  59.         self:Print("self.dragonflightRepID is", self.dragonflightRepID)
  60.         -- self:SwitchedZones()
  61.     end
  62.  
  63.     -- update both zones and subzones
  64.     zonesAndFactions = self:ZoneAndFactionList()
  65.     subZonesAndFactions = self:SubZonesAndFactions()
  66.     self:SwitchedZones()
  67. end
  Reply With Quote