There was some weirdness with hunter attack patterns. Tried to fix.

This commit is contained in:
Storm Dragon
2025-02-14 22:43:30 -05:00
parent 1d60c58532
commit 9fd23478bb

View File

@@ -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
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
# Only enforce level boundaries, not patrol boundaries
# Enforce level boundaries
if self.xPos < self.level.leftBoundary:
self.xPos = self.level.leftBoundary
self.movingRight = True
@@ -142,8 +144,12 @@ 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