Fixed a bug where random items found in coffins didn't correctly trigger events.

This commit is contained in:
Storm Dragon
2025-10-12 01:03:34 -04:00
parent 275ead1e80
commit 04b9ac5a51
2 changed files with 9 additions and 8 deletions

View File

@@ -57,13 +57,14 @@ class CoffinObject(Object):
dropDistance = random.randint(1, 2)
dropX = self.xPos + (direction * dropDistance)
self.droppedItem = PowerUp(
dropX, self.yPos, itemType, self.sounds, direction, self.level.leftBoundary, self.level.rightBoundary
)
# Apply sound override after creation (similar to how graves handle it)
# Use themed item name if override exists (for proper themed item handling)
actualItemType = itemType
if hasattr(self, 'itemSoundOverride'):
self.droppedItem.soundName = self.itemSoundOverride
actualItemType = self.itemSoundOverride
self.droppedItem = PowerUp(
dropX, self.yPos, actualItemType, self.sounds, direction, self.level.leftBoundary, self.level.rightBoundary
)
return True
return False

View File

@@ -562,9 +562,9 @@ class Level:
play_sound(self.sounds[f"get_{itemSound}"])
play_sound(self.sounds.get("fill_in_grave", "shovel_dig")) # Also play fill sound
self.player.stats.update_stat("Items collected", 1)
# Create PowerUp to handle the item effect
# Create PowerUp to handle the item effect (use themed name if override exists)
item = PowerUp(
obj.xPos, obj.yPos, obj.graveItem, self.sounds, 1, self.leftBoundary, self.rightBoundary
obj.xPos, obj.yPos, itemSound, self.sounds, 1, self.leftBoundary, self.rightBoundary
)
item.apply_effect(self.player, self)
# Stop grave's current audio channel