diff Looting.lua @ 89:b89558d3e833

Master looter detection. Starting to filter certain actions to only the ML.
author John@Yosemite-PC
date Mon, 16 Apr 2012 07:06:19 -0400
parents 6035541e47dd
children 0cd1d46e7b66
line wrap: on
line diff
--- a/Looting.lua	Mon Apr 16 07:05:37 2012 -0400
+++ b/Looting.lua	Mon Apr 16 07:06:19 2012 -0400
@@ -50,6 +50,7 @@
         if link and rarity >= threshold then
             table.insert(items,{link=link,mlid=i})
             print("Item: ", link, i)
+            isMasterLootEvent = true
         end
     end
     if not isMasterLootEvent then return end
@@ -57,13 +58,15 @@
     print("Let's get started SKing")
     -- todo: check that I am ML and that I'm an admin!
 
-    InitiateBeginLoot(items,stateactivelist)
+    if masterLooterIsMe and admin then
+        InitiateBeginLoot(items,stateactivelist)
 
-    local chan -- todo: idiom
-    if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end
-    _G.SendChatMessage("The following items are available -",chan)
-    for i,v in pairs(items) do
-        _G.SendChatMessage(v.link,chan)
+        local chan -- todo: idiom
+        if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end
+        _G.SendChatMessage("The following items are available -",chan)
+        for i,v in pairs(items) do
+            _G.SendChatMessage(v.link,chan)
+        end
     end
 end
 
@@ -129,7 +132,7 @@
         end
     end
 
-    if state == "bidding" and admin then -- todo: should only be ML
+    if state == "bidding" and admin and masterLooterIsMe then
         message = _G.strtrim(message)
         message = _G.strlower(message)
         if message == "bid" then
@@ -159,7 +162,6 @@
 
 function UpdateML()
     local lootmethod, masterlooterPartyID, masterlooterRaidID = _G.GetLootMethod()
-    print("lm",lootmethod)
     if lootmethod == "master" then
         local oldMasterLooter
         oldMasterLooter = masterLooter
@@ -172,10 +174,13 @@
             masterLooter = _G.UnitName("player") 
             masterLooterIsMe = true
         end
-        print("master looter is", masterLooter)
 
         if masterLooter ~= oldMasterLooter then
             statelistener:StateEvent() -- todo: this isn't how to fire an event!
+
+            if not masterLooterIsMe then
+                Comm:RequestCatchup()
+            end
         end
     else
         masterLooter = nil