Skip to content

Commit

Permalink
Add APL action for pre-pull
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyt857 committed Jul 29, 2023
1 parent ef3bd52 commit a99fc2d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ message APLAction {
APLActionAutocastOtherCooldowns autocast_other_cooldowns = 7;
APLActionChangeTarget change_target = 9;
APLActionCancelAura cancel_aura = 10;
APLActionTriggerICD trigger_icd = 11;
APLActionWait wait = 4;
}
}
Expand Down Expand Up @@ -148,6 +149,10 @@ message APLActionCancelAura {
ActionID aura_id = 1;
}

message APLActionTriggerICD {
ActionID aura_id = 1;
}

message APLActionWait {
APLValue duration = 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 @@ -80,6 +80,8 @@ func (rot *APLRotation) newAPLActionImpl(config *proto.APLAction) APLActionImpl
return rot.newActionChangeTarget(config.GetChangeTarget())
case *proto.APLAction_CancelAura:
return rot.newActionCancelAura(config.GetCancelAura())
case *proto.APLAction_TriggerIcd:
return rot.newActionTriggerICD(config.GetTriggerIcd())
case *proto.APLAction_Wait:
return rot.newActionWait(config.GetWait())
default:
Expand Down
26 changes: 26 additions & 0 deletions sim/core/apl_actions_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,29 @@ func (action *APLActionCancelAura) Execute(sim *Simulation) {
}
action.aura.Deactivate(sim)
}

type APLActionTriggerICD struct {
aura *Aura
}

func (rot *APLRotation) newActionTriggerICD(config *proto.APLActionTriggerICD) APLActionImpl {
aura := rot.aplGetICDAura(&proto.UnitReference{Type: proto.UnitReference_Self}, config.AuraId)
if aura.Get() == nil {
return nil
}
return &APLActionTriggerICD{
aura: aura.Get(),
}
}
func (action *APLActionTriggerICD) GetInnerActions() []*APLAction { return nil }
func (action *APLActionTriggerICD) Finalize(*APLRotation) {}
func (action *APLActionTriggerICD) Reset(*Simulation) {}
func (action *APLActionTriggerICD) IsReady(sim *Simulation) bool {
return action.aura.IsActive()
}
func (action *APLActionTriggerICD) Execute(sim *Simulation) {
if sim.Log != nil {
action.aura.Unit.Log(sim, "Triggering ICD %s", action.aura.ActionID)
}
action.aura.Icd.Use(sim)
}
2 changes: 1 addition & 1 deletion sim/core/apl_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (rot *APLRotation) aplGetAura(sourceRef *proto.UnitReference, auraId *proto
return aura
}

func (rot *APLRotation) aplGetProcAura(sourceRef *proto.UnitReference, auraId *proto.ActionID) AuraReference {
func (rot *APLRotation) aplGetICDAura(sourceRef *proto.UnitReference, auraId *proto.ActionID) AuraReference {
sourceUnit := rot.getSourceUnit(sourceRef)
if sourceUnit.Get() == nil {
return AuraReference{}
Expand Down
2 changes: 1 addition & 1 deletion sim/core/apl_values_aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type APLValueAuraInternalCooldown struct {
}

func (rot *APLRotation) newValueAuraInternalCooldown(config *proto.APLValueAuraInternalCooldown) APLValue {
aura := rot.aplGetProcAura(config.SourceUnit, config.AuraId)
aura := rot.aplGetICDAura(config.SourceUnit, config.AuraId)
if aura.Get() == nil {
return nil
}
Expand Down
11 changes: 11 additions & 0 deletions ui/core/components/individual_sim_ui/apl_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
APLActionAutocastOtherCooldowns,
APLActionChangeTarget,
APLActionCancelAura,
APLActionTriggerICD,
APLActionWait,
APLValue,
} from '../../proto/apl.js';
Expand Down Expand Up @@ -390,4 +391,14 @@ const actionKindFactories: {[f in NonNullable<APLActionKind>]: ActionKindConfig<
AplHelpers.actionIdFieldConfig('auraId', 'auras'),
],
}),
['triggerIcd']: inputBuilder({
label: 'Trigger ICD',
submenu: ['Misc'],
shortDescription: 'Triggers an aura\'s ICD, putting it on cooldown. Example usage would be to desync an ICD cooldown before combat starts.',
isPrepull: true,
newValue: () => APLActionTriggerICD.create(),
fields: [
AplHelpers.actionIdFieldConfig('auraId', 'icd_auras'),
],
}),
};

0 comments on commit a99fc2d

Please sign in to comment.