Determine Out-of-Combat State

I have written a simple combat logger. The logger records each combat event (“COMBAT_LOG_EVENT_UNFILTERED”) then, when the player exits combat, prints a summary (total damage, DPS, etc.,). However, I am unable to detect when combat ends. I’ve tried two methods, neither of which work as desired. The two methods are:

(1) When the PLAYER_REGEN_ENABLED event fires, issue the combat summary
(2) When UnitAffectingCombat(“Player”) is true, issue the combat summary.

For example, here’s an abbreviated output of the combat log generated by my addon. This log was generated by continuously attacking a target dummy for over a minute, i.e., with little or no pause in spell-casting.

Any thoughts?

Bathshebâ's Shadow Word: Pain dealt 533 Shadow damage to Training Dummy
<...>
Bathshebâ's Vampiric Touch dealt 818 Shadow damage to Training Dummy

*** COMBAT SUMMARY ***
Combat Ended After 52.93 seconds

36569 total damage (690.96 DPS).
2505 critical damage (6.85% of total)
24509 periodic damage (67.02% of total)
No failed casts (missed, dodged, or parried
-- Damage by School
Shadow: 36569 damage (100.00% of total)

Bathshebâ's Shadowform aura expired.
<...>
Bathshebâ's Void Eruption dealt 2563 Shadow damage to Training Dummy

*** COMBAT SUMMARY ***
Combat Ended After 0.96 seconds

256349 total damage (267867.29 DPS).
10253 critical damage (4.00% of total)
No failed casts (missed, dodged, or parried
-- Damage by School
Shadow: 256349 damage (100.00% of total)

Bathshebâ's Vampiric Touch dealt 1787 critical Shadow damage to Training Dummy
<...>
Bathshebâ's Vampiric Touch dealt 878 Shadow damage to Training Dummy

*** COMBAT SUMMARY ***
Combat Ended After 25.76 seconds

55717 total damage (2162.59 DPS).
15882 critical damage (28.50% of total)
26103 periodic damage (46.85% of total)
No failed casts (missed, dodged, or parried
-- Damage by School
Shadow: 55717 damage (100.00% of total)

Bathshebâ's Vampiric Touch dealt 878 Shadow damage to Training Dummy
<...>
Bathshebâ's Machinist's Brilliance aura expired.

Just install Details or any other damage meter?
or if you insist on re-inventing a wheel that already exists, download Details and see how it determines damage segments.

Events:

PLAYER_LEAVE_COMBAT
PLAYER_REGEN_ENABLED

I’ve tried both of these suggestions before making the original post.

The problem with Details is that its start/end combat semantics depend on events for which I could find no documentation (ENCOUNTER_END, ENCOUNTER_START). Moreover, when my addon registers for those events they never fire when combat is entered/exited.

As for the snark about reinventing the wheel, I would suggest you revisit wheel functionality. There are many different types of wheels and they are designed to solve different problems.

As always, Fizz, thanks for your suggestions. However, I’ve tried both in a number of different ways (PLAYER_LEAVE_COMBAT and PLAYER_REGEN_ENABLED). Sadly, I’ve not been able to get them to work.

I know I’m missing something obvious.

Cheers,

Some bits to try.

local ATTACKING, INCOMBAT, REGEN

local function OnEvent(self, event, ...)
	if (event == "PLAYER_ENTER_COMBAT") then
		ATTACKING = true
		INCOMBAT = true;
	elseif event == "PLAYER_ENTERING_WORLD" then
		ATTACKING = nil
		INCOMBAT = nil
		REGEN = true
	elseif event == "PLAYER_LEAVE_COMBAT" then
		ATTACKING = nil
		if REGEN then
			INCOMBAT = nil
		end
	elseif event == "PLAYER_REGEN_DISABLED" then
		REGEN = nil
		INCOMBAT = true
	elseif event == "PLAYER_REGEN_ENABLED" then
		REGEN = true
		if not ATTACKING then
			INCOMBAT = nil
		end
	end
	if not INCOMBAT then
		-- Turn off logging
	end
end

Thanks, Fizz. Much of your example’s logic is there but mine is missing some key parts. I’ll implement this and let you know.

Cheers,

I wasn’t sure how you started/indicated you were logging so presumably that would be part of the out-of-combat check:

if LOGGING and not INCOMBAT then
    LOGGING = nil
    -- Turn of logging
end
if not LOGGING and INCOMBAT then
        LOGGING = true
    -- Turn on logging if you have not done this somewhere else.
end

Edit: On Dummies, they don’t die even if their health says zero so, if you’ve left something ticking on them or stay too close when you decide you’ve had enough, they can continue to hold a grudge for quite a while.