From 3b94a7e0f3aaca3e02a959d5e0c9a2d405091a7c Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 12 Dec 2024 20:46:21 +0100 Subject: [PATCH] feat: added drone sound effect to enemies --- audio/drone.aup3 | 3 +++ godot/default_bus_layout.tres | 2 +- godot/objects/enemy.tscn | 13 ++++++++++++- godot/sounds/drone.ogg | 3 +++ godot/sounds/drone.ogg.import | 19 +++++++++++++++++++ src/enemy.cpp | 4 +++- src/enemy.hpp | 4 +++- 7 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 audio/drone.aup3 create mode 100644 godot/sounds/drone.ogg create mode 100644 godot/sounds/drone.ogg.import diff --git a/audio/drone.aup3 b/audio/drone.aup3 new file mode 100644 index 0000000..7735699 --- /dev/null +++ b/audio/drone.aup3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:705ed551d28b1e51bf43c558e42794bc2daab145c1315a155ac9b8b8bdd893aa +size 9003008 diff --git a/godot/default_bus_layout.tres b/godot/default_bus_layout.tres index 43a3c16..82c11a0 100644 --- a/godot/default_bus_layout.tres +++ b/godot/default_bus_layout.tres @@ -11,7 +11,7 @@ bus/1/name = &"Artillery" bus/1/solo = false bus/1/mute = false bus/1/bypass_fx = false -bus/1/volume_db = 0.185026 +bus/1/volume_db = -14.6228 bus/1/send = &"Master" bus/1/effect/0/effect = SubResource("AudioEffectLowPassFilter_i7nkl") bus/1/effect/0/enabled = true diff --git a/godot/objects/enemy.tscn b/godot/objects/enemy.tscn index fa9f0a9..18eef11 100644 --- a/godot/objects/enemy.tscn +++ b/godot/objects/enemy.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://0fykl1mw3c12"] +[gd_scene load_steps=4 format=3 uid="uid://0fykl1mw3c12"] [ext_resource type="PackedScene" uid="uid://bnr6lab7heo8e" path="res://objects/character_model_base.tscn" id="1_i7aop"] +[ext_resource type="AudioStream" uid="uid://b5evvhyrhybkf" path="res://sounds/drone.ogg" id="2_8cpm2"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_3tduq"] radius = 0.370388 @@ -102,4 +103,14 @@ shape = SubResource("CapsuleShape3D_3tduq") [node name="NavigationAgent3D" type="NavigationAgent3D" parent="."] unique_name_in_owner = true +[node name="DroneSound" type="AudioStreamPlayer3D" parent="."] +unique_name_in_owner = true +stream = ExtResource("2_8cpm2") +attenuation_model = 2 +volume_db = 1.0 +unit_size = 27.02 +autoplay = true +max_distance = 13.36 +panning_strength = 0.17 + [editable path="CharacterModel"] diff --git a/godot/sounds/drone.ogg b/godot/sounds/drone.ogg new file mode 100644 index 0000000..512307f --- /dev/null +++ b/godot/sounds/drone.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43387bbac2cc815fba70574f9637b44f359366fb1d95df78ce1d2f0fcbf010cb +size 117501 diff --git a/godot/sounds/drone.ogg.import b/godot/sounds/drone.ogg.import new file mode 100644 index 0000000..2e0761c --- /dev/null +++ b/godot/sounds/drone.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://b5evvhyrhybkf" +path="res://.godot/imported/drone.ogg-04eb7ed83dcda003c57d2f86862900d2.oggvorbisstr" + +[deps] + +source_file="res://sounds/drone.ogg" +dest_files=["res://.godot/imported/drone.ogg-04eb7ed83dcda003c57d2f86862900d2.oggvorbisstr"] + +[params] + +loop=true +loop_offset=1.0 +bpm=0.0 +beat_count=0 +bar_beats=4 diff --git a/src/enemy.cpp b/src/enemy.cpp index 565f8fe..0c58ee5 100644 --- a/src/enemy.cpp +++ b/src/enemy.cpp @@ -20,6 +20,7 @@ void Enemy::_ready() { timer->start(this->update_interval); timer->connect("timeout", callable_mp(this, &Enemy::update)); this->target_rotation = this->get_rotation().y; + this->drone_sound = this->get_node("%DroneSound"); } void Enemy::_process(double delta) { @@ -88,7 +89,7 @@ void Enemy::_physics_process(double delta [[maybe_unused]]) { basis.get_column(0) * motion.x + basis.get_column(1) * motion.y + basis.get_column(2) * motion.z - });\ + }); this->move_and_slide(); } @@ -98,6 +99,7 @@ void Enemy::damage() { this->set_collision_layer(0x0); this->set_process(false); this->set_physics_process(false); + this->drone_sound->stop(); } void Enemy::notice_player(Player *player) { diff --git a/src/enemy.hpp b/src/enemy.hpp index ae3a91c..5933b36 100644 --- a/src/enemy.hpp +++ b/src/enemy.hpp @@ -5,6 +5,7 @@ #include "player.hpp" #include "player_anim_tree.hpp" #include "utils/godot_macros.hpp" +#include #include #include namespace gd = godot; @@ -32,7 +33,7 @@ public: float get_update_interval() const; private: int const SHOTS_BEFORE_HIT{0}; - float const TURN_SPEED{1.5f}; + float const TURN_SPEED{3.f}; float const HIT_ANGLE{.05f}; float const MISS_ANGLE{.2f}; @@ -46,6 +47,7 @@ private: Player *player{nullptr}; gd::NavigationAgent3D *agent{nullptr}; PlayerAnimTree *anim_tree{nullptr}; + gd::AudioStreamPlayer3D *drone_sound{nullptr}; }; #endif // !ENEMY_HPP