Skip to content

Commit

Permalink
Updating for classic
Browse files Browse the repository at this point in the history
  • Loading branch information
funkjedi committed Sep 7, 2019
1 parent 0cd02a9 commit 04d38af
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion SheepMonitor.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Sheep Monitor
## Notes: Provides various methods of notification to help you keep track of your flock.
## Author: funkjedi
## Version: 1.19
## Version: 1.20
## SavedVariables: SheepMonitorDatabase
## OptionalDeps: Ace3, LibAuras, LibAuraInfo-1.0

Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.20
- updated for classic (tested only with Polymorph but others should/may work)

1.19
- updated for patch 8.2.0

Expand Down
36 changes: 31 additions & 5 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@ function SheepMonitor:OnInitialize()
--InterfaceOptionsFrame_OpenToCategory('SheepMonitor')
end

function SheepMonitor:IsClassic()
return select(1, GetBuildInfo()) < '8.0.0'
end

function SheepMonitor:OnEnable()
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
end


function SheepMonitor:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2, spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()
-- the classic always returns a spell id of zero so we
-- resolve the spell id using the spell name instead
if self:IsClassic() then
spellId = select(7, GetSpellInfo(spellName))
end
-- watch for polymorphed mobs
if (eventType == 'SPELL_AURA_APPLIED' or eventType == 'SPELL_AURA_REFRESH') and self.trackableAuras[spellId] then
if (self.db.char.monitorRaid and UnitInRaid(sourceName)) or sourceName == UnitName('player') then
Expand All @@ -67,7 +76,16 @@ function SheepMonitor:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
timestamp = GetTime(),
duration = LibAuraInfo:GetDuration(spellId, sourceGUID, destGUID),
}
if destGUID == UnitGUID('target') then
if self:IsClassic() then
local playerLevel = UnitLevel('player')
if spellId == 118 and playerLevel < 20 then
aura.duration = 20
elseif spellId == 118 and playerLevel < 40 then
aura.duration = 30
elseif spellId == 118 and playerLevel < 60 then
aura.duration = 40
end
elseif destGUID == UnitGUID('target') then
aura.duration = select(5, LibAuras:UnitAura('target', spellId, 'PLAYER|HARMFUL')) or 0
end
self:AuraApplied(aura)
Expand Down Expand Up @@ -185,10 +203,18 @@ function SheepMonitor:SendAnnouncement(message)
end

function SheepMonitor:PlaySoundFile(file)
local sounds = {
['Sound\\Interface\\AlarmClockWarning3.wav'] = 567458,
['Sound\\Interface\\RaidWarning.wav'] = 567397,
}
local sound
if self:IsClassic() then
sounds = {
['Sound\\Interface\\AlarmClockWarning3.wav'] = 'Sound\\Interface\\AlarmClockWarning3.ogg',
['Sound\\Interface\\RaidWarning.wav'] = 'Sound\\Interface\\RaidWarning.ogg',
}
else
sounds = {
['Sound\\Interface\\AlarmClockWarning3.wav'] = 567458,
['Sound\\Interface\\RaidWarning.wav'] = 567397,
}
end
if sounds[file] then
file = sounds[file]
end
Expand Down

0 comments on commit 04d38af

Please sign in to comment.