Files
draugnorak/src/creature_death.nvgt

22 lines
852 B
Plaintext

// Unified death handling functions for creatures
// Ensures consistent death behavior: stop sound -> play death sound -> create drop
// Handle creature death with sound cleanup and optional drop
// This consolidates the death pattern used across zombies, bandits, boars, etc.
void handle_creature_death(int creature_pos, string death_sound, float volume_step, string drop_type = "") {
// Play death sound at creature position
play_creature_death_sound(death_sound, x, creature_pos, volume_step);
// Create world drop if specified
if (drop_type != "") {
add_world_drop(creature_pos, drop_type);
}
}
// Cleanup sound handle before death (should be called before handle_creature_death)
void cleanup_creature_sound(int sound_handle_ref) {
if (sound_handle_ref != -1) {
p.destroy_sound(sound_handle_ref);
}
}