On-Foot Audio Player for SRGOOH v0.3

On-Foot Audio Player for other games: SR2 | SRTT | SRGOOH

On-Foot Audio Player for SRGOOH v0.3
Created by nclok1405 ◆VScYHamhfU
Download: srgooh_ofap_v0.3.zip

=== WHY? Can't you just use Minimaul's On-foot Radio? ===
Yes I know that. I just ported this from SRTT just in case someone values song title display or the ability to shuffle play order. This is also useful for Linux users.
This mod can also play "Sleazy music" and "Mission Complete" songs.

=== Description ===
This mod enables you to hear music during on-foot. You can switch station with Radio Station Switch keys, and you can push your F11 to skip to the next song.

When no other mods are installed, Prev/Next Radio Station keys are , (colon) and . (period) like in Saints Row IV.

=== Customization ===
You can open "module_ofap.lua" using a text editor to customize this mod.

Flags near the beginning of the file:
* OFAP_SHOW_SONG_TITLE: Change 'false' to 'true' to show song title whenever a new song starts playing
* OFAP_SHUFFLE: Change 'true' to 'false' to not randomize the play order

OFAP_RADIODATA table:
Each entry in this table represents a radio song.
Each entry has a flag named "mixtape". Change the "mixtape" flag to true to add the track to your on-foot Custom Playlist.

=== Installation ===
Copy "module_ofap.lua" and "sr4_5_city.lua" to Saints Row: Gat out of Hell's folder.

Default Steam Location: C:\Program Files (x86)\Steam\steamapps\common\Saints Row Gat out of Hell

If you are currently using another sr4_5_city.lua mod, follow these instructions:
1. Copy "module_ofap.lua" to your game's folder BUT NOT "sr4_5_city.lua"
2. Open your sr4_5_city.lua with a text editor
3. Insert the following line at the top of the file:
include("module_ofap.lua")
4. Search the line that contains "function sr4_5_city_main()"
5. Insert the following line next to the "function sr4_5_city_main()":
thread_new("ofap_main_thread")
6. Save sr4_5_city.lua and hope it works!

=== Credits ===
Main Mod Codes:
nclok1405

Original Sandbox+ for SRTT:
IdolNinja, mrtukleton, Corrodias, BadMadScientist, Pinnhead, shitface, RetroGangster, daven
https://www.saintsrowmods.com/forum/threads/sandbox-for-srtt.1076/

Sandbox+ - Things To Do In Steelport Edition:
Fan of Saints, IdolNinja, Quantum, Admixon, Erza Scarlet, JasonRyan
shitface, SkaterSaints, VSkyRimWalker, Xenoyaut,
Singa, -Iker-, rastaman289, Arondight, {JP}OchreHomo Mixer, P610, VSkyRimWalker
https://www.saintsrowmods.com/forum/threads/sandbox-things-to-do-in-steelport-edition.14440/

=== Changelog ===
On-Foot Audio Player for SRGOOH v0.3 (January 22, 2021)
* Fixed a bug that sometimes the radio music has a long delay between songs

On-Foot Audio Player for SRGOOH v0.2 (January 13, 2021)
* Now stops most diversion and activity music (except Pledge Rush)

On-Foot Audio Player for SRGOOH v0.1 (January 5, 2021)
* Initial Release
 

Attachments

Last edited:
Having the GoG version of the game, make this mod an essential. thank you for that.

Just one thing when you play with a controller D-pad left and right are already used to change the super power like F1, F2 etc

Is there a way to change that ? maybe combo button like B button + Dpad or something like that ?

also next track seems to be on the share/select buton on a controller wich open the tab menu so each time you check map or anything on tab menu you change track.

I'm digging into the code in find the CBA combo button etc but not sure how to do it properly

Will try and report anyway

[UPDATE]
I found out to do it. i did something for myself if someone is interested i can make a custom one
So now you have to press
-Left thumbstick button and press D-pad left or right to change station
-Left thumbstick button and press B to skip track

you can keep the left thumbstick pressed and use other button and so skip track indefinitely
that means if you change radio too quickly you'll change powers without wanting it

Code:
-- module_ofap.lua: On-Foot Audio Player for SRGOOH [nclok1405]

-- This mod uses codes from "Sandbox+ for SRTT" by IdolNinja and other contributors
-- https://www.saintsrowmods.com/forum/threads/sandbox-for-srtt.1076/
-- This mod also uses codes from "Sandbox+ - Things To Do In Steelport Edition" by Fan of Saints and other contributors
-- https://www.saintsrowmods.com/forum/threads/sandbox-things-to-do-in-steelport-edition.14440/

-- *** SONG TITLE DISPLAY ***
-- false: Do not show
-- true: Show song title when a new song plays
OFAP_SHOW_SONG_TITLE = false

-- *** ON-FOOT RADIO RANDOMIZE SETTINGS ***
-- OFAP_SHUFFLE = false has all on-foot radio play in the order you see them below in the OFAP_RADIODATA table
-- OFAP_SHUFFLE = true (default) forces all on-foot radio to auto shuffle on load
OFAP_SHUFFLE = true

-- ** ON-FOOT MIXTAPE PLAYLIST TRACK SETTINGS ***
-- NOTE: This applies to each entry in the following OFAP_RADIODATA table; including songs, commercials, newscasts, etc
-- mixtape = true  will add the track to your on-foot Custom Playlist
-- mixtape = false (default) will exclude that track from your on-foot custom playlist

OFAP_RADIODATA =
{
    -- GENX
    { mixtape = false    ,SongString = "IKILLYA - And Hell Followed with Him",        SongData = "GENX_AND_HELL_FOLLOWED_WITH_HIM",                station = "GENX" },
    { mixtape = false    ,SongString = "VANDARTH - B is for Bombs",                    SongData = "GENX_B_IS_FOR_BOMBS",                station = "GENX" },
    { mixtape = false    ,SongString = "Steve Ouimette - Best Laid Plans",            SongData = "GENX_BEST_LAID_PLANS",            station = "GENX" },
    { mixtape = false    ,SongString = "? - Dubstep Metal",                            SongData = "GENX_DUBSTEP_METAL",                station = "GENX" },
    { mixtape = false    ,SongString = "IKILLYA - Escape Plan",                        SongData = "GENX_ESCAPE_PLAN",                station = "GENX" },
    { mixtape = false    ,SongString = "Christopher Michael Walters - Everything",    SongData = "GENX_EVERYTHING",                station = "GENX" },
    { mixtape = false    ,SongString = "Modern Echo - Flatlined",                    SongData = "GENX_FLATLINED",                station = "GENX" },
    { mixtape = false    ,SongString = "? - Freeride Action",                        SongData = "GENX_FREERIDE_ACTION",                station = "GENX" },
    { mixtape = false    ,SongString = "Noah Lifschey - Pushing Me Closer",            SongData = "GENX_PUSHING_ME_CLOSER",                station = "GENX" },
    { mixtape = false    ,SongString = "? - Rallycross",                                SongData = "GENX_RALLYCROSS",                station = "GENX" },
    { mixtape = false    ,SongString = "? - Sportcars",                                SongData = "GENX_SPORTCARS",                station = "GENX" },

    -- MISC MUSIC
    { mixtape = false    ,SongString = "Sleazy music",    SongData = "AMB_DT_SLEAZYMUSIC",    station = "MISC", is_mission_song = true },
    { mixtape = false    ,SongString = "Mission Complete",    SongData = "MISSION_COMPLETION",            station = "MISC", event = "UI_MUSIC" },
}

-- Internal Station Names
OFAP_STATIONS = {
    "OFF", "GENX", "MISC",
}

-- Displayed Station Names
OFAP_DISPLAYED_STATION_NAMES = {
    ["GENX"] = "89.0 GENERATION X",
}

-- Event music stoppers
OFAP_EVENT_MUSIC_STOPPERS = {
--    "AMB_CS_GAMEROOM_MUSIC_STOP",
--    "AMB_CS_MUSIC_STOP",
--    "AMB_CS_SEXYROOM_MUSIC_STOP",
--    "CS_FUCKBUDDY_MUSIC_STOP",
--    "INTERACTIVE_MUSIC_STOP",
--    "LOAD_MUSIC_STOP",
    "LUST_GUN_MUSIC_LOOP_STOP",
--    "M17_MUSIC_STOP",
--    "MAIN_MENU_MUSIC_STOP",
--    "PLAY_AMB_EXT_MUFFLED_MUSIC_STOP",
    "PLAY_ARMOR_MUSIC_STOP",
    "PLAY_EXTRACTION_MUSIC_AMBEMITTER_STOP",
--    "PLAY_ULTOR_MUSIC_DUCKER_STOP",
--    "SPFC_MUSIC_STOP",
    "STOP_ARMOR_MUSIC",
    "STOP_DRAINED_MUSIC",
    "STOP_EXTRACTION_MUSIC",
--    "STOP_EXTRACTION_MUSIC_AMBEMITTER",
    "STOP_MARSHALLINGGROUNDS_MUSIC",
--    "STOP_MUSIC",
--    "STOP_PLEDGERUSH_MUSIC",
    "STOP_SPIRE_MUSIC",
    "STOP_SURVIVAL_MUSIC",
--    "STOP_UI_SFX_GLYPH_MUSIC",
--    "STOP_ULTOR_MUSIC_DUCKER",
--    "UI_MUSIC_STOP",
--    "UI_WHR_MENU_MUSIC_STOP",
    "STOP_ALTARS",
}
-- Mission/Activity music stoppers
OFAP_MISSION_ACTIVITY_MUSIC_STOPPERS = {
    "PLAY_INTROSEQUENCE_MUSIC_STOP",
    "PIRATESHIP_MUSIC_STOP",
    "STOP_HELLBLAZING_MUSIC",
    "STOP_MAYHEM_MUSIC",
    "STOP_SALVATION_MUSIC",
    "STOP_TORMENTFRAUD",
}

Ofap_radio_table = {}    -- Radio Table
Ofap_song_number = {}    -- Current song numbers
Ofap_last_message_handle = -1    -- Last message handle
Ofap_audio_handle = -1    -- Current song's audio handle
Ofap_current_station = 1    -- Current station ID

--Buttons:
B_PREV = "CBA_VDC_PREV_RADIO"
B_NEXT = "CBA_VDC_NEXT_RADIO"
B_SKIP = "CBA_VDC_WEAPON_MENU"
--Combo key
B_CROUCH = "CBA_OFC_CROUCH"

-- Main Thread of On-Foot Audio Player for SRTT
-- Run it by `thread_new("ofap_main_thread")` from sr3_city_main()
function ofap_main_thread()
    -- Populate song list
    if OFAP_SHUFFLE then
        ofap_shuffle(OFAP_RADIODATA)
    end
    ofap_populate_radio_table()

    -- Add Mixtape to selectable station
    if (Ofap_radio_table["MIXTAPE"] ~= nil) and (#Ofap_radio_table["MIXTAPE"] > 0) then
        OFAP_STATIONS[#OFAP_STATIONS + 1] = "MIXTAPE"
    end
    
    -- Wait until the loading screen goes away
    fade_in_block()

    local event_music_stop_timer = 0

    while true do
        thread_yield()

        -- If a cutscene is active, wait until it's over
        while not cutscene_play_check_done() do
            thread_yield()
        end

        -- Station Change buttons
        local change = 0
        if player_action_is_pressed(B_CROUCH) then -- CTRL (crouch)
            if player_action_is_pressed(B_PREV) then
                change = -1
            elseif player_action_just_pressed(B_NEXT) then
                change = 1
            end
        end
        
        -- Switch the station
        if change ~= 0 then
            -- Stop current music
            ofap_stop_current_song()
            
            Ofap_current_station = Ofap_current_station + change
            if Ofap_current_station < 1 then
                Ofap_current_station = #OFAP_STATIONS
            end
            if Ofap_current_station > #OFAP_STATIONS then
                Ofap_current_station = 1
            end
            
            audio_object_post_event("UI_STAG_PROTOTYPE_SCROLL", nil, nil, LOCAL_PLAYER)
            
            -- Station Change Notification
            if not OFAP_SHOW_SONG_TITLE then
                local displayed_station_name = ofap_get_displayed_station_name()
                ofap_message("STATION:\n"..displayed_station_name.."\n("..Ofap_current_station.."/"..tostring(#OFAP_STATIONS)..")")
            end
        end

        -- Stop game's event music
        if Ofap_current_station > 1 then
            event_music_stop_timer = event_music_stop_timer + get_frame_time()
            
            -- Stop the event music only every 1.5 sec and only when radio song is playing right now
            -- (prevents long silence between radio songs)
            if event_music_stop_timer >= 1.5 and audio_is_playing(Ofap_audio_handle) then
                event_music_stop_timer = 0
                
                local list = OFAP_EVENT_MUSIC_STOPPERS
                if mission_is_active() then
                    list = OFAP_MISSION_ACTIVITY_MUSIC_STOPPERS
                end
                
                for i, event in pairs(list) do
                    audio_object_post_event(event, nil, nil, LOCAL_PLAYER)
                end
            end
        end

        if (Ofap_audio_handle == -1) or (not audio_is_playing(Ofap_audio_handle)) then
            -- Check if the current song ended, if so play the new one
            local station_name = OFAP_STATIONS[Ofap_current_station]
            local displayed_station_name = ofap_get_displayed_station_name()
            local station_data = Ofap_radio_table[station_name]
            
            if (station_data ~= nil) and (#station_data >= 1) then
                local song_number = Ofap_song_number[station_name]
                if song_number == nil then
                    song_number = 0
                end
                song_number = song_number + 1
                if song_number > #station_data then
                    song_number = 1
                end

                local song = station_data[song_number]
                if song ~= nil then
                    if song.is_mission_song then
                        Ofap_audio_handle = audio_object_post_event(song.SongData, nil, nil, LOCAL_PLAYER)
                    else
                        local audio_event_name = song.event
                        if audio_event_name == nil then
                            audio_event_name = "RADIO_SONGS"
                        end
                        Ofap_audio_handle = audio_object_post_event(audio_event_name, audio_event_name, song.SongData, LOCAL_PLAYER)
                    end

                    -- New Song Notification
                    if OFAP_SHOW_SONG_TITLE then
                        ofap_message("STATION:\n"..displayed_station_name.."\n("..Ofap_current_station.."/"..tostring(#OFAP_STATIONS)..")\n\nNOW PLAYING:\n"..song.SongString.."\n("..tostring(song_number).."/"..tostring(#station_data)..")", 8)
                    end
                end

                Ofap_song_number[station_name] = song_number
            elseif change ~= 0 then
                -- Station changed to "OFF"
                if OFAP_SHOW_SONG_TITLE then
                    ofap_message("STATION:\n"..displayed_station_name.."\n("..Ofap_current_station.."/"..tostring(#OFAP_STATIONS)..")")
                end
            end
        else
            -- Song is still playing
            -- Check for the specific key, and if pressed, skip to the next music
            if player_action_is_pressed(B_CROUCH) then -- CTRL (crouch)
                if player_action_is_pressed(B_SKIP) then
                    ofap_stop_current_song()
                end
            end
        end
    end
end

-- Get the user-facing Station Name
function ofap_get_displayed_station_name(id)
    if id == nil then
        id = Ofap_current_station
    end
    local station_name = OFAP_STATIONS[id]
    local displayed_station_name = OFAP_DISPLAYED_STATION_NAMES[station_name]
    if displayed_station_name == nil then
        return station_name
    end
    return displayed_station_name
end

-- Shuffle elements in the table
function ofap_shuffle(table)
    local tmpCounter = #table
    while tmpCounter >= 2 do
        local random_pos = rand_int(1,tmpCounter)
        table[tmpCounter], table[random_pos] = table[random_pos], table[tmpCounter]
        tmpCounter = tmpCounter - 1
    end
    return table
end

-- Populate radio song list
function ofap_populate_radio_table()
    for i, song in pairs(OFAP_RADIODATA) do
        local station_name = song.station
        
        --debug_print("Adding song " .. song.SongString .. "\n")
        
        if Ofap_radio_table[station_name] == nil then
            --debug_print("Creating station table for "..station_name.."\n")
            Ofap_radio_table[station_name] = {}
        end
        
        local num = #Ofap_radio_table[station_name]
        Ofap_radio_table[station_name][num + 1] = song
        
        --debug_print("Added song to "..station_name.." #"..tostring(num + 1).."\n")
        
        -- If mixtape flag is true, add this song to mixtape station too
        if song.mixtape then
            if Ofap_radio_table["MIXTAPE"] == nil then
                --debug_print("Creating MIXTAPE table\n")
                Ofap_radio_table["MIXTAPE"] = {}
            end
            local mixtape_num = #Ofap_radio_table["MIXTAPE"]
            Ofap_radio_table["MIXTAPE"][mixtape_num + 1] = song
            --debug_print("Added song to MIXTAPE #"..tostring(num + 1).."\n")
        end
    end
end

-- Stop Current Song
function ofap_stop_current_song()
    if Ofap_audio_handle ~= -1 then
        audio_stop(Ofap_audio_handle)
        Ofap_audio_handle = -1
    end
end

-- Clear last displayed message
function ofap_message_clear()
    if Ofap_last_message_handle ~= -1 then
        message_remove(Ofap_last_message_handle, false)
    end
    Ofap_last_message_handle = -1
end

-- Show message
function ofap_message(msg, duration)
    if duration == nil then
        duration = 5
    end
    ofap_message_clear()
    Ofap_last_message_handle = message(msg, duration, false, SYNC_LOCAL)
end
 
Last edited:
Back
Top