Skip to content

Commit

Permalink
Merge branch 'main' into overload
Browse files Browse the repository at this point in the history
  • Loading branch information
Syntax2022 authored May 13, 2024
2 parents b649831 + 142a65d commit a211ea8
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a211ea8

Please sign in to comment.