From 648d4f825531a27d0e8d06a07f2a5ce68b8dab8c Mon Sep 17 00:00:00 2001 From: Lawtro37 <98205608+Lawtro37@users.noreply.github.com> Date: Sun, 27 Oct 2024 20:35:02 +1000 Subject: [PATCH] Add files via upload --- src/agent/agent.js | 18 +++++++++++++++++- src/agent/commands/actions.js | 13 +++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index 5be2385..dc3380b 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -28,6 +28,8 @@ export class Agent { initModes(this); + let last_death_pos = null; + let save_data = null; if (load_mem) { save_data = this.history.load(); @@ -260,7 +262,21 @@ export class Agent { this.bot.on('messagestr', async (message, _, jsonMsg) => { if (jsonMsg.translate && jsonMsg.translate.startsWith('death') && message.startsWith(this.name)) { console.log('Agent died: ', message); - this.handleMessage('system', `You died with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions.`); + let death_pos = this.bot.entity.position; + this.memory_bank.rememberPlace('last death position', death_pos); + let death_pos_text = null; + if (death_pos) { + death_pos_text = `x: ${death_pos.x.toFixed(2)}, y: ${death_pos.y.toFixed(2)}, z: ${death_pos.x.toFixed(2)}`; + } + let inventory = this.bot.inventory.slots; + let death_items = ""; + for (let i=0; i { diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index a80ad29..ffc61e4 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -295,6 +295,19 @@ export const actionsList = [ await skills.goToBed(agent.bot); }) }, + { + name: "!goToDeath", + description: "Go to the location of your bot's last death position and retrieve any lost items.", + perform: wrapExecution(async (agent) => { + let death_pos = agent.memory_bank.recallPlace('last death position')[0]; // <- dont even ask why this is an array + if (death_pos !== null) { + await skills.goToPosition(agent.bot, death_pos.x, death_pos.y, death_pos.z, 1); + console.log('going to death'); + } else { + skills.log(agent.bot, "No death location saved."); + } + }) + }, { name: '!activate', description: 'Activate the nearest object of a given type.',