#!/bin/sh

# Random gravity script for Alien Arena
# Written by Tony Jackson 15/07/2008
#
# Configure below and run using:
#   ./randomgravity &
# To stop use 'fg' and ctrl-c
# Calls Alien Arena rcon script - you must have ruby installed

########################
#    CONFIGURATION     #
########################

aapath=~/alienarena2008
serverip=localhost
serverport=27910
serverpass=your_rcon_pass_here
delay=5
maxgravity=1400
mingravity=100

########################
# END OF CONFIGURATION #
########################

# Do not edit below this line!

while [ 1 ]
do
	sleep $delay
	random=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "`
	random=$((($random%($maxgravity-$mingravity))+$mingravity))
#	echo "Set gravity to $random"
	$aapath/Tools/LinuxScripts/rcon $serverip:$serverport $serverpass set sv_gravity $random >/dev/null 2>&1
done
