Thread Tools Display Modes
07-11-23, 11:56 PM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Stumped getting the correct factionID

I am reworking the code chunk in RepByZone that handles getting either Wrathion's or Sabellion's factionID whenever the player's reputation changes. Instead of returning either dragon's factionID, the code is returning the backup of Valdrakken Accord.

What should be happening:
  1. Check the current friendship ranks and return the factionID of the highest rank.
  2. If the ranks are equal, check the progress to the next rank.
  3. If both factions are dead equal or the player hasn't discovered the factionIDs, then return Valdrakken Accord.
I have tested on my main, who is 2 of 6 with Wrathion and 1 of 6 with Sabellion. Each time I visit the Obsidian Throne, RBZ is not switching. The addon is still displaying Valdrakken Accord, and I can't spot the error. I've double-checked the areaID, and the factionIDs, done a few /dump tests, and have run out of ideas.

Here is my latest commit on GitHub: https://github.com/Myrroddin/repbyzone and the buggy code is on lines 444-475 of Core-Retail.lua.
  Reply With Quote
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

WoWInterface » Developer Discussions » Lua/XML Help » Stumped getting the correct factionID


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