From 717844f1fb0dc718d353640f54ef7d7b8aeff32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Hillerstr=C3=B6m?= Date: Tue, 31 Dec 2024 09:27:42 +0100 Subject: [PATCH] Add APL prepull action to set stacks of an aura --- proto/apl.proto | 8 ++++- sim/core/apl_action.go | 2 ++ sim/core/apl_actions_misc.go | 34 +++++++++++++++++++ .../individual_sim_ui/apl_actions.ts | 14 ++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/proto/apl.proto b/proto/apl.proto index 10fb6e4f21..788fe642e1 100644 --- a/proto/apl.proto +++ b/proto/apl.proto @@ -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. @@ -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; @@ -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; } diff --git a/sim/core/apl_action.go b/sim/core/apl_action.go index 1ca2623771..9b79f2f408 100644 --- a/sim/core/apl_action.go +++ b/sim/core/apl_action.go @@ -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: diff --git a/sim/core/apl_actions_misc.go b/sim/core/apl_actions_misc.go index e753d098be..0e27cdf2a5 100644 --- a/sim/core/apl_actions_misc.go +++ b/sim/core/apl_actions_misc.go @@ -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 diff --git a/ui/core/components/individual_sim_ui/apl_actions.ts b/ui/core/components/individual_sim_ui/apl_actions.ts index 543fbbdd27..8ddab990b2 100644 --- a/ui/core/components/individual_sim_ui/apl_actions.ts +++ b/ui/core/components/individual_sim_ui/apl_actions.ts @@ -3,6 +3,7 @@ import { Player } from '../../player.js'; import { APLAction, APLActionActivateAura, + APLActionActivateAuraWithStacks, APLActionAutocastOtherCooldowns, APLActionCancelAura, APLActionCastAllStatBuffCooldowns, @@ -575,6 +576,19 @@ const actionKindFactories: { [f in NonNullable]: 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, 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'],