Skip to content

Commit

Permalink
Big rock (#105)
Browse files Browse the repository at this point in the history
* initial commit - add caveman dan rock collecting

* yarn install

* prettier, lint

* get rid of npm lock file

* Revert yarn.lock

* ncforcers cause problems + get timecapsules once got pwd

* Allow familiars for input spec, and charge goose

* check for noncombatForcerActive for asdon tasks

* Set choices for Time Capsule task

* Set choices for Time Capsule task

* Apply suggestions from code review

We still have a few more places worth iterating our runChoices, but let's get this done

* Check for RoShamBo completion

* Manage quest property

* Don't set property if already set

* Only reset property once per ascension

* Actually have goose with you when chowing

* acc1 instead of equip fixes outfit issue

* verbose quest names

* Remove freeKramco chance from Fighting CaveDan

* nicer choice handling

* remove unnecessary autumnaton ready condition

---------

Co-authored-by: Tokoeka <nzgamer666@gmail.com>
Co-authored-by: Joe Kirchoff <joe.kirchoff@epicgames.com>
Co-authored-by: Shiverwarp <Lorenz69@gmail.com>
Co-authored-by: Joe Kirchoff <Kirchoff.Joseph.P@gmail.com>
Co-authored-by: neil <78829653+horrible-little-slime@users.noreply.github.com>
  • Loading branch information
6 people authored Aug 2, 2024
1 parent 4874f13 commit c006065
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export class ChronerEngine extends Engine<never, ChronerTask> {
),
);
}
this.propertyManager.setChoices({ 955: 2 });
}

shouldRepeatAdv(task: ChronerTask): boolean {
Expand Down
44 changes: 43 additions & 1 deletion src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ import {
inebrietyLimit,
isDarkMode,
Item,
mpCost,
myAdventures,
myFamiliar,
myHp,
myInebriety,
myMaxhp,
myMaxmp,
myMp,
print,
runChoice,
Skill,
totalFreeRests,
use,
useSkill,
visitUrl,
} from "kolmafia";
import { $familiar, get, SourceTerminal } from "libram";
import { $familiar, $item, get, have, SourceTerminal } from "libram";

/**
* Find the best element of an array, where "best" is defined by some given criteria.
Expand Down Expand Up @@ -90,6 +99,7 @@ export const args = Args.create("chrono", "A script for farming chroner", {
["rose", "Farm Roses from The Main Stage"],
["capsule", "Farm Time Capsules from the Cave Before Time"],
["future", "Farm... something from the Automated Future"],
["rock", "Get Caveman Dan's Favorite Rock - duped as much as possible"],
["soup", "Farm soup ingredients from the Primordial Stew"],
],
default: "rose",
Expand Down Expand Up @@ -146,3 +156,35 @@ export function realmAvailable(identifier: RealmType): boolean {
get(`${identifier}AirportAlways`, false)
);
}

export function freeRest(): boolean {
if (get("timesRested") >= totalFreeRests()) return false;

if (myHp() >= myMaxhp() && myMp() >= myMaxmp()) {
if (have($item`awful poetry journal`)) {
use($item`awful poetry journal`);
} else {
// burn some mp so that we can rest
const bestSkill = maxBy(
Skill.all().filter((sk) => have(sk) && mpCost(sk) >= 1),
(sk) => -mpCost(sk),
); // are there any other skills that cost mana which we should blacklist?
// Facial expressions? But this usually won't be an issue since all *NORMAL* classes have access to a level1 1mp skill
useSkill(bestSkill);
}
}

if (get("chateauAvailable")) {
visitUrl("place.php?whichplace=chateau&action=chateau_restlabelfree");
} else if (get("getawayCampsiteUnlocked")) {
visitUrl("place.php?whichplace=campaway&action=campaway_tentclick");
} else {
visitUrl("campground.php?action=rest");
}

return true;
}

export function freeRestsLeft(): boolean {
return get("timesRested") >= totalFreeRests();
}
25 changes: 24 additions & 1 deletion src/macro.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Item, Monster, myFamiliar, Skill } from "kolmafia";
import { haveEquipped, Item, Monster, myFamiliar, Skill } from "kolmafia";
import {
$familiar,
$item,
Expand Down Expand Up @@ -84,6 +84,29 @@ export default class Macro extends StrictMacro {
return this.step(steps);
}

getRocks(): this {
return this.externalIf(
myFamiliar() === $familiar`Grey Goose` &&
$familiar`Grey Goose`.experience >= 36,
Macro.trySkill($skill`Emit Matter Duplicating Drones`),
).externalIf(
haveEquipped($item`pro skateboard`),
Macro.trySkill($skill`Do an epic McTwist!`),
);
}

static getRocks(): Macro {
return new Macro().getRocks();
}

spikes(): this {
return this.trySkill($skill`Launch spikolodon spikes`);
}

static spikes(): Macro {
return new Macro().spikes();
}

standardCombat(): this {
return this.externalIf(
canOpenRedPresent() && myFamiliar() === $familiar`Crimbo Shrub`,
Expand Down
31 changes: 22 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
canAdventure,
cliExecute,
myAdventures,
myAscensions,
myClass,
myTurncount,
print,
Expand Down Expand Up @@ -48,6 +49,7 @@ import {
getBestAutomatedFutureSide,
} from "./future";
import { setup } from "./setup";
import { bigRock } from "./rocks";

const completed = () => {
const turncount = myTurncount();
Expand All @@ -64,6 +66,8 @@ function getQuest(): ChronerQuest {
return { ...rose, completed: completed() };
case "future":
return { ...future, completed: completed() };
case "rock":
return { ...bigRock, completed: completed() };
case "soup":
return { ...soup, completed: completed() };
default:
Expand Down Expand Up @@ -124,7 +128,10 @@ export function main(command?: string) {
},
{
name: "Clara's Bell",
completed: () => !have($item`Clara's bell`) || get("_claraBellUsed"),
completed: () =>
!have($item`Clara's bell`) ||
get("_claraBellUsed") ||
get("noncombatForcerActive"),
do: () => {
use($item`Clara's bell`);
},
Expand Down Expand Up @@ -255,6 +262,10 @@ export function main(command?: string) {
},
{
name: "Time Capsule",
ready: () =>
args.mode !== "rock" ||
get("_questCaveDan", 0) > 4 ||
get("lastCaveDanDefeat", 0) >= myAscensions(),
do: () => {
const turns = totalTurnsPlayed();
adv1($location`The Cave Before Time`, 0, "");
Expand All @@ -268,6 +279,7 @@ export function main(command?: string) {
forced: true,
sobriety: "either",
completed: () => false,
choices: { 955: 2 },
combat: new ChronerStrategy(() => Macro.standardCombat()),
},
{
Expand All @@ -284,18 +296,17 @@ export function main(command?: string) {
},
),
do: quest.location,
completed: () => false,
completed: () => get("noncombatForcerActive"),
prepare: () => cliExecute("parka spikolodon"),
combat: new ChronerStrategy(() =>
Macro.trySkill($skill`Launch spikolodon spikes`).standardCombat(),
),
combat: new ChronerStrategy(() => Macro.spikes().standardCombat()),
sobriety: "sober",
},
{
name: "Bowling Ball Run",
ready: () =>
get("cosmicBowlingBallReturnCombats") < 1 &&
get("hasCosmicBowlingBall"),
get("hasCosmicBowlingBall") &&
!get("noncombatForcerActive"),
do: $location`The Cave Before Time`,
sobriety: "sober",
completed: () => false,
Expand All @@ -311,7 +322,7 @@ export function main(command?: string) {
},
{
name: "Asdon Bumper",
ready: () => AsdonMartin.installed(),
ready: () => AsdonMartin.installed() && !get("noncombatForcerActive"),
completed: () =>
get("banishedMonsters").includes("Spring-Loaded Front Bumper"),
sobriety: "sober",
Expand All @@ -328,7 +339,7 @@ export function main(command?: string) {
},
{
name: "Asdon Missile",
ready: () => AsdonMartin.installed(),
ready: () => AsdonMartin.installed() && !get("noncombatForcerActive"),
completed: () => get("_missileLauncherUsed"),
combat: new ChronerStrategy(() => {
const romance = get("romanticTarget");
Expand All @@ -348,7 +359,9 @@ export function main(command?: string) {
name: "Spit Jurassic Acid",
completed: () => have($effect`Everything Looks Yellow`),
ready: () =>
have($item`Jurassic Parka`) && have($skill`Torso Awareness`),
have($item`Jurassic Parka`) &&
have($skill`Torso Awareness`) &&
!get("noncombatForcerActive"),
outfit: () =>
chooseQuestOutfit(
{ location: yrTarget, isFree: true },
Expand Down
14 changes: 9 additions & 5 deletions src/outfit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { freeFightFamiliar, MenuOptions } from "./familiar";
import { garboAverageValue, garboValue } from "./garboValue";
import { args, maxBy, realmAvailable, sober } from "./lib";
import { OutfitSlot, OutfitSpec } from "grimoire-kolmafia";
import {
canEquip,
Expand All @@ -19,10 +22,6 @@ import {
sumNumbers,
} from "libram";

import { freeFightFamiliar, MenuOptions } from "./familiar";
import { garboAverageValue, garboValue } from "./garboValue";
import { maxBy, realmAvailable, sober } from "./lib";

export function ifHave(
slot: OutfitSlot,
item: Item,
Expand All @@ -48,7 +47,8 @@ export function chooseQuestOutfit(
{ location, isFree }: TaskOptions,
...outfits: OutfitSpec[]
): OutfitSpec {
const familiar = chooseFamiliar({ location });
const mergedInputSpec = mergeSpecs(...outfits);
const familiar = mergedInputSpec.familiar ?? chooseFamiliar({ location });
const famEquip =
equipmentFamiliars.get(familiar) ??
(familiar.elementalDamage || familiar.physicalDamage
Expand Down Expand Up @@ -179,6 +179,10 @@ const accessories = new Map<Item, (isFree?: boolean) => number>([
[$item`lucky gold ring`, luckyGoldRing],
[$item`Mr. Screege's spectacles`, () => 180],
[$item`Mr. Cheeng's spectacles`, () => 220],
[
$item`pro skateboard`,
() => (args.mode === "rock" && get("_questCaveDan", 0) === 5 ? 10000 : 0),
],
]);

function getBestAccessories(isFree?: boolean) {
Expand Down
Loading

0 comments on commit c006065

Please sign in to comment.