Skip to content

Commit

Permalink
Merge pull request #1280 from hillerstorm/set_aura_stacks_action
Browse files Browse the repository at this point in the history
Add APL prepull action to set stacks of an aura
  • Loading branch information
hillerstorm authored Jan 1, 2025
2 parents 3a3b27d + 717844f commit 546b2eb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
8 changes: 7 additions & 1 deletion proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ message APLListItem {
APLAction action = 3; // The action to be performed.
}

// NextIndex: 24
// NextIndex: 25
message APLAction {
APLValue condition = 1; // If set, action will only execute if value is true or != 0.

Expand All @@ -68,6 +68,7 @@ message APLAction {
// Misc
APLActionChangeTarget change_target = 9;
APLActionActivateAura activate_aura = 13;
APLActionActivateAuraWithStacks activate_aura_with_stacks = 24;
APLActionCancelAura cancel_aura = 10;
APLActionTriggerICD trigger_icd = 11;
APLActionItemSwap item_swap = 17;
Expand Down Expand Up @@ -292,6 +293,11 @@ message APLActionActivateAura {
ActionID aura_id = 1;
}

message APLActionActivateAuraWithStacks {
ActionID aura_id = 1;
int32 num_stacks = 2;
}

message APLActionTriggerICD {
ActionID aura_id = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions sim/core/apl_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ func (rot *APLRotation) newAPLActionImpl(config *proto.APLAction) APLActionImpl
return rot.newActionChangeTarget(config.GetChangeTarget())
case *proto.APLAction_ActivateAura:
return rot.newActionActivateAura(config.GetActivateAura())
case *proto.APLAction_ActivateAuraWithStacks:
return rot.newActionActivateAuraWithStacks(config.GetActivateAuraWithStacks())
case *proto.APLAction_CancelAura:
return rot.newActionCancelAura(config.GetCancelAura())
case *proto.APLAction_TriggerIcd:
Expand Down
34 changes: 34 additions & 0 deletions sim/core/apl_actions_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,40 @@ func (action *APLActionActivateAura) String() string {
return fmt.Sprintf("Activate Aura(%s)", action.aura.ActionID)
}

type APLActionActivateAuraWithStacks struct {
defaultAPLActionImpl
aura *Aura
numStacks int32
}

func (rot *APLRotation) newActionActivateAuraWithStacks(config *proto.APLActionActivateAuraWithStacks) APLActionImpl {
aura := rot.GetAPLAura(rot.GetSourceUnit(&proto.UnitReference{Type: proto.UnitReference_Self}), config.AuraId)
if aura.Get() == nil {
return nil
}
if aura.Get().MaxStacks == 0 {
rot.ValidationMessage(proto.LogLevel_Warning, "%s is not a stackable aura", ProtoToActionID(config.AuraId))
return nil
}
return &APLActionActivateAuraWithStacks{
aura: aura.Get(),
numStacks: int32(min(config.NumStacks, aura.Get().MaxStacks)),
}
}
func (action *APLActionActivateAuraWithStacks) IsReady(sim *Simulation) bool {
return true
}
func (action *APLActionActivateAuraWithStacks) Execute(sim *Simulation) {
if sim.Log != nil {
action.aura.Unit.Log(sim, "Activating aura %s (%d stacks)", action.aura.ActionID, action.numStacks)
}
action.aura.Activate(sim)
action.aura.SetStacks(sim, action.numStacks)
}
func (action *APLActionActivateAuraWithStacks) String() string {
return fmt.Sprintf("Activate Aura(%s) Stacks(%d)", action.aura.ActionID, action.numStacks)
}

type APLActionTriggerICD struct {
defaultAPLActionImpl
aura *Aura
Expand Down
14 changes: 14 additions & 0 deletions ui/core/components/individual_sim_ui/apl_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Player } from '../../player.js';
import {
APLAction,
APLActionActivateAura,
APLActionActivateAuraWithStacks,
APLActionAutocastOtherCooldowns,
APLActionCancelAura,
APLActionCastAllStatBuffCooldowns,
Expand Down Expand Up @@ -575,6 +576,19 @@ const actionKindFactories: { [f in NonNullable<APLActionKind>]: ActionKindConfig
newValue: () => APLActionActivateAura.create(),
fields: [AplHelpers.actionIdFieldConfig('auraId', 'auras')],
}),
['activateAuraWithStacks']: inputBuilder({
label: 'Activate Aura With Stacks',
submenu: ['Misc'],
shortDescription: 'Activates and an aura with the specified number of stacks',
includeIf: (player: Player<any>, isPrepull: boolean) => isPrepull,
newValue: () => APLActionActivateAuraWithStacks.create({
numStacks: 1,
}),
fields: [AplHelpers.actionIdFieldConfig('auraId', 'stackable_auras'), AplHelpers.numberFieldConfig('numStacks', false, {
label: 'stacks',
labelTooltip: 'Desired number of initial aura stacks.',
})],
}),
['cancelAura']: inputBuilder({
label: 'Cancel Aura',
submenu: ['Misc'],
Expand Down

0 comments on commit 546b2eb

Please sign in to comment.