Audio: mood music, ambience, sound effects and creature voices (Kenney CC0 + synthesised); protocol 13
This commit is contained in:
@@ -219,6 +219,7 @@ func craft(player: Node, recipe_id: String) -> bool:
|
||||
inv.remove(id, int(r.inputs[id]))
|
||||
_give(player, r.output, r.count)
|
||||
crafted.emit(player, recipe_id, String(r.output), int(r.count))
|
||||
Sfx.at("craft", player.global_position)
|
||||
return true
|
||||
|
||||
func pickup(player: Node3D, pickup_node: Node3D) -> bool:
|
||||
@@ -239,6 +240,7 @@ func pickup(player: Node3D, pickup_node: Node3D) -> bool:
|
||||
notify.emit("+%d %s" % [pickup_node.amount, ItemDB.item_name(id)])
|
||||
elif _give(player, id, pickup_node.amount) <= 0:
|
||||
return false
|
||||
Sfx.at("pickup", pickup_node.global_position)
|
||||
pickup_node.collected()
|
||||
return true
|
||||
|
||||
@@ -262,6 +264,7 @@ func harvest_hit(player: Node3D, node: Node3D, hit_point: Vector3) -> bool:
|
||||
for id in drops:
|
||||
_give(player, id, int(drops[id]))
|
||||
use_held(player)
|
||||
Sfx.at(harvest_sound(String(node.tool_kind), bool(node.depleted)), hit_point)
|
||||
harvested.emit(player, node, bool(node.depleted))
|
||||
return true
|
||||
|
||||
@@ -285,6 +288,7 @@ func place(player: Node3D, slot: int, xf: Transform3D, world: Node3D) -> bool:
|
||||
return false
|
||||
player.inventory.take_from(slot, 1)
|
||||
var piece: Node3D = world.spawn_piece(def, xf)
|
||||
Sfx.at(place_sound(id), xf.origin)
|
||||
placed.emit(player, id, piece)
|
||||
return true
|
||||
|
||||
@@ -308,6 +312,7 @@ func dismantle(player: Node3D, piece: Node3D) -> bool:
|
||||
notify.emit("Inventory full")
|
||||
return false
|
||||
_give(player, piece.item_id, 1)
|
||||
Sfx.at("dismantle", piece.global_position)
|
||||
piece.get_parent().get_parent().remove_piece(piece, player)
|
||||
return true
|
||||
|
||||
@@ -317,6 +322,7 @@ func toggle_door(player: Node3D, door: Node3D) -> bool:
|
||||
if _online():
|
||||
return _ask("door", [WorldNet.nid(door)])
|
||||
door.set_open(not door.open)
|
||||
Sfx.at("door_open" if door.open else "door_close", door.global_position)
|
||||
return true
|
||||
|
||||
## E on the barrow's coffin (barrow.gd): take what's in it. Opening it wakes
|
||||
@@ -377,6 +383,7 @@ func use_bed(player: Node3D, bed: Node3D) -> bool:
|
||||
else:
|
||||
world.set_bed_spawn(bed)
|
||||
notify.emit("Spawn point set")
|
||||
Sfx.for_player(player, "ui_good")
|
||||
return true
|
||||
var why: String = world.sleep_block_reason(bed)
|
||||
if not why.is_empty():
|
||||
@@ -467,6 +474,7 @@ func hit_player(player: Node3D, peer: int) -> bool:
|
||||
return false
|
||||
player.melee_ready_at = Time.get_ticks_msec() + int(m.cooldown * 1000.0 * 0.8)
|
||||
target.survival.damage(m.damage, player.global_position, String(player.display))
|
||||
Sfx.at("hit_flesh", target.global_position)
|
||||
use_held(player)
|
||||
notify.emit("Hit %s" % String(target.display))
|
||||
return true
|
||||
@@ -499,6 +507,7 @@ func throw_spear(player: Node3D, slot: int, origin: Vector3, dir: Vector3, world
|
||||
var id: String = s.id
|
||||
var left := ItemDB.durability(s) - 1
|
||||
player.inventory.take_from(slot, 1)
|
||||
Sfx.at("throw", origin)
|
||||
var pr: Node3D = world.launch(id, origin, dir.normalized() * float(w.throw.speed) + player.velocity * 0.5,
|
||||
float(w.throw.damage), player)
|
||||
if ItemDB.max_durability(id) > 0:
|
||||
@@ -545,6 +554,7 @@ func shoot(player: Node3D, origin: Vector3, dir: Vector3, power: float, world: N
|
||||
var dmg: float = lerpf(float(bow.damage[0]), float(bow.damage[1]), power)
|
||||
dmg *= float(ItemDB.get_item(ammo).get("ammo", {}).get("damage_mult", 1.0))
|
||||
world.launch(ammo, origin, dir.normalized() * spd, dmg, player)
|
||||
Sfx.at("bow", origin)
|
||||
use_held(player)
|
||||
return true
|
||||
|
||||
@@ -558,6 +568,7 @@ func butcher(player: Node3D, carcass: Node3D) -> bool:
|
||||
var drops: Dictionary = carcass.butcher_drops()
|
||||
carcass.remove_from_group("carcass")
|
||||
butchered.emit(player, String(carcass.kind))
|
||||
Sfx.at("butcher", carcass.global_position)
|
||||
for id in drops:
|
||||
var got := _give(player, id, int(drops[id]))
|
||||
if got < int(drops[id]):
|
||||
@@ -583,6 +594,7 @@ func cast_line(player: Node3D, origin: Vector3, dir: Vector3, world: Node3D) ->
|
||||
var d := dir.normalized()
|
||||
d.y = maxf(d.y, -0.2) + 0.35 # a lobbed cast, even when looking level
|
||||
world.start_fishing(player, origin, d.normalized() * float(rod.get("cast_speed", 12.0)))
|
||||
Sfx.at("cast", origin)
|
||||
use_held(player)
|
||||
return true
|
||||
|
||||
@@ -596,12 +608,16 @@ func reel(player: Node3D, world: Node3D) -> bool:
|
||||
var caught := ""
|
||||
if b.state == "biting":
|
||||
caught = b.fish
|
||||
Sfx.at("reel", player.global_position)
|
||||
if not caught.is_empty():
|
||||
Sfx.at("catch", b.global_position)
|
||||
world.end_fishing(player)
|
||||
if caught.is_empty():
|
||||
return false
|
||||
if _give(player, caught, 1) == 0:
|
||||
world.drop_item(caught, 1, Transform3D(Basis(), player.global_position + Vector3(0, 0.1, 0)))
|
||||
notify.emit("Caught a %s" % ItemDB.item_name(caught).to_lower())
|
||||
Sfx.for_player(player, "ui_catch")
|
||||
emit_signal("caught", player, caught) # (the local `caught` hides the signal's name)
|
||||
return true
|
||||
|
||||
@@ -618,6 +634,7 @@ func wear(player: Node3D, slot: int) -> bool:
|
||||
_give(player, player.worn, 1)
|
||||
player.worn = id
|
||||
player.worn_changed.emit()
|
||||
Sfx.at("wear", player.global_position)
|
||||
notify.emit("Wearing %s" % ItemDB.item_name(id).to_lower())
|
||||
return true
|
||||
|
||||
@@ -663,6 +680,7 @@ func eat(player: Node3D, slot: int) -> bool:
|
||||
player.inventory.take_from(slot, 1)
|
||||
var eaten := String(s.id)
|
||||
player.survival.eat(food)
|
||||
Sfx.at("eat", player.global_position)
|
||||
notify.emit("Ate %s" % ItemDB.item_name(eaten).to_lower())
|
||||
ate.emit(player, eaten)
|
||||
# Raw meat and fish can make you ill (P4). Cooked, smoked or salted can't.
|
||||
@@ -688,6 +706,7 @@ func add_fuel(player: Node3D, fire: Node3D) -> bool:
|
||||
if player.inventory.count(id) > 0:
|
||||
player.inventory.remove(id, 1)
|
||||
fire.add_fuel(float(ItemDB.get_item(id).get("fuel", 10)))
|
||||
Sfx.at("fuel", fire.global_position)
|
||||
notify.emit("Added %s to the fire" % ItemDB.item_name(id).to_lower())
|
||||
return true
|
||||
notify.emit("Nothing to burn (wood or sticks)")
|
||||
@@ -703,3 +722,22 @@ func transfer(player: Node3D, from: Inventory, slot: int, to: Inventory, contain
|
||||
_ask("transfer", [WorldNet.nid(container), slot, from == player.inventory])
|
||||
return
|
||||
from.quick_move(slot, to)
|
||||
|
||||
# --- sounds (sfx.gd) --------------------------------------------------------------------
|
||||
|
||||
## The sound of a tool on a tree, a boulder or a bush; heavier when it falls.
|
||||
static func harvest_sound(tool_kind: String, felled: bool) -> String:
|
||||
match tool_kind:
|
||||
"axe":
|
||||
return "tree_fall" if felled else "chop"
|
||||
"pickaxe":
|
||||
return "rock_break" if felled else "mine"
|
||||
return "rustle"
|
||||
|
||||
## A piece going down: wood, stone, or something soft.
|
||||
static func place_sound(id: String) -> String:
|
||||
if id.contains("stone") or id in ["campfire", "forge", "hearth", "stonecutter"]:
|
||||
return "place_stone"
|
||||
if id.contains("rug") or id.contains("bed") or id == "smoking_rack":
|
||||
return "place_soft"
|
||||
return "place_wood"
|
||||
|
||||
Reference in New Issue
Block a user