From 4c2f5c3d857faa4c7a4ff57c9018d852891f5a06 Mon Sep 17 00:00:00 2001 From: Brandon Ubillus Date: Wed, 9 Sep 2026 15:50:21 -0500 Subject: [PATCH 1/3] feat(enemy): play Mothsache attack sound effect on player detection #1020 --- .../characters/enemies/guard/AttackSound.wav | 3 +++ .../enemies/guard/AttackSound.wav.import | 24 +++++++++++++++++++ .../enemies/mothsache/Mothsache.tscn | 6 +++++ .../characters/enemies/mothsache/mothsache.gd | 19 +++++++++++++-- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 assets/third_party/sounds/characters/enemies/guard/AttackSound.wav create mode 100644 assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import diff --git a/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav b/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav new file mode 100644 index 0000000000..c1bdfb769a --- /dev/null +++ b/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10f6278474a65a8160d66acd2568bf5ccf0d3ea3ee292e52cf087b756e89a1ac +size 232556 diff --git a/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import b/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import new file mode 100644 index 0000000000..2204629c6c --- /dev/null +++ b/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cbu4f3uo1kob5" +path="res://.godot/imported/AttackSound.wav-eab0a2971fa5a9d86abe29d77726626f.sample" + +[deps] + +source_file="res://assets/third_party/sounds/characters/enemies/guard/AttackSound.wav" +dest_files=["res://.godot/imported/AttackSound.wav-eab0a2971fa5a9d86abe29d77726626f.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn b/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn index 14ec1ac61c..ab2f3d1d88 100644 --- a/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn +++ b/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn @@ -3,6 +3,7 @@ [ext_resource type="Script" uid="uid://dg7jodlol6iao" path="res://scenes/game_elements/characters/enemies/mothsache/mothsache.gd" id="1_f7683"] [ext_resource type="SpriteFrames" uid="uid://b0nyiuolbvnl0" path="res://scenes/game_elements/characters/enemies/mothsache/components/mothsache_frames.tres" id="1_tm0nn"] [ext_resource type="AudioStream" uid="uid://dgpeb1dtmfqud" path="res://assets/third_party/sounds/characters/enemies/guard/AlertSound.ogg" id="2_8q7cb"] +[ext_resource type="AudioStream" uid="uid://cbu4f3uo1kob5" path="res://assets/third_party/sounds/characters/enemies/guard/AttackSound.wav" id="3_e2qj4"] [ext_resource type="Script" uid="uid://dy68p7gf07pi3" path="res://scenes/game_logic/sprite_behaviors/character_sprite_behavior.gd" id="3_fmv22"] [ext_resource type="Script" uid="uid://cx0sk4uhvnii0" path="res://scenes/game_logic/walk_behaviors/erratic_walk_behavior.gd" id="3_xxd2s"] [ext_resource type="Script" uid="uid://csev4hv57utxv" path="res://scenes/game_logic/walk_behaviors/character_speeds.gd" id="4_xxd2s"] @@ -37,6 +38,7 @@ motion_mode = 1 script = ExtResource("1_f7683") chase_speed = 200.0 alert_sound_stream = ExtResource("2_8q7cb") +attack_sound_stream = ExtResource("3_e2qj4") [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2128243933] rotation = 1.5707964 @@ -151,6 +153,10 @@ volume_db = -2.0 max_distance = 500.0 bus = &"SFX" +[node name="AttackSound" type="AudioStreamPlayer" parent="Sounds" unique_id=492596946] +unique_name_in_owner = true +bus = &"SFX" + [connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_animation_finished"] [connection signal="timeout" from="BehaviorTimer" to="." method="_on_BehaviorTimer_timeout"] [connection signal="body_entered" from="AttackRadius" to="." method="_on_attack_radius_body_entered"] diff --git a/scenes/game_elements/characters/enemies/mothsache/mothsache.gd b/scenes/game_elements/characters/enemies/mothsache/mothsache.gd index 5016a9917b..6cd936c083 100644 --- a/scenes/game_elements/characters/enemies/mothsache/mothsache.gd +++ b/scenes/game_elements/characters/enemies/mothsache/mothsache.gd @@ -37,7 +37,10 @@ const MAX_SPEED: float = 300 ## Sound played when entering DETECTING or ALERTED states. @export var alert_sound_stream: AudioStream: set = _set_alert_sound_stream - +## Sound played when entering ATTACKING state. +@export var attack_sound_stream: AudioStream: + set = _set_attack_sound_stream + var state: State = State.IDLE: set = _set_state var _awareness: float = 0.0 @@ -61,7 +64,7 @@ var _previous_non_detecting_state: State = State.IDLE @onready var animated_sprite: AnimatedSprite2D = %AnimatedSprite2D @onready var char_sprite_behavior: CharacterSpriteBehavior = %CharacterSpriteBehavior @onready var _alert_sound: AudioStreamPlayer = %AlertSound - +@onready var _attack_sound: AudioStreamPlayer = %AttackSound func _ready() -> void: if is_instance_valid(debug_label): @@ -71,6 +74,7 @@ func _ready() -> void: awareness_bar.value = 0.0 awareness_bar.visible = false _set_alert_sound_stream(alert_sound_stream) + _set_attack_sound_stream(attack_sound_stream) _initial_position = global_position state = State.IDLE @@ -233,6 +237,7 @@ func _set_state(new_state: State) -> void: match state: State.IDLE: _alert_sound.stop() + _attack_sound.stop() behavior_timer.start(idle_wait_time) awareness_bar.tint_progress = Color.WHITE _reached_max_speed = false @@ -245,6 +250,7 @@ func _set_state(new_state: State) -> void: _can_burst = false State.RETURNING: + _attack_sound.stop() _return_direction = global_position.direction_to(_initial_position) _return_start_position = global_position _stuck_timer = 0.0 @@ -264,6 +270,8 @@ func _set_state(new_state: State) -> void: State.ALERTED: if not _alert_sound.playing: _alert_sound.play() + if not _attack_sound.playing: + _attack_sound.play() awareness_bar.value = awareness_bar.max_value awareness_bar.tint_progress = Color.RED awareness_bar.modulate.a = 1.0 @@ -286,6 +294,8 @@ func _set_state(new_state: State) -> void: velocity = direction_to_player * _current_chase_speed State.ATTACKING: + if not _attack_sound.playing: + _attack_sound.play() if char_sprite_behavior: char_sprite_behavior.play_animations = false animated_sprite.play("attack") @@ -297,6 +307,11 @@ func _set_alert_sound_stream(new_value: AudioStream) -> void: await ready _alert_sound.stream = new_value +func _set_attack_sound_stream(new_value: AudioStream) -> void: + attack_sound_stream = new_value + if not is_node_ready(): + await ready + _attack_sound.stream = new_value ## Called when a body enters the detection area. func _on_detection_area_body_entered(body: Node2D) -> void: From 0001562dbd11e74617749766218cc716ce0c4a14 Mon Sep 17 00:00:00 2001 From: Brandon Ubillus Date: Sat, 12 Sep 2026 12:19:54 -0500 Subject: [PATCH 2/3] fix(enemy): fix audio import, remove setter, and apply pre-commit formatting for Mothsache #1020 --- .../sounds/throwing_enemy/attackSound.wav | 3 +++ .../throwing_enemy/attackSound.wav.import | 24 +++++++++++++++++++ .../characters/enemies/guard/AttackSound.wav | 3 --- .../enemies/guard/AttackSound.wav.import | 24 ------------------- .../enemies/mothsache/Mothsache.tscn | 7 +++--- .../characters/enemies/mothsache/mothsache.gd | 19 ++++----------- 6 files changed, 35 insertions(+), 45 deletions(-) create mode 100644 assets/first_party/sounds/throwing_enemy/attackSound.wav create mode 100644 assets/first_party/sounds/throwing_enemy/attackSound.wav.import delete mode 100644 assets/third_party/sounds/characters/enemies/guard/AttackSound.wav delete mode 100644 assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import diff --git a/assets/first_party/sounds/throwing_enemy/attackSound.wav b/assets/first_party/sounds/throwing_enemy/attackSound.wav new file mode 100644 index 0000000000..ea2094e60b --- /dev/null +++ b/assets/first_party/sounds/throwing_enemy/attackSound.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11a6a6513668df2c3b9b0e0106cbb2c9e65f34e3550ddeecb7f999d2ebc3ce51 +size 93490 diff --git a/assets/first_party/sounds/throwing_enemy/attackSound.wav.import b/assets/first_party/sounds/throwing_enemy/attackSound.wav.import new file mode 100644 index 0000000000..e476d1ba50 --- /dev/null +++ b/assets/first_party/sounds/throwing_enemy/attackSound.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c5nln8i3amtlt" +path="res://.godot/imported/attackSound.wav-5330013a6325690f9475e4388885002d.sample" + +[deps] + +source_file="res://assets/first_party/sounds/throwing_enemy/attackSound.wav" +dest_files=["res://.godot/imported/attackSound.wav-5330013a6325690f9475e4388885002d.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav b/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav deleted file mode 100644 index c1bdfb769a..0000000000 --- a/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:10f6278474a65a8160d66acd2568bf5ccf0d3ea3ee292e52cf087b756e89a1ac -size 232556 diff --git a/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import b/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import deleted file mode 100644 index 2204629c6c..0000000000 --- a/assets/third_party/sounds/characters/enemies/guard/AttackSound.wav.import +++ /dev/null @@ -1,24 +0,0 @@ -[remap] - -importer="wav" -type="AudioStreamWAV" -uid="uid://cbu4f3uo1kob5" -path="res://.godot/imported/AttackSound.wav-eab0a2971fa5a9d86abe29d77726626f.sample" - -[deps] - -source_file="res://assets/third_party/sounds/characters/enemies/guard/AttackSound.wav" -dest_files=["res://.godot/imported/AttackSound.wav-eab0a2971fa5a9d86abe29d77726626f.sample"] - -[params] - -force/8_bit=false -force/mono=false -force/max_rate=false -force/max_rate_hz=44100 -edit/trim=false -edit/normalize=false -edit/loop_mode=2 -edit/loop_begin=0 -edit/loop_end=-1 -compress/mode=2 diff --git a/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn b/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn index ab2f3d1d88..ea40aac76b 100644 --- a/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn +++ b/scenes/game_elements/characters/enemies/mothsache/Mothsache.tscn @@ -3,11 +3,11 @@ [ext_resource type="Script" uid="uid://dg7jodlol6iao" path="res://scenes/game_elements/characters/enemies/mothsache/mothsache.gd" id="1_f7683"] [ext_resource type="SpriteFrames" uid="uid://b0nyiuolbvnl0" path="res://scenes/game_elements/characters/enemies/mothsache/components/mothsache_frames.tres" id="1_tm0nn"] [ext_resource type="AudioStream" uid="uid://dgpeb1dtmfqud" path="res://assets/third_party/sounds/characters/enemies/guard/AlertSound.ogg" id="2_8q7cb"] -[ext_resource type="AudioStream" uid="uid://cbu4f3uo1kob5" path="res://assets/third_party/sounds/characters/enemies/guard/AttackSound.wav" id="3_e2qj4"] [ext_resource type="Script" uid="uid://dy68p7gf07pi3" path="res://scenes/game_logic/sprite_behaviors/character_sprite_behavior.gd" id="3_fmv22"] [ext_resource type="Script" uid="uid://cx0sk4uhvnii0" path="res://scenes/game_logic/walk_behaviors/erratic_walk_behavior.gd" id="3_xxd2s"] [ext_resource type="Script" uid="uid://csev4hv57utxv" path="res://scenes/game_logic/walk_behaviors/character_speeds.gd" id="4_xxd2s"] [ext_resource type="Texture2D" uid="uid://c75ofhy3swhj3" path="res://scenes/game_elements/characters/enemies/guard/components/exclamation_mark.png" id="7_8q7cb"] +[ext_resource type="AudioStream" uid="uid://c5nln8i3amtlt" path="res://assets/first_party/sounds/throwing_enemy/attackSound.wav" id="8_e2qj4"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_0607a"] @@ -38,7 +38,6 @@ motion_mode = 1 script = ExtResource("1_f7683") chase_speed = 200.0 alert_sound_stream = ExtResource("2_8q7cb") -attack_sound_stream = ExtResource("3_e2qj4") [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2128243933] rotation = 1.5707964 @@ -153,8 +152,10 @@ volume_db = -2.0 max_distance = 500.0 bus = &"SFX" -[node name="AttackSound" type="AudioStreamPlayer" parent="Sounds" unique_id=492596946] +[node name="AttackSound" type="AudioStreamPlayer2D" parent="Sounds" unique_id=441928978] unique_name_in_owner = true +stream = ExtResource("8_e2qj4") +volume_db = 5.0 bus = &"SFX" [connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_animation_finished"] diff --git a/scenes/game_elements/characters/enemies/mothsache/mothsache.gd b/scenes/game_elements/characters/enemies/mothsache/mothsache.gd index 6cd936c083..32892f66d6 100644 --- a/scenes/game_elements/characters/enemies/mothsache/mothsache.gd +++ b/scenes/game_elements/characters/enemies/mothsache/mothsache.gd @@ -38,9 +38,8 @@ const MAX_SPEED: float = 300 @export var alert_sound_stream: AudioStream: set = _set_alert_sound_stream ## Sound played when entering ATTACKING state. -@export var attack_sound_stream: AudioStream: - set = _set_attack_sound_stream - +@export var attack_sound_stream: AudioStream + var state: State = State.IDLE: set = _set_state var _awareness: float = 0.0 @@ -64,7 +63,8 @@ var _previous_non_detecting_state: State = State.IDLE @onready var animated_sprite: AnimatedSprite2D = %AnimatedSprite2D @onready var char_sprite_behavior: CharacterSpriteBehavior = %CharacterSpriteBehavior @onready var _alert_sound: AudioStreamPlayer = %AlertSound -@onready var _attack_sound: AudioStreamPlayer = %AttackSound +@onready var _attack_sound: AudioStreamPlayer2D = %AttackSound + func _ready() -> void: if is_instance_valid(debug_label): @@ -74,9 +74,7 @@ func _ready() -> void: awareness_bar.value = 0.0 awareness_bar.visible = false _set_alert_sound_stream(alert_sound_stream) - _set_attack_sound_stream(attack_sound_stream) _initial_position = global_position - state = State.IDLE @@ -237,7 +235,6 @@ func _set_state(new_state: State) -> void: match state: State.IDLE: _alert_sound.stop() - _attack_sound.stop() behavior_timer.start(idle_wait_time) awareness_bar.tint_progress = Color.WHITE _reached_max_speed = false @@ -250,7 +247,6 @@ func _set_state(new_state: State) -> void: _can_burst = false State.RETURNING: - _attack_sound.stop() _return_direction = global_position.direction_to(_initial_position) _return_start_position = global_position _stuck_timer = 0.0 @@ -294,8 +290,6 @@ func _set_state(new_state: State) -> void: velocity = direction_to_player * _current_chase_speed State.ATTACKING: - if not _attack_sound.playing: - _attack_sound.play() if char_sprite_behavior: char_sprite_behavior.play_animations = false animated_sprite.play("attack") @@ -307,11 +301,6 @@ func _set_alert_sound_stream(new_value: AudioStream) -> void: await ready _alert_sound.stream = new_value -func _set_attack_sound_stream(new_value: AudioStream) -> void: - attack_sound_stream = new_value - if not is_node_ready(): - await ready - _attack_sound.stream = new_value ## Called when a body enters the detection area. func _on_detection_area_body_entered(body: Node2D) -> void: From 1903cc6f4e269180ef48ad3e21e18b285dc519ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= Date: Mon, 14 Sep 2026 19:12:36 -0300 Subject: [PATCH 3/3] Update scenes/game_elements/characters/enemies/mothsache/mothsache.gd --- scenes/game_elements/characters/enemies/mothsache/mothsache.gd | 1 - 1 file changed, 1 deletion(-) diff --git a/scenes/game_elements/characters/enemies/mothsache/mothsache.gd b/scenes/game_elements/characters/enemies/mothsache/mothsache.gd index 32892f66d6..46564a147c 100644 --- a/scenes/game_elements/characters/enemies/mothsache/mothsache.gd +++ b/scenes/game_elements/characters/enemies/mothsache/mothsache.gd @@ -38,7 +38,6 @@ const MAX_SPEED: float = 300 @export var alert_sound_stream: AudioStream: set = _set_alert_sound_stream ## Sound played when entering ATTACKING state. -@export var attack_sound_stream: AudioStream var state: State = State.IDLE: set = _set_state