Working on fixing enemy identification

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 21:06:31 +01:00
parent 12e2e7e3a8
commit 1ec891d9a0
18 changed files with 293 additions and 292 deletions

View File

@@ -16,18 +16,13 @@ class Guard extends Enemy {
required super.angle,
required super.mapId,
}) : super(
spriteIndex: 50,
spriteIndex: EnemyType.guard.spriteBaseIdx,
state: EntityState.idle,
);
static Guard? trySpawn(int objId, double x, double y, Difficulty difficulty) {
// Guards span 108 to 143. (124 and 125 are decorative dead bodies).
if (objId >= MapObject.guardStart &&
objId <= MapObject.guardStart + 35 &&
objId != 124 &&
objId != 125) {
// If the ID is in the second half of the block, it's a Patrolling guard
bool isPatrolling = objId >= MapObject.guardStart + 18;
static Guard? trySpawn(int objId, double x, double y, Difficulty _) {
if (EnemyType.guard.claimsMapId(objId) && objId != 124 && objId != 125) {
bool isPatrolling = objId >= EnemyType.guard.mapBaseId + 18;
return Guard(
x: x,
@@ -110,15 +105,15 @@ class Guard extends Enemy {
case EntityState.attacking:
int timeShooting = elapsedMs - lastActionTime;
if (timeShooting < 150) {
spriteIndex = 96; // Aiming
spriteIndex = 90; // Aiming
} else if (timeShooting < 300) {
spriteIndex = 97; // Firing
spriteIndex = 91; // Firing
if (!_hasFiredThisCycle) {
onDamagePlayer(10);
_hasFiredThisCycle = true;
}
} else if (timeShooting < 450) {
spriteIndex = 98; // Recoil
spriteIndex = 90; // Recoil (back to aim pose)
} else {
state = EntityState.patrolling;
lastActionTime = elapsedMs;
@@ -126,8 +121,7 @@ class Guard extends Enemy {
break;
case EntityState.pain:
spriteIndex = 94; // Ouch frame
// Stay in pain for a brief moment, then resume attacking
spriteIndex = 92; // Ouch frame
if (elapsedMs - lastActionTime > 250) {
state = EntityState.patrolling;
lastActionTime = elapsedMs;
@@ -137,15 +131,14 @@ class Guard extends Enemy {
case EntityState.dead:
if (isDying) {
int deathFrame = (elapsedMs - lastActionTime) ~/ 150;
if (deathFrame < 4) {
// FIX: Removed the buggy "- 1"
spriteIndex = 90 + deathFrame;
if (deathFrame < 3) {
spriteIndex = 93 + deathFrame; // Cycles 93, 94, 95
} else {
spriteIndex = 95; // Final dead frame
isDying = false;
}
} else {
spriteIndex = 95;
spriteIndex = 95; // Final dead frame
}
break;