Merge pull request #282 from kolbytn/return_death

Return to death
This commit is contained in:
Max Robinson 2024-11-03 23:02:12 -06:00 committed by GitHub
commit 0a21561dcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -273,7 +273,14 @@ 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.x, death_pos.y, death_pos.z);
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 dimention = this.bot.game.dimension;
this.handleMessage('system', `You died at position ${death_pos_text || "unknown"} in the ${dimention} dimension with the final message: '${message}'. Your place of death is saved as 'last_death_position' if you want to return. Previous actions were stopped and you have respawned.`);
}
});
this.bot.on('idle', () => {

View file

@ -120,7 +120,7 @@ const modes = [
update: async function (agent) {
const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 16);
if (enemy && await world.isClearPath(agent.bot, enemy)) {
say(agent, `Aaa! A ${enemy.name}!`);
say(agent, `Aaa! A ${enemy.name.replace("_", " ")}!`);
execute(this, agent, async () => {
await skills.avoidEnemies(agent.bot, 24);
});