From 1cbdb96a147a5805d767b4a18c9963a869abbe94 Mon Sep 17 00:00:00 2001 From: Vollmer Date: Mon, 25 Mar 2024 15:28:19 +0100 Subject: [PATCH] Implement Living Flames pre pull normalizer --- src/analysis/retail/evoker/shared/index.ts | 1 + .../LivingFlamePrePullNormalizer.ts | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/analysis/retail/evoker/shared/modules/normalizers/LivingFlamePrePullNormalizer.ts diff --git a/src/analysis/retail/evoker/shared/index.ts b/src/analysis/retail/evoker/shared/index.ts index 57573b3937f..ce771ae9342 100644 --- a/src/analysis/retail/evoker/shared/index.ts +++ b/src/analysis/retail/evoker/shared/index.ts @@ -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'; diff --git a/src/analysis/retail/evoker/shared/modules/normalizers/LivingFlamePrePullNormalizer.ts b/src/analysis/retail/evoker/shared/modules/normalizers/LivingFlamePrePullNormalizer.ts new file mode 100644 index 00000000000..8288b1941e7 --- /dev/null +++ b/src/analysis/retail/evoker/shared/modules/normalizers/LivingFlamePrePullNormalizer.ts @@ -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;