Skip to content

Commit

Permalink
Add APL prepull action to set stacks of an aura
Browse files Browse the repository at this point in the history
  • Loading branch information
hillerstorm committed Dec 31, 2024
1 parent b4c8a28 commit dbe5ad3
Show file tree
Hide file tree
Showing 4 changed files with 48 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 Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
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 @@ -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:
Expand Down
30 changes: 30 additions & 0 deletions sim/core/apl_actions_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions ui/core/components/individual_sim_ui/apl_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
APLActionMultishield,
APLActionResetSequence,
APLActionSchedule,
APLActionSetAuraStacks,
APLActionSequence,
APLActionStrictSequence,
APLActionTriggerICD,
Expand Down Expand Up @@ -582,6 +583,14 @@ const actionKindFactories: { [f in NonNullable<APLActionKind>]: 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<any>, isPrepull: boolean) => isPrepull,
newValue: () => APLActionSetAuraStacks.create(),
fields: [AplHelpers.actionIdFieldConfig('auraId', 'stackable_auras'), AplHelpers.numberFieldConfig('stacks', false)],
}),
['triggerIcd']: inputBuilder({
label: 'Trigger ICD',
submenu: ['Misc'],
Expand Down

0 comments on commit dbe5ad3

Please sign in to comment.