Character Customization Change Player Voice with Juiced Patch

Question. Just like saints row 1. In saints row 2 there are death moans exist. It only works if character is defeated by props (e.g fire hydrate, glass bottle, etc).
Is there anyway to fix this so every kills causes the script to trigger?
Theoretically it could be done via lua with the "on_death" function. Something like:
Code:
function player_death_scream()

    local function play_death_scream_situation()
        audio_play_persona_line(LOCAL_PLAYER, "voice - death scream")
    end

    on_death("play_death_scream_situation", LOCAL_PLAYER)

    player_death_scream()
end
However, the above code doesn't work if I add it to sr2_city.lua (master lua script). I've tried multiple things to get it to work, but the game either crashes upon loading a save, or nothing happens.

Posting it here in case anyone knows what's wrong.
 
Found it! It's one I missed: observe - driver hit something
I haven't listened to all the voice lines in this situation, but the one you referenced is likely in there.
I noticed this one because it gets disabled for some Activities in "activity_player_persona_replacement.xtbl".

I've also found these that I missed from the list:
voice - grunt (long)
bmplayer_voc_pain - (Only works with Male Voice 2.)

I've updated the list in my Animations guide.

I haven't tested Activity related Persona Situations, but I can't recall hearing any Activity specific voice lines from Playa.
Oh yeah i found this missed voiceline when you only sit inside the car as passenger.. i figure it out when the mission with pearce driving to chase samedi helicopter... The boss start say something that doesnt even exist in normal free roam.. so i try to explore it sit in passenger seat too inside saints crew car... Then those voicelines are exist.. pretty brilliant for SR2 has hidden voiceline like this.


I'm glad you found this on audio files seabound.. in future we probably can add this voiceline as new taunt voice or something.
 
Theoretically it could be done via lua with the "on_death" function. Something like:
Code:
function player_death_scream()

    local function play_death_scream_situation()
        audio_play_persona_line(LOCAL_PLAYER, "voice - death scream")
    end

    on_death("play_death_scream_situation", LOCAL_PLAYER)

    player_death_scream()
end
However, the above code doesn't work if I add it to sr2_city.lua (master lua script). I've tried multiple things to get it to work, but the game either crashes upon loading a save, or nothing happens.

Posting it here in case anyone knows what's wrong.
Thank you for your effort. I'm not really smart when it comes to coding or saints row 2 modding just it's worth asking. Just I believe soon with help we can enable it to work. :)
 
Theoretically it could be done via lua with the "on_death" function. Something like:
Code:
function player_death_scream()

    local function play_death_scream_situation()
        audio_play_persona_line(LOCAL_PLAYER, "voice - death scream")
    end

    on_death("play_death_scream_situation", LOCAL_PLAYER)

    player_death_scream()
end
However, the above code doesn't work if I add it to sr2_city.lua (master lua script). I've tried multiple things to get it to work, but the game either crashes upon loading a save, or nothing happens.
Assuming you've played it in the Juiced Console itself with either audio_play_persona_line(LOCAL_PLAYER, "voice - death scream") or player_death_scream() and the sound plays fine (I don't have SR2 on hand, and the magic of dev console isn't on other games yet...)
here's some suggestions;

1. Try audio_play_persona_line( LOCAL_PLAYER, "voice - death scream") (one space before LOCAL_PLAYER)
2. Remove the second player_death_scream() just before the "end", like the below spoiler (otherwise it will recursively call itself again, instead of doing actual Saints Row 2 stuff)
Code:
function player_death_scream()

    local function play_death_scream_situation()
        audio_play_persona_line(LOCAL_PLAYER, "voice - death scream")
    end

    on_death("play_death_scream_situation", LOCAL_PLAYER)

end

3. Then inside function sr2_city_main() (if it's called that- SR3 calls it sr3_city_main());
we'd want to start a "Handle" (idk what a Handle is either)

Code:
function sr2_city_main()
    debug_print("sr2_city_main() processed".."\n")
    Death_Voice_Handle = thread_new("play_death_scream_situation")
    -- other stuff here, don't delete them.
end

THIS IS JUST GUESSWORK.
I'm redownloading SR2 as I type this to test my findings, but if anyone's watching knows LUA more and already knows how to fix the problem go on right ahead.

I have enough time to write the code, but not enough time to actually test it proper (doesn't crash tho).
Hmm, nothing happens. Whoopsie. [Edit: I've deleted my file since it doesn't work. Don't need that one archived. Go to the post below!)
 
Last edited:
I'm glad you found this on audio files seabound.. in future we probably can add this voiceline as new taunt voice or something.
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.

Assuming you've played it in the Juiced Console itself with either audio_play_persona_line(LOCAL_PLAYER, "voice - death scream") or player_death_scream() and the sound plays fine (I don't have SR2 on hand, and the magic of dev console isn't on other games yet...)
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.
3. Then inside function sr2_city_main() (if it's called that- SR3 calls it sr3_city_main());
we'd want to start a "Handle" (idk what a Handle is either)
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:
 

Attachments

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.

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:
Holy [bleep]! It works with the Playa's default voice and using NPCs' ones. (Personally I tested it with a <Damage_Received_Mult>-1</Damage_Received_Mult> within difficulty_levels.xtbl; but I'm sure your OHKO mod works for that too)
Great job Seabound, you've kept improving with each mod but this one truly takes the cake (especially since it's something I really care about).

I don't remember if enemies also have the same issue or the game's "distanced audio" makes it too quiet, but probably recursion isn't the best way to solve it in that case. Seems a bit too many NPCs.
 
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:
That sr2_city.lua included with death moan rn or what (Sorry gotta asked this since i really want to put this on my game)?? Since yeah i figure that out the boss only make sound of death moan when.. they got throwed by Stuff like Basketball or Glass from the stuff you found on the ground in SR2mp.
 
That sr2_city.lua included with death moan rn or what (Sorry gotta asked this since i really want to put this on my game)??
Yeah it works like SR3 does, tested it by starting a new game and dying to the prison guards
 
Holy [bleep]! It works with the Playa's default voice and using NPCs' ones.
Nice! I hadn't thought about that! I guess it would be a commonly used persona situation.

I tried other persona situations with this code, but only voice - death scream seems to work. I wonder if there's a flag or something somewhere that allows it to play while a character's dead which the other persona situations don't have.
(Personally I tested it with a <Damage_Received_Mult>-1</Damage_Received_Mult> within difficulty_levels.xtbl; but I'm sure your OHKO mod works for that too)
I just went and got shot a lot. This actually resulted in the cops arresting me, which I've never seen before. I assumed it was broken. I didn't hear the special - player arrested by cop persona play, but that would be even more difficult to do through lua, since there's barely anything related to being arrested/busted in nclok1405's lua functions list.

I didn't know about difficulty_levels.xtbl. Thanks for that! That would probably be a better way of doing OHKO...
I don't remember if enemies also have the same issue or the game's "distanced audio" makes it too quiet, but probably recursion isn't the best way to solve it in that case. Seems a bit too many NPCs.
There is voice_distances.xtbl, which is referenced by persona_situations.xtbl. Modifying that might fix low NPC volumes.

I don't think just calling an NPC by it's name would work. For mission scripts, the character variable (eg: "CHARACTER_GAT") refers to the human in that mission's .cts file (eg: "tss03_$gat"), which uses the NPC model (eg: "npc_gat"). Either way, it would be a lot for the game to process for every NPC.

I've replaced the 10 second delay with a "repeat until" loop (which is how the delay() function works in system_lib.lua):
Code:
    local function player_death_scream_play(player)
        while (character_is_dead(player)) do
            audio_play_persona_line(player, persona_situation)
        repeat
            thread_yield()
        until (not character_is_dead(player))
        end
    end
I've made versions which merge with GotR, Sandbox+ and Sandbox++. I'll upload everything now... Uploaded!
 
Last edited:
Back
Top