Made vulnerable and spawn code not depend on the enemy type. Hopefully nothing broke.

This commit is contained in:
Storm Dragon
2025-02-17 12:52:53 -05:00
parent fdb8381603
commit 5b0615db7f
6 changed files with 153 additions and 70 deletions

View File

@@ -147,7 +147,12 @@ class Level:
damage=obj.get("damage", 1),
attack_range=obj.get("attack_range", 1),
movement_range=obj.get("movement_range", 5),
attack_pattern=obj.get("attack_pattern", {'type': 'patrol'}) # Add this line
attack_pattern=obj.get("attack_pattern", {'type': 'patrol'}),
can_spawn=obj.get("can_spawn", False),
spawn_type=obj.get("spawn_type", "zombie"),
spawn_cooldown=obj.get("spawn_cooldown", 2000),
spawn_chance=obj.get("spawn_chance", 25),
spawn_distance=obj.get("spawn_distance", 5)
)
self.enemies.append(enemy)
else:
@@ -215,11 +220,12 @@ class Level:
continue
enemy.update(currentTime, self.player)
if enemy.channel is None or not enemy.channel.get_busy():
enemy.channel = obj_play(self.sounds, enemy.enemyType, self.player.xPos, enemy.xPos)
if enemy.channel is not None:
enemy.channel = obj_update(enemy.channel, self.player.xPos, enemy.xPos)
if not enemy.hasVulnerabilitySystem:
if enemy.channel is None or not enemy.channel.get_busy():
enemy.channel = obj_play(self.sounds, enemy.enemyType, self.player.xPos, enemy.xPos)
if enemy.channel is not None:
enemy.channel = obj_update(enemy.channel, self.player.xPos, enemy.xPos)
# Update catapults
for obj in self.objects: