linux-game-manager/.scripts/FreeDoom.sh

123 lines
3.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Dialog setup:
DIALOG_ITEM_HELP=""
export DIALOGOPTS='--no-lines --visit-items'
2023-11-05 21:54:46 -05:00
# Path where doom wads are stored
doomPath="$(find /usr/share -type d -name "doom" 2> /dev/null | head -1)"
# Path to gzdoom.
gzdoom="$(command -v gzdoom)"
# Version of the accessibility mod
tobyVersion="6-1"
doomGames=(
# Unmodified Doom with accessibility.
2023-11-10 19:40:01 -05:00
"${doomPath}/TobyAccMod_V${tobyVersion}.pk3" "FreeDoom"
# Toby accessibility mods
2023-11-10 19:40:01 -05:00
"${doomPath}/TobyAccMod_V${tobyVersion}.pk3 ${doomPath}/TobyDoomLevels.wad" "Freedoom Toby Mod"
# OperationMDK
2023-11-10 19:40:01 -05:00
"${doomPath}/TobyAccMod_V${tobyVersion}.pk3 ${doomPath}/OpMDK.wad" "Freedoom OperationMDK"
)
grepStrings=(
'-E'
'-e' '^[0-9]+\. '
'-e' '^"cl_run"'
'-e' '^Game saved. '
'-e' '^A secret is revealed!$'
'-e' '^MAP[0-9]*'
2023-11-10 19:45:41 -05:00
'-e' '^Player (was|is|left) '
'-e' '^Please select a game wad \(or 0 to exit\):'
'-e' '^You have no keys in your pocket!$'
)
sedStrings=(
'-e' 's/"cl_run" = "true"/run/'
'-e' 's/"cl_run" = "false"/walk/'
'-e' 's/MAP0\([1-9]\)/Map \1/'
'-e' 's:.*/:Game saved. (:'
)
gameOption="$(dialog --backtitle "Select your Doom!" \
--clear \
--no-tags \
--ok-label "Single Player" \
--cancel-label "Death Match" \
--extra-button \
--extra-label "co-op" \
--help-button \
--help-label "Exit" \
--menu "Please select one" 0 0 0 "${doomGames[@]}" --stdout)"
buttonCode=$?
case ${buttonCode} in
1)
# Death match setup
dialog --backtitle "Death Match" \
--clear \
--msgbox "Coming soon!" -1 -1 --stdout
exit 1
;;
2)
# Exit was pressed, so exit.
exit 0
;;
3)
# Co-op setup
ipAddress="$(dialog --backtitle "Co-op Options" \
--clear \
--no-tags \
--ok-label "Join" \
--cancel-label "Exit" \
--extra-button \
--extra-label "Host" \
--inputbox "Enter ip or URL, required for join." -1 -1 --stdout)"
buttonCode=$?
[[ $buttonCode -eq 1 ]] && exit 0
if [[ $buttonCode -eq 0 ]]; then
if [[ "${#ipAddress}" -lt 3 ]]; then
dialog --backtitle "Co-op" --clear --msgbox "No ip address or URL given." -1 -1 --stdout
exit 1
fi
2023-11-10 19:40:01 -05:00
flags=('-join' "${ipAddress}")
else
# Get ip address
yourIpAddress="$(curl -4s https://icanhazip.com)"
players="$(dialog --backtitle "Host Co-op Game" \
--clear \
--ok-label "Next" \
--cancel-label "Exit" \
--rangebox "Select number of players. Remember to give them your IP address: ${yourIpAddress}" -1 -1 2 10 --stdout)"
[[ $? -eq 1 ]] && exit 0
skillLevel="$(dialog --backtitle "Host Co-op Game" \
--clear \
--ok-label "Start" \
--cancel-label "Exit" \
2023-11-10 16:12:59 -05:00
--rangebox "Select difficulty. 1 easiest, 5 hardest." -1 -1 1 5 3 --stdout)"
[[ $? -eq 1 ]] && exit 0
flags=(
'-host' "${players}"
'-skill' "${skillLevel}"
2023-11-10 15:58:58 -05:00
'+set' 'sv_cheats' '1'
'+set' 'sv_weaponsstay' '1'
'+set' 'sv_respawnprotect' '1'
2023-11-10 19:40:01 -05:00
#'+set' 'sv_itemrespawn' '1'
'+set' 'sv_respawnsuper' '1'
'+set' 'alwaysapplydmflags' ''1
2023-11-10 15:58:58 -05:00
'-extratic' '-dup' '3'
)
fi
2023-11-10 19:40:01 -05:00
exec stdbuf -oL ${gzdoom} ${gameOption} "${flags[@]}" | stdbuf -oL grep "${grepStrings[@]}" | stdbuf -oL sed "${sedStrings[@]}" | spd-say -e
;;
0)
2023-11-10 19:40:01 -05:00
exec stdbuf -oL ${gzdoom} ${gameOption} | stdbuf -oL grep "${grepStrings[@]}" | stdbuf -oL sed "${sedStrings[@]}" | spd-say -e
;;
esac
exit 0