Yeah, you totally can! You'd just have to add it to a Compliment/Insult in customizable_actions.xtbl. The animation mod I'm currently working on will make doing this even easier.
Running
audio_play_persona_line(LOCAL_PLAYER, "voice - death scream") through the Juiced lua console successfully plays the audio, but immediately crashes the game.
Thanks to your example, I've managed it! It was a bugger for a lua noob like me to get working, but after a lot of trial and error, it works quite nicely.
Code:
-- Top of file --
IN_COOP = false -- Co-op check. [~SeaboundSaint~]
-- (some other stuff...)
function sr2_city_main()
-- (some other stuff...)
-- Start player scream on death thread. [~SeaboundSaint~]
thread_new("player_death_scream", LOCAL_PLAYER, "voice - death scream")
if (IN_COOP) then
thread_new("player_death_scream", REMOTE_PLAYER, "voice - death scream")
end
end
-- Player scream on death. [~SeaboundSaint~]
function player_death_scream(player, persona_situation)
-- Play the persona situation while the player is dead, then delay so it doesn't repeat.
local function player_death_scream_play(player)
while (character_is_dead(player)) do
audio_play_persona_line(player, persona_situation)
delay(10) -- Delay thread for the combined duration of "Smoked!" screen fade-out and respawn delay (both found in gameplay_constants.xtbl).
end
end
-- Recursively scan to see if the player is dead.
while(true) and (not character_is_dead(player)) do
thread_yield()
-- delay(1) -- Per-second delay (for testing).
-- message("thread_is_running", 5) -- Confirmation that thread is running (for testing).
player_death_scream_play(player)
end
end
The one thing I would change is the 10 second delay, so that it actually checks to see if the player is alive again. That way modifications in gameplay_constants.xtbl won't interfere with this.
I believe the handle would only be needed if we needed to kill the thread, which we don't because it should always be running. It's just a way to refer to that specific "thread_new" from elsewhere.
Here's the modified Vanilla sr2_city.lua: