1 QuestHelper_File
["collect_monster.lua"] = "Development Version"
2 QuestHelper_Loadtime
["collect_monster.lua"] = GetTime()
4 local debug_output
= false
5 if QuestHelper_File
["collect_monster.lua"] == "Development Version" then debug_output
= true end
17 local logon
= GetTime() -- Because I'm incredibly paranoid, I'm waiting fifteen minutes after logon to assume they're not drunk.
18 local drunk_logon
= true
19 local drunk_message
= false
21 local function SystemMessage(arg
, arg2
, arg3
)
22 if strfind(arg
, Patterns
["DRUNK_MESSAGE_SELF2"]) or strfind(arg
, Patterns
["DRUNK_MESSAGE_SELF3"]) or strfind(arg
, Patterns
["DRUNK_MESSAGE_SELF4"]) or strfind(arg
, Patterns
["DRUNK_MESSAGE_ITEM_SELF2"]) or strfind(arg
, Patterns
["DRUNK_MESSAGE_ITEM_SELF3"]) or strfind(arg
, Patterns
["DRUNK_MESSAGE_ITEM_SELF4"]) then
24 elseif strfind(arg
, Patterns
["DRUNK_MESSAGE_SELF1"]) or strfind(arg
, Patterns
["DRUNK_MESSAGE_ITEM_SELF1"]) then
29 local InteractDistances
= {28, 11, 10, 0} -- There's actually a 4, but it's also 28 and it's kind of handy to be able to do it this way.
31 local recentlySeenCritters
= {} -- We try not to repeatedly record critters frequently.
33 -- Kind of a nasty system here, built for efficiency and simplicity. All newly-seen critters go into Recent. When Recent reaches a certain size (100?) everything in NextTrash is deleted and NextTrash is replaced with Recent. Badabing, badaboom.
34 local recentlySeenCritters_NextTrash
= {}
35 local recentlySeenCritters_Recent
= {}
37 local function AccumulateFrequency(target
, name
, data
)
38 local key
= name
.. "_" .. tostring(data
)
39 target
[key
] = (target
[key
] or 0) + 1
42 local function MouseoverUnit()
43 if logon
and logon
+ 60 * 15 < GetTime() then
48 -- First off, we see if it's "interesting".
49 -- The original code for this filtered out critters. I don't, because critters are cute, and rare.
50 if UnitExists("mouseover") and UnitIsVisible("mouseover") and not UnitIsPlayer("mouseover") and not UnitPlayerControlled("mouseover") then
51 local guid
= UnitGUID("mouseover")
53 if not IsMonsterGUID(guid
) then return end -- pet that isn't controlled by a player? NPC pet? It's kind of unclear, but I'm getting some, so, FIXED
54 local creatureid
= GetMonsterUID(guid
)
56 if not recentlySeenCritters
[creatureid
] then
57 recentlySeenCritters_Recent
[creatureid
] = true
58 recentlySeenCritters
[creatureid
] = true
60 -- register the critter here
61 local cid
= GetMonsterType(guid
)
63 if not QHCM
[cid
] then QHCM
[cid
] = {} end
64 local critter
= QHCM
[cid
]
66 if cid
< 30621 or cid
> 30625 then AccumulateFrequency(critter
, "name", UnitName("mouseover")) end -- The exceptions are for Herald Volasj's minions, which are named after your partymembers.
67 AccumulateFrequency(critter
, "reaction", UnitReaction("mouseover", "player"))
68 if not drunk_logon
and not drunk_message
then
69 AccumulateFrequency(critter
, "level", UnitLevel("mouseover"))
72 local minrange
= InteractDistances
[1]
74 -- Now we try to derive a bound for how far away it is
75 for i
= #InteractDistances
- 1, 1, -1 do
76 if CheckInteractDistance("mouseover", i
) then
77 minrange
= InteractDistances
[i
+ 1]
78 maxrange
= InteractDistances
[i
]
82 QuestHelper
: Assert(minrange
>= 0 and minrange
< 256 and maxrange
>= 0 and maxrange
< 256)
83 Merger
.Add(critter
, GetLoc() .. strchar(minrange
, maxrange
))
85 if #recentlySeenCritters_Recent
>= 100 then
86 for k
, v
in recentlySeenCritters_NextTrash
do
87 recentlySeenCritters
[v
] = nil
90 recentlySeenCritters_NextTrash
= recentlySeenCritters_Recent
91 recentlySeenCritters_Recent
= {} -- BAM, garbage collection!
97 function QH_Collect_Monster_Init(QHCData
, API
)
98 if not QHCData
.monster
then QHCData
.monster
= {} end
99 QHCM
= QHCData
.monster
101 QH_Event("UPDATE_MOUSEOVER_UNIT", MouseoverUnit
)
102 QH_Event("CHAT_MSG_SYSTEM", SystemMessage
)
104 Patterns
= API
.Patterns
105 QuestHelper
: Assert(Patterns
)
107 API
.Patterns_Register("DRUNK_MESSAGE_SELF1", "|c.*|r")
108 API
.Patterns_Register("DRUNK_MESSAGE_SELF2", "|c.*|r")
109 API
.Patterns_Register("DRUNK_MESSAGE_SELF3", "|c.*|r")
110 API
.Patterns_Register("DRUNK_MESSAGE_SELF4", "|c.*|r")
111 API
.Patterns_Register("DRUNK_MESSAGE_ITEM_SELF1", "|c.*|r")
112 API
.Patterns_Register("DRUNK_MESSAGE_ITEM_SELF2", "|c.*|r")
113 API
.Patterns_Register("DRUNK_MESSAGE_ITEM_SELF3", "|c.*|r")
114 API
.Patterns_Register("DRUNK_MESSAGE_ITEM_SELF4", "|c.*|r")
116 GetLoc
= API
.Callback_LocationBolusCurrent
117 QuestHelper
: Assert(GetLoc
)
119 Merger
= API
.Utility_Merger
120 QuestHelper
: Assert(Merger
)
122 IsMonsterGUID
= API
.Utility_IsMonsterGUID
123 GetMonsterUID
= API
.Utility_GetMonsterUID
124 GetMonsterType
= API
.Utility_GetMonsterType
125 QuestHelper
: Assert(IsMonsterGUID
)
126 QuestHelper
: Assert(GetMonsterUID
)
127 QuestHelper
: Assert(GetMonsterType
)