diff --git a/bridge/src/index.js b/bridge/src/index.js index d4c3660..4441b5d 100644 --- a/bridge/src/index.js +++ b/bridge/src/index.js @@ -262,6 +262,8 @@ let combatActive = false; let combatTargetId = null; let combatInterval = null; let lastEquipCheck = 0; +const combatBlacklist = new Map(); // entityId → timestamp (don't re-engage) +const COMBAT_BLACKLIST_DURATION = 30000; // 30 seconds function startCombat(target) { if (combatActive) return; @@ -321,7 +323,11 @@ function endCombat(reason) { if (combatInterval) clearInterval(combatInterval); combatInterval = null; combatActive = false; - log('client', 'INFO', `⚔ Combat ended: ${reason}`); + // Blacklist this entity so we don't re-engage immediately + if (combatTargetId != null) { + combatBlacklist.set(combatTargetId, Date.now()); + } + log('client', 'INFO', `Combat ended: ${reason} (blacklisted for 30s)`); sendEvent('combat_ended', { reason }); combatTargetId = null; } @@ -330,6 +336,12 @@ function endCombat(reason) { setInterval(() => { if (!spawned || combatActive) return; + // Clean expired blacklist entries + const now = Date.now(); + for (const [id, time] of combatBlacklist) { + if (now - time > COMBAT_BLACKLIST_DURATION) combatBlacklist.delete(id); + } + const pos = bot.entity.position; let closestHostile = null; let closestDist = 8; // Aggro range @@ -337,6 +349,8 @@ setInterval(() => { for (const entity of Object.values(bot.entities)) { if (entity === bot.entity || !entity.position) continue; if (!isHostile(entity)) continue; + // Skip blacklisted entities (already fought, didn't die) + if (combatBlacklist.has(entity.id)) continue; const dist = entity.position.distanceTo(pos); if (dist < closestDist) { closestDist = dist;