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