From 348ee2d871ed7df3ac0d53b253fc1d94541aa663 Mon Sep 17 00:00:00 2001 From: Kent Rasmussen Date: Thu, 15 Feb 2024 15:33:51 +0900 Subject: [PATCH] Add clarifying comments for what `targeted` does --- node/server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/node/server.js b/node/server.js index a3b74b1..1560843 100644 --- a/node/server.js +++ b/node/server.js @@ -8594,10 +8594,13 @@ function init_io() { // Only look at the first 16 targets in the array if more are provided for (const t of data.targets.slice(0, 16)) { const id = t[0]; + + // Prevent attacking the same entity twice if (targeted[id]) { continue; } targeted[id] = true; + const mp = max(0, parseInt(t[1]) || 0); if (mp <= 0) { continue; @@ -8678,15 +8681,17 @@ function init_io() { if (is_array(data.ids)) { // Only look at the first Xshot targets in the array if more are provided for (const id of data.ids.slice(0, data.name === "5shot" ? 5 : 3)) { + // Prevent attacking the same entity twice if (targeted[id]) { - // Already targeted this monster continue; } targeted[id] = true; + target = instances[player.in].monsters[id]; if (!target) { target = instances[player.in].players[id]; } + if (!target || is_invinc(target) || target.name == player.name) { continue; }