Kill kill kill

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-13 21:03:34 +01:00
parent d4d5a84bc4
commit 2f66ba451a
4 changed files with 158 additions and 39 deletions

View File

@@ -14,6 +14,25 @@ abstract class Enemy extends Entity {
super.lastActionTime,
});
int health = 25; // Standard guard health
bool isDying = false;
void takeDamage(int amount, int currentTime) {
if (state == EntityState.dead) return;
health -= amount;
lastActionTime = currentTime; // CRITICAL: Mark the start of the death/pain
if (health <= 0) {
state = EntityState.dead;
isDying = true; // This triggers the animation in BrownGuard
} else if (math.Random().nextDouble() < 0.5) {
state = EntityState.pain;
} else {
state = EntityState.patrolling;
}
}
// Decodes the Map ID to figure out which way the enemy is facing
static double getInitialAngle(int objId) {
int normalizedId = (objId - 108) % 36;