/trunk
## Interface: 40300 |
## Author: Animor |
## Title: Animor's AutoReply |
## Version: 0.9.04 |
## Version: 0.9.03 |
## Notes: Auto reply whispers in specific combat related situations. |
## OptionalDeps: Ace3, Recount, LibDataBroker-1.1 |
## X-Embeds: Ace3, LibDataBroker-1.1 |
end |
end |
------------------------------------------------- |
-- Boss engage event - check for start/kill/wipe |
------------------------------------------------- |
function AutoReply:INSTANCE_ENCOUNTER_ENGAGE_UNIT() |
if self.db.profile.raidEn or self.db.profile.dungeonEn then |
if not self.bossEngaged then |
self:CheckBossFightStart() |
else |
self:CheckBossKill("INSTANCE_ENCOUNTER_ENGAGE_UNIT") |
end |
end |
end |
---------------------------------------- |
-- Check if boss fight started |
---------------------------------------- |
-- self:Print("boss fight start") |
self.bossEngaged = true |
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
self:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT", "CheckBossKill") |
self:RegisterEvent("CHAT_MSG_MONSTER_YELL", "CheckBossKill") |
self:RegisterEvent("CHAT_MSG_MONSTER_EMOTE", "CheckBossKill") |
self:RegisterEvent("RAID_BOSS_EMOTE", "CheckBossKill") |
self.bossID = nil |
self.bossName = "Unknown" |
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
self:UnregisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT") |
self:UnregisterEvent("CHAT_MSG_MONSTER_YELL") |
self:UnregisterEvent("CHAT_MSG_MONSTER_EMOTE") |
self:UnregisterEvent("RAID_BOSS_EMOTE") |
end |
end |
return allBossesDead, bossFound |
return allBossesDead |
end |
---------------------------------------- |
---------------------------------------- |
function AutoReply:CheckBossKill(eventname) |
-- self:Print(eventname) |
if self.bossEngaged and (not UnitAffectingCombat("player")) and (self.db.profile.raidEn or self.db.profile.dungeonEn) then |
if self.bossEngaged and (self.db.profile.raidEn or self.db.profile.dungeonEn) then |
-- self:Print("CheckBossKill") |
local allBossesDead, bossFound = self:AllBossesDead() |
if allBossesDead or (self:GroupSurvived() and not bossFound) then |
-- if self:AllBossesDead() or self:GroupSurvived() then |
if self:AllBossesDead() then |
-- self:Print("boss fight: kill") |
self.numKilledBosses = self.numKilledBosses + 1 |
self:ReplyAllMissedBoss("kill") |
-- Check if group is alive |
---------------------------------------- |
function AutoReply:GroupSurvived() |
if not IsInInstance() then return false end -- Do not check if player is not in instance (return false). |
local playerInInstance = IsInInstance() |
local posX, posY = nil |
local playerSurvived = false |
local unitId = ((GetNumRaidMembers() == 0) and "party") or "raid" |
SetMapToCurrentZone() -- Sets the current world map continent and zone to be the zone the player is currently in. |
for i = 0, math.max(GetNumRaidMembers(), GetNumPartyMembers()) do |
local id = (i == 0 and "player") or unitId..i |
-- Check if player is out of combat and didn't use any feign death ability to reset the boss. |
-- Check in addition if player is in 100 yard range. |
if UnitIsVisible(id) and not (UnitAffectingCombat(id) or UnitIsDeadOrGhost(id) or UnitIsFeignDeath(id) or |
if not (UnitAffectingCombat(id) or UnitIsDeadOrGhost(id) or UnitIsFeignDeath(id) or |
UnitAura(id, "Vanish") or UnitAura(id, "Invisibility") or UnitAura(id, "Shadowmeld")) then |
-- self:Print(UnitName(id)) |
return true |
-- Check if player is in the instance |
posX, posY = GetPlayerMapPosition(id) |
if (posX ~= 0 and posY ~= 0 and playerInInstance) or (posX == 0 and posY == 0 and not playerInInstance) then |
playerSurvived = true |
end |
end |
end |
return false |
return playerSurvived |
end |
--------------------------------------------- |
-- Get initial dungeon progress |
---------------------------------------- |
function AutoReply:LFG_PROPOSAL_SHOW() |
local _, id, _, _, instanceName, _, _, _, _, completedEncounters = GetLFGProposal() |
local _, _, _, _, _, _, _, _, totalEncounters, completedEncounters = GetLFGProposal() |
self.numKilledBosses = completedEncounters |
if id == 416 or id == 417 then -- Siege of Wyrmrest Temple or Fall of Deathwing |
self.locationName = "Dragon Soul" |
else |
self.locationName = instanceName |
end |
end |
--====================================== |
-- Send to missed senders list |
for sender in pairs(self.missedSenders) do |
if type(sender) == "number" or IsInInstance() or not sender:find("-") then -- Do not reply cross-realm whisperes when out of instance |
if IsInInstance() or not sender:find("-") then -- Do not reply cross-realm whisperes when out of instance |
self:SendReply(replyMsg, sender) |
end |
end |
self:RegisterEvent("CHAT_MSG_BN_WHISPER") |
self:RegisterEvent("LFG_PROPOSAL_SHOW") |
self:RegisterEvent("PLAYER_REGEN_DISABLED") |
self:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT") |
self:RegisterEvent("PLAYER_REGEN_ENABLED") |
self:RegisterEvent("ZONE_CHANGED_NEW_AREA") |
self:RegisterEvent("PLAYER_LOGOUT") |
self:UnregisterEvent("CHAT_MSG_BN_WHISPER") |
self:UnregisterEvent("LFG_PROPOSAL_SHOW") |
self:UnregisterEvent("PLAYER_REGEN_DISABLED") |
self:UnregisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT") |
self:UnregisterEvent("PLAYER_REGEN_ENABLED") |
self:UnregisterEvent("ZONE_CHANGED_NEW_AREA") |
self:UnregisterEvent("PLAYER_LOGOUT") |