From fae645c05ec11aa50b40bf798e20519973e9e7a1 Mon Sep 17 00:00:00 2001 From: horrible little slime <69secret69email69@gmail.com> Date: Sat, 28 Sep 2024 14:34:17 -0400 Subject: [PATCH 1/3] allow passing specific override options to `customizeMacro` --- packages/garbo/src/combat.ts | 43 +++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/packages/garbo/src/combat.ts b/packages/garbo/src/combat.ts index 3b6f97da4..87585e9f6 100644 --- a/packages/garbo/src/combat.ts +++ b/packages/garbo/src/combat.ts @@ -863,25 +863,42 @@ export class Macro extends StrictMacro { } } -function customizeMacro(macro: M) { +type CustomizeMacroOptions = { + freeWanderer: (macro: StrictMacro) => Macro; + tentacle: (macro: StrictMacro) => Macro; + innateWanderer: (macro: StrictMacro) => Macro; +}; +const DEFAULT_MACRO_OPTIONS = { + freeWanderer: () => Macro.kill(), + tentacle: () => Macro.basicCombat(), + innateWanderer: (macro: StrictMacro) => + Macro.externalIf( + haveEquipped($item`backup camera`) && + get("_backUpUses") < 11 && + get("lastCopyableMonster") === globalOptions.target && + (!targettingMeat() || myFamiliar() === meatFamiliar()), + Macro.skill($skill`Back-Up to your Last Enemy`).step(macro), + Macro.basicCombat(), + ), +} as const satisfies CustomizeMacroOptions; + +function customizeMacro( + macro: M, + options: Partial = {}, +) { + const { freeWanderer, tentacle, innateWanderer } = { + ...DEFAULT_MACRO_OPTIONS, + ...options, + }; return Macro.if_( $monsters`giant rubber spider, time-spinner prank`, - Macro.kill(), + freeWanderer(macro), ) .externalIf( have($effect`Eldritch Attunement`), - Macro.if_($monster`Eldritch Tentacle`, Macro.basicCombat()), - ) - .ifInnateWanderer( - Macro.externalIf( - haveEquipped($item`backup camera`) && - get("_backUpUses") < 11 && - get("lastCopyableMonster") === globalOptions.target && - (!targettingMeat() || myFamiliar() === meatFamiliar()), - Macro.skill($skill`Back-Up to your Last Enemy`).step(macro), - Macro.basicCombat(), - ), + Macro.if_($monster`Eldritch Tentacle`, tentacle(macro)), ) + .ifInnateWanderer(innateWanderer(macro)) .step(macro); } From a8b69a7bba416ec2ee14e51b42e7d4e51c63c2c0 Mon Sep 17 00:00:00 2001 From: horrible little slime <69secret69email69@gmail.com> Date: Sat, 28 Sep 2024 14:36:20 -0400 Subject: [PATCH 2/3] add `CustomizeMacroOptions` to the GarboStrategy constructor --- packages/garbo/src/combat.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/garbo/src/combat.ts b/packages/garbo/src/combat.ts index 87585e9f6..7f30d28d7 100644 --- a/packages/garbo/src/combat.ts +++ b/packages/garbo/src/combat.ts @@ -981,11 +981,12 @@ export class GarboStrategy extends CombatStrategy { macro: () => Macro, postAuto = macro, useAutoAttack = () => true, + options: Partial = {}, ) { super(); - const macroCustom = () => customizeMacro(macro()); + const macroCustom = () => customizeMacro(macro(), options); if (useAutoAttack()) { - const postAutoCustom = () => customizeMacro(postAuto()); + const postAutoCustom = () => customizeMacro(postAuto(), options); this.autoattack(macroCustom).macro(postAutoCustom); } else { this.macro(macroCustom); From 3df9cff794f302ffc4b97d85fef7080ec7502b5f Mon Sep 17 00:00:00 2001 From: horrible little slime <69secret69email69@gmail.com> Date: Sat, 28 Sep 2024 19:29:24 -0400 Subject: [PATCH 3/3] basic combat for all! --- packages/garbo/src/combat.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/garbo/src/combat.ts b/packages/garbo/src/combat.ts index 7f30d28d7..462e64e98 100644 --- a/packages/garbo/src/combat.ts +++ b/packages/garbo/src/combat.ts @@ -869,7 +869,7 @@ type CustomizeMacroOptions = { innateWanderer: (macro: StrictMacro) => Macro; }; const DEFAULT_MACRO_OPTIONS = { - freeWanderer: () => Macro.kill(), + freeWanderer: () => Macro.basicCombat(), tentacle: () => Macro.basicCombat(), innateWanderer: (macro: StrictMacro) => Macro.externalIf(