Skip to content

Instantly share code, notes, and snippets.

@myndzi
Last active February 28, 2021 00:17
Show Gist options
  • Save myndzi/528eb1a782d9b1e32daadde86c5593d7 to your computer and use it in GitHub Desktop.
Save myndzi/528eb1a782d9b1e32daadde86c5593d7 to your computer and use it in GitHub Desktop.
;wumpus 1.0
;myndzi - 6/5/2006
on *:text:!wumpus:*:wump $nick $fulladdress
on me:*:join:#wumpus:%wumpuscid = $cid
on *:start:wumplisten | cave1
alias wumplisten {
if ($sock(wumpus_l)) sockclose wumpus_l
socklisten -dp 0.0.0.0 wumpus_l 2421
if ($sock(wumpus_l2)) sockclose wumpus_l2
socklisten -dp 0.0.0.0 wumpus_l2 2422
}
on *:socklisten:wumpus_l:{
inc %wumpchat
var %sn = wumpus_dccs. $+ %wumpchat
sockaccept %sn
.timer $+ %sn -o 1 15 sockclose %sn
}
on *:socklisten:wumpus_l2:{
inc %wumpchat
var %sn = wumpus_spoof. $+ %wumpchat
sockaccept %sn
sockwrite -n %sn To enter the caves, speak thy name.
.timer $+ %sn -o 1 15 sockclose %sn
}
on *:sockread:wumpus_spoof.*:{
if ($sockerr) return
.timer $+ $sockname off
var %i = $sock(wump.*, 0), %n, %re = /^(?!\d)[A-Za-z0-9\\\|\[\]\{\}^`\-_]+$/
sockread %n
if (!$regex(%n, %re)) {
sockwrite -n $sockname Egads, what a mouthful! (try a different nick)
return
}
while (%i) {
if (%n * iswm $gettok($sock(wump.*, %i).mark, 1, 32)) {
sockwrite -n $sockname A player with that nick is already in the game!
return
}
dec %i
}
if ($sock(wump.*, 0)) sockwrite -n wump.* * %n joins the partyline
sockmark $sockname %n !@
var %sn = $replace($sockname, wumpus_spoof, wump)
sockrename $sockname %sn
sockpause -r %sn
greet %sn
}
on *:sockread:wumpus_dccs.*:{
if ($sockerr) return
.timer $+ $sockname off
var %i = $sock(wump.*, 0), %t, %n, %re = /^(?!\d)[A-Za-z0-9\\\|\[\]\{\}^`\-_]+$/
sockread %t | tokenize 32 %t
if (100 == $1) {
%n = $2
if (!$regex(%n, %re)) {
sockwrite -n $sockname 151 rejected - Invalid nick!
goto cleanup
}
while (%i) {
if (%n * iswm $sock(wump.*, %i).mark) {
sockwrite -n $sockname 151 rejected - A player with that nick is already in the game!
goto cleanup
}
dec %i
}
sockwrite -n $sockname 101 myndzi
if ($sock(wump.*, 0)) sockwrite -n wump.* * %n joins the partyline
sockmark $sockname %n !@
var %sn = $replace($sockname, wumpus_dccs, wump)
sockrename $sockname %sn
sockpause -r %sn
greet %sn
return
}
:cleanup
sockclose $sockname
}
on *:socklisten:wumpl.*:{
inc %wumpchat
var %n = $gettok($sock($sockname).mark, 1, 32)
if ($sock(wump.*, 0)) sockwrite -n wump.* * %n joins the partyline
sockaccept wump. $+ %wumpchat
sockmark wump. $+ %wumpchat $sock($sockname).mark
greet wump. $+ %wumpchat
sockclose $sockname
}
on *:sockread:wump.*:{
if ($sockerr) return $wumpclean
var %t, %n = $gettok($sock($sockname).mark, 1, 32)
sockread %t
if ($floodchk(wumpus, 2) > 8) { sockclose $sockname | return }
while ($sockbr) {
tokenize 32 %t
if ($regex($1, /^!?h(elp)?$/)) cmdhelp $sockname
elseif ($regex($1, /^[!.]?w(ho)?$/i)) cmdwho $sockname
elseif ($regex($1, /^[!.]?howtoplay$/i)) cmdrules $sockname
elseif ($regex($1, /^[!.]?e(nter)?$/i)) && (!$hget(wumpus_game, %n)) addplayer %n
elseif ($regex($1, /^[!.]?s(hoot)?$/i)) && ($0 > 1) && ($hget(wumpus_game, %n)) shootarrow %n $2-
elseif ($regex($1, /^[!.]?l(ook)?$/i)) && ($hget(wumpus_game, %n)) lookaround %n
elseif ($regex($1, /^[!.]?m(ove)?$/i)) && ($hget(wumpus_game, %n)) moveplayer %n $2-
elseif ($regex($1, /^[!.]?sc(ore)?$/i)) scorelist $sockname $2-
elseif ($1 isnum) && ($hget(wumpus_game, %n)) moveplayer %n $1-
elseif ("* iswm $1) wsay $sockname %n $mid($1-,2)
elseif ($regex($1-, /^\x01ACTION (.*)\x01$/)) wdesc $sockname %n $regml(1)
else wsay $sockname %n $1-
sockread %t
}
}
alias greet {
var %% = sockwrite -n $1
%% Welcome, $gettok($sock($sockname).mark, 1, 32) $+ , to Hunt the Wumpus!
%% This mIRC script is an adaptation by myndzi of the original BASIC game written by Gregory Yob.
%% You can view maps of the caves at: http://krisreeves.com/wumpus/index.html
%% If this is your first time playing, type 'help'
%%
%% Current map: %wumpus_map
cmdwho $1
}
alias cmdhelp {
var %% = sockwrite -n $1
%% Commands:
%% howtoplay - game rules
%% help   (h) - this screen
%% who    (w) - display connected players
%% enter  (e) - enter game
%% shoot  (s) - shoot an arrow
%% look   (l) - show current location
%% move   (m) - move to another room
%% score (sc) - display score info
%%
%% You can also move simply by specifying the number(s) of the room(s) to move through, without a command.
%% Anything else will be sent to the partyline. You can use "text to force text to be sent to the partyline.
}
alias cmdrules {
var %% = sockwrite -n $1
%% Hunt the Wumpus is simple. Each cave is made of a network of rooms. Each room has three exits. Within the caves are bottomless pits, super bats, other players, and, of course, the Wumpus.
%% The goal is to kill the Wumpus. You must do this by using the clues displayed in each room to determine the location of the Wumpus without dying.
%% 
%% To move around, you must select a room to enter. You are presented with three choices, and you can move by simply typing the number of the room you want to move to.
%% You can move through as many rooms as you like by typing them all in a row: 2 3 4 5 10, for example. Be careful though, you will be stopped by the first wrong turn or any obstacle you encounter.
%% 
%% If you walk into a room with a bottomless pit, you die. If you walk into a room with a super bat, it will transport you (and itself) to a random room.
%% If you shoot yourself or are shot by another player, you die. If you walk into a room with the Wumpus, you wake it up. The Wumpus will also wake up any time a crooked arrow is shot.
%% When the Wumpus wakes up, he might decide to go to another room, or he might stay where he is. If he ends up in your room, however, you die.
%% 
%% You have five crooked arrows. If you run out of arrows, you die. You may shoot your arrows through up to five rooms by specifying the room numbers in sequence:
%% shoot 1 7 9 10 12
%% ...but if you choose a wrong number, the arrow will begin taking random turns and may even end up coming back to get you, so beware!
}
alias cmdwho {
var %i = $sock(wump.*, 0), %r
while (%i) {
%r = %r $gettok($sock(wump.*, %i).mark, 1, 32)
dec %i
}
sockwrite -n $1 Connected players: %r
}
alias wsay {
var %i = $sock(wump.*, 0), %sn = $1, %n = $2, %t = $3-
while (%i) {
if ($sock(wump.*, %i) != %sn) sockwrite -n $ifmatch < $+ %n $+ > %t
dec %i
}
}
alias wdesc {
var %i = $sock(wump.*, 0), %sn = $1, %n = $2, %t = $3-
while (%i) {
if ($sock(wump.*, %i) != %sn) sockwrite -n $ifmatch * %n %t
dec %i
}
}
on *:sockwrite:wump.*:if ($sockerr) return $wumpclean
on *:sockclose:wump.*:if ($sockerr) return $wumpclean | wumpclean
alias wumpclean {
var %n = $gettok($sock($sockname).mark, 1, 32)
killplayer $sock($sockname).mark
sockwrite -n wump.* * %n $iif($sockerr, was disconnected: $sock($sockname).wsmsg, quit the partyline)
}
alias getport {
var %port = %wumpus_minport
while (%port <= %wumpus_maxport) {
if ($portfree(%port)) { return %port }
inc %port
}
return 0
}
alias wump {
if ($comchan($1, 0)) {
var %i = $sock(wump.*, 0)
while (%i) {
if ($nick * iswm $sock(wump.*, %i).mark) {
notice $nick Sorry, a player with that nick is already in the game!
return
}
dec %i
}
inc %wumpchat
var %sn = wumpl. $+ %wumpchat
var %bindport = $getport
if (%bindport == 0) {
notice $nick No ports free, sorry :(
return
}
socklisten -dp 0.0.0.0 %sn %bindport
sockmark %sn $1 $mask($2, 3)
.raw PRIVMSG $1 : $+ $chr(1) $+ DCC CHAT chat $longip($ip) $sock(%sn).port $+ $chr(1)
.timer $+ %sn 1 60 sockclose %sn
}
}
alias scorelist {
var %detail, %sn = $1
tokenize 32 $2-
if ($istok(bats pits pks arrows suicides wumpus, $1, 32)) {
var %detail = $1
tokenize 32 $2-
}
if ($1 == $null) {
sockwrite -n %sn Syntax: score [bats|pits|pks|arrows|suicides|wumpus] <nick>
return
}
var %n = $1
if ($hget(wscore, %n)) {
tokenize 32 $ifmatch
var %d = $calc($2 + $3 + $5 + $6 + $7)
if (%detail) {
if (%detail == bats) %t = %n has been jerked around by bats $once($1, time) $+ .
elseif (%detail == pits) %t = %n has walked straight into a bottomless pit $once($2, time) $iif($2 > 1, (how is that even possible?)) $+ .
elseif (%detail == pks) %t = %n has killed $once($4, player) and been pked $once($3, time) $+ .
elseif (%detail == arrows) %t = %n has run out of arrows $once($5, time) $+ .
elseif (%detail == suicides) %t = %n has committed suicide $once($10, time) $+ .
elseif (%detail == wumpus) %t = %n has blundered right into the Wumpus's mouth $once($6, time) $+ . %n scared the Wumpus into another player's room $once($8, time) $+ . The Wumpus walked into %n $+ 's room $once($7, time) $+ .
}
else %t = %n has killed the wumpus $once($9, time) and died $once(%d, time) $+ . $iif($4, %n has killed $once($4, player) $+ .) $iif($10, Demonstrating uncanny skill at archery $+ $chr(44) %n has found $10 of their own arrows the hard way $+ .)
out %t
}
}
alias -l out if ($sock(wump.*, 0)) sockwrite -n wump.* $1-
on *:start:{
hmake wscore 10
hload wscore wscore.htbl
}
;bat - player went for a ride
;pit - player fell down a pit
;pked - player got killed by player
;pker - player killed another player
;noammo - player ran out of crooked arrows
;wumpus_stupid - player caused self to be eaten by wumpus
;wumpus_unlucky - player got eaten by wumpus
;wumpus_scare - player scared wumpus into eating another player
;won - player killed the wumpus
;suicide - player killed self
alias -l once return $iif($1 == 1, 1 $2, $1 $2s)
alias score {
var %tokens = bat pit pked pker noammo wumpus_stupid wumpus_unlucky wumpus_scare won suicide
var %thing = $1, %p = $2, %k = $3, %sc = $hget(wscore, $2), %n
if (%sc == $null) %sc = 0 0 0 0 0 0 0 0 0 0
%n = $findtok(%tokens, %thing, 32)
%sc = $puttok(%sc, $calc($gettok(%sc, %n, 32) + 1), %n, 32)
hadd -m wscore %p %sc
hsave -o wscore wscore.htbl
}
;alias cave0 return 1
alias cave0 return 8
alias cave1 {
if ($isid) {
if ($prop == desc) return Dodecahedron
return $false
}
else {
loadcave cave1 2 2 2 5 6 1 3 8 2 4 10 3 5 12 1 4 14 1 7 15 6 8 16 2 7 9 8 10 17 3 9 11 10 12 18 4 11 13 12 14 19 5 13 15 6 14 20 7 17 20 9 16 18 11 17 19 13 18 20 15 16 19
out Loaded: Dodecahedron
}
}
alias cave2 {
if ($isid) {
if ($prop == desc) return Pentagram
return $false
}
else {
loadcave cave2 1 1 2 3 4 3 4 5 4 5 1 5 1 2 1 2 3
out Loaded: Pentagram
}
}
alias cave3 {
if ($isid) {
if ($prop == desc) return Super Pentagram
return $false
}
else {
loadcave cave3 2 3 2 11 21 3 12 22 4 13 23 5 14 24 6 15 25 7 16 26 8 17 27 9 18 28 10 19 29 1 20 30 1 21 31 2 22 32 3 23 33 4 24 34 5 25 35 6 26 36 7 27 37 8 28 38 9 29 39 10 30 40 1 11 30 2 12 21 3 13 22 4 14 23 5 15 24 6 16 25 7 17 26 8 18 27 9 19 28 10 20 29 11 35 37 12 36 38 13 37 39 14 38 40 15 39 31 16 40 32 17 31 33 18 32 34 19 33 35 20 34 36
out Loaded: Super Pentagram
}
}
alias cave4 {
if ($isid) {
if ($prop == desc) return Sprout
if ($prop == pit) {
if ($istok(5 6 8 9 12 13 15 16 35 36 38 39 42 43 45 46 20 21 23 24 27 28 30 31, $1, 32)) return $false
else return $true
}
elseif ($prop == bat) return $false
}
else {
loadcave cave4 2 3 2 17 32 1 3 10 1 4 7 1 5 6 1 6 31 1 5 8 1 8 9 1 6 9 1 8 12 1 11 14 1 12 13 1 9 13 1 12 15 1 15 16 1 13 16 1 15 35 1 18 25 1 19 22 1 20 21 1 21 46 1 20 23 1 23 24 1 21 24 1 23 27 1 26 29 1 27 28 1 24 28 1 27 30 1 30 31 1 28 31 1 30 5 1 33 40 1 34 37 1 35 36 1 16 36 1 35 38 1 38 39 1 36 39 1 38 42 1 41 44 1 42 43 1 39 43 1 42 45 1 45 46 1 43 46 1 45 20
out Loaded: Sprout
}
}
alias cave5 {
if ($isid) {
if ($prop == desc) return Batty!
if ($prop != special) return $false
hadd wumpus_game 1 $hget(wumpus_game, 1) !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat !bat
}
else {
loadcave cave5 0 0 1 2 1 1 3 1 2 4 1 3 5 1 4 6 1 5 7 1 6 8 1 7 9 1 8 10 1 9 11 1 10 12 1 11 13 1 12 14 1 13 15 1 14 16 1 15 17 1 16 18 1 17 19 1 18 20 1 19 20 1
out Loaded: Batty
}
}
alias cave6 {
if ($isid) {
if ($prop == desc) return Cubic
if ($prop == pit) {
if ($istok(1 5 9 17 13 21 25 29, $1, 32)) return $true
else return $false
}
else return $false
}
else {
loadcave cave6 2 3 2 4 29 1 3 6 2 4 7 1 3 8 6 8 9 2 5 7 3 6 8 4 5 7 5 10 12 9 11 14 10 12 15 9 11 16 14 16 17 10 13 15 11 14 16 12 13 15 13 18 20 17 19 22 18 20 23 17 19 24 22 24 25 18 21 23 19 22 24 20 21 23 21 26 28 25 27 30 26 28 31 25 27 32 1 30 32 26 29 31 27 30 32 28 29 31
out Loaded: Cubic
}
}
alias cave7 {
if ($isid) {
if ($prop == desc) return Hunting Ground
return $false
}
else {
loadcave cave7 0 0 2 20 6 3 11 7 4 12 8 5 13 9 6 14 10 7 15 1 8 16 2 9 17 3 10 18 4 1 19 5 20 1 16 11 2 17 12 3 18 13 4 19 14 5 20 15 6 11 16 7 12 17 8 13 18 9 14 19 10 15
out Loaded: Hunting Ground
}
}
alias cave8 {
if ($isid) {
if ($prop == desc) return Triangulation
if ($prop == special) {
tokenize 32 $hget(wumpus_map, $hget(wumpus_game, !wumpus))
hadd wumpus_game $1 !pit
hadd wumpus_game $2 !pit
hadd wumpus_game $3 !pit
}
else return $false
}
else {
loadcave cave8 0 2 2 4 5 1 3 9 2 4 13 1 3 17 1 6 8 5 7 20 6 8 21 5 7 10 2 10 12 8 9 11 10 12 22 9 11 14 3 14 16 12 13 15 14 16 23 13 15 18 4 18 20 16 17 19 18 20 24 6 17 19 7 22 24 11 21 23 15 22 24 19 21 23
out Loaded: Triangulation
}
}
alias cave9 {
if ($isid) {
if ($prop == desc) return Truncated Icosahedron
return $false
}
else {
loadcave cave9 2 3 2 5 9 1 3 12 2 4 15 3 5 18 1 4 6 5 7 20 6 8 22 7 9 25 1 8 10 9 11 26 10 12 29 2 11 13 12 14 30 13 15 33 3 14 16 15 17 34 16 18 37 4 17 19 18 20 38 6 19 21 20 22 40 7 21 23 22 24 42 23 25 44 8 24 26 10 25 27 26 28 45 27 29 47 11 28 30 13 29 31 30 32 48 31 33 50 14 32 34 16 33 35 34 36 51 35 37 53 17 36 38 19 37 39 38 40 54 21 39 41 40 42 55 23 41 43 42 44 57 24 43 45 27 44 46 45 47 58 28 46 48 31 47 49 48 50 59 32 49 51 35 50 52 51 53 60 36 52 54 39 53 55 41 54 56 55 57 60 43 56 58 46 57 59 49 58 60 52 56 59
out Loaded: Truncated Icosahedron
}
}
alias cavevil {
if ($isid) {
if ($prop == desc) return IT'S A TRAP
if ($prop == special) {
hdel wumpus_game $hget(wumpus_game, !wumpus)
hadd wumpus_game !wumpus 1
hadd wumpus_game 1 !wumpus
}
else return $false
}
else {
loadcave cavevil 0 0 2 3 4 2 3 4 3 4 2 4 3 2
out Loaded: IT'S A TRAP
}
}
alias endgame {
var %r = $le(1, $cave0)
out Restarting game....
cave $+ %r
}
alias loadcave {
var %n, %i, %t, %call = $chr(36) $+ $1, %pits = $2, %bats = $3, %c = $true
tokenize 32 $4-
if (3 \\ $0) return
%n = $calc($0 / 3)
%i = $0
if (%n < 4) return
if ($calc(%pits + bats + 1) >= %n) return
while (%i) {
if ($gettok($1-, %i, 32) !isnum 1- $+ %n) { echo -a $v1 !isnum $v2 | return }
dec %i
}
if ($hget(wumpus_map)) hfree wumpus_map
if ($hget(wumpus_game)) hfree wumpus_game
hmake wumpus_map 100
hmake wumpus_game 100
set %wumpus_map $eval( %call $+ ().desc, 2)
%i = 1
while ($0) {
hadd wumpus_map %i $1-3
tokenize 32 $4-
inc %i
}
hadd wumpus_map 0 %n
%t = $le(1, %n)
while ($hget(wumpus_game, %t)) %t = $le(1, %n)
hadd wumpus_game %t !wumpus
hadd wumpus_game !wumpus %t
noop $eval( %call $+ ().special, 2)
%c = $true
while (%pits) {
while ($hget(wumpus_game, %t)) || (%c) {
%t = $le(1, %n)
%c = $eval( %call $+ ( $+ %t $+ ).pit , 2)
}
hadd wumpus_game %t !pit
dec %pits
}
%c = $true
while (%bats) {
while ($hget(wumpus_game, %t)) || (%c) {
%t = $le(1, %n)
%c = $eval( %call $+ ( $+ %t $+ ).bat , 2)
}
hadd wumpus_game %t !bat
dec %bats
}
}
; addplayer playername
alias addplayer {
if (! isin $1) return
var %n = $hget(wumpus_map, 0), %t = $le(1, %n), %p = $1
while (! isin $hget(wumpus_game, %t)) %t = $le(1, %n)
hadd wumpus_game %t $hget(wumpus_game, %t) %p
hadd wumpus_game %p %t 5 5
out %p wanders warily into the caves...
lookaround %p
}
; killplayer playername
alias killplayer {
var %p = $1, %r = $gettok($hget(wumpus_game, %p), 1, 32)
if (%r) hadd wumpus_game %r $remtok($hget(wumpus_game, %r), %p, 1, 32)
if ($isalias(fwcmdw/errat)) .timer 1 1 fwcmdw/errat " $+ $replace(%p, $chr(160), $chr(32)) $+ " You have died! Better luck next time...
wumppoints %p $calc(0 - 7500 / $hget(wumpus_map, 0))
hdel wumpus_game %p
}
; moveplayer playername dest
alias moveplayer {
var %p = $1, %r = $gettok($hget(wumpus_game, %p), 1, 32), %d = $2
if (%r !isnum) return
if ($3 != bat) && (!$istok($hget(wumpus_map, %r), %d, 32)) return
if ($3 != bat) && (! !isin $hget(wumpus_game, %d)) {
if ($3 == $null) out %p delves deeper into the darkness...
else {
out %p forges blindly ahead!
tokenize 32 $3-
while ($0) {
if ($istok($hget(wumpus_map, %d), $1, 32)) {
%d = $1
if (! isin $hget(wumpus_game, %d)) break
}
else {
out ... smack into a wall.
break
}
tokenize 32 $2-
}
}
}
var %%wg = $hget(wumpus_game, %p), %%2 = $gettok(%%wg, 2, 32), %%3 = $gettok(%%wg, 3, 32)
hadd wumpus_game %p %d $gettok($hget(wumpus_game, %p), 2, 32) $calc(%%3 + 1)
hadd wumpus_game %d $hget(wumpus_game, %d) %p
hadd wumpus_game %r $remtok($hget(wumpus_game, %r), %p, 1, 32)
checkroom %p %d $3
}
; checkroom playername dest
alias checkroom {
var %p = $1, %d = $2, %t = $hget(wumpus_game, %d)
if (!wumpus isin %t) wakewumpus %p move
%t = $hget(wumpus_game, %d)
if (!wumpus !isin %t) {
if (!pit isin %t) falldie %p
elseif (!bat isin %t) && ($3 != bat) superbat %p
else {
if (!bat isin %t) out %p narrowly avoids being splattered by giant guano.
lookaround %p
}
}
}
; shootarrow playername room(s)
alias shootarrow {
var %p = $1, %r = $gettok($hget(wumpus_game, %p), 1, 32), %n = $0 - 1, %? = $false, %t
if (%n > 5) return
out %p looses a crooked arrow into the night. It whistles as it flies through the air...
tokenize 32 $2-
while ($0) {
if (%?) %r = $gettok($hget(wumpus_map, %r), $le(1, 3), 32)
else {
if ($istok($hget(wumpus_map, %r), $1, 32)) %r = $1
else {
%? = $true
continue
}
}
tokenize 32 $2-
}
if (!wumpus isin $hget(wumpus_game, %r)) {
out The arrow flies true! There comes a distant SPLACK! as the arrow buries itself into the Wumpus's head. %p is victorious!
var %%wg = $hget(wumpus_game, %p), %%2 = $gettok(%%wg, 2, 32), %%3 = $gettok(%%wg, 3, 32), %points = $calc($hget(wumpus_map, 0) ^ 2 - (%%3 - %%2) ^ 2)
if (%points > 0) wumppoints %p %points
if ($calc($ctime - 180) > %wumpwin) {
fwcmd/echo %p has defeated the Wumpus!
%wumpwin = $ctime
}
score won %p
endgame
}
else {
tokenize 32 $hget(wumpus_game, %p)
var %ar = $2 - 1
hadd wumpus_game %p $1 %ar $3
var %pl = $regsubex($hget(wumpus_game, %r), /(?<=\s|^)(!\S+)(?=\s|$)/g, )
if ($remove(%pl, $chr(32)) != $null) {
if (%pl == %p) {
out %p nocks an arrow, takes careful aim, and looses it into the dark. %p hears a whistling sound getting louder, and a sudden sharp pain.
score suicide %p
wakewumpus %p shoot
if ($hget(wumpus_game, %p)) out Slowly bleeding to death, %p realizes that handling a bow after failing Archery 101 may not have been the best of ideas....
killplayer %p
}
else {
%pl = $gettok(%pl, $le(1, $numtok(%pl, 32)), 32)
out %p hears in the distance a startled yelp, followed by a slightly louder THUD! %p thinks, only %ar arrows left but at least one got put to good use.
out In a dark room in another part of the caves, %pl falls over dead, a crooked arrow sticking out of a place crooked arrows shouldn't be.
score pked %pl
score pker %p
wumppoints %p $iif($sqrt($wumppoints(%pl)) > 100, $v1, 100)
killplayer %pl
wakewumpus %p shoot
}
}
else {
if (%ar <= 0) {
wakewumpus %p shoot
out %p hears nothing more, then realizes belatedly that there are no arrows left! %p can no longer escape an unsightly death deep below the Earth....
score noammo %p
killplayer %p
}
else {
out %p hears nothing more. %p looks nervously at the quiver, which now holds a mere %ar crooked arrows.
wakewumpus %p shoot
}
}
}
}
alias wakewumpus {
var %p = $1
if ($2 == move) out %p has stumbled into the Wumpus, waking it up!
if ($2 == shoot) out %p hears a roar in the distance and the sounds of suckering movement...
if ($le(0,3)) {
if ($2 == move) {
out ... luckily for %p $+ , the Wumpus shambles off into another room.
}
movewumpus $2 %p
}
else wumpuseat wake
}
alias wumpuseat {
var %r = $hget(wumpus_game, !wumpus), %t = $1, %p = $2
tokenize 32 $regsubex($hget(wumpus_game, %r), /(?<=\s|^)(!\S+)(?=\s|$)/g, )
while ($0) {
killplayer $1
if (%t == wake) {
score wumpus_stupid $1
out The Wumpus blinks sleepily, realizing it is no longer alone. Then it eats $1 up and goes back to sleep.
}
elseif (%t == shoot) {
if (%p == $1) score wumpus_stupid $1
else {
score wumpus_unlucky $1
score wumpus_scare %p
}
out Oh no! The Wumpus strolls in and casually devours $1 $+ .
%t = move2
}
elseif (%t == move) {
if (%p == $1) score wumpus_stupid $1
else {
score wumpus_unlucky $1
score wumpus_scare %p
}
out .... $1, however, isn't as lucky. The Wumpus saunters in and makes itself a $1 $+ -wich for an evening snack.
%t = move2
}
elseif (%t == move2) {
if (%p == $1) score wumpus_stupid $1
else {
score wumpus_unlucky $1
score wumpus_scare %p
}
out ..... $1 follows soon after, for dessert.
%t = move3
}
elseif (%t == move3) {
if (%p == $1) score wumpus_stupid $1
else {
score wumpus_unlucky $1
score wumpus_scare %p
}
out The Wumpus glances over $1, and decides it has room for one more. CHOMP!
}
tokenize 32 $2-
}
}
alias movewumpus {
var %r = $hget(wumpus_game, !wumpus), %d = $gettok($hget(wumpus_map, %r), $le(1, 3), 32)
hadd wumpus_game !wumpus %d
hadd wumpus_game %r $remtok($hget(wumpus_game, %r), !wumpus, 1, 32)
hadd wumpus_game %d $hget(wumpus_game, %d) !wumpus
wumpuseat $1 $2
}
alias movebat {
var %r = $1, %d = $2
hadd wumpus_game %r $remtok($hget(wumpus_game, %r), !bat, 1, 32)
hadd wumpus_game %d $hget(wumpus_game, %d) !bat
}
alias falldie {
var %p = $1
out AAAIIIIIIIEEEEEEEeeeee...... (Poor %p walked right into a bottomless pit! Goodbye %p $+ !)
score pit %p
killplayer %p
}
alias superbat {
var %p = $1, %r = $gettok($hget(wumpus_game, %p), 1, 32), %d = %r
while (%d == %r) %d = $le(1, $hget(wumpus_map, 0))
out %p hears soft flapping noises, but too late! A large bat swoops down and grabs %p $+ , flying off to another place...
score bat %p
moveplayer %p %d bat
movebat %r %d
}
alias lookaround {
var %p = $1, %r = $gettok($hget(wumpus_game, %p), 1, 32), %u, %pl = $regsubex($hget(wumpus_game, %r), /(?<=\s|^)(!\S+)(?=\s|$)/g, ), %x = $hget(wumpus_map, %r)
var %t = $chr(3) $+ $base($calc($hash(%p, 32) % 14 + 2), 10, 10, 2) $+ ( $+ %p $+ : %x $+ )
%pl = $remtok(%pl, %p, 1, 32)
tokenize 32 %x
while ($0) {
%u = $hget(wumpus_game, $1)
if (!wumpus isin %u) %t = $addtok(%t, You smell a Wumpus!, 10)
if (!pit isin %u) %t = $addtok(%t, You feel a draft., 10)
if (!bat isin %u) %t = $addtok(%t, You hear a distant squeaking., 10)
if ($remove($regsubex(%u, /(?<=\s|^)(!\S+)(?=\s|$)/g, ), $chr(32)) != $null) %t = $addtok(%t, You see faint footsteps in the dust., 10)
tokenize 32 $2-
}
%t = $replace(%t, $lf, $chr(32))
if (%pl) %t = %t In the dim light, you the $iif($numtok(%pl, 32) > 1, players, player) $+ : $replace(%pl, $chr(32), $+($chr(44), $chr(32)))
out %t
}
alias wumppoints {
var %i = $sock(wump.*, 0)
while (%i) {
if ($1 * iswm $sock(wump.*, %i).mark) {
var %u = $gettok($v2, 2, 32)
if ($isid) return $points(%u)
return $points(%u, $$2)
}
dec %i
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment