home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / amigalibdisks / disk950 / bbdoors / bbdoors65.lha / rexxDoors / StarTrek.rexx < prev    next >
OS/2 REXX Batch file  |  1993-08-24  |  36KB  |  1,462 lines

  1. /*  STAR TREK - THE FINAL FRONTIER  - Online BBS Game
  2.     Written By Steve Berry
  3.     Rev A - 4/24/87 IBM 370
  4.     Rev B - 5/21/88
  5.          modified to run on Amiga                          
  6.     Rev C - 10/23/91
  7.          modified to run from CLI or BBBBS
  8.          also updated enemy from Klingons to Romulans
  9.     Mods for Atredes by Bob Hassel and Michael Cox
  10.     ANSI version & other enhancements by Michael Cox
  11.     BBBBS mods by Richard Lee Stockton
  12.     3 bugs fixed August 24,1993 by Charles Johnston
  13.     (1) Saved games would not survive a reload - FIXED
  14.     (2) After torpedos were used up one could continue firing them - FIXED
  15.     (3) After phasers were used up one could continue firing them -FIXED
  16. */
  17.  
  18. CALL TIME('R')
  19. SIGNAL ON BREAK_C
  20. bbspath=GETCLIP('BBS_path')
  21. PARSE ARG UName . . . secs .
  22. IF secs='' THEN secs=3600
  23. gamepath=''
  24. IF UName~='' & bbspath~='' THEN gamepath=bbspath'rexxDoors/Data/'
  25. maxtime=5000
  26. justcleared='true'
  27. highest=0
  28. highname=0
  29. HOM='H'
  30. RESET=''
  31. POS='0H'
  32. CLS='H'
  33. CLR=''
  34. CLL=''
  35. WHITEONBLUE=''
  36. REDONBLUE=''
  37. YELLOWONBLUE=''
  38. CYANONBLACK=''
  39. YELLOWONBLACK=''
  40. MAGENTAONBLACK=''
  41. BLUEONBLACK=''
  42. REDONYELLOW=''
  43. WHITE=''
  44. RED=''
  45. YELLOW=''
  46. BLACK=''
  47. GREEN=''
  48. CYAN=''
  49. MAGENTA=''
  50. BLUE=''
  51. IF ADDRESS()~='BAUD' THEN
  52.   DO
  53.     BLUE=GREEN
  54.     WHITEONBLUE=''
  55.     REDONBLUE=''
  56.     YELLOWONBLUE=''
  57.   END
  58. call time 'R'           /* reset timer */
  59. do i=1 to 10
  60.  highscore.i=0
  61.  highname.i=' '
  62. end
  63. stardate=time('E')
  64. junk=randu(time('S'))
  65. blanks='                                 '
  66.  
  67. call old_highest
  68. CALL mess CLS
  69. CALL mess BLUE||'                           Welcome to STARTREK!'
  70. CALL mess
  71. CALL mess YELLOW||'                             TOP TEN PLAYERS'
  72. CALL mess WHITE
  73. do i=1 to 10
  74.    if highscore.i=0 then iterate
  75.    CALL mess substr(blanks,1,20) highname.i substr(blanks,1,30-length(highname.i)) RIGHT(highscore.i,6)
  76. end
  77.  
  78. CALL mess CYAN
  79. CALL mess '         (You need an ANSI-compatible terminal to play this game.)'
  80. CALL mess 
  81. OPTIONS PROMPT '               Do you need instructions (y/N)? '
  82. PULL res
  83.  if res='Y' then
  84.    call instructions
  85.   else
  86.   do                             /* Anyone ever heard of BRACKETS? */
  87.    CALL mess
  88.    CALL mess 'You can get the instructions at any time by entering the word HELP.'
  89.    OPTIONS PROMPT 'Hit [RETURN] to continue: '
  90.    PULL res
  91.   end
  92. CALL mess CLS
  93. CALL mess 
  94. CALL mess
  95. OPTIONS PROMPT 'Load and play an old game (y/N)? '
  96. PULL fn
  97. CALL mess CLS
  98.  
  99. mission=1
  100.  
  101. /* Are we playing an OLD Game? */
  102.  
  103. if fn='Y' then
  104.     call load_old_game fn
  105. else
  106.  
  107. newmission:
  108.  CALL mess 'Please stand by... universe under construction'
  109.  select
  110.   when mission=1 then call init_variables_1
  111.   when mission=2 then call init_variables_2
  112.   when mission=3 then call init_variables_3
  113.   when mission=4 then call init_variables_4
  114.   when mission=5 then call init_variables_5
  115.   when mission=6 then call init_variables_6
  116.   when mission=7 then call init_variables_7
  117.   when mission=8 then call init_variables_8
  118.   when mission=9 then call init_variables_9
  119.   when mission=10 then call init_variables_10
  120. /*  otherwise */
  121.  end
  122.  
  123.  
  124. /* ********** */
  125. /* Main do loop */
  126. /* ************ */
  127.  
  128. main: /* added this function name so 'load_old_game:' could signal to it*/
  129.  
  130. starttime=stardate
  131. CALL mess CLS
  132. do until energy=0
  133. CALL checkBBS()
  134. CALL mess HOM
  135.  call print_quadrent x,y,ex,ey
  136.  t0=time('R')
  137.  
  138. /* get user input and parse the commands */
  139.  if stardate - starttime > maxtime then call toolong
  140.  OPTIONS PROMPT 'Your command, Captain? '
  141.  PULL instring
  142.  rc=parse_command(instring)
  143.  
  144. /* process the commands */
  145.  
  146.   if rc=0 then do
  147.     do loop=1 to 3
  148.      if arg1.loop='' then leave
  149.      call process_command arg1.loop,arg2.loop
  150.      if alive='no' | energy <= 0 then leave
  151.     end
  152.    end
  153.   else CALL mess "Command not understood. Enter HELP for reminder."
  154.  
  155. /* Check for illegal input */
  156.  
  157.   if missstat='completed' then do
  158.     CALL mess CLS
  159.     CALL mess
  160.     CALL mess ' CONGRATULATIONS !!! You have completed the mission!'
  161.     CALL mess
  162.      exit 0
  163.     end
  164.  
  165. /* Did player kill himself? */
  166.  
  167.  If alive='no' | energy <= 0 then do
  168.    CALL mess CLS
  169.    CALL mess
  170.    CALL mess
  171.    CALL mess
  172.    CALL mess
  173.    CALL mess ' Suicide is not in the BEST interests of the FEDERATION.'
  174.    CALL mess
  175.    CALL mess ' But you did get 'points' points.'
  176.    CALL mess
  177.    CALL mess
  178.    CALL mess
  179.    CALL mess 'Game over.'
  180.    CALL mess
  181.    CALL mess
  182.    exit
  183.   end
  184.  
  185. /* Time for a little wear and tear on the enterprize */
  186.  
  187.  call wear_and_tear
  188.  
  189. /* Is the Enterprize DEAD in Space? */
  190.  
  191.  If alive='no' then do
  192.    CALL mess CLS
  193.    CALL mess
  194.    CALL mess
  195.    CALL mess
  196.    CALL mess
  197.    CALL mess ' Sorry but you let the Enterprise deteriorate into '
  198.    CALL mess ' into a rusting hunk of space debris.'
  199.    CALL mess
  200.    CALL mess ' But you did get 'points' points.'
  201.    CALL mess
  202.    CALL mess
  203.    CALL mess
  204.    CALL mess 'Game over.'
  205.    CALL mess
  206.    CALL mess
  207.    exit
  208.   end
  209.  
  210. /* Ok. now it's the Bad guy's turn */
  211.  
  212. /* now call mission specific routine */
  213. /* for bad guy routine and points awarded */
  214.  
  215.  select
  216.   when mission=1 then call mission1
  217.   when mission=2 then call mission2
  218.   when mission=3 then call mission3
  219.   when mission=4 then call mission4
  220.   when mission=5 then call mission5
  221.   when mission=6 then call mission6
  222.   when mission=7 then call mission7
  223.   when mission=8 then call mission8
  224.   when mission=9 then call mission9
  225.   when mission=10 then call mission10
  226.  end
  227.  
  228. /* Is the Enterprize KILLED? KRUSHED? DESTROYED? */
  229.  
  230.  If alive='no' then do
  231.    CALL mess
  232.    CALL mess
  233.    CALL mess
  234.    CALL mess
  235.    CALL mess ' Sorry but you let your crew and the Federation down.'
  236.    CALL mess ' Perhaps you should consider another career.'
  237.    CALL mess
  238.    CALL mess ' But you did get 'points' points.'
  239.    CALL mess
  240.    CALL mess
  241.    CALL mess
  242.    CALL mess 'Game over.'
  243.    CALL mess
  244.    CALL mess
  245.    exit
  246.   end
  247.  
  248. /* end of the loop - now go print the screen */
  249. end
  250.  
  251.  
  252. /* ********************************************** */
  253. /* ********************************************** */
  254. /*          SUBROUTINE SECTION                    */
  255. /* ********************************************** */
  256. /* ********************************************** */
  257.  
  258.  
  259.  
  260. /* ********************************************** */
  261. /* ********************************************** */
  262. /*          SUBROUTINE LOAD_OLD_GAME              */
  263. /*  PASSED VALUES - fn                            */
  264. /* ********************************************** */
  265. /* ********************************************** */
  266.  
  267. load_old_game:
  268.  
  269.  
  270. bstr='   |o| * <->(B))\_ # '
  271. missstat='not yet'
  272. CALL mess 'Loading your previously saved game...'
  273. /* get variables */
  274.  if ~Open(fnn,gamepath||UName,'R') then
  275.  
  276. do
  277. CALL mess "Can't find a saved game for you! Exiting STARTREK."
  278. exit
  279. end
  280.  inn=Readln(fnn)
  281.  parse var inn stardate mission energy points x y ex ey shields klshields docked kltot
  282.  inn=Readln(fnn)
  283.  parse var inn status.0 status.1 status.2 status.3 status.4 status.5
  284.  
  285. /* start interval timer */
  286.  
  287. stardate=stardate + time('E')
  288.  
  289. /* Load galactic map */
  290.  
  291.  do l=0 to 9
  292.   inn1=Readln(fnn)
  293.   parse var inn1 map.l.0 map.l.1 map.l.2 map.l.3 map.l.4 map.l.5 map.l.6 map.l.7 map.l.8 map.l.9
  294.   
  295.  end
  296.  
  297.  do l=0 to 9
  298.   inn1=Readln(fnn)
  299.   parse var inn1 quad.l.0 quad.l.1 quad.l.2 quad.l.3 quad.l.4 quad.l.5 quad.l.6 quad.l.7 quad.l.8 quad.l.9
  300.  end
  301. alive='yes'
  302. junk=Close(fnn)
  303. signal main /* bug fix so old game is loaded properly and not overwritten as fresh game*/
  304. return
  305.  
  306. /* ********************************************** */
  307. /* ********************************************** */
  308. /*          SUBROUTINE INIT_VARIABLES_1           */
  309. /*  PASSED VALUES - none                          */
  310. /* ********************************************** */
  311. /* ********************************************** */
  312.  
  313. init_variables_1:
  314.  
  315. bstr='   |o| * <->(B))\_ # '
  316. alive='yes'
  317. energy=1000000
  318. x=0
  319. y=0
  320. points=0
  321. mission=1
  322. shields='down'
  323. kltot=0
  324. missstat='not yet'
  325.  
  326. do a=0 to 9
  327.  do b=0 to 9
  328.    map.a.b=random(0,1) * 100 + random(0,1)*10 + random(0,9)
  329.    if map.a.b > 99 then kltot=kltot + 1
  330.  end
  331. end
  332.  
  333. klshields=5000
  334. status.0=0
  335. status.1=0
  336. status.2=0
  337. status.3=0
  338. status.4=0
  339. status.5=0
  340. ex=5
  341. ey=4
  342.  
  343.  
  344. newscreen:
  345. /* initialize quadr