Skip to content

Commit

Permalink
Implement Living Flames pre pull normalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Mar 25, 2024
1 parent 14e371d commit 1cbdb96
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/analysis/retail/evoker/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {
getWastedEssenceBurst,
} from './modules/normalizers/LeapingFlamesNormalizer';
export { default as LeapingFlames } from './modules/talents/LeapingFlames';
export { default as LivingFlamePrePullNormalizer } from './modules/normalizers/LivingFlamePrePullNormalizer';
export { default as SpellEssenceCost } from './modules/core/essence/SpellEssenceCost';
export { default as EssenceTracker } from './modules/core/essence/EssenceTracker';
export { default as EssenceGraph } from './modules/core/essence/EssenceGraph';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import SPELLS from 'common/SPELLS/evoker';
import { AnyEvent, BeginCastEvent, EventType } from 'parser/core/Events';
import EventsNormalizer from 'parser/core/EventsNormalizer';
import Haste from 'parser/shared/modules/Haste';
import { isRealCast } from 'parser/shared/normalizers/Channeling';

/**
* Living flame is a very common pre-pull cast
* however it often occurs that you'll start channeling it pre-pull and only
* the cast success event (PrePullNormalizer doesn't account for this since we don't have a way to define instant cast spells)
* will trigger, this messes with how we handle GCDs and makes for a messy timeline.
*
* This normalizer aims to correct those situation */
class LivingFlamePrePullNormalizer extends EventsNormalizer {
static dependencies = {
...EventsNormalizer.dependencies,
haste: Haste,
};
protected haste!: Haste;
normalize(events: AnyEvent[]) {
const fixedEvents: AnyEvent[] = [];
let foundBegin = false;

events.forEach((event) => {
if (foundBegin) {
fixedEvents.push(event);
return;
}

if (
(event.type === EventType.BeginCast ||
event.type === EventType.EmpowerStart ||
event.type === EventType.EmpowerEnd ||
(event.type === EventType.Cast && isRealCast(event))) &&
event.sourceID === this.owner.selectedCombatant.id
) {
// First cast found is not living flame or it was a beginCast living flame
if (event.type !== EventType.Cast || event.ability.guid !== SPELLS.LIVING_FLAME_CAST.id) {
foundBegin = true;
fixedEvents.push(event);
return;
}

// Start the pre-pull normalizing
const startTime = event.timestamp - 1500 / (1 + this.haste.current);

const beginCastEvent: BeginCastEvent = {
ability: event.ability,
type: EventType.BeginCast,
timestamp: startTime,
castEvent: event,
channel: {
type: EventType.BeginChannel,
timestamp: startTime,
ability: event.ability,
sourceID: event.sourceID,
isCancelled: false,
},
isCancelled: false,
sourceID: event.sourceID,
sourceIsFriendly: event.sourceIsFriendly,
target: event.target ?? {
name: 'Environment',
id: -1,
guid: 0,
type: 'NPC',
icon: 'NPC',
},
targetIsFriendly: event.targetIsFriendly,
__fabricated: true,
prepull: true,
};
fixedEvents.push(beginCastEvent);
fixedEvents.push(event);
return;
}

fixedEvents.push(event);
});
return fixedEvents;
}
}
export default LivingFlamePrePullNormalizer;

0 comments on commit 1cbdb96

Please sign in to comment.