Linux Hack & Slash client

In the last millennium, I developed a custom Hack & Slash gaming client for Windows ’98, because I wanted to embed both music and sound effects to enhance online play.  The result was a big hit among its players.  But as a Linux user, I could not get that cool feature… that is, until today.

The result is this Tcl/Expect script (listed below).  First, you will need to make certain you have these dependent packages installed:

yum install expect fluid-soundfont-lite-patches timidity++

Next, you will need to fetch the multimedia files into your home directory:

svn co Music/hack

Then, setup your telnet session attributes in .telnetrc to automatically load when you connect:
    mode character
    set crlf off
    unset escape

And last, simply copy/paste the script below into an executable text file of your choice and run it.

#!/usr/bin/expect -f

# play a MIDI file
proc midi s {
  set mid [string range $s 3 end-3]
  set bool [string range $s end-1 end-1]
  set cmd "killall playmus 2> /dev/null; playmus -v 25 Music/hack/$mid.mid &> /dev/null &"
  system $cmd

# play a WAVE file
proc wave s {
  set wav [string range $s 3 end-3]
  set bool [string range $s end-1 end-1]
  set cmd "play Music/hack/$wav.wav &> /dev/null"
  if {$bool == 0} { set cmd "$cmd &" }
  system $cmd

# connect to the game server ...
log_user 0
spawn telnet 7000
wave "...dungeon;0."

expect_background {
  -re "33[{.*}" { midi $expect_out(0,string); return }
  -re "33[[.*]" { wave $expect_out(0,string); return }
  -re "(.*)" { send_user -- $expect_out(0,string); }