2023-11-05 21:51:14 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-11-10 01:57:27 -05:00
|
|
|
# Dialog setup:
|
|
|
|
DIALOG_ITEM_HELP=""
|
|
|
|
export DIALOGOPTS='--no-lines --visit-items'
|
2023-11-05 21:51:14 -05:00
|
|
|
|
2023-11-05 21:54:46 -05:00
|
|
|
|
2023-11-05 21:51:14 -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
|
2024-01-21 01:13:08 -05:00
|
|
|
tobyVersion="7-0"
|
2023-11-05 21:51:14 -05:00
|
|
|
|
|
|
|
|
|
|
|
doomGames=(
|
|
|
|
# Unmodified Doom with accessibility.
|
2024-01-21 05:02:41 -05:00
|
|
|
"TobyAccMod_V${tobyVersion}.pk3" "Freedoom"
|
2023-11-05 21:51:14 -05:00
|
|
|
# Toby accessibility mods
|
2024-01-21 05:02:41 -05:00
|
|
|
"TobyAccMod_V${tobyVersion}.pk3 TobyDoomLevels.wad" "Freedoom Toby Delux Map Pack"
|
2023-11-05 21:51:14 -05:00
|
|
|
# OperationMDK
|
2024-01-21 05:02:41 -05:00
|
|
|
"TobyAccMod_V${tobyVersion}.pk3 OpMDK.wad" "Freedoom OperationMDK"
|
2023-11-05 21:51:14 -05:00
|
|
|
)
|
|
|
|
|
2023-11-10 15:28:28 -05:00
|
|
|
grepStrings=(
|
|
|
|
'-E'
|
|
|
|
'-e' '^[0-9]+\. '
|
|
|
|
'-e' '^"cl_run"'
|
|
|
|
'-e' '^Game saved. '
|
|
|
|
'-e' '^A secret is revealed!$'
|
2023-11-10 21:42:14 -05:00
|
|
|
'-e' '^Player[: ]'
|
2023-11-10 15:28:28 -05:00
|
|
|
'-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:.*/:Game saved. (:'
|
|
|
|
)
|
|
|
|
|
2023-11-10 01:57:27 -05:00
|
|
|
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=$?
|
2023-11-27 18:47:42 -05:00
|
|
|
if [[ -e "${doomPath}/DoomMetalVol6.wad" ]]; then
|
2024-01-21 05:02:41 -05:00
|
|
|
gameOption+=" DoomMetalVol6.wad"
|
2023-11-27 18:47:42 -05:00
|
|
|
fi
|
2023-11-10 01:57:27 -05:00
|
|
|
|
|
|
|
case ${buttonCode} in
|
|
|
|
1)
|
|
|
|
# Death match setup
|
2024-01-21 13:12:55 -05:00
|
|
|
# Ignore the choice of map made above
|
|
|
|
gameOption="${doomPath}/TobyAccMod_V${tobyVersion}.pk3 ${doomPath}/TobyDeathArena_V1-0.wad"
|
|
|
|
ipAddress="$(dialog --backtitle "Deathmatch Options" \
|
2023-11-10 15:28:28 -05:00
|
|
|
--clear \
|
2024-01-21 13:12:55 -05:00
|
|
|
--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 "Deathmatch" --clear --msgbox "No ip address or URL given." -1 -1 --stdout
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
flags=('-join' "${ipAddress}")
|
|
|
|
else
|
|
|
|
# List of maps included:
|
|
|
|
maps=(
|
|
|
|
"1" "Com Station (2-4 players)"
|
|
|
|
"2" "Warehouse (2-4 players)"
|
|
|
|
"3" "Sector 3 (2-4 players)"
|
|
|
|
"4" "Dungeon of Doom (2-4 players)"
|
|
|
|
"5" "Ocean Fortress (2-4 players)"
|
|
|
|
"6" "Water Treatment Facility (2-4 players)"
|
|
|
|
"7" "Phobos Base Site 4 (2-4 players)"
|
|
|
|
"8" "Hangar Bay 18 (2-4 players)")
|
|
|
|
# Array of how many players a given map supports in dialog rangebox syntax
|
|
|
|
declare -a mapPlayers=(
|
|
|
|
[1]="2 4"
|
|
|
|
[2]="2 4"
|
|
|
|
[3]="2 4"
|
|
|
|
[4]="2 4"
|
|
|
|
[5]="2 4"
|
|
|
|
[6]="2 4"
|
|
|
|
[7]="2 4"
|
|
|
|
[8]="2 4")
|
2024-01-21 13:48:58 -05:00
|
|
|
map="$(dialog --backtitle "Select Map" \
|
|
|
|
--clear \
|
|
|
|
--no-tags \
|
|
|
|
--cancel-label "Exit" \
|
|
|
|
--ok-label "Host" \
|
|
|
|
--menu "Please select one" 0 0 0 "${maps[@]}" --stdout)"
|
|
|
|
fraglimit="$(dialog --backtitle "Fraglimit" \
|
|
|
|
--clear \
|
|
|
|
--ok-label "Next" \
|
|
|
|
--cancel-label "Exit" \
|
|
|
|
--rangebox "Select Fraglimit" -1 -1 1 1000000 20 --stdout)"
|
|
|
|
[[ $? -eq 1 ]] && exit 0
|
2024-01-21 13:12:55 -05:00
|
|
|
# Get ip address
|
|
|
|
yourIpAddress="$(curl -4s https://icanhazip.com)"
|
|
|
|
players="$(dialog --backtitle "Host Deathmatch Game" \
|
|
|
|
--clear \
|
|
|
|
--ok-label "Next" \
|
|
|
|
--cancel-label "Exit" \
|
|
|
|
--rangebox "Select number of players. Remember to give them your IP address: ${yourIpAddress}" -1 -1 ${mapPlayers[$map]} --stdout)"
|
|
|
|
[[ $? -eq 1 ]] && exit 0
|
|
|
|
skillLevel="$(dialog --backtitle "Host Deathmatch Game" \
|
|
|
|
--clear \
|
|
|
|
--ok-label "Start" \
|
|
|
|
--cancel-label "Exit" \
|
|
|
|
--rangebox "Select difficulty. 1 easiest, 5 hardest." -1 -1 1 5 3 --stdout)"
|
|
|
|
[[ $? -eq 1 ]] && exit 0
|
|
|
|
flags=(
|
|
|
|
'-host' "${players}"
|
|
|
|
'-skill' "${skillLevel}"
|
|
|
|
'-deathmatch'
|
|
|
|
'+set' 'sv_cheats' '1'
|
2024-01-21 13:17:54 -05:00
|
|
|
'+fraglimit' "$fraglimit"
|
2024-01-21 13:12:55 -05:00
|
|
|
'+dmflags' '16384' '+dmflags' '4' '+dmflags' '128' '+dmflags' '4096'
|
|
|
|
'-extratic' '-dup' '3'
|
|
|
|
'-warp' "$map"
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
exec stdbuf -oL ${gzdoom} ${gameOption} "${flags[@]}" | stdbuf -oL grep "${grepStrings[@]}" | stdbuf -oL sed "${sedStrings[@]}" | spd-say -e
|
2023-11-10 01:57:27 -05:00
|
|
|
;;
|
|
|
|
2)
|
|
|
|
# Exit was pressed, so exit.
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
3)
|
|
|
|
# Co-op setup
|
2023-11-10 15:28:28 -05:00
|
|
|
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
|
2024-01-21 05:02:41 -05:00
|
|
|
flags=("keyshare-universal.pk3" '-join' "${ipAddress}")
|
2023-11-10 15:28:28 -05:00
|
|
|
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)"
|
2023-11-10 15:28:28 -05:00
|
|
|
[[ $? -eq 1 ]] && exit 0
|
|
|
|
flags=(
|
2024-01-21 05:02:41 -05:00
|
|
|
"keyshare-universal.pk3"
|
2023-11-10 15:28:28 -05:00
|
|
|
'-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 17:48:43 -05:00
|
|
|
'+set' 'sv_respawnsuper' '1'
|
|
|
|
'+set' 'alwaysapplydmflags' ''1
|
2023-11-10 15:58:58 -05:00
|
|
|
'-extratic' '-dup' '3'
|
2023-11-10 15:28:28 -05:00
|
|
|
)
|
|
|
|
fi
|
2024-01-21 04:34:06 -05:00
|
|
|
pushd "${doomPath}"
|
2023-11-29 23:38:10 -05:00
|
|
|
exec stdbuf -oL ${gzdoom} ${gameOption} "${flags[@]}" | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e; } || echo "$l";done
|
2023-11-10 01:57:27 -05:00
|
|
|
;;
|
|
|
|
0)
|
2024-01-21 04:34:06 -05:00
|
|
|
pushd "${doomPath}"
|
2023-11-30 00:35:38 -05:00
|
|
|
exec stdbuf -oL ${gzdoom} ${gameOption} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e > /dev/null 2>&1; }; echo "$l";done
|
2023-11-10 01:57:27 -05:00
|
|
|
;;
|
|
|
|
esac
|
2023-11-05 21:51:14 -05:00
|
|
|
|
|
|
|
exit 0
|