There was some weirdness with hunter attack patterns. Tried to fix.
This commit is contained in:
24
src/enemy.py
24
src/enemy.py
@@ -126,15 +126,17 @@ class Enemy(Object):
|
||||
# Handle movement based on enemy type and pattern
|
||||
if (self.enemyType == "zombie" or
|
||||
(self.attackPattern['type'] == 'hunter' and self.hunting)):
|
||||
# Direct chase behavior for zombies and activated hunters
|
||||
if player.xPos > self.xPos:
|
||||
self.movingRight = True
|
||||
self.xPos += self.movementSpeed
|
||||
else:
|
||||
self.movingRight = False
|
||||
self.xPos -= self.movementSpeed
|
||||
|
||||
# Only enforce level boundaries, not patrol boundaries
|
||||
distanceToPlayer = player.xPos - self.xPos
|
||||
|
||||
# If we've moved past the player by more than the turn threshold, turn around
|
||||
if abs(distanceToPlayer) >= self.turnThreshold:
|
||||
self.movingRight = distanceToPlayer > 0
|
||||
|
||||
# Otherwise keep moving in current direction
|
||||
self.xPos += self.movementSpeed if self.movingRight else -self.movementSpeed
|
||||
|
||||
# Enforce level boundaries
|
||||
if self.xPos < self.level.leftBoundary:
|
||||
self.xPos = self.level.leftBoundary
|
||||
self.movingRight = True
|
||||
@@ -142,9 +144,13 @@ class Enemy(Object):
|
||||
self.xPos = self.level.rightBoundary
|
||||
self.movingRight = False
|
||||
else:
|
||||
# Other enemies and non-activated hunters use patrol pattern
|
||||
# Non-hunting enemies use standard patrol
|
||||
self.patrol_movement()
|
||||
|
||||
# Check for attack opportunity
|
||||
if self.can_attack(currentTime, player):
|
||||
self.attack(currentTime, player)
|
||||
|
||||
if self.enemyType == "revenant" and self.hunting: # Only spawn when player enters territory
|
||||
# Check if it's time to spawn a zombie
|
||||
if currentTime - self.lastZombieSpawn >= self.zombieSpawnCooldown:
|
||||
|
Reference in New Issue
Block a user