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
|
# Handle movement based on enemy type and pattern
|
||||||
if (self.enemyType == "zombie" or
|
if (self.enemyType == "zombie" or
|
||||||
(self.attackPattern['type'] == 'hunter' and self.hunting)):
|
(self.attackPattern['type'] == 'hunter' and self.hunting)):
|
||||||
# Direct chase behavior for zombies and activated hunters
|
|
||||||
if player.xPos > self.xPos:
|
distanceToPlayer = player.xPos - self.xPos
|
||||||
self.movingRight = True
|
|
||||||
self.xPos += self.movementSpeed
|
# If we've moved past the player by more than the turn threshold, turn around
|
||||||
else:
|
if abs(distanceToPlayer) >= self.turnThreshold:
|
||||||
self.movingRight = False
|
self.movingRight = distanceToPlayer > 0
|
||||||
self.xPos -= self.movementSpeed
|
|
||||||
|
# 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:
|
if self.xPos < self.level.leftBoundary:
|
||||||
self.xPos = self.level.leftBoundary
|
self.xPos = self.level.leftBoundary
|
||||||
self.movingRight = True
|
self.movingRight = True
|
||||||
@@ -142,8 +144,12 @@ class Enemy(Object):
|
|||||||
self.xPos = self.level.rightBoundary
|
self.xPos = self.level.rightBoundary
|
||||||
self.movingRight = False
|
self.movingRight = False
|
||||||
else:
|
else:
|
||||||
# Other enemies and non-activated hunters use patrol pattern
|
# Non-hunting enemies use standard patrol
|
||||||
self.patrol_movement()
|
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
|
if self.enemyType == "revenant" and self.hunting: # Only spawn when player enters territory
|
||||||
# Check if it's time to spawn a zombie
|
# Check if it's time to spawn a zombie
|
||||||
|
Reference in New Issue
Block a user