From 5320b7805a3baf70e2fba1ebc44927face0c40c2 Mon Sep 17 00:00:00 2001 From: jarryd229 <15334102+jarryd229@users.noreply.github.com> Date: Thu, 9 May 2024 17:24:20 +1000 Subject: [PATCH] fix death sound --- .../world/interact/entity/death/NPCDeath.kts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/NPCDeath.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/NPCDeath.kts index ff4fbc2eb..a42d6109f 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/NPCDeath.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/death/NPCDeath.kts @@ -4,6 +4,7 @@ import net.pearx.kasechange.toSnakeCase import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.chat.plural import world.gregs.voidps.engine.data.definition.AnimationDefinitions +import world.gregs.voidps.engine.data.definition.SoundDefinitions import world.gregs.voidps.engine.entity.Despawn import world.gregs.voidps.engine.entity.Spawn import world.gregs.voidps.engine.entity.World @@ -40,6 +41,7 @@ val npcs: NPCs by inject() val floorItems: FloorItems by inject() val tables: DropTables by inject() val animationDefinitions: AnimationDefinitions by inject() +val soundDefinitions: SoundDefinitions by inject() npcDeath { npc -> npc.mode = PauseMode @@ -52,7 +54,7 @@ npcDeath { npc -> npc["death_tile"] = tile npc.setAnimation(deathAnimation(npc)) val name = npc.def.name.toSnakeCase() - (killer as? Player)?.playSound("${name}_death", delay = 40) + (killer as? Player)?.playSound(deathSound(npc)) pause(4) dropLoot(npc, killer, name, tile) npc.attackers.clear() @@ -98,6 +100,22 @@ fun deathAnimation(npc: NPC): String { return "" } + +fun deathSound(npc: NPC): String { + var sound: String + if (npc.race.isNotEmpty()) { + sound = "${npc.race}_death" + if (soundDefinitions.contains(sound)) { + return sound + } + } + sound = "${npc.id}_death" + if (soundDefinitions.contains(sound)) { + return sound + } + return "" +} + fun dropLoot(npc: NPC, killer: Character?, name: String, tile: Tile) { var table = tables.get("${npc.def["drop_table", name]}_drop_table") if (table == null) {