Drone gets louder when beast is near

This commit is contained in:
Rob Kelly 2025-04-18 14:44:24 -06:00
parent 986dd518e3
commit 2e3b08271f
6 changed files with 35 additions and 11 deletions

BIN
assets/npc/slutch_beast/face_nodule_E.png (Stored with Git LFS)

Binary file not shown.

View File

@ -3,9 +3,13 @@ extends AudioStreamPlayer
const MUTE_VOLUME := -80.0
@export var volume_increment := 0.618
@export var base_volume := -14.0
@export var base_volume := -18.0
@export var boosted_volume := -2.0
@export_category("Beast Proximity Boost")
@export var proximity_cutoff := 20.0
@export var proximity_scale := 17.0
var target_volume := MUTE_VOLUME
var suppressed := false
var boosted := false
@ -20,7 +24,28 @@ func get_target_volume() -> float:
return MUTE_VOLUME
if boosted:
return boosted_volume
return target_volume
return target_volume + beast_proximity_boost(closest_beast_distance())
## Calculate the volume gain from proximity to a beast
func beast_proximity_boost(distance: float) -> float:
return max(0.0, proximity_scale * (proximity_cutoff - distance) / proximity_cutoff)
## Get the distance from the player to the closest beast
func closest_beast_distance() -> float:
if not is_instance_valid(Player.instance):
return INF
var min_dist_sq := INF
var nodes := get_tree().get_nodes_in_group("GrunkBeast")
for node: Node in nodes:
var n3d := node as Node3D
if is_instance_valid(n3d):
var dist_sq := n3d.global_position.distance_squared_to(Player.instance.global_position)
if dist_sq < min_dist_sq:
min_dist_sq = dist_sq
return sqrt(min_dist_sq)
## Temporarily suppress ambience

View File

@ -71,7 +71,6 @@ volume_db = -80.0
autoplay = true
bus = &"Music"
script = ExtResource("5_jiowi")
base_volume = -18.0
[node name="AmbientSFX" type="Node3D" parent="."]

View File

@ -215,10 +215,10 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -401.288
offset_top = -299.409
offset_right = -401.288
offset_bottom = -299.409
offset_left = -400.86
offset_top = -300.741
offset_right = -400.86
offset_bottom = -300.741
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("4_ud8na")

View File

@ -226,7 +226,7 @@ metadata/_custom_type_script = "uid://om57w2acvgb7"
script = ExtResource("11_mbqcc")
mean_time = 4.0
st_dev_time = 0.6
wait_time = 3.41713
wait_time = 4.5275
metadata/_custom_type_script = "uid://beyk2xtbjrsg4"
[node name="RandomStalkingBehavior" type="Node" parent="GrunkBeastBehavior/StateSelector/StalkingSequence/RandomDelay"]
@ -272,7 +272,7 @@ metadata/_custom_type_script = "uid://cg016dbe7gs1x"
script = ExtResource("11_mbqcc")
mean_time = 5.0
st_dev_time = 1.0
wait_time = 4.96224
wait_time = 6.19423
metadata/_custom_type_script = "uid://beyk2xtbjrsg4"
[node name="PickRandomLurkTarget" type="Node" parent="GrunkBeastBehavior/StateSelector/LurkSequence/RandomDelay"]