Skip to content

Commit

Permalink
Merge pull request #3646 from wowsims/apl
Browse files Browse the repository at this point in the history
Add APLValue for Cat Excess Energy
  • Loading branch information
jimmyt857 authored Sep 10, 2023
2 parents 8970bc7 + 03f907c commit c8a6efa
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 14 deletions.
5 changes: 4 additions & 1 deletion proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ message APLAction {
}
}

// NextIndex: 52
// NextIndex: 53
message APLValue {
oneof value {
// Operators
Expand Down Expand Up @@ -128,6 +128,7 @@ message APLValue {

// Class or Spec-specific values
APLValueTotemRemainingTime totem_remaining_time = 49;
APLValueCatExcessEnergy cat_excess_energy = 52;
}
}

Expand Down Expand Up @@ -400,4 +401,6 @@ message APLValueSequenceTimeToReady {

message APLValueTotemRemainingTime {
ShamanTotems.TotemType totem_type = 1;
}
message APLValueCatExcessEnergy {
}
69 changes: 69 additions & 0 deletions sim/druid/feral/apl_values.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package feral

import (
"time"

"github.com/wowsims/wotlk/sim/core"
"github.com/wowsims/wotlk/sim/core/proto"
)

func (cat *FeralDruid) NewAPLValue(rot *core.APLRotation, config *proto.APLValue) core.APLValue {
switch config.Value.(type) {
case *proto.APLValue_CatExcessEnergy:
return cat.newValueCatExcessEnergy(rot, config.GetCatExcessEnergy())
default:
return nil
}
}

type APLValueCatExcessEnergy struct {
core.DefaultAPLValueImpl
cat *FeralDruid
}

func (cat *FeralDruid) newValueCatExcessEnergy(rot *core.APLRotation, config *proto.APLValueCatExcessEnergy) core.APLValue {
return &APLValueCatExcessEnergy{
cat: cat,
}
}
func (value *APLValueCatExcessEnergy) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueCatExcessEnergy) GetFloat(sim *core.Simulation) float64 {
cat := value.cat
pendingPool := PoolingActions{}
pendingPool.create(4)

curCp := cat.ComboPoints()
simTimeRemain := sim.GetRemainingDuration()
rakeDot := cat.Rake.CurDot()
ripDot := cat.Rip.CurDot()
mangleRefreshPending := cat.bleedAura.IsActive() && cat.bleedAura.RemainingDuration(sim) < (simTimeRemain-time.Second)
endThresh := time.Second * 10

if ripDot.IsActive() && (ripDot.RemainingDuration(sim) < simTimeRemain-endThresh) && curCp == 5 {
ripCost := core.Ternary(cat.berserkExpectedAt(sim, ripDot.ExpiresAt()), cat.Rip.DefaultCast.Cost*0.5, cat.Rip.DefaultCast.Cost)
pendingPool.addAction(ripDot.ExpiresAt(), ripCost)
cat.ripRefreshPending = true
}
if rakeDot.IsActive() && (rakeDot.RemainingDuration(sim) < simTimeRemain-rakeDot.Duration) {
rakeCost := core.Ternary(cat.berserkExpectedAt(sim, rakeDot.ExpiresAt()), cat.Rake.DefaultCast.Cost*0.5, cat.Rake.DefaultCast.Cost)
pendingPool.addAction(rakeDot.ExpiresAt(), rakeCost)
}
if mangleRefreshPending {
mangleCost := core.Ternary(cat.berserkExpectedAt(sim, cat.bleedAura.ExpiresAt()), cat.MangleCat.DefaultCast.Cost*0.5, cat.MangleCat.DefaultCast.Cost)
pendingPool.addAction(cat.bleedAura.ExpiresAt(), mangleCost)
}
if cat.SavageRoarAura.IsActive() {
roarCost := core.Ternary(cat.berserkExpectedAt(sim, cat.SavageRoarAura.ExpiresAt()), cat.SavageRoar.DefaultCast.Cost*0.5, cat.SavageRoar.DefaultCast.Cost)
pendingPool.addAction(cat.SavageRoarAura.ExpiresAt(), roarCost)
}

pendingPool.sort()

floatingEnergy := pendingPool.calcFloatingEnergy(cat, sim)
return cat.CurrentEnergy() - floatingEnergy
}
func (value *APLValueCatExcessEnergy) String() string {
return "Cat Excess Energy()"
}
6 changes: 3 additions & 3 deletions sim/druid/feral/pooling_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func (pa *PoolingActions) sort() {
})
}

func (pa *PoolingActions) calcFloatingEnergy(currentTime time.Duration, tfExpectedBefore func(refreshTime time.Duration) bool) float64 {
func (pa *PoolingActions) calcFloatingEnergy(cat *FeralDruid, sim *core.Simulation) float64 {
floatingEnergy := 0.0
previousTime := currentTime
previousTime := sim.CurrentTime
tfPending := false

for _, s := range pa.actions {
delta_t := float64((s.refreshTime - previousTime) / core.EnergyTickDuration)
if !tfPending {
tfPending = tfExpectedBefore(s.refreshTime)
tfPending = cat.tfExpectedBefore(sim, s.refreshTime)
if tfPending {
s.cost -= 60
}
Expand Down
9 changes: 2 additions & 7 deletions sim/druid/feral/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,8 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {
pendingPool.addAction(ripDot.ExpiresAt(), ripCost)
cat.ripRefreshPending = true
}
if rakeDot.IsActive() && (rakeDot.RemainingDuration(sim) < simTimeRemain-rakeDot.Duration) {
if poolForRake && rakeDot.IsActive() && (rakeDot.RemainingDuration(sim) < simTimeRemain-rakeDot.Duration) {
rakeCost := core.Ternary(cat.berserkExpectedAt(sim, rakeDot.ExpiresAt()), cat.Rake.DefaultCast.Cost*0.5, cat.Rake.DefaultCast.Cost)
if !poolForRake {
rakeCost = 0
}
pendingPool.addAction(rakeDot.ExpiresAt(), rakeCost)
}
if mangleRefreshPending {
Expand Down Expand Up @@ -550,9 +547,7 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {
flowershiftNow = flowerEnd+time.Duration(math.Floor(energyToDump/42)*float64(time.Second)) < sim.CurrentTime+simTimeRemain
}

floatingEnergy := pendingPool.calcFloatingEnergy(sim.CurrentTime, func(refreshTime time.Duration) bool {
return cat.tfExpectedBefore(sim, refreshTime)
})
floatingEnergy := pendingPool.calcFloatingEnergy(cat, sim)
excessE := curEnergy - floatingEnergy

timeToNextAction := time.Duration(0)
Expand Down
4 changes: 1 addition & 3 deletions sim/druid/feral/rotation_aoe.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ func (cat *FeralDruid) doAoeRotation(sim *core.Simulation) (bool, time.Duration)

pendingPool.sort()

floatingEnergy := pendingPool.calcFloatingEnergy(sim.CurrentTime, func(refreshTime time.Duration) bool {
return cat.tfExpectedBefore(sim, refreshTime)
})
floatingEnergy := pendingPool.calcFloatingEnergy(cat, sim)
excessE := curEnergy - floatingEnergy

timeToNextAction := time.Duration(0)
Expand Down
11 changes: 11 additions & 0 deletions ui/core/components/individual_sim_ui/apl_values.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Class,
Spec,
} from '../../proto/common.js';

import {
Expand Down Expand Up @@ -62,6 +63,7 @@ import {
APLValueNextRuneCooldown,
APLValueNumberTargets,
APLValueTotemRemainingTime,
APLValueCatExcessEnergy,
} from '../../proto/apl.js';

import { EventID } from '../../typed_event.js';
Expand Down Expand Up @@ -894,4 +896,13 @@ const valueKindFactories: {[f in NonNullable<APLValueKind>]: ValueKindConfig<APL
totemTypeFieldConfig('totemType'),
],
}),
'catExcessEnergy': inputBuilder({
label: 'Excess Energy',
submenu: ['Feral Druid'],
shortDescription: 'Returns the amount of excess energy available, after subtracting energy that will be needed to maintain DoTs.',
newValue: APLValueCatExcessEnergy.create,
includeIf: (player: Player<any>, isPrepull: boolean) => player.spec == Spec.SpecFeralDruid,
fields: [
],
}),
};

0 comments on commit c8a6efa

Please sign in to comment.