From f87b7fdfba2e7483ae38794efa3f3cd9c0c761ac Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 3 Nov 2026 22:54:31 +0100 Subject: AI: debug-log NPC relation changes --- src/esp.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/esp.cpp') diff --git a/src/esp.cpp b/src/esp.cpp index 0966ff5..b09588f 100644 --- a/src/esp.cpp +++ b/src/esp.cpp @@ -151,6 +151,22 @@ static bool model_is_neutral(const char *m) { static bool npc_is_friendly(int idx, const char *model, int local_idx, bool &neutral) { int rel = server_npc_relation(idx, local_idx); + // Debug-only: relation values are the authoritative answer and are the + // first thing to check when a friendly NPC still looks hostile. Logged only + // when an entity's relation changes, so this does not flood the log. + static int rel_cache[2048]; + static bool rel_cache_init = false; + if (!rel_cache_init) { + for (int i = 0; i < 2048; i++) + rel_cache[i] = -999; + rel_cache_init = true; + } + if (idx > 0 && idx < 2048 && rel_cache[idx] != rel) { + rel_cache[idx] = rel; + logd("npc %d (%s): relation=%d followtarget=%d local=%d", idx, + model ? model : "?", rel, + (int)server_npc_has_follow_target(idx), local_idx); + } if (rel == 3) { // D_LI neutral = false; return true; -- cgit v1.2.3