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
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user