From dbe5ad30c0dab2a68bdf9cd11576b65348396790 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 | 30 +++++++++++++++++++ .../individual_sim_ui/apl_actions.ts | 9 ++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/proto/apl.proto b/proto/apl.proto index 10fb6e4f21..fa207140a6 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. @@ -73,6 +73,7 @@ message APLAction { APLActionItemSwap item_swap = 17; APLActionMove move = 21; APLActionMoveDuration move_duration = 22; + APLActionSetAuraStacks set_aura_stacks = 24; // Class or Spec-specific actions APLActionCatOptimalRotationAction cat_optimal_rotation_action = 18; @@ -292,6 +293,11 @@ message APLActionActivateAura { ActionID aura_id = 1; } +message APLActionSetAuraStacks { + ActionID aura_id = 1; + int32 stacks = 2; +} + message APLActionTriggerICD { ActionID aura_id = 1; } diff --git a/sim/core/apl_action.go b/sim/core/apl_action.go index 1ca2623771..9ffc4dfafc 100644 --- a/sim/core/apl_action.go +++ b/sim/core/apl_action.go @@ -179,6 +179,8 @@ func (rot *APLRotation) newAPLActionImpl(config *proto.APLAction) APLActionImpl return rot.newActionActivateAura(config.GetActivateAura()) case *proto.APLAction_CancelAura: return rot.newActionCancelAura(config.GetCancelAura()) + case *proto.APLAction_SetAuraStacks: + return rot.newActionSetAuraStacks(config.GetSetAuraStacks()) case *proto.APLAction_TriggerIcd: return rot.newActionTriggerICD(config.GetTriggerIcd()) case *proto.APLAction_ItemSwap: diff --git a/sim/core/apl_actions_misc.go b/sim/core/apl_actions_misc.go index e753d098be..3e79d51169 100644 --- a/sim/core/apl_actions_misc.go +++ b/sim/core/apl_actions_misc.go @@ -93,6 +93,36 @@ func (action *APLActionActivateAura) String() string { return fmt.Sprintf("Activate Aura(%s)", action.aura.ActionID) } +type APLActionSetAuraStacks struct { + defaultAPLActionImpl + aura *Aura + stacks int32 +} + +func (rot *APLRotation) newActionSetAuraStacks(config *proto.APLActionSetAuraStacks) APLActionImpl { + aura := rot.GetAPLAura(rot.GetSourceUnit(&proto.UnitReference{Type: proto.UnitReference_Self}), config.AuraId) + if aura.Get() == nil || aura.Get().MaxStacks == 0 { + return nil + } + return &APLActionSetAuraStacks{ + aura: aura.Get(), + stacks: int32(min(config.Stacks, aura.Get().MaxStacks)), + } +} +func (action *APLActionSetAuraStacks) IsReady(sim *Simulation) bool { + return true +} +func (action *APLActionSetAuraStacks) Execute(sim *Simulation) { + if sim.Log != nil { + action.aura.Unit.Log(sim, "Setting stacks on aura %s to %d", action.aura.ActionID, action.stacks) + } + action.aura.Activate(sim) + action.aura.SetStacks(sim, action.stacks) +} +func (action *APLActionSetAuraStacks) String() string { + return fmt.Sprintf("Set Aura Stacks(%s, %d)", action.aura.ActionID, action.stacks) +} + 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..b9e640d91d 100644 --- a/ui/core/components/individual_sim_ui/apl_actions.ts +++ b/ui/core/components/individual_sim_ui/apl_actions.ts @@ -20,6 +20,7 @@ import { APLActionMultishield, APLActionResetSequence, APLActionSchedule, + APLActionSetAuraStacks, APLActionSequence, APLActionStrictSequence, APLActionTriggerICD, @@ -582,6 +583,14 @@ const actionKindFactories: { [f in NonNullable]: ActionKindConfig newValue: () => APLActionCancelAura.create(), fields: [AplHelpers.actionIdFieldConfig('auraId', 'auras')], }), + ['setAuraStacks']: inputBuilder({ + label: 'Set Aura Stacks', + submenu: ['Misc'], + shortDescription: 'Activates and sets the stacks of an aura.', + includeIf: (player: Player, isPrepull: boolean) => isPrepull, + newValue: () => APLActionSetAuraStacks.create(), + fields: [AplHelpers.actionIdFieldConfig('auraId', 'stackable_auras'), AplHelpers.numberFieldConfig('stacks', false)], + }), ['triggerIcd']: inputBuilder({ label: 'Trigger ICD', submenu: ['Misc'],