Skip to content

Commit

Permalink
Merge branch 'main' into dangerous-effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinn committed Sep 29, 2024
2 parents beb9004 + 1fc80ed commit 00dd9af
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 36 deletions.
48 changes: 33 additions & 15 deletions packages/garbo/src/combat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,25 +863,42 @@ export class Macro extends StrictMacro {
}
}

function customizeMacro<M extends StrictMacro>(macro: M) {
type CustomizeMacroOptions = {
freeWanderer: (macro: StrictMacro) => Macro;
tentacle: (macro: StrictMacro) => Macro;
innateWanderer: (macro: StrictMacro) => Macro;
};
const DEFAULT_MACRO_OPTIONS = {
freeWanderer: () => Macro.basicCombat(),
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<M extends StrictMacro>(
macro: M,
options: Partial<CustomizeMacroOptions> = {},
) {
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);
}

Expand Down Expand Up @@ -964,11 +981,12 @@ export class GarboStrategy extends CombatStrategy {
macro: () => Macro,
postAuto = macro,
useAutoAttack = () => true,
options: Partial<CustomizeMacroOptions> = {},
) {
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);
Expand Down
23 changes: 2 additions & 21 deletions packages/garbo/src/resources/realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@ import {
runChoice,
visitUrl,
} from "kolmafia";
import {
$item,
get,
have,
maxBy,
property,
realmAvailable,
set,
withProperty,
} from "libram";
import { $item, get, have, maxBy, property, set, withProperty } from "libram";
import { globalOptions } from "../config";
import { garboValue } from "../garboValue";
import { HIGHLIGHT } from "../lib";
Expand All @@ -29,17 +20,7 @@ function volcanoItemValue({ quantity, item }: VolcanoItem): number {
if (!have($item`Clara's bell`) || globalOptions.clarasBellClaimed) {
return Infinity;
}
// Check if we can use Clara's bell for Yachtzee
// If so, we call the opportunity cost of this about 40k
if (
realmAvailable("sleaze") &&
have($item`fishy pipe`) &&
!get("_fishyPipeUsed")
) {
return quantity * 40000;
} else {
return quantity * get("valueOfAdventure");
}
return quantity * get("valueOfAdventure");
}

if (!item.tradeable) return Infinity;
Expand Down
56 changes: 56 additions & 0 deletions packages/garbo/src/tasks/barfTurn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ import {
canEquip,
eat,
getWorkshed,
Item,
itemAmount,
Location,
mallPrice,
maximize,
myAdventures,
myAscensions,
myInebriety,
myLevel,
myLightning,
myRain,
myTurncount,
outfitPieces,
retrieveItem,
runChoice,
totalTurnsPlayed,
use,
Expand All @@ -39,13 +43,15 @@ import {
GingerBread,
have,
HeavyRains,
maxBy,
questStep,
realmAvailable,
set,
SourceTerminal,
sum,
TrainSet,
undelay,
withProperty,
} from "libram";
import { OutfitSpec, Quest } from "grimoire-kolmafia";
import { WanderDetails } from "garbo-lib";
Expand Down Expand Up @@ -321,6 +327,22 @@ function vampOut(additionalReady: () => boolean) {
};
}

let bestDupeItem: Item | null = null;
function getBestDupeItem(): Item {
if (bestDupeItem === null || !have(bestDupeItem)) {
// Machine elf can dupe PVPable food, booze, spleen item or potion
const validItems = Item.all().filter(
(i) =>
i.tradeable &&
i.discardable &&
(i.inebriety || i.fullness || i.potion || i.spleen) &&
have(i),
);
bestDupeItem = maxBy(validItems, garboValue);
}
return bestDupeItem;
}

function willDrunkAdventure() {
return have($item`Drunkula's wineglass`) && globalOptions.ascend;
}
Expand Down Expand Up @@ -367,6 +389,40 @@ const NonBarfTurnTasks: AlternateTask[] = [
: 0,
spendsTurn: true,
},
{
name: "Machine Elf Dupe",
ready: () =>
have($familiar`Machine Elf`) &&
// Dupe at end of day even if not ascending, encountersUntilDMTChoice does not reset on rollover
willDrunkAdventure() === !sober() &&
get("encountersUntilDMTChoice") === 0 &&
garboValue(getBestDupeItem()) > get("valueOfAdventure"),
completed: () => get("lastDMTDuplication") === myAscensions(),
do: $location`The Deep Machine Tunnels`,
prepare: () => {
if (itemAmount(getBestDupeItem()) === 0) {
withProperty("autoSatisfyWithMall", false, () =>
retrieveItem(getBestDupeItem()),
);
}
},
outfit: () =>
sober()
? {
avoid: $items`Kramco Sausage-o-Matic™`,
familiar: $familiar`Machine Elf`,
}
: {
offhand: $item`Drunkula's wineglass`,
familiar: $familiar`Machine Elf`,
},
combat: new GarboStrategy(() =>
Macro.abortWithMsg("Hit unexpected combat!"),
),
turns: () => 1,
spendsTurn: true,
choices: () => ({ 1119: 4, 1125: `1&iid=${getBestDupeItem().id}` }),
},
{
name: "Lava Dogs (drunk)",
...lavaDogs(() => willDrunkAdventure(), {
Expand Down

0 comments on commit 00dd9af

Please sign in to comment.