From 58d38af36962223c458e716afb4f30c9d6b3e7ba Mon Sep 17 00:00:00 2001 From: Kolby Nottingham Date: Thu, 12 Dec 2024 12:33:00 -0800 Subject: [PATCH] task init fixes --- src/agent/tasks.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 453125e..9dfa232 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -66,7 +66,10 @@ export class Task { if (!task) { throw new Error(`Task ${task_id} not found`); } - + if ((!task.agent_count || task.agent_count <= 1) && this.agent.count_id > 0) { + task = null; + } + return task; } catch (error) { console.error('Error loading task:', error); @@ -104,7 +107,7 @@ export class Task { //wait for a bit so inventory is cleared await new Promise((resolve) => setTimeout(resolve, 500)); - if (this.data.agent_number > 1) { + if (this.data.agent_count > 1) { var initial_inventory = this.data.initial_inventory[this.agent.count_id.toString()]; console.log("Initial inventory:", initial_inventory); } else if (this.data) { @@ -135,13 +138,13 @@ export class Task { // Finding if there is a human player on the server for (const playerName in bot.players) { const player = bot.players[playerName]; - if (!available_agents.some((n) => n === name)) { + if (!available_agents.some((n) => n === playerName)) { console.log('Found human player:', player.username); human_player_name = player.username break; } - } - + } + // If there are multiple human players, teleport to the first one // teleport near a human player if found by default