Skip to content

Commit

Permalink
Update empowerChannelSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Mar 25, 2024
1 parent 533a653 commit f4154fe
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions src/parser/shared/normalizers/Channeling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import InsertableEventsWrapper from 'parser/core/InsertableEventsWrapper';
import { Options } from 'parser/core/Module';
import { TALENTS_DEMON_HUNTER } from 'common/TALENTS';
import { TALENTS_PRIEST } from 'common/TALENTS';
import { playerInfo } from '../metrics/apl/conditions/test-tools';
import {
getEmpowerEndEvent,
isFromTipTheScales,
} from 'analysis/retail/evoker/shared/modules/normalizers/EmpowerNormalizer';

/**
* Channels and casts are handled differently in events, and some information is also missing and must be inferred.
Expand Down Expand Up @@ -322,7 +325,7 @@ export function buffChannelSpec(spellId: number): ChannelSpec {
* Sometimes Empowers don't produce EmpowerEnd, mainly when cancelling the spell. To account for this
* we will also cancel the channel on next cast, begincast or if buff is removed(fire breath).
*
* Tipped Empowers don't produce a EmpowerStart event so we use this event to filter those out.
* TODO: change this comment
*
* @param spellId the guid for the tracked Cast and EmpowerStart/EmpowerEnd events.
*/
Expand All @@ -334,42 +337,43 @@ export function empowerChannelSpec(spellId: number): ChannelSpec {
eventIndex: number,
state: ChannelState,
) => {
if (
event.type === EventType.EmpowerStart ||
event.type === EventType.Cast ||
event.type === EventType.RemoveBuff
) {
// Tipped cast is instant cast so don't start a channel
if (event.type === EventType.Cast && !isFromTipTheScales(event)) {
// do standard start channel stuff
cancelCurrentChannel(event, state);
if (event.type === EventType.EmpowerStart) {
beginEmpowerCurrentChannel(event, state);
beginCurrentChannel(event, state);

// If we know the end event use that
const potentiallyEmpowerEnd = getEmpowerEndEvent(event);
if (potentiallyEmpowerEnd) {
endCurrentChannel(potentiallyEmpowerEnd, state);
return {
handler,
guids,
};
}
// now scan ahead for the matched empowerend, cast or begincast and end the channel at it

// now scan ahead for the matched empowerend, cancel channel on all other casts
// This is mainly used as fallback incase our normalizer failed to find the empowerEnd event
// or to confirm the empower was cancelled
for (let idx = eventIndex + 1; idx < events.length; idx += 1) {
const laterEvent = events[idx];
if (
// Empower finished
HasAbility(laterEvent) &&
laterEvent.ability.guid === spellId &&
laterEvent.type === EventType.EmpowerEnd
) {
endCurrentChannel(laterEvent, state);
break;
} else if (
laterEvent.type === EventType.BeginCast ||
(laterEvent.type === EventType.Cast &&
isRealCast(laterEvent) &&
laterEvent.timestamp > event.timestamp &&
event.sourceID === playerInfo.playerId)
) {
endCurrentChannel(laterEvent, state);
break;
} else if (
HasAbility(laterEvent) &&
laterEvent.ability.guid === spellId &&
laterEvent.type === EventType.RemoveBuff &&
laterEvent.timestamp > event.timestamp
// Empower never finished
(laterEvent.type === EventType.BeginCast ||
laterEvent.type === EventType.EmpowerStart ||
(laterEvent.type === EventType.Cast && isRealCast(laterEvent))) &&
event.sourceID === laterEvent.sourceID
) {
endCurrentChannel(laterEvent, state);
cancelCurrentChannel(laterEvent, state);
break;
}
}
Expand Down

0 comments on commit f4154fe

Please sign in to comment.