# -*-tcl-*-
# This is an example character init file.
#################################################################

# automatically recast some spells

action set {^Your layer of bark begins to flake off} {write "bark me"}
action set {^You shed your chitinous armour} {write "chit me"}
action set {^You feel your stats returning to normal} {
    write "dex me"
    after 3000 {write "dex me"}
}

# Annoy thieves
# action set {%^You suddenly notice %w groping around in your pockets} {
#     global targ

#     write "br $2" "h $2"
#     set targ $2
#     echo [color "CAUGHT A THIEF! ($2)" {bold red}]
# }

# Beep when someone talks to us.

action set {^%w tells you:|%^%w asks you:} {bell}

# For the truly paranoid, set target to anyone
# who enters a room with you or who is in a room
# you enter.

alias set paranoid {
    set pattern {^%s arrives|^%s is here}

    if {$1} {
	action set $pattern {
	    global targ

	    set targ $1$2
	    echo [color target: {bold magenta}] $targ
	}
    } else {
	action delete -exact -- $pattern
    }
}

mud_attack h
mud_attack hh
mud_attack en
mud_attack br

# Ready a bow or put it down.
# Argument is either off or type of arrow to get.

alias set holdbow {
    if {[string compare $1 "off"] == 0} {
	write "drop bow" equip "get bow" "put quivers in bags"
    } else {
	write "get $1 quivers from bags" "get bow from bags" \
	    "hold hands" "hold bow"
    }
}

# Get to places quickly
# speedwalk is defined in the sample mmucl.rc
alias set toeluten {speedwalk 4n10w7ne2nw2n2w}
alias set tokhan {speedwalk 2n5w10n3w2nen2e2nen}

# Set up some convenient key bindings.

# Hit escape twice to bail out.
key set <Double-Escape> {write quit}

# protective spells
key set <F1> {write "bark me"}
key set <F2> {write "chit me"}
key set <F3> {write "dex me"}
key set <F4> {write "cure me"}

# offensive spells
key set <F5> {write "en $targ"}
key set <F6> {write "br $targ"}
key set <F7> {write "pf $targ"}
key set <F8> {write "hunt $targ"}

# miscellaneous
key set <F9>  {write "look $targ"}
key set <F10> {}
key set <F11> {}
key set <F12> {
    if {[walk suspend]} {
	walk suspend 0
	echo "WALK CONTINUED"
    } else {
	walk suspend 1
	echo "WALK STOPPED"
    }
}

# Turn a robot for a location on or off

alias set robot {
    global walk kill

    if {[string compare $1 on] == 0} {
	ak on $kill($2) hh q
	walk on $walk($2)
	monitor on

	action set "%^Hunt who?" {write q; walk suspend 0}
	action set "%^You are far too exhausted" {write q;walk suspend 0}
	action set {You look around and can't seem to find your target} {
	    write q
	    walk suspend 0
	}
    } else {
	walk off
	ak off
	action delete -exact -- "%^Hunt who?"
	action delete -exact -- "%^You are far too exhausted"
	action delete -exact -- {You look around and can't seem to find your target}
    }
}

# This is used by monitor defined in mmucl.rc
# It is called everytime status(hp) changes.

proc hp_check {args} {
    global status

    if {$status(hp) < 1000} {
	write quit
    } elseif {$status(hp) < 5000} {
	write "cure me"
    }

    return
}
