Skip to content

Commit

Permalink
Merge branch 'main' into grimoire-embezzlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinn committed Sep 26, 2024
2 parents 48fe0de + 8caffed commit ebdbe19
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 289 deletions.
289 changes: 18 additions & 271 deletions packages/garbo/src/fights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
Familiar,
familiarEquippedEquipment,
getAutoAttack,
getWorkshed,
haveEquipped,
haveOutfit,
inebrietyLimit,
Expand All @@ -32,7 +31,6 @@ import {
myFamiliar,
myInebriety,
myLevel,
myPath,
myThrall,
myTurncount,
numericModifier,
Expand Down Expand Up @@ -69,15 +67,12 @@ import {
$locations,
$monster,
$monsters,
$path,
$phylum,
$skill,
$slot,
$stat,
$thrall,
ActionSource,
AprilingBandHelmet,
AsdonMartin,
ChestMimic,
CinchoDeMayo,
clamp,
Expand Down Expand Up @@ -131,7 +126,6 @@ import {
tryFillLatte,
} from "./resources";
import {
bestFairy,
freeFightFamiliar,
meatFamiliar,
setBestLeprechaunAsMeatFamiliar,
Expand Down Expand Up @@ -184,8 +178,16 @@ import { wanderer } from "./garboWanderer";
import { runTargetFight } from "./target/execution";
import { TargetFightRunOptions } from "./target/staging";
import { FreeFightQuest, runGarboQuests } from "./tasks";
import { expectedFreeFights, possibleTentacleFights } from "./tasks/freeFight";
import {
expectedFreeFightQuestFights,
possibleFreeFightQuestTentacleFights,
} from "./tasks/freeFight";
import { PostQuest } from "./tasks/post";
import {
expectedFreeGiantSandwormQuestFights,
FreeGiantSandwormQuest,
possibleFreeGiantSandwormQuestTentacleFights,
} from "./tasks/freeGiantSandworm";

const firstChainMacro = () =>
Macro.if_(
Expand Down Expand Up @@ -772,42 +774,6 @@ function molemanReady() {
}

const freeFightSources = [
new FreeFight(
() =>
have($item`Apriling band quad tom`)
? $item`Apriling band quad tom`.dailyusesleft
: 0,
() => {
ensureBeachAccess();
AprilingBandHelmet.play("Apriling band quad tom");
visitUrl("main.php");
runCombat();
},
true,
{
effects: () =>
have($skill`Steely-Eyed Squint`) && !get("_steelyEyedSquintUsed")
? $effects`Steely-Eyed Squint`
: [],
spec: () => {
if (
have($item`January's Garbage Tote`) &&
!have($item`broken champagne bottle`) &&
get("garbageChampagneCharge") > 0
) {
cliExecute("fold broken champagne bottle");
}

if (
have($item`broken champagne bottle`) &&
get("garbageChampagneCharge") > 0
) {
return { weapon: $item`broken champagne bottle` };
}
return {};
},
},
),
new FreeFight(
() => (wantPills() ? 5 - get("_saberForceUses") : 0),
() => {
Expand Down Expand Up @@ -1659,197 +1625,6 @@ const freeRunFightSources = [
),
];

function sandwormSpec(spec: OutfitSpec = {}): OutfitSpec {
const copy = { ...spec, equip: [...(spec.equip ?? [])] };
// Effective drop rate of spice melange is 0.1, each 1% item drop increases the chance by 0.1/10000
const itemDropBonus = (0.1 / 10000) * garboValue($item`spice melange`);
copy.modifier = [`${itemDropBonus.toFixed(2)} Item Drop 10000 max`];
if (
have($item`January's Garbage Tote`) &&
get("garbageChampagneCharge") > 0
) {
copy.equip?.push($item`broken champagne bottle`);
}
if (have($item`Lil' Doctor™ bag`) && get("_otoscopeUsed")) {
copy.equip?.push($item`Lil' Doctor™ bag`);
}
const familiar = bestFairy();
copy.familiar = familiar;
if (familiar === $familiar`Reagnimated Gnome`) {
copy.equip?.push($item`gnomish housemaid's kgnee`);
}
if (familiar === $familiar`Jill-of-All-Trades`) {
copy.equip?.push($item`LED candle`);
copy.modes = { ...copy.modes, jillcandle: "disco" };
}
copy.equip = [...new Set(copy.equip)]; // Prune doubled-up stuff
return copy;
}

const freeKillSources = [
// 22 3 0 0 Chest X-Ray combat skill must have a Lil' Doctor™ bag equipped
new FreeFight(
() =>
have($item`Lil' Doctor™ bag`)
? clamp(3 - get("_chestXRayUsed"), 0, 3)
: 0,
() => {
ensureBeachAccess();
withMacro(
Macro.trySingAlong()
.tryHaveSkill($skill`Otoscope`)
.trySkill($skill`Chest X-Ray`),
() => use($item`drum machine`),
);
},
true,
{
spec: () => sandwormSpec({ equip: $items`Lil' Doctor™ bag` }),
effects: () =>
have($skill`Emotionally Chipped`) && get("_feelLostUsed") < 3
? $effects`Feeling Lost`
: [],
},
),

new FreeFight(
() => !get("_gingerbreadMobHitUsed") && have($skill`Gingerbread Mob Hit`),
() => {
ensureBeachAccess();
withMacro(
Macro.trySingAlong()
.tryHaveSkill($skill`Otoscope`)
.trySkill($skill`Gingerbread Mob Hit`),
() => use($item`drum machine`),
);
},
true,
{
spec: sandwormSpec,
effects: () =>
have($skill`Emotionally Chipped`) && get("_feelLostUsed") < 3
? $effects`Feeling Lost`
: [],
},
),

new FreeFight(
() =>
have($skill`Shattering Punch`)
? clamp(3 - get("_shatteringPunchUsed"), 0, 3)
: 0,
() => {
ensureBeachAccess();
withMacro(
Macro.trySingAlong()
.tryHaveSkill($skill`Otoscope`)
.trySkill($skill`Shattering Punch`),
() => use($item`drum machine`),
);
},
true,
{
spec: sandwormSpec,
effects: () =>
have($skill`Emotionally Chipped`) && get("_feelLostUsed") < 3
? $effects`Feeling Lost`
: [],
},
),

new FreeFight(
() =>
have($item`replica bat-oomerang`)
? clamp(3 - get("_usedReplicaBatoomerang"), 0, 3)
: 0,
() => {
ensureBeachAccess();
withMacro(
Macro.trySingAlong()
.tryHaveSkill($skill`Otoscope`)
.item($item`replica bat-oomerang`),
() => use($item`drum machine`),
);
},
true,
{
spec: sandwormSpec,
effects: () =>
have($skill`Emotionally Chipped`) && get("_feelLostUsed") < 3
? $effects`Feeling Lost`
: [],
},
),

new FreeFight(
() =>
!get("_missileLauncherUsed") &&
getWorkshed() === $item`Asdon Martin keyfob (on ring)`,
() => {
ensureBeachAccess();
AsdonMartin.fillTo(100);
withMacro(
Macro.trySingAlong()
.tryHaveSkill($skill`Otoscope`)
.skill($skill`Asdon Martin: Missile Launcher`),
() => use($item`drum machine`),
);
},
true,
{
spec: sandwormSpec,
effects: () =>
have($skill`Emotionally Chipped`) && get("_feelLostUsed") < 3
? $effects`Feeling Lost`
: [],
},
),

new FreeFight(
() => (globalOptions.ascend ? get("shockingLickCharges") : 0),
() => {
ensureBeachAccess();
withMacro(
Macro.trySingAlong()
.tryHaveSkill($skill`Otoscope`)
.skill($skill`Shocking Lick`),
() => use($item`drum machine`),
);
},
true,
{
spec: sandwormSpec,
effects: () =>
have($skill`Emotionally Chipped`) && get("_feelLostUsed") < 3
? $effects`Feeling Lost`
: [],
},
),

new FreeFight(
() =>
have($item`Jurassic Parka`) && !have($effect`Everything Looks Yellow`),
() => {
ensureBeachAccess();
cliExecute("parka dilophosaur");
withMacro(
Macro.trySingAlong()
.tryHaveSkill($skill`Otoscope`)
.trySkill($skill`Spit jurassic acid`),
() => use($item`drum machine`),
);
},
true,
{
spec: () => sandwormSpec({ equip: $items`Jurassic Parka` }),
effects: () =>
have($skill`Emotionally Chipped`) && get("_feelLostUsed") < 3
? $effects`Feeling Lost`
: [],
},
),
];

function targetCopiesInProgress(): boolean {
return (
get("beGregariousFightsLeft") > 0 ||
Expand Down Expand Up @@ -1903,39 +1678,14 @@ export function freeFights(): void {

killRobortCreaturesForFree();

// Use free fights on melanges if we have Tote/Squint and prices are reasonable.
const canSquint =
have($effect`Steely-Eyed Squint`) ||
(have($skill`Steely-Eyed Squint`) && !get("_steelyEyedSquintUsed"));
if (
have($item`January's Garbage Tote`) &&
canSquint &&
mallPrice($item`drum machine`) < 0.02 * mallPrice($item`spice melange`)
) {
try {
for (const freeKillSource of freeKillSources) {
if (freeKillSource.isAvailable()) {
// TODO: Add potions that are profitable for free kills.
ensureEffect($effect`Steely-Eyed Squint`);
}

freeKillSource.runAll();
}
} finally {
if (have($item`January's Garbage Tote`)) {
cliExecute("fold wad of used tape");
}
}
}

// TODO: Run unconverted free fights
for (const freeFightSource of freeFightSources) {
freeFightSource.runAll();
}

// TODO: Run grimorized free fights until all are converted
// TODO: freeFightMood()
runGarboQuests([PostQuest(), FreeFightQuest]);
runGarboQuests([PostQuest(), FreeFightQuest, FreeGiantSandwormQuest]);

tryFillLatte();
postFreeFightDailySetup();
Expand Down Expand Up @@ -2096,15 +1846,6 @@ function doGhost() {
postCombatActions();
}

function ensureBeachAccess() {
if (
get("lastDesertUnlock") !== myAscensions() &&
myPath() !== $path`Actually Ed the Undying` /* Actually Ed the Undying*/
) {
create($item`bitchin' meatcar`);
}
}

type ItemStealZone = {
item: Item;
location: Location;
Expand Down Expand Up @@ -2421,21 +2162,27 @@ function killRobortCreaturesForFree() {
}
}

// Expected free fights, not including tentacles
export function estimatedFreeFights(): number {
return (
sum(freeFightSources, (source: FreeFight) => {
const avail = source.available();
return typeof avail === "number" ? avail : toInt(avail);
}) + expectedFreeFights()
}) +
expectedFreeFightQuestFights() +
expectedFreeGiantSandwormQuestFights()
);
}

// Possible additional free fights from tentacles
export function estimatedTentacles(): number {
return (
sum(freeFightSources, (source: FreeFight) => {
const avail = source.tentacle ? source.available() : 0;
return typeof avail === "number" ? avail : toInt(avail);
}) + possibleTentacleFights()
}) +
possibleFreeFightQuestTentacleFights() +
possibleFreeGiantSandwormQuestTentacleFights()
);
}

Expand Down
Loading

0 comments on commit ebdbe19

Please sign in to comment.