Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
charredUtensil committed Dec 2, 2024
1 parent 5594ee2 commit f20c6ec
Show file tree
Hide file tree
Showing 24 changed files with 204 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/core/architects/blackout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const BLACKOUT = [
plan.lakeSize >= 3 &&
plan.pearlRadius > 0 &&
!cavern.context.hasSlugs &&
0.03,
cavern.context.anchorWhimsy * 0.03,
},
] as const satisfies readonly Architect<typeof METADATA>[];
export default BLACKOUT;
12 changes: 6 additions & 6 deletions src/core/architects/build_and_power.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,26 @@ function bidHelper(
max: number,
dormant: number,
active: number,
): number | false {
): number {
let extantCount = 0;
let unestablishedCount = 0;
for (const p of plans) {
if (p.kind === "cave" && !p.architect) {
unestablishedCount++;
} else if (p.metadata?.tag === TAG) {
if (p.metadata.template !== template) {
return false;
return 0;
}
extantCount += 1;
if (extantCount >= max) {
return false;
return 0;
}
}
}
if (extantCount > 0) {
return active;
} else {
return unestablishedCount >= max * 2 && dormant;
return unestablishedCount >= max * 2 ? dormant : 0;
}
}

Expand Down Expand Up @@ -262,7 +262,7 @@ export const BUILD_AND_POWER = [
intersectsOnly(plans, plan, null) &&
hops.length > 5 &&
!hops.some((h) => plans[h].metadata?.tag === TAG) &&
bidHelper(plans, GEOLOGICAL_CENTER, 3, 0.04, 10)
cavern.context.planWhimsy * bidHelper(plans, GEOLOGICAL_CENTER, 3, 0.04, 10)
);
},
},
Expand Down Expand Up @@ -292,7 +292,7 @@ export const BUILD_AND_POWER = [
amd.special === 'gasLeak' &&
hops.length > 3 &&
!hops.some((h) => plans[h].metadata?.tag === TAG) &&
bidHelper(plans, SUPPORT_STATION, 3, 10, 5)
cavern.context.planWhimsy * bidHelper(plans, SUPPORT_STATION, 3, 10, 5)
);
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/established_hq/fixed_complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const FIXED_COMPLETE = [
name: "Hq.FixedComplete",
...BASE,
...FC_BASE,
anchorBid: ({ plan }) => !plan.fluid && plan.pearlRadius > 6 && 0.1,
anchorBid: ({ cavern, plan }) => !plan.fluid && plan.pearlRadius > 6 && cavern.context.anchorWhimsy * 0.1,
},
] as const satisfies readonly Architect<HqMetadata>[];

Expand Down
4 changes: 3 additions & 1 deletion src/core/architects/established_hq/gas_leak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ELECTRIC_FENCE_ID,
} from "../../models/building";
import { gCreatures } from "../utils/creature_spawners";
import { hintSelectLaserGroup } from "../utils/hints";
import { gObjectives } from "../utils/objectives";
import { mkVars } from "../utils/script";
import { BASE, HqMetadata, getPlaceBuildings } from "./base";
Expand Down Expand Up @@ -76,6 +77,7 @@ const GAS_LEAK_BASE: Pick<
// Loop
`${v.holdLoop};`,
);
hintSelectLaserGroup(sb);
},
};

Expand All @@ -90,7 +92,7 @@ const GAS_LEAK = [
cavern.context.hasAirLimit &&
plan.lakeSize > 3 &&
plan.pearlRadius > 3 &&
0.2,
cavern.context.anchorWhimsy * 0.2,
},
] satisfies Architect<HqMetadata>[];

Expand Down
4 changes: 2 additions & 2 deletions src/core/architects/established_hq/island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ const ISLAND = [
{ of: Rough.WATER, width: 2, grow: 2 },
{ of: Rough.MIX_FRINGE },
),
anchorBid: ({ plan }) =>
anchorBid: ({ cavern, plan }) =>
plan.fluid === Tile.WATER &&
plan.lakeSize > 3 &&
plan.path.baseplates.length === 1 &&
plan.pearlRadius > 5 &&
0.2,
cavern.context.anchorWhimsy * 0.2,
},
] satisfies Architect<HqMetadata>[];

Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/established_hq/lost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const LOST = [
hops.length <= MAX_HOPS &&
plans[cavern.anchor]?.metadata?.tag !== "mobFarm" &&
!plans.some((p) => p.metadata?.tag === "hq") &&
(plans[hops[0]].metadata?.tag === "nomads" ? 5 : 0.5),
cavern.context.planWhimsy * (plans[hops[0]].metadata?.tag === "nomads" ? 5 : 0.5),
},
] as const satisfies readonly Architect<HqMetadata>[];

Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/lost_miners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ const LOST_MINERS = [
(r, p) => (p.metadata?.tag === "lostMiners" ? r + 1 : r),
0,
) < 4 &&
MULTIPLIERS[cavern.context.biome],
cavern.context.planWhimsy * MULTIPLIERS[cavern.context.biome],
},
] as const satisfies readonly Architect<LostMinersMetadata>[];
export default LOST_MINERS;
11 changes: 2 additions & 9 deletions src/core/architects/mob_farm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import { mkVars } from "./utils/script";
import {
MOB_FARM_NO_LONGER_BLOCKING,
} from "../lore/graphs/events";
import { HINT_SELECT_LASER_GROUP } from "../lore/graphs/hints";
import { gObjectives } from "./utils/objectives";
import { hintSelectLaserGroup } from "./utils/hints";

const BANLIST = [
DOCKS,
Expand Down Expand Up @@ -160,8 +160,6 @@ const BASE: PartialArchitect<MobFarmMetadata> = {
},
script({ cavern, plan, sb }) {
const v = mkVars(`p${plan.id}MbFm`, [
"hintGroup",
"msgHintGroup",
"msgNotBlocking",
]);
const rng = cavern.dice.script(plan.id);
Expand All @@ -183,12 +181,7 @@ const BASE: PartialArchitect<MobFarmMetadata> = {
// Hint to tell players about control groups. This isn't super annoying
// under normal circumstances, but here it's almost a necessity that the
// player have their lasers bound to a single key.
sb.declareInt(v.hintGroup, 0);
[MINING_LASER, SMLC].forEach((e) =>
sb.when(`${e.id}.click`, `((${e.id}>1))${v.hintGroup}=1;`),
);
sb.declareString(v.msgHintGroup, HINT_SELECT_LASER_GROUP);
sb.if(`${v.hintGroup}>0`, `msg:${v.msgHintGroup};`);
hintSelectLaserGroup(sb);
},
monsterSpawnScript: (args) =>
monsterSpawnScript(args, {
Expand Down
47 changes: 42 additions & 5 deletions src/core/architects/ore_waste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { Architect, BaseMetadata } from "../models/architect";
import { ORE_REFINERY, POWER_STATION, SUPPORT_STATION, TELEPORT_PAD, TOOL_STORE } from "../models/building";
import { Tile } from "../models/tiles";
import { DefaultSpawnArchitect, PartialArchitect } from "./default";
import { hintEjectRefineOre } from "./utils/hints";
import { getTotalOre } from "./utils/resources";
import { mkRough, Rough } from "./utils/rough";

const METADATA = {tag: "oreWaste"} as const satisfies BaseMetadata;

// TO DO:
// Need a hint for when there's a lot of ore collected, but few studs.

/**
* Approximately how much ore is needed to build a functional base capable
* of producing Building Studs.
Expand All @@ -23,8 +27,8 @@ const ORE_OVERHEAD = (
POWER_STATION.ore + 5 +
// Support Station Lv1
SUPPORT_STATION.ore +
// Ore Refinery Lv4 (2 ore/stud)
ORE_REFINERY.ore + 5 * 3
// Ore Refinery Lv1
ORE_REFINERY.ore
);

function wasted(t: Tile) {
Expand Down Expand Up @@ -52,7 +56,7 @@ const BASE: PartialArchitect<typeof METADATA> = {
hops: 0.20,
order: -0.20,
},
caveOreSeamBias: 0.5,
caveOreSeamBias: 0.6,
...cavern.initialContext,
});
return { ...cavern, context };
Expand All @@ -73,11 +77,44 @@ const BASE: PartialArchitect<typeof METADATA> = {
// ore. No reason to prolong this with an additional ore objective.
return undefined;
}
const studs = (getTotalOre(cavern) - ORE_OVERHEAD) * 0.12 / 2;
// Assume 5 ore per stud - better ratios are available by upgrading the
// refinery, but this is really just a bonus. After some testing, I noticed
// some major issues that make ore collection excruciatingly boring:

// 1. Assuming the player won't build a remote base (at a cost of 1 stud)
// and use this to "teleport" the ore back to their main base, even with
// an upgraded refinery each stud takes up at least two cargo spaces.
// This means double the trips. Even with an armada of Tunnel
// Transports, the game seems to take forever between the point when
// enough ore is available on the ground and when it's all collected and
// converted to studs. By this point there's really no interaction left.
// 2. Early game takes a very long time. The player will spend much of it
// without a power station - which means no Electric Fences. No Support
// Station means no air but also no vehicles. Rubble is everywhere but
// there's no reward for clearing it. While this is not _entirely_ true
// since the rubble around the edges of caves actually does have normal
// amounts of ore, the player is unlikely to notice this and assume no
// rubble contains ore.
// 3. Vehicle AI is bad and annoying. I frequently observed STTs picking up
// a single Energy Crystal, driving back to base, picking up one stud,
// and then driving back out to some other random cave to collect a
// single ore before driving back to drop all three off at the Tool
// Store. All the while, piles of ore sitting _near_ the base would be
// ignored.
// 4. Continuing to mine after enough resources are exposed actively makes
// things worse - If the player doesn't turn off crystal collection,
// vehicles will be distracted.
const studs = (getTotalOre(cavern) - ORE_OVERHEAD) * cavern.context.crystalGoalRatio / 5;
if (studs <= 0) {
return undefined;
}
return {
studs: Math.floor(studs / 5) * 5,
sufficient: false,
}
},
script({sb}) {
hintEjectRefineOre(sb);
}
};

Expand All @@ -95,7 +132,7 @@ const ORE_WASTE = [
plan.lakeSize >= 3 &&
plan.pearlRadius > 0 &&
cavern.plans.reduce((r, p) => p.hasErosion ? r + 1 : r, 0) < 3 &&
0.03,
cavern.context.anchorWhimsy * 0.03,
},
] as const satisfies readonly Architect<typeof METADATA>[];
export default ORE_WASTE;
2 changes: 1 addition & 1 deletion src/core/architects/seismic/boss_battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const BOSS_BATTLE = [
plan.pearlRadius >= 5 &&
plan.path.baseplates.length === 1 &&
!plan.intersects.some((_, i) => plans[i].metadata?.tag === "seismic") &&
0.1,
cavern.context.planWhimsy * 0.1,
},
] as const satisfies readonly Architect<Metadata>[];

Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/seismic/eruption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const ERUPTION = [
(_, i) =>
plans[i].fluid === Tile.WATER || plans[i].metadata?.tag === "seismic",
) &&
1,
cavern.context.planWhimsy * 1,
},
] as const satisfies readonly Architect<typeof METADATA>[];

Expand Down
4 changes: 2 additions & 2 deletions src/core/architects/seismic/secret_tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ const SECRET_TUNNEL = [
name: "Seismic.SecretTunnel",
...BASE,
...mkRough({ of: Rough.SOLID_ROCK }, { of: Rough.VOID, grow: 1 }),
hallBid: ({ plan, plans }) =>
hallBid: ({ cavern, plan, plans }) =>
!plan.fluid &&
plan.path.kind === "auxiliary" &&
plan.path.exclusiveSnakeDistance > 1 &&
!plan.intersects.some((_, i) => plans[i].metadata?.tag === "seismic") &&
0.75,
cavern.context.planWhimsy * 0.75,
},
] as const satisfies readonly Architect<typeof METADATA>[];

Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/slugs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const SLUGS = [
!plan.hasErosion &&
intersectsOnly(plans, plan, null) &&
!plans.some((p) => p.metadata?.tag === "slugNest") &&
0.25,
cavern.context.planWhimsy * 0.25,
},
{
name: "Slugs.Hall",
Expand Down
16 changes: 8 additions & 8 deletions src/core/architects/treasure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ const TREASURE = [
{ of: Rough.LOOSE_ROCK, shrink: 1 },
{ of: Rough.HARD_ROCK, grow: 0.5 },
),
caveBid: ({ plans, plan }) =>
caveBid: ({ cavern, plans, plan }) =>
!plan.fluid &&
plan.path.baseplates.length === 1 &&
isDeadEnd(plan) &&
intersectsOnly(plans, plan, null) &&
0.5,
cavern.context.planWhimsy * 0.5,
},
{
name: "Treasure.Hoard.Sealed",
Expand All @@ -160,11 +160,11 @@ const TREASURE = [
{ of: Rough.ALWAYS_LOOSE_ROCK },
{ of: Rough.ALWAYS_HARD_ROCK, grow: 0.5 },
),
caveBid: ({ plan }) =>
caveBid: ({ cavern, plan }) =>
!plan.fluid &&
plan.path.baseplates.length === 1 &&
isDeadEnd(plan) &&
0.5,
cavern.context.planWhimsy * 0.5,
},
{
name: "Treasure.Rich.Open",
Expand Down Expand Up @@ -215,13 +215,13 @@ const TREASURE = [
{ of: Rough.LOOSE_ROCK, shrink: 1 },
{ of: Rough.HARD_ROCK, grow: 0.5 },
),
caveBid: ({ plans, plan }) =>
caveBid: ({ cavern, plans, plan }) =>
plan.fluid === Tile.WATER &&
plan.pearlRadius > 3 &&
plan.path.baseplates.length >= 1 &&
isDeadEnd(plan) &&
intersectsOnly(plans, plan, null) &&
0.5,
cavern.context.planWhimsy * 0.5,
},
{
name: "Treasure.Rich.Lava.Island",
Expand All @@ -248,13 +248,13 @@ const TREASURE = [
{ of: Rough.BRIDGE_ON_LAVA, width: 2, grow: 3 },
{ of: Rough.HARD_ROCK, grow: 0.5 },
),
caveBid: ({ plans, plan }) =>
caveBid: ({ cavern, plans, plan }) =>
plan.fluid === Tile.LAVA &&
plan.pearlRadius > 3 &&
plan.path.baseplates.length >= 1 &&
isDeadEnd(plan) &&
intersectsOnly(plans, plan, null) &&
0.5,
cavern.context.planWhimsy * 0.5,
},
] as const satisfies readonly Architect<typeof METADATA>[];
export default TREASURE;
27 changes: 27 additions & 0 deletions src/core/architects/utils/hints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { HINT_EJECT_ORE, HINT_SELECT_LASER_GROUP } from "../../lore/graphs/hints";
import { MINING_LASER, ORE_REFINERY } from "../../models/building";
import { LMLC, SMLC } from "../../models/vehicle";
import { mkVars, ScriptBuilder } from "./script";

export function hintEjectRefineOre(sb: ScriptBuilder) {
const v = mkVars('hintEjectOre', ['do', 'msg']);
sb.declareInt(v.do, 0);
sb.when(
'ore>10',
`((${ORE_REFINERY.id}==0))return;`,
`((studs<5))return;`,
`${v.do}=1;`
);
sb.declareString(v.msg, HINT_EJECT_ORE);
sb.if(`${v.do}>0`, `msg:${v.msg};`);
}

export function hintSelectLaserGroup(sb: ScriptBuilder) {
const v = mkVars('hintLG', ['do', 'msg']);
sb.declareInt(v.do, 0);
[MINING_LASER, SMLC, LMLC].forEach((e) =>
sb.when(`${e.id}.click`, `((${e.id}>1))${v.do}=1;`),
);
sb.declareString(v.msg, HINT_SELECT_LASER_GROUP);
sb.if(`${v.do}>0`, `msg:${v.msg};`);
}
2 changes: 1 addition & 1 deletion src/core/architects/utils/tile_scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EventChainLine, ScriptBuilder, transformPoint } from "./script";

const TRIGGERS = {
flood: (cavern, x, y) => `place:${transformPoint(cavern, [x, y])},${Tile.WATER.id};`,
waste: (cavern, x, y) => `place:${transformPoint(cavern, [x, y])},${Tile.WASTE_RUBBLE_3.id};`,
waste: (cavern, x, y) => `place:${transformPoint(cavern, [x, y])},${Tile.WASTE_RUBBLE_2.id};`,
} as const satisfies {[key: string]: (cavern: PreprogrammedCavern, x: number, y: number) => EventChainLine};

export function tileScript({cavern, sb}: {
Expand Down
Loading

0 comments on commit f20c6ec

Please sign in to comment.