yamagi-quake2_quake2.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. config_game_dir=~/games/quake2
  3. config_script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
  4. mapfile=$(find $config_game_dir/*/{maps/*.bsp,pak0.pak} -type f | shuf -n 1)
  5. installed_bin=$(which qpakman 2>/dev/null || echo false)
  6. compiled_bin="$HOME/src/qpakman/qpakman"
  7. qpakman_command=$(if [ ! $installed_bin = "false" ]; then echo "qpakman"; else if [ -f "$compiled_bin" ]; then echo "$compiled_bin"; fi; fi) \
  8. get_random_map() {
  9. if [[ "$mapfile" == *"pak"* ]]; then
  10. # Get map directory name
  11. mapdir=$(dirname $mapfile)
  12. mapdir=$(echo ${mapdir} | awk -F/ '{print $(NF)}')
  13. # Get map pak file map name
  14. pakfile=$mapfile
  15. mapfile=$(${qpakman_command} -l "$pakfile" | grep 'maps/' | grep '.bsp' | awk '{ print $5 }' | shuf -n 1)
  16. else
  17. # Get map directory name
  18. mapdir=$(dirname "$mapfile")
  19. mapdir=$(echo ${mapdir} | awk -F/ '{print $(NF-1)}')
  20. fi
  21. }
  22. get_random_map
  23. while [ -z $mapdir ]
  24. do
  25. unset mapdir
  26. get_random_map
  27. done
  28. echo "INFO: $0 - Map directory $mapdir"
  29. # get map name
  30. mapname=$(basename -- "${mapfile%.*}")
  31. echo "INFO: $0 - Map name $mapname"
  32. # run
  33. system_name=$(uname)
  34. if [ $system_name="OpenBSD" ]; then
  35. installed_bin=$(which quake2 2>/dev/null || echo false)
  36. installed_bin_name=quake2
  37. else
  38. installed_bin=$(which yamagi-quake2 2>/dev/null || echo false)
  39. installed_bin_name=yamagi-quake2
  40. fi
  41. compiled_bin="$HOME/src/yquake2/release/baseq2"
  42. set -x
  43. $(if [ ! $installed_bin = "false" ]; then echo $installed_bin_name; else if [ -f "$compiled_bin" ]; then echo "$compiled_bin"; fi; fi) \
  44. +seta r_customheight 1920 \
  45. +seta r_customwidth 1080 \
  46. +seta vid_fullscreen 1 \
  47. +seta r_mode -1 \
  48. +set vid_renderer gl3 \
  49. +set gl3_particle_square 1 \
  50. +set gl3_colorlight 1 \
  51. +set gl_texturemode GL_NEAREST \
  52. +set vid_restart 1 \
  53. +set al_driver libopenal.so.4.2 \
  54. +set ogg_enable 1 \
  55. -datadir $config_game_dir \
  56. +game $mapdir +skill 0 \
  57. +map $mapname \
  58. +set cl_showfps 2 \
  59. +seta com_allowconsole 1 \
  60. > /tmp/quake2.log
  61. set +x