View Single Post
11-25-21, 03:46 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Attached is the latest zip with all the file changes.
  • Moved RepByZone.WoDFollowerZones to the top of Core-Retail.lua
  • Moved CitySubZonesAndFactions to the top of the file
  • Removed table length operator
  • Reinitialized data tables in CheckPandaren() and JoinedCovenant()
  • Refactored GetRacialRep() to correctly assign a default reputation if all others are unknown
  • Added debug prints in SwitchedZones()
  • Disabled watched bodyguard WoD zones in Options.lua if no bodyguard exists
  • Fixed bodyguard returned factions to factionID numbers, was strings before
This is what I found out:
  1. When in WoD zones, with the option enabled, or disabled code commented out, the print correctly says true. When the options are set to false, the print is nil. That is correct.
  2. If the setting is disabled, either by clicking to false or commenting out the disabled line, RBZ sets WoD zones correctly as per the hard-coded tables.
  3. However, the return for CheckBodyguard() is nil in all cases. I've played around with the return's placement, and so far everything I've tried always returns nil.
I'm glad I put the print statements into SwitchedZone(); at least I know the zone tables are working, both if there is a bodyguard and not.

I have the feeling that CheckBodyguard() is returning nil because "Lua doesn't work that way", a mistake I seem to make a lot, given this thread.

For brevity, here's the function by itself. The commented URL is a list of IsQuestCompleted() if the player talks to the bodyguard and says "come with me, I need muscle". I'm not sure if I need to check for quest completion, or if simply assigning the follower to the barracks is enough. If the follower is not actually hanging out with the player, the follower does not gain reputation, so I might have to check.
Lua Code:
  1. -- WoD garrison bodyguard code
  2. local garrFollowerIDToReputationID = {
  3.     -- garrison followerID = factionID
  4.     -- see full list of garrFollowerIDs: [url]https://wowpedia.fandom.com/wiki/GarrFollowerID[/url]
  5.     [193]       = 1736,     -- Tormmok
  6.     [207]       = A and 1738 or H and 1740, -- Defender Illona or Aeda Brightdawn
  7.     [216]       = A and 1733 or H and 1739, -- Delvar Ironfist or Vivianne
  8.     [218]       = 1737,     -- Talonpriest Ishaal
  9.     [219]       = 1741,     -- Leorajh
  10. }
  11.  
  12. -- WoD barracks buildingIDs
  13. local barracks_ids = {
  14.     [27]        = true,     -- level 2
  15.     [28]        = true,     -- level 3
  16. }
  17.  
  18. -- [url]https://www.wowhead.com/quests/garrisons/garrison-support#q=tracking[/url]
  19.  
  20. function RepByZone:CheckBodyguard()
  21.     local bodyguardRep
  22.     local buildings = C_Garrison.GetBuildings(Enum.GarrisonType.Type_6_0)
  23.     for i = 1, #buildings do
  24.         local building = buildings[i]
  25.         local building_id = building.buildingID
  26.         local plot_id = building.plotID
  27.         if barracks_ids[building_id] then
  28.             local name, _, _, _, _, garrFollowerID = C_Garrison.GetFollowerInfoForBuilding(plot_id)
  29.             if name then
  30.                 bodyguardRep = garrFollowerIDToReputationID[garrFollowerID]
  31.             end
  32.             break
  33.         end
  34.         return bodyguardRep
  35.     end
  36.     return bodyguardRep
  37. end
Attached Files
File Type: zip RepByZone.zip (219.2 KB, 82 views)
  Reply With Quote