2024-04-17 03:18:57 -04:00
#!/usr/bin/env bash
# Set up the pk3 and wad files
gameOption = (
2024-07-31 17:48:58 -04:00
" ${ gamePath } /TobyAccMod_V ${ tobyVersion } .pk3 "
2024-12-28 22:31:52 -05:00
" $gamePath /Addons/MENU/TobyV*_ " *
2024-04-17 03:18:57 -04:00
)
2024-08-20 15:43:02 -04:00
# Get a list of pk3s to use for the custom death match.
2024-12-15 18:49:52 -05:00
mapfile -t pk3List < <( find " ${ gamePath } " -maxdepth 1 -mindepth 1 -size +10M -iname '*.pk3' )
2024-08-20 15:43:02 -04:00
if [ [ -e " ${ gamePath } /aoddoom1.wad " ] ] ; then
pk3List += ( " ${ gamePath } /aoddoom1.wad " )
fi
declare -a pk3Menu
for i in " ${ pk3List [@] } " ; do
title = " ${ i ##*/ } "
title = " ${ title %.* } "
pk3Menu += ( " ${ i } " " ${ title } " )
done
2024-04-17 03:18:57 -04:00
# Death match setup
ipAddress = " $( dialog --backtitle "Deathmatch 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
2024-08-20 15:43:02 -04:00
pk3 = " $( dialog --backtitle "Select Customization" \
--clear \
--no-tags \
--cancel-label "Exit" \
--ok-label "Next" \
--menu "Please select one" 0 0 0 " ${ pk3Menu [@] } " --stdout) "
[ [ $? -ne 0 ] ] && exit 0
2024-04-17 03:18:57 -04:00
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
2024-12-28 23:02:15 -05:00
flags = ( '-join' " ${ ipAddress } " '+Toby_SnapToTargetTargetingMode' '0' )
2024-04-17 03:18:57 -04:00
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)"
2024-12-28 22:31:52 -05:00
"8" "Hangar Bay 18 (2-4 players)"
"9" "Garden of Demon (2-4 players)"
"10" "Outpost 69 (2-4 players)" )
2024-04-17 03:18:57 -04:00
# 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"
2024-12-28 22:31:52 -05:00
[ 8] = "2 4"
[ 9] = "2 4"
[ 10] = "2 4" )
2024-04-17 03:18:57 -04:00
map = " $( dialog --backtitle "Select Map" \
--clear \
--no-tags \
--cancel-label "Exit" \
--ok-label "Next" \
--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 500 20 --stdout) "
[ [ $? -eq 1 ] ] && exit 0
# 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" \
--extra-button \
--extra-label "Bots Only" \
--rangebox "Select difficulty. 1 easiest, 5 hardest." -1 -1 1 5 3 --stdout) "
code = $?
[ [ $code -eq 1 ] ] && exit 0
if [ [ $code -eq 3 ] ] ; then
players = 1
dialog --backtitle "Preparing to Launch" \
--msgbox "When the game starts, press \` to open the console. Type addbot, press enter. Repeat addbot for as many bots as you would like. Press \` again to close the console." -1 -1 --stdout
fi
flags = (
'-host' " ${ players } "
'-skill' " ${ skillLevel } "
'-deathmatch'
2024-12-28 23:02:15 -05:00
'+Toby_SnapToTargetTargetingMode' '0'
2024-04-17 03:18:57 -04:00
'+set' 'sv_cheats' '1'
'+fraglimit' " $fraglimit "
'+dmflags' '16384' '+dmflags' '4' '+dmflags' '128' '+dmflags' '4096'
'+dmflags2' '512' '+dmflags2' '1024'
'-extratic' '-dup' '3'
'-warp' " $map "
)
fi
2024-08-20 15:43:02 -04:00
gameOption += ( " ${ pk3 } "
2024-12-28 22:31:52 -05:00
" ${ gamePath } /Addons/MAPS/TobyDeathArena_V1-5.wad "
2024-08-20 15:43:02 -04:00
)