Skip to content

Commit

Permalink
Update for 2.14.2-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacetech committed Dec 22, 2024
1 parent b0964ee commit f11143e
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 49 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "TARS",
"description": "Let TARS play the game for you. Good thing there are no black holes in Wayward.",
"version": "3.2.1",
"version": "3.2.2",
"author": "Spacetech",
"github": "https://github.com/WaywardGame/tars",
"waywardVersion": "2.14.0-beta",
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"watch": "npx tsc --build --watch --pretty --preserveWatchOutput"
},
"devDependencies": {
"@wayward/types": "^2.14.1-beta",
"@wayward/types": "^2.14.2-beta",
"rimraf": "3.0.2",
"typescript": "^5.7.2"
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/ITars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export interface IBase {
furnace: Doodad[];
intermediateChest: Doodad[];
kiln: Doodad[];
sailboat: Doodad[];
boat: Doodad[];
solarStill: Doodad[];
waterStill: Doodad[];
well: Doodad[];
Expand Down Expand Up @@ -200,7 +200,7 @@ export const baseInfo: Record<BaseInfoKey, IBaseInfo> = {
litType: DoodadTypeGroup.LitKiln,
tryPlaceNear: "anvil",
},
sailboat: {
boat: {
doodadTypes: [DoodadType.Sailboat],
nearBaseDistanceSq: Infinity,
allowMultiple: true,
Expand Down Expand Up @@ -261,7 +261,7 @@ export interface IInventoryItems {
knife?: Item;
lockPick?: Item;
pickAxe?: Item;
sailboat?: Item;
boat?: Item;
shovel?: Item;
solarStill?: Item;
tongs?: Item;
Expand Down Expand Up @@ -538,7 +538,7 @@ export const inventoryItemInfo: Record<keyof IInventoryItems, IInventoryItemInfo
option: ActionType.Mine,
},
},
sailboat: {
boat: {
itemTypes: [ItemType.Sailboat],
// allowInChests: true,
// allowOnTiles: true,
Expand Down Expand Up @@ -607,7 +607,7 @@ export const inventoryBuildItems: Array<keyof IInventoryItems> = [
"furnace",
"anvil",
"solarStill",
"sailboat",
"boat",
"altar",
];

Expand Down
31 changes: 19 additions & 12 deletions src/core/Tars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ export default class Tars extends EventEmitter.Host<ITarsEvents> {
furnace: [],
intermediateChest: [],
kiln: [],
sailboat: [],
boat: [],
solarStill: [],
waterStill: [],
well: [],
Expand Down Expand Up @@ -1478,21 +1478,19 @@ export default class Tars extends EventEmitter.Host<ITarsEvents> {
interrupts.push(...this.getRecoverInterrupts(context, true, true));
}

interrupts = interrupts.concat([
this.buildItemObjectives(context),
// this.reduceWeightInterrupt(context),
]);
interrupts.push(...this.buildItemObjectives(context));
// this.reduceWeightInterrupt(context),

if (stayHealthy) {
interrupts.push(...this.getRecoverInterrupts(context, false, true));
}

interrupts = interrupts.concat([
interrupts = interrupts.concat(
this.gatherFromCorpsesInterrupt(context),
this.repairsInterrupt(context),
this.escapeCavesInterrupt(context),
this.returnToBaseInterrupt(context),
]);
);

const organizeInventoryInterrupts = this.organizeInventoryInterrupts(context);
if (organizeInventoryInterrupts) {
Expand Down Expand Up @@ -1709,14 +1707,14 @@ export default class Tars extends EventEmitter.Host<ITarsEvents> {
return this.utilities.item.getItemsToBuild(context).map(item => new BuildItem(item));
}

private gatherFromCorpsesInterrupt(context: Context): IObjective[] | undefined {
private gatherFromCorpsesInterrupt(context: Context): IObjective[][] | undefined {
if (!this.inventory.butcher) {
return undefined;
}

const targets = this.utilities.object.findCarvableCorpses(context, "gatherFromCorpsesInterrupt", corpse => Vector2.distance(context.human, corpse) < 16);

const objectives: IObjective[] = [];
const objectivePipelines: IObjective[][] = [];

for (const target of targets) {
const tile = target.tile;
Expand All @@ -1731,15 +1729,18 @@ export default class Tars extends EventEmitter.Host<ITarsEvents> {
const step = corpse.step || 0;
const count = resources.length - step;

const objectives: IObjective[] = [];
// try to butcher it the maximum amount of times. the actual amount of times could be different due to randomness
for (let i = 0; i < count; i++) {
objectives.push(new ButcherCorpse(corpse));
}

objectivePipelines.push(objectives);
}
}
}

return objectives;
return objectivePipelines;
}

private reduceWeightInterrupt(context: Context): IObjective | undefined {
Expand Down Expand Up @@ -1858,12 +1859,13 @@ export default class Tars extends EventEmitter.Host<ITarsEvents> {
continue;
}

const items: Item[] = [];

while (itemsToMove.length > 0) {
const itemToMove = itemsToMove[0];
const itemToMoveWeight = itemToMove.getTotalWeight(undefined, backpackContainer);
if (weight + itemToMoveWeight < weightCapacity) {
objectives.push(new ExecuteAction(MoveItemAction, [itemToMove, backpackContainer])
.setStatus(`Moving ${itemToMove.getName()} into ${backpack.getName()}`));
items.push(itemToMove);

weight += itemToMoveWeight;

Expand All @@ -1873,6 +1875,11 @@ export default class Tars extends EventEmitter.Host<ITarsEvents> {
break;
}
}

if (items.length > 0) {
objectives.push(new ExecuteAction(MoveItemAction, [items, backpackContainer])
.setStatus(`Moving ${items.join(",")} into ${backpack.getName()}`));
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/core/navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ export default class Navigation {
mapInfo.dirtyDijkstra = true;
mapInfo.dijkstraMap.updateNode(tile.x, tile.y, penalty, isDisabled);

const canSlip = tile.canSlip(undefined, true, true);
// we can't slip into a blocked tile
// todo: change the check for this?
const canSlip = !tile.hasBlockingTerrain && !tile.hasBlockingDoodad && tile.canSlip(undefined, true, true);

for (const direction of Direction.CARDINALS) {
const neighborTile = tile.getTileInDirection(direction);
Expand All @@ -315,7 +317,7 @@ export default class Navigation {
let nextNoSlipTile: Tile | undefined = neighborTile;

// if the entity can slip on this tile, we will assume they will and take that into account
while (nextNoSlipTile?.canSlip(undefined, true, true)) {
while (nextNoSlipTile && !nextNoSlipTile.hasBlockingTerrain && !nextNoSlipTile.hasBlockingDoodad && nextNoSlipTile.canSlip(undefined, true, true)) {
// direction ??= tile.getDirectionToTile(nextNoSlipTile);
nextNoSlipTile = nextNoSlipTile.getTileInDirection(direction);
}
Expand Down
20 changes: 16 additions & 4 deletions src/modes/Survival.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,19 @@ export class SurvivalMode extends BaseMode implements ITarsMode {
return objectives;
}

if (context.inventory.sailboat && context.human.island.items.isContainableInContainer(context.inventory.sailboat, context.human.inventory)) {
if (context.inventory.boat && context.human.island.items.isContainableInContainer(context.inventory.boat, context.human.inventory)) {
// we likely just moved to a new island
const movedToNewIslandObjectives: IObjective[] = [];

if (context.utilities.base.hasBase(context)) {
// we have a base, so maybe we're still preparing the move?
movedToNewIslandObjectives.push(new MoveToBase());

// this should be done in a Build interrupt
// if (context.base.boat.length === 0) {
// objectives.push([new AcquireInventoryItem("boat"), new BuildItem()]);
// }

} else {
const target = await context.utilities.base.findInitialBuildTile(context);
if (target) {
Expand Down Expand Up @@ -288,6 +294,12 @@ export class SurvivalMode extends BaseMode implements ITarsMode {

if (safeToDrinkWaterContainers.length < 2 && availableWaterContainers.length > 0) {
// we are trying to gather water. wait before moving on to upgrade objectives

// if (context.utilities.base.canBuildWaterDesalinators(context) && context.base.waterStill.length < 2 &&
// (context.base.dripStone.length === 0 || context.base.dripStone.every(dripStone => context.utilities.doodad.isWaterSourceDoodadBusy(dripStone))) || (context.base.waterStill.length === 0 || context.base.waterStill.every(waterStill => context.utilities.doodad.isWaterSourceDoodadBusy(waterStill)))) {
// objectives.push([new AcquireInventoryItem("waterStill"), new BuildItem()]);
// }

objectives.push([
new AcquireWater({ disallowTerrain: true, disallowWell: true, allowStartingWaterSourceDoodads: true, allowWaitingForWater: true })
.setStatus("Gathering water before upgrade objectives"),
Expand Down Expand Up @@ -438,9 +450,9 @@ export class SurvivalMode extends BaseMode implements ITarsMode {
case MovingToNewIslandState.Preparing:
// make a sail boat

// it's possible theres a sailboat at the time this is checked, but it's actually dropped after
if (context.base.sailboat.length === 0) {
objectives.push([new AcquireInventoryItem("sailboat"), new BuildItem()]);
// it's possible theres a boat at the time this is checked, but it's actually dropped after
if (context.base.boat.length === 0) {
objectives.push([new AcquireInventoryItem("boat"), new BuildItem()]);
}

if (needHealthRecovery) {
Expand Down
8 changes: 4 additions & 4 deletions src/objectives/core/MoveToTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ export default class MoveToTarget extends Objective {
}
}

if (this.options?.allowBoat && context.inventory.sailboat && !context.human.vehicleItemReference) {
if (this.options?.allowBoat && context.inventory.boat && !context.human.vehicleItemReference) {
const tile = context.human.tile;
const terrainDescription = tile.description;
if (terrainDescription?.water) {
return [
new UseItem(Ride, context.inventory.sailboat),
new UseItem(Ride, context.inventory.boat),
new MoveToTarget(this.target, this.moveAdjacentToTarget, { ...this.options, allowBoat: false }),
];
}
Expand All @@ -285,7 +285,7 @@ export default class MoveToTarget extends Objective {
if (firstWaterTile) {
return [
new MoveToTarget(firstWaterTile, false),
new UseItem(Ride, context.inventory.sailboat),
new UseItem(Ride, context.inventory.boat),
new MoveToTarget(this.target, this.moveAdjacentToTarget, { ...this.options }),
];
}
Expand Down Expand Up @@ -415,7 +415,7 @@ export default class MoveToTarget extends Objective {
}
}

if (this.options?.allowBoat && context.inventory.sailboat && !context.human.vehicleItemReference) {
if (this.options?.allowBoat && context.inventory.boat && !context.human.vehicleItemReference) {
const tile = context.human.tile;
const terrainDescription = tile.description;
if (terrainDescription?.water) {
Expand Down
4 changes: 2 additions & 2 deletions src/objectives/other/item/BuildItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ActionType } from "@wayward/game/game/entity/action/IAction";
import type Item from "@wayward/game/game/item/Item";
import Build from "@wayward/game/game/entity/action/actions/Build";
import type Tile from "@wayward/game/game/tile/Tile";
import { ItemType } from "@wayward/game/game/item/IItem";
import { VehicleType } from "@wayward/game/game/item/IItem";

import type Context from "../../../core/context/Context";
import { ContextDataType } from "../../../core/context/IContext";
Expand Down Expand Up @@ -68,7 +68,7 @@ export default class BuildItem extends Objective {

let moveToTargetObjectives: IObjective[];

if (item.type === ItemType.Sailboat) {
if (item.description?.vehicle?.type === VehicleType.Boat) {
moveToTargetObjectives = [
new MoveToWater(MoveToWaterType.SailAwayWater, { disallowBoats: true }),
];
Expand Down
6 changes: 3 additions & 3 deletions src/objectives/utility/OrganizeBase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ItemType } from "@wayward/game/game/item/IItem";
import { VehicleType } from "@wayward/game/game/item/IItem";
import type Item from "@wayward/game/game/item/Item";
import type Tile from "@wayward/game/game/tile/Tile";

Expand Down Expand Up @@ -49,8 +49,8 @@ export default class OrganizeBase extends Objective {
const itemsToMove: Item[] = [];

for (const item of tile.containedItems) {
if (item.type === ItemType.Sailboat) {
// don't organize sailboats
if (item.description?.vehicle?.type === VehicleType.Boat) {
// don't organize boats
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions src/objectives/utility/SailToCivilization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class SailToCivilization extends Objective {
}
}

objectives.push(new AcquireInventoryItem("sailboat"));
objectives.push(new AcquireInventoryItem("boat"));

if (!game.isChallenge) {
// todo: add a way to set this only for a specific item?
Expand All @@ -73,9 +73,9 @@ export default class SailToCivilization extends Objective {
}

objectives.push(
new MoveItemsIntoInventory(context.inventory.sailboat),
new MoveItemsIntoInventory(context.inventory.boat),
new MoveToWater(MoveToWaterType.SailAwayWater),
new ExecuteAction(SailToCivilizationAction, [context.inventory.sailboat, true]).setStatus(this),
new ExecuteAction(SailToCivilizationAction, [context.inventory.boat, true]).setStatus(this),
);

return objectives;
Expand Down
10 changes: 5 additions & 5 deletions src/objectives/utility/moveTo/MoveToIsland.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ export default class MoveToIsland extends Objective {

const objectivePipelines: IObjective[][] = [];

for (const sailboat of context.base.sailboat) {
const result = sailboat.tile.canSailAwayFrom(context.human);
for (const boat of context.base.boat) {
const result = boat.tile.canSailAwayFrom(context.human);
if (result.canSailAway) {
objectivePipelines.push([
new MoveToTarget(sailboat, false),
new MoveToTarget(boat, false),
new ExecuteAction(SailToIsland, [islandPosition.x, islandPosition.y]).setStatus(this),
]);
}
}

if (objectivePipelines.length === 0) {
// no sail boats or sailboats are not in good spots
// no sail boats or boats are not in good spots
objectivePipelines.push([
new AcquireInventoryItem("sailboat"),
new AcquireInventoryItem("boat"),
new MoveToWater(MoveToWaterType.SailAwayWater),
new ExecuteAction(SailToIsland, [islandPosition.x, islandPosition.y]).setStatus(this),
]);
Expand Down
4 changes: 1 addition & 3 deletions src/objectives/utility/moveTo/MoveToWater.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { WaterType } from "@wayward/game/game/island/IIsland";
import { TerrainType } from "@wayward/game/game/tile/ITerrain";
import type Tile from "@wayward/game/game/tile/Tile";

import type Context from "../../../core/context/Context";
Expand Down Expand Up @@ -57,7 +56,6 @@ export default class MoveToWater extends Objective {
return false;
}

const tileType = tile.type;
const terrainDescription = tile.description;
if (!terrainDescription) {
return false;
Expand All @@ -72,7 +70,7 @@ export default class MoveToWater extends Objective {
break;

case MoveToWaterType.SailAwayWater:
if (tileType !== TerrainType.DeepSeawater) {
if (!terrainDescription.water && !terrainDescription.shallowWater) {
return false;
}

Expand Down

0 comments on commit f11143e

Please sign in to comment.