Skip to content

Commit

Permalink
Adds fail event in comms and fail print to chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Slivo-fr committed May 9, 2021
1 parent b2979f0 commit 9de6f06
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/comms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ end
-----------------------------------------------------------------------------------------------------------------------

-- Broadcast a tranqshot event
function TranqRotate:sendSyncTranq(hunter, fail, timestamp)
function TranqRotate:sendSyncTranq(hunter, fail, timestamp, failEvent)
local message = {
['type'] = TranqRotate.constants.commsTypes.tranqshotDone,
['timestamp'] = timestamp,
['player'] = hunter.name,
['fail'] = fail,
['failEvent'] = failEvent,
}

TranqRotate:sendRaidAddonMessage(message)
Expand Down Expand Up @@ -138,7 +139,7 @@ function TranqRotate:receiveSyncTranq(prefix, message, channel, sender)
TranqRotate:rotate(hunter)
end
else
TranqRotate:handleFailTranq(hunter)
TranqRotate:handleFailTranq(hunter, message.failEvent)
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED()
TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceSuccessMessage, destName)
end
elseif (event == "SPELL_MISSED" or event == "SPELL_DISPEL_FAILED") then
TranqRotate:sendSyncTranq(hunter, true, timestamp)
TranqRotate:handleFailTranq(hunter)
TranqRotate:sendSyncTranq(hunter, true, timestamp, event)
TranqRotate:handleFailTranq(hunter, event)
if (sourceGUID == UnitGUID("player")) then
TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceFailMessage, destName)
end
Expand Down
4 changes: 3 additions & 1 deletion src/rotation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ function TranqRotate:rotate(lastHunter, rotateWithoutCooldown)
end

-- Handle miss or dispel resist scenario
function TranqRotate:handleFailTranq(hunter)
function TranqRotate:handleFailTranq(hunter, event)

-- Do not process multiple SPELL_DISPEL_FAILED events or multiple fail broadcasts
local duplicate = hunter.lastFailTime >= GetTime() - TranqRotate.constants.duplicateFailedTranqshotDelayThreshold
if (duplicate) then
return
end

TranqRotate:printFail(hunter, event)

local playerName, realm = UnitName("player")
local hasPlayerFailed = playerName == hunter.name
local nextHunter = TranqRotate:getHighlightedHunter()
Expand Down
11 changes: 11 additions & 0 deletions src/tranqRotate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,14 @@ function TranqRotate:formatAddonVersion(version)
return version
end
end

function TranqRotate:printFail(hunter, event)
if (event == "SPELL_MISSED") then
TranqRotate:printPrefixedMessage(hunter.name .. " missed his tranqshot!")
elseif(event == "SPELL_DISPEL_FAILED") then
TranqRotate:printPrefixedMessage(hunter.name .. "'s tranqshot was resisted!")
else
-- v1.5.1 and older do not send the event type
TranqRotate:printPrefixedMessage(hunter.name .. "'s tranqshot was missed or resisted!")
end
end

0 comments on commit 9de6f06

Please sign in to comment.