aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2020-07-05 21:30:31 -0400
committerB. Watson <yalhcru@gmail.com>2020-07-05 21:30:31 -0400
commit87db1d2f47377e1525090e7656145ba8b6d64779 (patch)
tree1a36b73ae6b98834aadde9651b10901fa47c912d
parent0af243616ea2870796382d778dc1281121714288 (diff)
downloadmisc-scripts-87db1d2f47377e1525090e7656145ba8b6d64779.tar.gz
Add randoom
-rwxr-xr-xrandoom59
1 files changed, 59 insertions, 0 deletions
diff --git a/randoom b/randoom
new file mode 100755
index 0000000..dd86af6
--- /dev/null
+++ b/randoom
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+
+set -e
+
+DIR=~/.randoom
+MIDIDIR=$DIR/midi
+ENGINE=${ENGINE:-gzdoom}
+
+mkdir -p $DIR
+cd $DIR
+
+wepselect=$(( ( $RANDOM / 1000 ) % 10 ))
+case "$wepselect" in
+ 0|1|2) WEP=shotgun ;;
+ 3|4|5) WEP=supershotgun ;;
+ 6|7|8) WEP=chaingun ;;
+ 9) WEP=chainsaw ;;
+esac
+
+EXTRA="+give $WEP +give backpack"
+
+if [ "$#" = "1" -a "$1" = "-a" ]; then
+ if [ -e slige.out -a -e D_RUNNIN.lmp ]; then
+ again=1
+ EXTRA="$( cat extraargs )"
+ fi
+elif [ "$#" = "1" -a "$1" = "-r" ]; then
+ OBLIGECFG=$HOME/.oblige/rockets.cfg
+ EXTRA="+give rocketlauncher +give backpack"
+elif [ "$#" = "2" -a "$1" = "-k" ]; then
+ if [ -e slige.out ]; then
+ mv slige.out "$2".wad
+ echo "Keeping level as $2.wad"
+ exit 0
+ fi
+fi
+
+if [ "$again" != "1" ]; then
+ echo "$EXTRA" > extraargs
+ mv -f slige.out slige.out.old 2>/dev/null || true
+ mv -f D_RUNNIN.lmp D_RUNNIN.lmp.old 2>/dev/null || true
+
+# Pick some random music
+ if [ -d "$MIDIDIR" ]; then
+ MIDI="$( /bin/ls $MIDIDIR/*.mid | sort -R | head -1 )"
+ echo "'$MIDI'"
+ LMP=./D_RUNNIN.lmp
+ cat "$MIDI" > $LMP
+ fi
+
+# slige -doom2 -nulls
+# warm -q slige.out
+# glbsp -q slige.out -o slige.out
+ oblige --load ${OBLIGECFG:-$HOME/.oblige/CONFIG.txt} --batch slige.out
+fi
+
+$ENGINE -iwad doom2 -skill 3 -warp 1 $EXTRA -file slige.out $LMP
+echo "Used MIDI file: $MIDI"