Skip to content

Commit

Permalink
Merge branch 'wowsims:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyzin1 authored Nov 13, 2023
2 parents 5cb836f + 5416524 commit 31473e1
Show file tree
Hide file tree
Showing 42 changed files with 1,993 additions and 602 deletions.
1 change: 1 addition & 0 deletions proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ message SpellStats {
bool has_shield = 6; // Whether this spell applies a shield effect.
bool prepull_only = 5; // Whether this spell may only be cast during prepull.
bool encounter_only = 8; // Whether this spell may only be cast during the encounter (not prepull).
bool has_cast_time = 9; // Whether this spell has a cast time or not.
}
message APLActionStats {
repeated string warnings = 1;
Expand Down
16 changes: 15 additions & 1 deletion proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ message APLAction {
}
}

// NextIndex: 64
// NextIndex: 66
message APLValue {
oneof value {
// Operators
Expand All @@ -97,6 +97,10 @@ message APLValue {
APLValueIsExecutePhase is_execute_phase = 41;
APLValueNumberTargets number_targets = 28;

// Boss values
APLValueBossSpellTimeToReady boss_spell_time_to_ready = 64;
APLValueBossSpellIsCasting boss_spell_is_casting = 65;

// Resource values
APLValueCurrentHealth current_health = 26;
APLValueCurrentHealthPercent current_health_percent = 27;
Expand Down Expand Up @@ -321,6 +325,16 @@ message APLValueIsExecutePhase {
ExecutePhaseThreshold threshold = 1;
}

message APLValueBossSpellTimeToReady {
UnitReference target_unit = 1;
ActionID spell_id = 2;
}

message APLValueBossSpellIsCasting {
UnitReference target_unit = 1;
ActionID spell_id = 2;
}

message APLValueCurrentHealth {
UnitReference source_unit = 1;
}
Expand Down
11 changes: 11 additions & 0 deletions sim/core/apl_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ func (rot *APLRotation) GetAPLSpell(spellId *proto.ActionID) *Spell {
return spell
}

func (rot *APLRotation) GetTargetAPLSpell(spellId *proto.ActionID, targetUnit UnitReference) *Spell {
actionID := ProtoToActionID(spellId)
target := targetUnit.Get()
spell := target.GetSpell(actionID)

if spell == nil {
rot.ValidationWarning("%s does not know spell %s", target.Label, actionID)
}
return spell
}

func (rot *APLRotation) GetAPLDot(targetUnit UnitReference, spellId *proto.ActionID) *Dot {
spell := rot.GetAPLSpell(spellId)

Expand Down
6 changes: 6 additions & 0 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
case *proto.APLValue_NumberTargets:
return rot.newValueNumberTargets(config.GetNumberTargets())

// Boss
case *proto.APLValue_BossSpellIsCasting:
return rot.newValueBossSpellIsCasting(config.GetBossSpellIsCasting())
case *proto.APLValue_BossSpellTimeToReady:
return rot.newValueBossSpellTimeToReady(config.GetBossSpellTimeToReady())

// Resources
case *proto.APLValue_CurrentHealth:
return rot.newValueCurrentHealth(config.GetCurrentHealth())
Expand Down
56 changes: 56 additions & 0 deletions sim/core/apl_values_boss.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package core

import (
"fmt"
"time"

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

type APLValueBossSpellIsCasting struct {
DefaultAPLValueImpl
spell *Spell
}

func (rot *APLRotation) newValueBossSpellIsCasting(config *proto.APLValueBossSpellIsCasting) APLValue {
spell := rot.GetTargetAPLSpell(config.SpellId, rot.GetTargetUnit(config.TargetUnit))
if spell == nil {
return nil
}
return &APLValueBossSpellIsCasting{
spell: spell,
}
}
func (value *APLValueBossSpellIsCasting) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeBool
}
func (value *APLValueBossSpellIsCasting) GetBool(sim *Simulation) bool {
return value.spell.Unit.Hardcast.ActionID == value.spell.ActionID && value.spell.Unit.Hardcast.Expires > sim.CurrentTime
}
func (value *APLValueBossSpellIsCasting) String() string {
return fmt.Sprintf("Boss is Casting(%s)", value.spell.ActionID)
}

type APLValueBossSpellTimeToReady struct {
DefaultAPLValueImpl
spell *Spell
}

func (rot *APLRotation) newValueBossSpellTimeToReady(config *proto.APLValueBossSpellTimeToReady) APLValue {
spell := rot.GetTargetAPLSpell(config.SpellId, rot.GetTargetUnit(config.TargetUnit))
if spell == nil {
return nil
}
return &APLValueBossSpellTimeToReady{
spell: spell,
}
}
func (value *APLValueBossSpellTimeToReady) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueBossSpellTimeToReady) GetDuration(sim *Simulation) time.Duration {
return value.spell.TimeToReady(sim)
}
func (value *APLValueBossSpellTimeToReady) String() string {
return fmt.Sprintf("Boss Spell Time to Ready(%s)", value.spell.ActionID)
}
8 changes: 8 additions & 0 deletions sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ func (character *Character) Finalize() {

character.Unit.finalize()

// For now, restrict this optimization to rogues only. Ferals will require
// some extra logic to handle their ExcessEnergy() calc.
if character.Class == proto.Class_ClassRogue {
character.Env.RegisterPostFinalizeEffect(func() {
character.energyBar.setupEnergyThresholds()
})
}

character.majorCooldownManager.finalize()
character.ItemSwap.finalize()
}
Expand Down
12 changes: 2 additions & 10 deletions sim/core/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,6 @@ func (unit *Unit) finalize() {
for _, spell := range unit.Spellbook {
spell.finalize()
}

// For now, restrict this optimization to rogues only. Ferals will require
// some extra logic to handle their ExcessEnergy() calc.
agent := unit.Env.Raid.GetPlayerFromUnit(unit)
if agent != nil && agent.GetCharacter().Class == proto.Class_ClassRogue {
unit.Env.RegisterPostFinalizeEffect(func() {
unit.energyBar.setupEnergyThresholds()
})
}
}

func (unit *Unit) reset(sim *Simulation, _ Agent) {
Expand Down Expand Up @@ -545,6 +536,7 @@ func (unit *Unit) GetMetadata() *proto.UnitMetadata {
HasShield: spell.shields != nil || spell.selfShield != nil,
PrepullOnly: spell.Flags.Matches(SpellFlagPrepullOnly),
EncounterOnly: spell.Flags.Matches(SpellFlagEncounterOnly),
HasCastTime: spell.DefaultCast.CastTime > 0,
}
})

Expand All @@ -563,7 +555,7 @@ func (unit *Unit) GetMetadata() *proto.UnitMetadata {
return metadata
}

func (unit *Unit) StartAPLLoop(sim *Simulation) {
func (unit *Unit) StartAPLLoop(_ *Simulation) {
if unit.HasManaBar() {
unit.ManaRequired = 0
}
Expand Down
Loading

0 comments on commit 31473e1

Please sign in to comment.