gen_doom_slige_map.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #!/bin/sh
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. show_usage (){
  7. printf "Usage: $0 [options [parameters]]\n"
  8. printf "\n"
  9. printf "Mandatory options:\n"
  10. printf " -i|--iwad [doom|doom2]\n"
  11. printf "\n"
  12. printf "Options:\n"
  13. printf " -d|--game-dir [/path/to/doom/base/directory] (Optional, default: '~/games/doom')\n"
  14. printf " --levels [number of levels to generate] (Optional, default: '1')\n"
  15. printf " --rooms [rooms to generate per level] (Optional, default: '18')\n"
  16. printf " --bimo big monsters [true|false] (Optional, default: 'true')\n"
  17. printf " --bimobimo big monsters (!) [true|false] (Optional, default: 'true')\n"
  18. printf " --biwe big weapons [true|false] (Optional, default: 'true')\n"
  19. printf " --arena generate big arena level [true|false] (Optional, default: 'false')\n"
  20. printf " --minlight [minlight value] (Optional, default: '180')\n"
  21. printf " -h|--help, Print help\n"
  22. exit
  23. }
  24. if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
  25. show_usage
  26. fi
  27. if [ -z "$1" ]; then
  28. show_usage
  29. fi
  30. while [ -n "$1" ]; do
  31. case "$1" in
  32. --game-dir|-d)
  33. shift
  34. echo "INFO: param - game directory: $1"
  35. param_game_dir=$1
  36. ;;
  37. --iwad|-i)
  38. shift
  39. echo "INFO: param - iwad: $1"
  40. param_iwad=$1
  41. ;;
  42. --levels)
  43. shift
  44. echo "INFO: param - levels: $1"
  45. param_levels=$1
  46. ;;
  47. --rooms)
  48. shift
  49. echo "INFO: param - rooms: $1"
  50. param_rooms=$1
  51. ;;
  52. --bimo)
  53. shift
  54. echo "INFO: param - big monsters: $1"
  55. param_bimo=$1
  56. ;;
  57. --bimobimo)
  58. shift
  59. echo "INFO: param - big monsters !: $1"
  60. param_bimobimo=$1
  61. ;;
  62. --biwe)
  63. shift
  64. echo "INFO: param - big weapons: $1"
  65. param_biwe=$1
  66. ;;
  67. --arena)
  68. shift
  69. echo "INFO: param - arena level: $1"
  70. param_arena=$1
  71. ;;
  72. --minlight)
  73. shift
  74. echo "INFO: param - minlight: $1"
  75. param_minlight=$1
  76. ;;
  77. *)
  78. show_usage
  79. ;;
  80. esac
  81. shift
  82. done
  83. ### Configuration
  84. if [ -z "$param_game_dir" ]; then
  85. param_game_dir="$HOME/games/doom"
  86. fi
  87. config_script_dir="$(pwd $(dirname $0))"
  88. config_iwad_dir=$param_game_dir/wads/iwads
  89. if [ -z "$param_iwad" ]; then
  90. echo "ERROR: iwad parameter is mandatory"
  91. exit 1
  92. fi
  93. if [ -z "$param_levels" ]; then
  94. param_levels=1
  95. fi
  96. if [ -z "$param_rooms" ]; then
  97. param_rooms=18
  98. fi
  99. if [ -z "$param_bimo" ]; then
  100. param_bimo=true
  101. fi
  102. if [ -z "$param_bimobimo" ]; then
  103. param_bimobimo=true
  104. fi
  105. if [ -z "$param_biwe" ]; then
  106. param_biwe=true
  107. fi
  108. if [ -z "$param_minlight" ]; then
  109. #param_minlight=180
  110. param_minlight=100
  111. fi
  112. if [ -z "$param_arena" ]; then
  113. param_arena=false
  114. fi
  115. ### check parameter values
  116. doom_game="doom doom2"
  117. echo "$doom_game" | tr ' ' '\n' | while read -r item; do
  118. if [ "$item" = "$param_iwad" ]; then touch match; fi
  119. done
  120. if [ ! -f match ]; then echo "ERROR: $param_iwad is not a valid option, valid options are: $doom_game"; exit 1; fi; rm match
  121. opts="true false"
  122. echo "$opts" | tr ' ' '\n' | while read -r item; do
  123. if [ "$item" = "$param_bimo" ]; then touch match; fi
  124. done
  125. if [ ! -f match ]; then echo "ERROR: $param_bimo is not a valid option, valid options are: $opts"; exit 1; fi; rm match
  126. opts="true false"
  127. echo "$opts" | tr ' ' '\n' | while read -r item; do
  128. if [ "$item" = "$param_bimobimo" ]; then touch match; fi
  129. done
  130. if [ ! -f match ]; then echo "ERROR: $param_bimobimo is not a valid option, valid options are: $opts"; exit 1; fi; rm match
  131. opts="true false"
  132. echo "$opts" | tr ' ' '\n' | while read -r item; do
  133. if [ "$item" = "$param_biwe" ]; then touch match; fi
  134. done
  135. if [ ! -f match ]; then echo "ERROR: $param_biwe is not a valid option, valid options are: $opts"; exit 1; fi; rm match
  136. opts="true false"
  137. echo "$opts" | tr ' ' '\n' | while read -r item; do
  138. if [ "$item" = "$param_arena" ]; then touch match; fi
  139. done
  140. if [ ! -f match ]; then echo "ERROR: $param_arena is not a valid option, valid options are: $opts"; exit 1; fi; rm match
  141. # generate map
  142. if [ ! -f "$param_game_dir"/tools/slige/slige490/slige ]; then
  143. echo "Slige not available in '$param_game_dir/tools/slige/slige490/' directory. Please compile it and try again"
  144. exit 1
  145. fi
  146. echo "INFO: creating new slige map..."
  147. config_pwad_file="$param_game_dir/wads/slige/slige_"${param_iwad}".wad"
  148. slige_opts="-config $param_game_dir/tools/slige/slige490/slige.cfg $(if [ "$param_iwad" = "doom" ]; then echo "-E1M1"; fi) $(if [ "$param_iwad" = "doom2" ]; then echo "-$param_iwad"; fi) -levels $param_levels -rooms $param_rooms -map1 $(if [ "$param_bimo" = "true" ]; then echo "-bimo"; fi) $(if [ "$param_bimobimo" = "true" ]; then echo "-bimo!"; fi) $(if [ "$param_biwe" = "true" ]; then echo "-biwe"; fi) $(if [ "$param_arena" = "true" ]; then echo "-arena"; fi) -minlight $param_minlight -nocustom"
  149. $param_game_dir/tools/slige/slige490/slige ${slige_opts} $param_game_dir/wads/slige/slige_"${param_iwad}".out && $param_game_dir/tools/bsp/bsp-5.2/bsp $param_game_dir/wads/slige/slige_"${param_iwad}".out -o $config_pwad_file
  150. echo "INFO: new slige map created - ${config_pwad_file}"