From f11143e02ba1dfad0a370109a7060d857191bb04 Mon Sep 17 00:00:00 2001 From: Spacetech <824323+Spacetech@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:39:46 -0800 Subject: [PATCH] Update for 2.14.2-beta --- mod.json | 2 +- package-lock.json | 8 ++--- package.json | 2 +- src/core/ITars.ts | 10 +++--- src/core/Tars.ts | 31 ++++++++++++------- src/core/navigation/Navigation.ts | 6 ++-- src/modes/Survival.ts | 20 +++++++++--- src/objectives/core/MoveToTarget.ts | 8 ++--- src/objectives/other/item/BuildItem.ts | 4 +-- src/objectives/utility/OrganizeBase.ts | 6 ++-- src/objectives/utility/SailToCivilization.ts | 6 ++-- src/objectives/utility/moveTo/MoveToIsland.ts | 10 +++--- src/objectives/utility/moveTo/MoveToWater.ts | 4 +-- 13 files changed, 68 insertions(+), 49 deletions(-) diff --git a/mod.json b/mod.json index eec7d82..297544f 100644 --- a/mod.json +++ b/mod.json @@ -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", diff --git a/package-lock.json b/package-lock.json index 1b27d94..4835e40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "@wayward/tars", "version": "1.0.0", "devDependencies": { - "@wayward/types": "^2.14.1-beta", + "@wayward/types": "^2.14.2-beta", "rimraf": "3.0.2", "typescript": "^5.7.2" } @@ -34,9 +34,9 @@ } }, "node_modules/@wayward/types": { - "version": "2.14.1-beta", - "resolved": "https://registry.npmjs.org/@wayward/types/-/types-2.14.1-beta.tgz", - "integrity": "sha512-+35M87OKml5XwC6jUrRb03yzTdTYdmvRs6oH6uLeRkut2MGL3QftW0xWX6EByRS3lHO82YPtZVzjyP3viSDlUQ==", + "version": "2.14.2-beta", + "resolved": "https://registry.npmjs.org/@wayward/types/-/types-2.14.2-beta.tgz", + "integrity": "sha512-h66bAUd48QXXSonkB+6d/9BcqcPb2G+VxXhw9LvpQpxmyekGYHgwYehoFZu0NtYdWEu6fXw0hCgb9EdHcaZnZw==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index a54b88f..93e3e4d 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/src/core/ITars.ts b/src/core/ITars.ts index dac3f23..5d38d69 100644 --- a/src/core/ITars.ts +++ b/src/core/ITars.ts @@ -107,7 +107,7 @@ export interface IBase { furnace: Doodad[]; intermediateChest: Doodad[]; kiln: Doodad[]; - sailboat: Doodad[]; + boat: Doodad[]; solarStill: Doodad[]; waterStill: Doodad[]; well: Doodad[]; @@ -200,7 +200,7 @@ export const baseInfo: Record = { litType: DoodadTypeGroup.LitKiln, tryPlaceNear: "anvil", }, - sailboat: { + boat: { doodadTypes: [DoodadType.Sailboat], nearBaseDistanceSq: Infinity, allowMultiple: true, @@ -261,7 +261,7 @@ export interface IInventoryItems { knife?: Item; lockPick?: Item; pickAxe?: Item; - sailboat?: Item; + boat?: Item; shovel?: Item; solarStill?: Item; tongs?: Item; @@ -538,7 +538,7 @@ export const inventoryItemInfo: Record = [ "furnace", "anvil", "solarStill", - "sailboat", + "boat", "altar", ]; diff --git a/src/core/Tars.ts b/src/core/Tars.ts index 7a8b3c3..80250e2 100644 --- a/src/core/Tars.ts +++ b/src/core/Tars.ts @@ -1077,7 +1077,7 @@ export default class Tars extends EventEmitter.Host { furnace: [], intermediateChest: [], kiln: [], - sailboat: [], + boat: [], solarStill: [], waterStill: [], well: [], @@ -1478,21 +1478,19 @@ export default class Tars extends EventEmitter.Host { 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) { @@ -1709,14 +1707,14 @@ export default class Tars extends EventEmitter.Host { 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; @@ -1731,15 +1729,18 @@ export default class Tars extends EventEmitter.Host { 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 { @@ -1858,12 +1859,13 @@ export default class Tars extends EventEmitter.Host { 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; @@ -1873,6 +1875,11 @@ export default class Tars extends EventEmitter.Host { break; } } + + if (items.length > 0) { + objectives.push(new ExecuteAction(MoveItemAction, [items, backpackContainer]) + .setStatus(`Moving ${items.join(",")} into ${backpack.getName()}`)); + } } } diff --git a/src/core/navigation/Navigation.ts b/src/core/navigation/Navigation.ts index ba1d8ef..9d53d3f 100644 --- a/src/core/navigation/Navigation.ts +++ b/src/core/navigation/Navigation.ts @@ -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); @@ -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); } diff --git a/src/modes/Survival.ts b/src/modes/Survival.ts index 737e4a1..4197e6b 100644 --- a/src/modes/Survival.ts +++ b/src/modes/Survival.ts @@ -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) { @@ -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"), @@ -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) { diff --git a/src/objectives/core/MoveToTarget.ts b/src/objectives/core/MoveToTarget.ts index bcce412..2e150dd 100644 --- a/src/objectives/core/MoveToTarget.ts +++ b/src/objectives/core/MoveToTarget.ts @@ -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 }), ]; } @@ -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 }), ]; } @@ -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) { diff --git a/src/objectives/other/item/BuildItem.ts b/src/objectives/other/item/BuildItem.ts index 513faf9..036f909 100644 --- a/src/objectives/other/item/BuildItem.ts +++ b/src/objectives/other/item/BuildItem.ts @@ -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"; @@ -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 }), ]; diff --git a/src/objectives/utility/OrganizeBase.ts b/src/objectives/utility/OrganizeBase.ts index 599d7b0..604105e 100644 --- a/src/objectives/utility/OrganizeBase.ts +++ b/src/objectives/utility/OrganizeBase.ts @@ -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"; @@ -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; } diff --git a/src/objectives/utility/SailToCivilization.ts b/src/objectives/utility/SailToCivilization.ts index 1c8fa2b..ec48bd6 100644 --- a/src/objectives/utility/SailToCivilization.ts +++ b/src/objectives/utility/SailToCivilization.ts @@ -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? @@ -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; diff --git a/src/objectives/utility/moveTo/MoveToIsland.ts b/src/objectives/utility/moveTo/MoveToIsland.ts index 64275da..5d1202b 100644 --- a/src/objectives/utility/moveTo/MoveToIsland.ts +++ b/src/objectives/utility/moveTo/MoveToIsland.ts @@ -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), ]); diff --git a/src/objectives/utility/moveTo/MoveToWater.ts b/src/objectives/utility/moveTo/MoveToWater.ts index f8776d9..4a5be91 100644 --- a/src/objectives/utility/moveTo/MoveToWater.ts +++ b/src/objectives/utility/moveTo/MoveToWater.ts @@ -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"; @@ -57,7 +56,6 @@ export default class MoveToWater extends Objective { return false; } - const tileType = tile.type; const terrainDescription = tile.description; if (!terrainDescription) { return false; @@ -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; }