Skip to content

Commit

Permalink
fix PI for locks
Browse files Browse the repository at this point in the history
  • Loading branch information
lime-green committed Oct 2, 2023
1 parent ba92548 commit 99f858a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
8 changes: 6 additions & 2 deletions sim/core/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package core
import (
"fmt"
"golang.org/x/exp/constraints"
"log"
"math"
"strconv"
"time"
Expand Down Expand Up @@ -440,6 +441,9 @@ func (at *auraTracker) NumActiveAurasWithTag(tag string) int32 {
return count
}
func (at *auraTracker) HasActiveAuraWithTag(tag string) bool {
if tag == "Bloodlust" {
log.Println(at.aurasByTag[tag])
}
for _, aura := range at.aurasByTag[tag] {
if aura.active {
return true
Expand Down Expand Up @@ -645,9 +649,9 @@ func (aura *Aura) Deactivate(sim *Simulation) {

if !aura.ActionID.IsEmptyAction() {
if sim.CurrentTime > aura.expires {
aura.metrics.Uptime += aura.expires - aura.startTime
aura.metrics.Uptime += aura.expires - MaxDuration(aura.startTime, 0)
} else {
aura.metrics.Uptime += sim.CurrentTime - aura.startTime
aura.metrics.Uptime += sim.CurrentTime - MaxDuration(aura.startTime, 0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion sim/warlock/TestDemonology.results
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ dps_results: {
dps_results: {
key: "TestDemonology-Settings-Orc-P2-Demonology Warlock--FullBuffs-ShortSingleTarget"
value: {
dps: 12436.88976
dps: 12437.18825
tps: 10461.28742
}
}
Expand Down
46 changes: 24 additions & 22 deletions sim/warlock/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ func (warlock *Warlock) setupCooldowns(sim *core.Simulation) {
}

// TODO: find a way of getting the duration directly from the spell instead
durMap := make(map[core.ActionID]time.Duration)
durMap := make(map[int32]time.Duration)
if warlock.MetamorphosisAura != nil {
durMap[core.ActionID{SpellID: 47241}] = warlock.MetamorphosisAura.Duration
}
durMap[core.ActionID{SpellID: 33697}] = 15 * time.Second
durMap[core.ActionID{SpellID: 54758}] = 12 * time.Second
durMap[core.ActionID{SpellID: 10060}] = 15 * time.Second
durMap[core.ActionID{ItemID: 40211}] = 15 * time.Second
durMap[core.ActionID{ItemID: 40212}] = 15 * time.Second
durMap[core.ActionID{ItemID: 45466}] = 20 * time.Second
durMap[core.ActionID{ItemID: 45148}] = 20 * time.Second
durMap[core.ActionID{ItemID: 37873}] = 20 * time.Second

ignoredCDs := make(map[core.ActionID]struct{})
ignoredCDs[core.ActionID{ItemID: 42641}] = struct{}{} // sapper
ignoredCDs[core.ActionID{ItemID: 41119}] = struct{}{} // saronite bomb
ignoredCDs[core.ActionID{ItemID: 40536}] = struct{}{} // explosive decoy
ignoredCDs[core.BloodlustActionID.WithTag(-1)] = struct{}{} // don't mess with BL
durMap[47241] = warlock.MetamorphosisAura.Duration
}
durMap[33697] = 15 * time.Second
durMap[54758] = 12 * time.Second
durMap[10060] = 15 * time.Second
durMap[40211] = 15 * time.Second
durMap[40212] = 15 * time.Second
durMap[45466] = 20 * time.Second
durMap[45148] = 20 * time.Second
durMap[37873] = 20 * time.Second

ignoredCDs := make(map[int32]struct{})
ignoredCDs[42641] = struct{}{} // sapper
ignoredCDs[41119] = struct{}{} // saronite bomb
ignoredCDs[40536] = struct{}{} // explosive decoy
ignoredCDs[core.BloodlustActionID.SpellID] = struct{}{} // don't mess with BL
if warlock.Inferno != nil {
ignoredCDs[warlock.Inferno.ActionID] = struct{}{}
ignoredCDs[warlock.Inferno.ActionID.SpellID] = struct{}{}
}

var executeActive func() bool
Expand All @@ -59,18 +59,20 @@ func (warlock *Warlock) setupCooldowns(sim *core.Simulation) {
}

lustCD := warlock.GetMajorCooldownIgnoreTag(core.BloodlustActionID)

for _, cd := range warlock.GetMajorCooldowns() {
if _, ignored := ignoredCDs[cd.Spell.ActionID]; ignored {
if _, ignored := ignoredCDs[cd.Spell.ActionID.SpellID]; ignored {
continue
}

spellCD := core.MaxDuration(cd.Spell.CD.Duration, cd.Spell.SharedCD.Duration)
runTime := time.Duration(float64(durMap[cd.Spell.ActionID]) * 0.75)
runTime := time.Duration(float64(durMap[cd.Spell.ActionID.SpellID]) * 0.75)
spell := cd.Spell

cd.ShouldActivate = func(sim *core.Simulation, character *core.Character) bool {
timeLeft := sim.GetRemainingDuration() - runTime
timeUntilExecute := core.MaxDuration(0, executePhase-sim.CurrentTime)
lustIsActive := lustCD != nil && character.HasActiveAura("Bloodlust-"+lustCD.Spell.ActionID.String())

// if time until execute is less than the CD AND remaining time minus time till execute gives
// the same amount of uses as remaining time alone then delay
Expand All @@ -87,14 +89,14 @@ func (warlock *Warlock) setupCooldowns(sim *core.Simulation) {
}
}

if lustCD != nil && !character.HasActiveAuraWithTag(core.BloodlustAuraTag) &&
if lustCD != nil && !lustIsActive &&
lustCD.TimeToNextCast(sim) < spellCD+runTime && retainUses(timeLeft, spellCD,
lustCD.TimeToNextCast(sim)) {
return false
}

if spell.ActionID.SameActionIgnoreTag(core.PowerInfusionActionID) &&
(character.HasActiveAuraWithTag(core.BloodlustAuraTag) || (lustCD != nil && lustCD.TimeToNextCast(sim) < runTime)) {
(lustIsActive || (lustCD != nil && lustCD.TimeToNextCast(sim) < runTime)) {
return false // don't use PI while lust is active or it would overlap
}

Expand Down
4 changes: 3 additions & 1 deletion ui/warlock/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Debuffs,
TristateEffect,
Faction,
Spec,
Spec, Profession,
} from '../core/proto/common.js';
import { SavedRotation, SavedTalents } from '../core/proto/ui.js';
import { Player } from '../core/player.js';
Expand Down Expand Up @@ -188,6 +188,8 @@ export const DestroDebuffs = Debuffs.create({

export const OtherDefaults = {
distanceFromTarget: 25,
profession1: Profession.Engineering,
profession2: Profession.Tailoring,
};

export const SWP_BIS = {
Expand Down

0 comments on commit 99f858a

Please sign in to comment.