Mobs keep attacking until the player dies (2026-11-27, Claude)
Owner report (Janari): when standing next to mobs for a long time, they eventually stop attacking. They must keep attacking until the player is dead.
Cause (reproduced, not the aggro timer)
Aggro/leash were fine: aggro stayed refreshed (3 s while in sight), no leash, no return home. Two stalls in Scripts/Enemies/OverworldSkeleton.gd:
- Attack-line ray hit the wall at the player's feet.
_clear_attack_line_fromcasts a ray from the mob to the target's feet (+5 px). When the player stands against a fence, wall, rock or tree, the last pixels of the ray touch that collider, the line counts as blocked, so the mob stays in CHASE right next to the player (~48 px), pushing into the player forever, never swinging. Sparring moves the mob around, so sooner or later it lands on such an angle. Archers had the same freeze (their ray ends at the player's centre). - Pressed just outside attack_range. In ATTACK state (allowed up to attack_range + 14) a melee mob pinned against a wall/body at e.g. 88.5 px with range 88 never started a swing (start needed <= attack_range) and could not get closer.
Fix (OverworldSkeleton.gd only; online server mobs are separate, untouched)
ATTACK_LINE_END_SLACK = 14: a ray hit within 14 px of the target end is not cover.- If the line really is blocked at striking distance for 0.6 s,
_update_reposition/_find_attack_spotwalk the mob to a free spot around the target (sides first) with a clear line; new spot after 2 s; stays inside leash. - A melee mob that is not moving (real speed < 6) may start its swing up to attack_range + ATTACK_EXIT_MARGIN (reach is attack_range + melee_damage_extra_range, so it lands).
Pure local AI decisions, no new synced state: multiplayer-compatible.
Test
Scripts/Build/GameChecks/game_check_mob_persist.gd (run with run_one_game_check.ps1 -Script game_check_mob_persist.gd, ~3 min). Player stands still (godmode) next to goblin, skeleton, and with feet on GraveFenceWest_middle_07 vs goblin, skeleton, archer. PASS = swings keep coming, no gap > 8 s.
- Before: 5/5 FAIL (gaps 28-30 s, archer 0 shots). After: 5/5 PASS twice (gaps <= 2.9 s).
- run_game_checks quick: play 36/37, armor 9/9.
click_pathFAIL also on the old code (pre-existing, player click navigation, not this change). stress_40 79.4 FPS (budget 80) measured with the editor open and other threads running; the new code only runs while a mob is blocked.
Archive / rollback: D:/WieldHavenBackups/archive/mob_keep_attacking_20261127/ (OverworldSkeleton.gd.before, .after). Nothing deleted.