aboutsummaryrefslogtreecommitdiff
path: root/randoom
blob: dd86af68e0d17042284f3032d3c6c8d58eadc0db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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"