Skip to content

Commit

Permalink
Merge pull request #3757 from wowsims/apl
Browse files Browse the repository at this point in the history
Add Max Ticks option to channel action, and tiny improvement to sprie…
  • Loading branch information
jimmyt857 authored Sep 26, 2023
2 parents 58d78fd + 9ed31e8 commit c110da2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ message APLActionChannelSpell {
UnitReference target = 2;

APLValue interrupt_if = 3;
APLValue max_ticks = 4;
}

message APLActionMultidot {
Expand Down
12 changes: 9 additions & 3 deletions sim/core/apl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type APLRotation struct {
// Will be nil when there is no active channel.
interruptChannelIf APLValue

// Max ticks for the current channel, or 0 for no maximum.
channelMaxTicks int32

// Used inside of actions/value to determine whether they will occur during the prepull or regular rotation.
parsingPrepull bool

Expand Down Expand Up @@ -149,6 +152,8 @@ func (rot *APLRotation) allPrepullActions() []*APLAction {
func (rot *APLRotation) reset(sim *Simulation) {
rot.controllingAction = nil
rot.inLoop = false
rot.interruptChannelIf = nil
rot.channelMaxTicks = 0
for _, action := range rot.allAPLActions() {
action.impl.Reset(sim)
}
Expand Down Expand Up @@ -208,10 +213,11 @@ func (apl *APLRotation) shouldInterruptChannel(sim *Simulation) bool {
// Channel has ended, but apl.unit.ChanneledDot hasn't been cleared yet meaning the aura is still active.
return false
}
if apl.unit.ChanneledDot.lastTickTime != sim.CurrentTime {
// Don't allow interupts between ticks, just continue channeling until next tick.
return false

if apl.channelMaxTicks != 0 && channeledDot.TickCount >= apl.channelMaxTicks {
return true
}

if apl.interruptChannelIf == nil || !apl.interruptChannelIf.GetBool(sim) {
// Continue the channel.
return false
Expand Down
9 changes: 9 additions & 0 deletions sim/core/apl_actions_casting.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type APLActionChannelSpell struct {
spell *Spell
target UnitReference
interruptIf APLValue
maxTicks APLValue
}

func (rot *APLRotation) newActionChannelSpell(config *proto.APLActionChannelSpell) APLActionImpl {
Expand All @@ -52,6 +53,8 @@ func (rot *APLRotation) newActionChannelSpell(config *proto.APLActionChannelSpel
})
}

maxTicks := rot.coerceTo(rot.newAPLValue(config.MaxTicks), proto.APLValueType_ValueTypeInt)

spell := rot.GetAPLSpell(config.SpellId)
if spell == nil {
return nil
Expand All @@ -69,14 +72,20 @@ func (rot *APLRotation) newActionChannelSpell(config *proto.APLActionChannelSpel
spell: spell,
target: target,
interruptIf: interruptIf,
maxTicks: maxTicks,
}
}
func (action *APLActionChannelSpell) IsReady(sim *Simulation) bool {
return action.spell.CanCast(sim, action.target.Get())
}
func (action *APLActionChannelSpell) Execute(sim *Simulation) {
maxTicks := int32(0)
if action.maxTicks != nil {
maxTicks = action.maxTicks.GetInt(sim)
}
action.spell.Cast(sim, action.target.Get())
action.spell.Unit.Rotation.interruptChannelIf = action.interruptIf
action.spell.Unit.Rotation.channelMaxTicks = maxTicks
}
func (action *APLActionChannelSpell) String() string {
return fmt.Sprintf("Channel Spell(%s, interruptIf=%s)", action.spell.ActionID, action.interruptIf)
Expand Down
1 change: 1 addition & 0 deletions sim/core/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func newDot(config Dot) *Dot {
dot.Spell.Unit.ChanneledDot = nil
if dot.Spell.Unit.IsUsingAPL {
dot.Spell.Unit.Rotation.interruptChannelIf = nil
dot.Spell.Unit.Rotation.channelMaxTicks = 0
}
}
})
Expand Down
4 changes: 4 additions & 0 deletions ui/core/components/individual_sim_ui/apl_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ const actionKindFactories: {[f in NonNullable<APLActionKind>]: ActionKindConfig<
label: 'Interrupt If',
labelTooltip: 'Condition which must be true to allow the channel to be interrupted.',
}),
AplValues.valueFieldConfig('maxTicks', {
label: 'Max Ticks',
labelTooltip: 'Maximum number of ticks to use for the channel, evaluated when casting begins. <b>None</b> or <b>0</b> will allow the full duration.',
}),
],
}),
['autocastOtherCooldowns']: inputBuilder({
Expand Down
4 changes: 2 additions & 2 deletions ui/shadow_priest/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ export const ROTATION_PRESET_DEFAULT = {
{"action":{"condition":{"cmp":{"op":"OpGe","lhs":{"remainingTime":{}},"rhs":{"const":{"val":"0s"}}}},"castSpell":{"spellId":{"spellId":34433}}}},
{"action":{"condition":{"cmp":{"op":"OpGe","lhs":{"currentTime":{}},"rhs":{"const":{"val":"1s"}}}},"autocastOtherCooldowns":{}}},
{"action":{"condition":{"cmp":{"op":"OpGe","lhs":{"currentTime":{}},"rhs":{"const":{"val":"61s"}}}},"castSpell":{"spellId":{"otherId":"OtherActionPotion"}}}},
{"action":{"condition":{"cmp":{"op":"OpLe","lhs":{"remainingTime":{}},"rhs":{"const":{"val":"2s"}}}},"castSpell":{"spellId":{"spellId":48300}}}},
{"action":{"condition":{"cmp":{"op":"OpLe","lhs":{"remainingTime":{}},"rhs":{"const":{"val":"1.75s"}}}},"castSpell":{"spellId":{"spellId":48300}}}},
{"action":{"condition":{"and":{"vals":[{"not":{"val":{"dotIsActive":{"spellId":{"spellId":48125}}}}},{"or":{"vals":[{"and":{"vals":[{"cmp":{"op":"OpEq","lhs":{"const":{"val":"5"}},"rhs":{"auraNumStacks":{"auraId":{"spellId":15258}}}}},{"cmp":{"op":"OpGe","lhs":{"remainingTime":{}},"rhs":{"const":{"val":"75s"}}}}]}},{"and":{"vals":[{"cmp":{"op":"OpLe","lhs":{"const":{"val":"3"}},"rhs":{"auraNumStacks":{"auraId":{"spellId":15258}}}}},{"cmp":{"op":"OpLt","lhs":{"remainingTime":{}},"rhs":{"const":{"val":"75s"}}}}]}}]}}]}},"castSpell":{"spellId":{"spellId":48125}}}},
{"action":{"condition":{"cmp":{"op":"OpLe","lhs":{"dotRemainingTime":{"spellId":{"spellId":48160}}},"rhs":{"spellCastTime":{"spellId":{"spellId":48160}}}}},"castSpell":{"spellId":{"spellId":48160}}}},
{"action":{"condition":{"and":{"vals":[{"cmp":{"op":"OpLe","lhs":{"dotRemainingTime":{"spellId":{"spellId":48160}}},"rhs":{"spellCastTime":{"spellId":{"spellId":48160}}}}},{"cmp":{"op":"OpGe","lhs":{"remainingTime":{}},"rhs":{"const":{"val":"3s"}}}}]}},"castSpell":{"spellId":{"spellId":48160}}}},
{"action":{"condition":{"not":{"val":{"dotIsActive":{"spellId":{"spellId":48300}}}}},"castSpell":{"spellId":{"spellId":48300}}}},
{"hide":true,"action":{"condition":{"and":{"vals":[{"cmp":{"op":"OpGe","lhs":{"spellCastTime":{"spellId":{"spellId":48127}}},"rhs":{"const":{"val":"750ms"}}}},{"cmp":{"op":"OpLe","lhs":{"auraRemainingTime":{"auraId":{"spellId":57669}}},"rhs":{"const":{"val":"5s"}}}}]}},"castSpell":{"spellId":{"spellId":48127}}}},
{"hide":true,"action":{"condition":{"cmp":{"op":"OpGe","lhs":{"spellCastTime":{"spellId":{"spellId":48127}}},"rhs":{"const":{"val":"750ms"}}}},"castSpell":{"spellId":{"spellId":48127}}}},
Expand Down

0 comments on commit c110da2

Please sign in to comment.