Skip to content

Commit

Permalink
fix(priest): fix various bugs with shadow priest script
Browse files Browse the repository at this point in the history
Imported insanity values were 100 times higher than expected.
Allow to break a channeling spell.
Fix bug with spells that are cast during channeling.

Fixes #732
  • Loading branch information
Sidoine committed Dec 14, 2020
1 parent ebfbd76 commit 523377a
Show file tree
Hide file tree
Showing 19 changed files with 242 additions and 402 deletions.
10 changes: 3 additions & 7 deletions src/engine/best-action.ts
@@ -1,7 +1,6 @@
import { OvaleActionBarClass } from "./action-bar";
import { OvaleDataClass } from "./data";
import { OvaleEquipmentClass, SlotName } from "../states/Equipment";
import { OvaleStateClass } from "./state";
import aceEvent, { AceEvent } from "@wowts/ace_event-3.0";
import { pairs, tonumber } from "@wowts/lua";
import {
Expand Down Expand Up @@ -58,7 +57,6 @@ export class OvaleBestActionClass {
private ovaleActionBar: OvaleActionBarClass,
private ovaleData: OvaleDataClass,
private ovaleCooldown: OvaleCooldownClass,
private ovaleState: OvaleStateClass,
Ovale: OvaleClass,
private OvaleGUID: OvaleGUIDClass,
private OvalePower: OvalePowerClass,
Expand Down Expand Up @@ -127,7 +125,7 @@ export class OvaleBestActionClass {
result.actionType = "item";
result.actionId = itemId;
result.actionTarget = target;
result.castTime = this.OvaleFuture.GetGCD(undefined, atTime);
result.castTime = this.OvaleFuture.GetGCD(atTime);
this.profiler.StopProfiling("OvaleBestAction_GetActionItemInfo");
return result;
};
Expand Down Expand Up @@ -161,7 +159,7 @@ export class OvaleBestActionClass {
result.actionIsCurrent = IsCurrentAction(action);
result.actionType = "macro";
result.actionId = macro;
result.castTime = this.OvaleFuture.GetGCD(undefined, atTime);
result.castTime = this.OvaleFuture.GetGCD(atTime);
this.profiler.StopProfiling("OvaleBestAction_GetActionMacroInfo");
return result;
};
Expand Down Expand Up @@ -392,7 +390,7 @@ export class OvaleBestActionClass {
result.actionIsCurrent = false;
result.actionType = "texture";
result.actionId = actionTexture;
result.castTime = this.OvaleFuture.GetGCD(undefined, atTime);
result.castTime = this.OvaleFuture.GetGCD(atTime);

this.profiler.StopProfiling("OvaleBestAction_GetActionTextureInfo");
return result;
Expand All @@ -403,8 +401,6 @@ export class OvaleBestActionClass {
};

public StartNewAction() {
this.ovaleState.ResetState();
this.OvaleFuture.ApplyInFlightSpells();
this.runner.refresh();
}

Expand Down
6 changes: 2 additions & 4 deletions src/engine/condition.ts
Expand Up @@ -219,9 +219,7 @@ export class OvaleConditionClass {
(positionalParams[infos.targetIndex] === "target" ||
positionalParams[infos.targetIndex] === "cycle")
) {
positionalParams[
infos.targetIndex
] = this.baseState.next.defaultTarget;
positionalParams[infos.targetIndex] = this.baseState.defaultTarget;
}
return infos.func(atTime, ...unpack(positionalParams));
}
Expand Down Expand Up @@ -269,7 +267,7 @@ export function ParseCondition(
namedParams.target = namedParams.target || target;

if (target === "cycle" || target === "target") {
target = baseState.next.defaultTarget;
target = baseState.defaultTarget;
}
let filter: AuraType | undefined;
if (namedParams.filter) {
Expand Down
49 changes: 2 additions & 47 deletions src/engine/runner.ts
Expand Up @@ -275,7 +275,7 @@ export class Runner {
} else {
const target =
(isString(namedParameters.target) && namedParameters.target) ||
this.baseState.next.defaultTarget;
this.baseState.defaultTarget;
const result = this.actionHandlers[element.name](
element,
atTime,
Expand Down Expand Up @@ -432,52 +432,7 @@ export class Runner {
nodeId,
action
);

// TODO
// let newStart = atTime;
// if (this.OvaleFuture.IsChanneling(atTime)) {
// let spell = this.OvaleFuture.GetCurrentCast(atTime);
// if (spell) {
// let si =
// spell.spellId &&
// this.ovaleData.spellInfo[spell.spellId];
// if (si) {
// let channel = si.channel || si.canStopChannelling;
// if (channel) {
// let hasteMultiplier = this.ovalePaperDoll.GetHasteMultiplier(
// si.haste,
// this.ovalePaperDoll.next
// );
// let numTicks = floor(
// channel * hasteMultiplier + 0.5
// );
// let tick =
// (spell.stop - spell.start) / numTicks;
// let tickTime = spell.start;
// for (let i = 1; i <= numTicks; i += 1) {
// tickTime = tickTime + tick;
// if (newStart <= tickTime) {
// break;
// }
// }
// newStart = tickTime;
// this.tracer.Log(
// "[%d] %s start=%f, numTicks=%d, tick=%f, tickTime=%f",
// nodeId,
// spell.spellId,
// newStart,
// numTicks,
// tick,
// tickTime
// );
// }
// }
// }
// }
// if (start < newStart) {
// start = newStart;
// }
// start = atTime;
start = atTime;
}
this.tracer.Log(
"[%d] Action %s can start at %f.",
Expand Down
16 changes: 16 additions & 0 deletions src/engine/state.ts
Expand Up @@ -12,8 +12,24 @@ export type SpellCastEventHandler = (

export interface StateModule {
CleanState(): void;

/** Called each time the script is executed.
* Should clear the values that computes the engine state
* TODO: I don't see the point of this method, it should be removed
* and its code should be in ResetState
*/
InitializeState(): void;

/** Called after InitializeState and after any script
* recompilation. Anything that depends on the script should
* be done instead of InitializeState
*/
ResetState(): void;

/**
* These three methods are called after ResetState for each spell cast that
* is in flight or that currently cast
*/
ApplySpellStartCast?: SpellCastEventHandler;
ApplySpellAfterCast?: SpellCastEventHandler;
ApplySpellOnHit?: SpellCastEventHandler;
Expand Down
2 changes: 0 additions & 2 deletions src/ioc.ts
Expand Up @@ -270,7 +270,6 @@ export class IoC {
this.ovale,
this.profiler,
this.data,
this.future,
this.baseState,
this.paperDoll,
this.spellBook,
Expand Down Expand Up @@ -353,7 +352,6 @@ export class IoC {
this.actionBar,
this.data,
this.cooldown,
this.state,
this.ovale,
this.guid,
this.power,
Expand Down
12 changes: 6 additions & 6 deletions src/scripts/ovale_priest_spells.ts
Expand Up @@ -52,7 +52,7 @@ Define(dark_thought 341207)
SpellAddBuff(dark_thought dark_thought add=1)
Define(devouring_plague 335467)
# Afflicts the target with a disease that instantly causes (65 of Spell Power) Shadow damage plus an additional o2 Shadow damage over 6 seconds. Heals you for e2*100 of damage dealt.rnrnIf this effect is reapplied, any remaining damage will be added to the new Devouring Plague.
SpellInfo(devouring_plague insanity=5000 duration=6 tick=3)
SpellInfo(devouring_plague insanity=50 duration=6 tick=3)
# Suffering s2 damage every t2 sec.
SpellAddTargetDebuff(devouring_plague devouring_plague add=1)
Define(divine_star 110744)
Expand Down Expand Up @@ -158,7 +158,7 @@ Define(schism 214621)
SpellAddTargetDebuff(schism schism add=1)
Define(searing_nightmare 341385)
# Instantly deals (43 of Spell Power) Shadow damage to enemies around the target and afflicts them with Shadow Word: Pain. If the enemy is already afflicted by your Shadow Word: Pain, Searing Nightmare's damage is increased by m1.rnrnOnly usable while channeling Mind Sear.
SpellInfo(searing_nightmare insanity=3000)
SpellInfo(searing_nightmare insanity=30)
SpellRequire(searing_nightmare unusable set=1 enabled=(not hastalent(searing_nightmare_talent)))
Define(shadow_covenant 314867)
# Make a shadowy pact, healing the target and s3-1 other injured allies within A2 yds for (150 of Spell Power). For 9 seconds, your Shadow spells deal 322105m2 increased damage and healing, but you cannot cast Holy spells.
Expand All @@ -171,7 +171,7 @@ Define(shadow_covenant_buff 322105)
SpellInfo(shadow_covenant_buff duration=9 gcd=0 offgcd=1)
Define(shadow_crash 342834)
# Hurl a bolt of slow-moving Shadow energy at the destination, dealing (85 of Spell Power) Shadow damage to all targets within 205386A1 yards.rnrnIf Shadow Crash hits a lone target, they suffer 342835m2 increased damage from your next Shadow Crash within 15 seconds. Stacks up to 342835u.rnrn|cFFFFFFFFGenerates /100;s2 Insanity.|r
SpellInfo(shadow_crash cd=45 insanity=-800)
SpellInfo(shadow_crash cd=45 insanity=-8)
SpellRequire(shadow_crash unusable set=1 enabled=(not hastalent(shadow_crash_talent)))
# Damage taken from the Priests' Shadow Crash increased by w2.
SpellAddTargetDebuff(shadow_crash shadow_crash_debuff add=1)
Expand All @@ -183,7 +183,7 @@ Define(shadow_word_death 32379)
SpellInfo(shadow_word_death cd=30)
Define(shadow_word_pain 589)
# A word of darkness that causes (12.920000000000002 of Spell Power) Shadow damage instantly, and an additional o2 Shadow damage over 12 seconds.?a185916[rnrn|cFFFFFFFFGenerates m3/100 Insanity.|r][]
SpellInfo(shadow_word_pain duration=12 insanity=-400 tick=2)
SpellInfo(shadow_word_pain duration=12 insanity=-4 tick=2)
# Suffering w2 Shadow damage every t2 sec.
SpellAddTargetDebuff(shadow_word_pain shadow_word_pain add=1)
Define(shadowfiend 34433)
Expand Down Expand Up @@ -223,12 +223,12 @@ Define(unfurling_darkness 341291)
SpellInfo(unfurling_darkness duration=15 gcd=0 offgcd=1)
Define(vampiric_touch 34914)
# A touch of darkness that causes 34914o2 Shadow damage over 21 seconds, and heals you for e2*100 of damage dealt.rn?s322116[rnIf Vampiric Touch is dispelled, the dispeller flees in Horror for 3 seconds.rn][]rn|cFFFFFFFFGenerates m3/100 Insanity.|r
SpellInfo(vampiric_touch duration=21 insanity=-500 tick=3)
SpellInfo(vampiric_touch duration=21 insanity=-5 tick=3)
# Suffering w2 Shadow damage every t2 sec.
SpellAddTargetDebuff(vampiric_touch vampiric_touch add=1)
Define(void_bolt 205448)
# Sends a bolt of pure void energy at the enemy, causing (81.6 of Spell Power) Shadow damage?s193225[, refreshing the duration of Devouring Plague on the target][]?a231688[ and extending the duration of Shadow Word: Pain and Vampiric Touch on all nearby targets by <ext> sec][]. rnrnRequires Voidform.rnrn|cFFFFFFFFGenerates /100;s3 Insanity.|r
SpellInfo(void_bolt cd=4.5 insanity=-1200)
SpellInfo(void_bolt cd=4.5 insanity=-12)
Define(void_eruption 228260)
# Releases an explosive blast of pure void energy, activating Voidform and causing (64.60000000000001 of Spell Power)*2 Shadow damage to all enemies within a1 yds of your target.rnrnDuring Voidform, this ability is replaced by Void Bolt.
SpellInfo(void_eruption cd=90)
Expand Down
7 changes: 4 additions & 3 deletions src/states/Aura.ts
Expand Up @@ -10,7 +10,7 @@ import {
} from "../engine/data";
import { OvaleGUIDClass } from "../engine/guid";
import { OvaleSpellBookClass } from "./SpellBook";
import { OvaleStateClass, States } from "../engine/state";
import { OvaleStateClass, StateModule, States } from "../engine/state";
import { OvaleClass } from "../Ovale";
import { LastSpell, SpellCast, PaperDollSnapshot } from "./LastSpell";
import aceEvent, { AceEvent } from "@wowts/ace_event-3.0";
Expand Down Expand Up @@ -325,7 +325,9 @@ let stacks: number;
let startChangeCount, endingChangeCount: number;
let startFirst: number, endingLast: number;

export class OvaleAuraClass extends States<AuraInterface> {
export class OvaleAuraClass
extends States<AuraInterface>
implements StateModule {
private debug: Tracer;
private module: AceModule & AceEvent;
private profiler: Profiler;
Expand Down Expand Up @@ -754,7 +756,6 @@ export class OvaleAuraClass extends States<AuraInterface> {

IsActiveAura(aura: Aura, atTime: number): aura is Aura {
let boolean = false;
atTime = atTime || this.baseState.next.currentTime;
if (aura.state) {
if (
aura.serial == this.next.auraSerial &&
Expand Down
22 changes: 8 additions & 14 deletions src/states/BaseState.ts
@@ -1,24 +1,18 @@
import { StateModule, States } from "../engine/state";
import { StateModule } from "../engine/state";
import { GetTime } from "@wowts/wow-mock";

class BaseStateData {
currentTime = 0;
export class BaseState implements StateModule {
/** The default target for the current icon. */
defaultTarget = "target";
}

export class BaseState extends States<BaseStateData> implements StateModule {
constructor() {
super(BaseStateData);
}
/** Cached value of GetTime(), the real current time */
currentTime = 0;

InitializeState() {
this.next.defaultTarget = "target";
}
InitializeState() {}

ResetState() {
const now = GetTime();
this.next.currentTime = now;
this.next.defaultTarget = this.current.defaultTarget;
this.currentTime = GetTime();
this.defaultTarget = "target";
}

CleanState() {}
Expand Down
8 changes: 4 additions & 4 deletions src/states/Cooldown.ts
Expand Up @@ -4,7 +4,7 @@ import { LastSpell, SpellCast, SpellCastModule } from "./LastSpell";
import aceEvent, { AceEvent } from "@wowts/ace_event-3.0";
import { next, pairs, LuaObj, kpairs } from "@wowts/lua";
import { GetSpellCooldown, GetTime, GetSpellCharges } from "@wowts/wow-mock";
import { States } from "../engine/state";
import { StateModule, States } from "../engine/state";
import { OvalePaperDollClass, HasteType } from "./PaperDoll";
import { LuaArray } from "@wowts/lua";
import { AceModule } from "@wowts/tsaddon";
Expand Down Expand Up @@ -90,7 +90,7 @@ export class CooldownData {

export class OvaleCooldownClass
extends States<CooldownData>
implements SpellCastModule {
implements SpellCastModule, StateModule {
serial = 0;
sharedCooldown: LuaObj<LuaArray<boolean>> = {};
gcd = {
Expand Down Expand Up @@ -227,7 +227,7 @@ export class OvaleCooldownClass
duration,
enable
);
if (start && start > 0) {
if (start !== undefined && start > 0) {
const [gcdStart, gcdDuration] = this.GetGlobalCooldown();
this.tracer.Log(
"GlobalCooldown is %d, %d",
Expand Down Expand Up @@ -385,7 +385,7 @@ export class OvaleCooldownClass
"cd",
targetGUID
);
if (duration) {
if (duration !== undefined) {
if (duration < 0) {
duration = 0;
}
Expand Down

0 comments on commit 523377a

Please sign in to comment.