Fix enemy idle->patrolling state transition
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -96,7 +96,7 @@ abstract class Enemy extends Entity {
|
||||
// Reaction delay has passed
|
||||
isAlerted = true;
|
||||
|
||||
if (state == EntityState.idle) {
|
||||
if (state == EntityState.idle || state == EntityState.ambush) {
|
||||
state = EntityState.patrolling;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ class Guard extends Enemy {
|
||||
);
|
||||
}
|
||||
|
||||
// Attack if the player is within 6 tiles and the cooldown has passed.
|
||||
if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 1500) {
|
||||
// Attack if the player is within 6 tiles and the brief cooldown has passed.
|
||||
if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 400) {
|
||||
if (hasLineOfSight(playerPosition, isWalkable)) {
|
||||
state = EntityState.attacking;
|
||||
lastActionTime = elapsedMs;
|
||||
|
||||
@@ -89,8 +89,8 @@ class SS extends Enemy {
|
||||
);
|
||||
}
|
||||
|
||||
// FIX 3: Only attack if alerted (Adjust the distance/timing per enemy class!)
|
||||
if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 1500) {
|
||||
// Attack if the player is within 6 tiles and the brief cooldown has passed.
|
||||
if (isAlerted && distance < 6.0 && elapsedMs - lastActionTime > 400) {
|
||||
if (hasLineOfSight(playerPosition, isWalkable)) {
|
||||
state = EntityState.attacking;
|
||||
lastActionTime = elapsedMs;
|
||||
|
||||
Reference in New Issue
Block a user