Audio: mood music, ambience, sound effects and creature voices (Kenney CC0 + synthesised); protocol 13

This commit is contained in:
Paul Bailey
2026-11-05 21:03:54 +00:00
parent 2a9d47630e
commit caa611fac6
159 changed files with 1814 additions and 3 deletions

View File

@@ -339,6 +339,7 @@ func swing() -> void:
if _swing_cd > 0.0:
return
_swing_cd = float(Actions.melee_stats(player).cooldown)
get_tree().create_timer(0.12).timeout.connect(func(): Sfx.me("swing")) # (as it comes down)
var tw := create_tween()
var wind := Transform3D(_view_rest.basis.rotated(Vector3.RIGHT, deg_to_rad(35)), _view_rest.origin + Vector3(0, 0.08, 0.05))
var strike := Transform3D(_view_rest.basis.rotated(Vector3.RIGHT, deg_to_rad(-70)), _view_rest.origin + Vector3(-0.05, -0.05, -0.15))

View File

@@ -103,3 +103,42 @@ func _physics_process(delta: float) -> void:
velocity.z = move_toward(velocity.z, 0, current_speed)
move_and_slide()
_footsteps(delta, swimming)
# --- footsteps (sfx.gd) ------------------------------------------------------------
const STRIDE := 1.9 ## metres between footsteps (walking; a little longer sprinting)
var _stride := 0.0
## A footstep every stride on the ground, by what's underfoot (a floor
## piece's wood or stone, snow up high or while it's snowing, else grass);
## a stroke now and then while swimming. Only you hear your own.
func _footsteps(dt: float, swimming: bool) -> void:
var v := Vector2(velocity.x, velocity.z).length()
if v < 1.0 or not (is_on_floor() or swimming):
_stride = minf(_stride, STRIDE * 0.6) # (the first step after stopping comes soon)
return
_stride += v * dt
var gap := STRIDE * (1.2 if v > speed + 0.5 else 1.0) * (1.6 if swimming else 1.0)
if _stride < gap:
return
_stride = 0.0
Sfx.me("swim" if swimming else step_sound())
func step_sound() -> String:
var q := PhysicsRayQueryParameters3D.create(global_position + Vector3(0, 0.3, 0), global_position - Vector3(0, 0.5, 0))
q.exclude = [get_rid()]
var hit := get_world_3d().direct_space_state.intersect_ray(q)
var c: Object = hit.get("collider")
# (a piece's collider is its body or one of its children)
for _i in range(3):
if not (c is Node):
break
if (c as Node).is_in_group("piece"):
return "step_stone" if String((c as Node).get("item_id")).contains("stone") else "step_wood"
c = (c as Node).get_parent()
var w: Node = get_parent()
var wx: Node = w.get("weather") if w != null else null
if wx != null and (String(wx.get("state")) in ["snow", "blizzard"] or global_position.y > float(wx.get("snowline")) - 1.0):
return "step_snow"
return "step_grass"