Fixed a few bugs with the new override system.
This commit is contained in:
@@ -52,5 +52,9 @@ class CoffinObject(Object):
|
||||
drop_x, self.yPos, item_type, self.sounds, direction, self.level.leftBoundary, self.level.rightBoundary
|
||||
)
|
||||
|
||||
# Apply sound override after creation (similar to how graves handle it)
|
||||
if hasattr(self, 'itemSoundOverride'):
|
||||
self.dropped_item.soundName = self.itemSoundOverride
|
||||
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -12,7 +12,7 @@ class GraspingHands(Object):
|
||||
super().__init__(
|
||||
xRange,
|
||||
y,
|
||||
"", # Empty string so no regular object sound plays
|
||||
"grasping_hands", # Set base sound name for override system
|
||||
isStatic=True,
|
||||
isCollectible=False,
|
||||
isHazard=True,
|
||||
@@ -21,6 +21,9 @@ class GraspingHands(Object):
|
||||
self.delay = delay # Delay in milliseconds before ground starts crumbling
|
||||
self.crumble_speed = crumble_speed # How fast the crumbling catches up (tiles per frame)
|
||||
|
||||
# Sound prefix for different sound effects (can be overridden)
|
||||
self.soundPrefix = "grasping_hands"
|
||||
|
||||
# Default messages (can be overridden by sound override system)
|
||||
self.warningMessage = "The ground crumbles as the dead reach for you."
|
||||
self.deathMessage = "The hands of the dead drag you down!"
|
||||
@@ -56,7 +59,7 @@ class GraspingHands(Object):
|
||||
self.isReset = False
|
||||
|
||||
# Play initial warning sound
|
||||
play_sound(self.sounds["grasping_hands_start"])
|
||||
play_sound(self.sounds[f"{self.soundPrefix}_start"])
|
||||
speak(self.warningMessage)
|
||||
|
||||
def reset(self):
|
||||
@@ -72,7 +75,7 @@ class GraspingHands(Object):
|
||||
self.crumbleChannel = None
|
||||
|
||||
# Play the end sound
|
||||
play_sound(self.sounds["grasping_hands_end"])
|
||||
play_sound(self.sounds[f"{self.soundPrefix}_end"])
|
||||
|
||||
def update(self, currentTime, player):
|
||||
"""Update the grasping hands trap state"""
|
||||
@@ -97,7 +100,7 @@ class GraspingHands(Object):
|
||||
# Manage the looping positional audio for the crumbling ground
|
||||
if self.crumbleChannel is None or not self.crumbleChannel.get_busy():
|
||||
# Start the sound if it's not playing
|
||||
self.crumbleChannel = obj_play(self.sounds, "grasping_hands", player.xPos, self.crumblePosition)
|
||||
self.crumbleChannel = obj_play(self.sounds, self.soundPrefix, player.xPos, self.crumblePosition)
|
||||
else:
|
||||
# Update the sound position
|
||||
self.crumbleChannel = obj_update(self.crumbleChannel, player.xPos, self.crumblePosition)
|
||||
|
||||
13
src/level.py
13
src/level.py
@@ -171,6 +171,9 @@ class Level:
|
||||
self, # Pass level reference
|
||||
item=obj.get("item", "random"), # Get item type or default to random
|
||||
)
|
||||
# Apply sound overrides if specified
|
||||
if "sound_overrides" in obj:
|
||||
self._apply_object_sound_overrides(coffin, obj["sound_overrides"])
|
||||
self.objects.append(coffin)
|
||||
# Check if this is a spider web
|
||||
elif obj.get("type") == "spider_web":
|
||||
@@ -601,11 +604,13 @@ class Level:
|
||||
if hasattr(obj, 'launchSound') and "launch" in soundOverrides:
|
||||
obj.launchSound = soundOverrides["launch"]
|
||||
|
||||
# For grasping hands, check for message overrides
|
||||
# For grasping hands, check for message overrides and sound prefix override
|
||||
if hasattr(obj, 'warningMessage') and "warning_message" in soundOverrides:
|
||||
obj.warningMessage = soundOverrides["warning_message"]
|
||||
if hasattr(obj, 'deathMessage') and "death_message" in soundOverrides:
|
||||
obj.deathMessage = soundOverrides["death_message"]
|
||||
if hasattr(obj, 'soundPrefix') and "base" in soundOverrides:
|
||||
obj.soundPrefix = soundOverrides["base"]
|
||||
|
||||
# Handle item sound overrides for graves
|
||||
if hasattr(obj, 'graveItem') and obj.graveItem and "item" in soundOverrides:
|
||||
@@ -613,3 +618,9 @@ class Level:
|
||||
# Store the override for later use
|
||||
if not hasattr(obj, 'itemSoundOverride'):
|
||||
obj.itemSoundOverride = soundOverrides["item"]
|
||||
|
||||
# Handle item sound overrides for coffins
|
||||
if hasattr(obj, 'specified_item') and obj.specified_item and obj.specified_item != "random" and "item" in soundOverrides:
|
||||
# Store the override for later use when coffin is broken
|
||||
if not hasattr(obj, 'itemSoundOverride'):
|
||||
obj.itemSoundOverride = soundOverrides["item"]
|
||||
|
||||
Reference in New Issue
Block a user