home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 2
/
FFMCD02.bin
/
new
/
amigalibdisks
/
disk950
/
bbdoors
/
bbdoors65.lha
/
rexxDoors
/
Ship_Hunt.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-08-07
|
19KB
|
692 lines
/* Ship_Hunt.rexx version 2.3 by Matt English 1-10-93
This is an ONLINE game designed for the BBBBS system.
This game is freely distributable as long as no one makes
any money from it and the credits remain on the title screen.
To run on BBBBS, just copy the program "Ship_Hunt.rexx"
to your RexxDoors directory.
For bug reports or comments call Matt English (sysop)
Alternative BBS
503-761-3043
*/
options results
FF='0C'x /* FormFeed */
CR='0D'x /* Carraige Return */
CALL TIME('R')
SIGNAL ON BREAK_C
SIGNAL ON BREAK_E
bbspath=GETCLIP('BBS_path')
bbspath=bbspath'rexxDoors/Data/'
datapath = bbspath'Ship'
PARSE arg Username winnings . colorflag secs .
IF secs='' THEN secs=3600
signal on syntax
name = Username
letters = 'abcdefghijq'
def=''
pen0=''
pen2=''
pen3=''
pen4=''
pen5=''
pen6=''
pen7=''
bak2=''
bak3=''
bak4=''
bak5=''
bak6=''
bak7=''
CLS = 'H'
UNL = '
'
IF colorflag=1 THEN
DO
def=''
pen0='
'
pen2='
'
pen3='
'
pen4='
'
pen5='
'
pen6='
'
pen7='
'
bak2='
'
bak3='
'
bak4='
'
bak5='
'
bak6='
'
bak7='
'
CLS = 'H'
UNL = '
'
END
PPrompt = '2H'
pmess = '12H'
pmess2 = '12H'
pturn = '64H'
down.1 = '7H'
down.2 = '7H'
down.3 = '57H'
down.4 = '57H'
stline = 5
do aa = c2d('A') to c2d('J')
al = d2c(aa)
stpos = 28
stline = stline + 1
do bb = 1 to 10
stpos = stpos + 2
p.al.bb = ''stline';'stpos'H'
end
end
/* Open the support library if it is not already open. */
if ~show('L',"rexxsupport.library") then do
addlib('rexxsupport.library',0,-30,0)
end
wz = random(1,999,time('S')) /* initalize random number generator */
if ~exists(datapath) then makedir(datapath)
if ~exists(datapath'/winners') then do
call open(win,datapath'/winners','w')
top = 90
do 10
call writeln(win,''date()'... MATT_ENGLISH..... sank all the ships in 'top' shots!')
top = top + 1
end
call close(win)
end
say cr
say cr
say cr
say' 'bak7''pen0' Welcome to Ship Hunt ! 'def''cr
say' 'bak7''pen0' version 2.3 1-10-93 'def''cr
say' 'bak7''pen0' by Matt English 'def''cr
say cr
say cr
call delay(100)
call showwin
say cr
options prompt' Type "I" for instructions or hit return to play > '
pull input
if input ~= 'I' then call start
else call instructions
call start
showwin:
call open(win,datapath'/winners','r')
say' 'bak5''pen0'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'def''cr
say' 'bak5''pen0'% Top Ship Hunt Winners! %'def''cr
say' 'bak5''pen0'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'def''cr
say cr
say cr
do 10
line = readln(win)
call sac70''line''
end
call close(win)
say cr
call delay(200)
return
instructions:
say cr
say' This is a very simple game. The object is to sink the 5 ships'cr
say' that the computer has hidden on a 10 x 10 grid. If you can sink'cr
say' all the ships using less shots than a player on the WINNERS list,'cr
say' your name will be added to the winners list and you''ll be famous!'cr
say cr
say' The computer will generate a new grid for each game played, so you''ll'cr
say' never play the same game twice and no other player plays the same grid'cr
say' that you''re playing. The ships are:'cr
say' Carrier...... 5 spots'cr
say' Battleship... 4 spots'cr
say' Destroyer.... 3 spots'cr
say' Submarine.... 3 spots'cr
say' PT Boat...... 2 spots'cr
say cr
say' If you decide to quit in the middle of a game, your stats will be'cr
say' saved and you can pick up where you left off next time.'cr
say cr
call sac70'HAVE FUN!'
say cr
call pressreturn
return
START:
shipsdown = ''
if ~exists(datapath'/'name) then do
say'Stand by, setting up the game..'
call setupdata
end
if justsetup ~= 1 then do
say cr
options prompt' Would you like to continue your previous game? (Y,n) > '
pull answer
if answer = 'N' then do
say' OK,Setting up a new game..'cr
call setupdata
end
else do
say cr
say' OK, Loading your previous game...'cr
say cr
end
end
call loaddata
say cr
if justsetup ~= 1 then say' You last played this game on 'pen7''lastplay''def''cr
call delay(100)
say cr
say cr
say cr
call play
Play:
say cls
say' 'pen5' 'bak2'Ship Hunt'def''cr
say cr
say' 1 2 3 4 5 6 7 8 9 10'cr
say' ' cr
say' 'bak6''UNL'Ship Size'def' A 's.a.1' 's.a.2' 's.a.3' 's.a.4' 's.a.5' 's.a.6' 's.a.7' 's.a.8' 's.a.9' 's.a.10' 'bak4''UNL'Ships Sunk'def''cr
say' 'bak6' 'def' B 's.B.1' 's.B.2' 's.B.3' 's.B.4' 's.b.5' 's.b.6' 's.b.7' 's.b.8' 's.b.9' 's.b.10''cr
say' 'bak6'Carrier 5 'def' C 's.c.1' 's.c.2' 's.c.3' 's.c.4' 's.c.5' 's.c.6' 's.c.7' 's.c.8' 's.c.9' 's.c.10''cr
say' 'bak6'Battleship 4 'def' D 's.d.1' 's.d.2' 's.d.3' 's.d.4' 's.d.5' 's.d.6' 's.d.7' 's.d.8' 's.d.9' 's.d.10''cr
say' 'bak6'Destroyer 3 'def' E 's.e.1' 's.e.2' 's.e.3' 's.e.4' 's.e.5' 's.e.6' 's.e.7' 's.e.8' 's.e.9' 's.e.10''cr
say' 'bak6'Submarine 3 'def' F 's.f.1' 's.f.2' 's.f.3' 's.f.4' 's.f.5' 's.f.6' 's.f.7' 's.f.8' 's.f.9' 's.f.10''cr
say' 'bak6'PT Boat 2 'def' G 's.g.1' 's.g.2' 's.g.3' 's.g.4' 's.g.5' 's.g.6' 's.g.7' 's.g.8' 's.g.9' 's.g.10''cr
say' H 's.h.1' 's.h.2' 's.h.3' 's.h.4' 's.h.5' 's.h.6' 's.h.7' 's.h.8' 's.h.9' 's.h.10''cr
say' I 's.i.1' 's.i.2' 's.i.3' 's.i.4' 's.i.5' 's.i.6' 's.i.7' 's.i.8' 's.i.9' 's.i.10' 'pen3'"Q" = Quit'def''cr
say' J 's.j.1' 's.j.2' 's.j.3' 's.j.4' 's.j.5' 's.j.6' 's.j.7' 's.j.8' 's.j.9' 's.j.10' Turn # 'cr
say cr
say cr
call clrl2
call pullshotl
clrl:
arg where
call writech('STDOUT',''where' ')
return
clrl2:
call writech('STDOUT',''pmess''bak3' 'def'')
call writech('STDOUT',''pmess2''bak3' 'def'')
return
pullshotl:
if shipsdown ~= '' then do sd = 1 to words(shipsdown)
say''down.sd''word(shipsdown,sd)''
end
turns = turns + 1
say''pturn''turns''
options prompt''PPrompt'Enter your shot, Captain 'name' > '
pull theshot
CALL checkBBS()
call clrl pprompt
call clrl2
theshot = strip(theshot)
if theshot = 'Q' then call quit
shotl = substr(theshot,1,1)
shotn = strip(substr(theshot,2,2))
if length(theshot) > 3 | if theshot = '' | ~(instring(shotl,letters)) | ~datatype(shotn,'W') | shotn > 10 | shotn < 1 then do
say''pmess' 'bak3' Please enter your shot in letter/number format'def''cr
say''pmess2' 'bak3' Examples: A3 B10 C4 'def''cr
turns = turns - 1
call pullshotl
end
call checkshot
Quit:
turns = turns - 1
say cr
say''pmess''bak3' OK, Saving your stats for next time....'def''cr
call delay(50)
if exists(datapath'/'name) then call delete(datapath'/'name)
call open(stat,datapath'/'name,'w')
call writeln(stat,pos.c)
call writeln(stat,pos.b)
call writeln(stat,pos.d)
call writeln(stat,pos.s)
call writeln(stat,pos.p)
call writeln(stat,damage.c)
call writeln(stat,damage.b)
call writeln(stat,damage.d)
call writeln(stat,damage.s)
call writeln(stat,damage.p)
call writeln(stat,shipssunk)
call writeln(stat,hits)
call writeln(stat,misses)
call writeln(stat,lastplay)
call writeln(stat,turns)
call close(stat)
say cr
call showwin
say cr
say' 'pen2'Returning to the BBS...'def''
say cr
call delay(25)
exit
checkBBS:
IF ADDRESS()~='BAUD' THEN RETURN 0
IF TIME('E')>secs THEN SIGNAL Quit
dcd
IF RC=0 THEN SIGNAL Quit
temp=secs-TIME('E')
IF temp<120 THEN SAY '*** Only' temp 'seconds left! ***'CR
RETURN 0
showshot:
gg = 0