From 04b9ac5a51be9806b64ad69dbe2cee78e5e06c10 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sun, 12 Oct 2025 01:03:34 -0400 Subject: [PATCH] Fixed a bug where random items found in coffins didn't correctly trigger events. --- src/coffin.py | 13 +++++++------ src/level.py | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/coffin.py b/src/coffin.py index 1f58896..0b7fe9a 100644 --- a/src/coffin.py +++ b/src/coffin.py @@ -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 diff --git a/src/level.py b/src/level.py index f85f7e2..87f7110 100644 --- a/src/level.py +++ b/src/level.py @@ -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