Fix enemy idle->patrolling state transition

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-17 14:05:20 +01:00
parent 6927c902a7
commit 9c60c81da5
3 changed files with 5 additions and 5 deletions

View File

@@ -96,7 +96,7 @@ abstract class Enemy extends Entity {
// Reaction delay has passed // Reaction delay has passed
isAlerted = true; isAlerted = true;
if (state == EntityState.idle) { if (state == EntityState.idle || state == EntityState.ambush) {
state = EntityState.patrolling; state = EntityState.patrolling;
} }

View File

@@ -105,8 +105,8 @@ class Guard extends Enemy {
); );
} }
// Attack if the player is within 6 tiles and the cooldown has passed. // Attack if the player is within 6 tiles and the brief cooldown has passed.
if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 1500) { if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 400) {
if (hasLineOfSight(playerPosition, isWalkable)) { if (hasLineOfSight(playerPosition, isWalkable)) {
state = EntityState.attacking; state = EntityState.attacking;
lastActionTime = elapsedMs; lastActionTime = elapsedMs;

View File

@@ -89,8 +89,8 @@ class SS extends Enemy {
); );
} }
// FIX 3: Only attack if alerted (Adjust the distance/timing per enemy class!) // Attack if the player is within 6 tiles and the brief cooldown has passed.
if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 1500) { if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 400) {
if (hasLineOfSight(playerPosition, isWalkable)) { if (hasLineOfSight(playerPosition, isWalkable)) {
state = EntityState.attacking; state = EntityState.attacking;
lastActionTime = elapsedMs; lastActionTime = elapsedMs;