home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume18 / xmpb / part06 < prev    next >
Encoding:
Internet Message Format  |  1993-07-11  |  57.1 KB

  1. Path: uunet!news.tek.com!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v18i006:  xmpb - multiplayer space combat for X, Part06/08
  5. Date: 26 Jun 1993 00:32:56 GMT
  6. Organization: Tektronix, Inc, Redmond, OR, USA
  7. Lines: 2826
  8. Approved: billr@saab.CNA.TEK.COM
  9. Message-ID: <20g5fo$6sp@ying.cna.tek.com>
  10. NNTP-Posting-Host: saab.cna.tek.com
  11. Xref: uunet comp.sources.games:1796
  12.  
  13. Submitted-by: ddp@deakin.edu.au (Damien De Paoli)
  14. Posting-number: Volume 18, Issue 6
  15. Archive-name: xmpb/Part06
  16. Environment: X11, Xlib
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 6 (of 8)."
  27. # Contents:  Imakefile average.npc basic.npc bitmaps/ship.0 bits.c
  28. #   damage_ship.c disp_ship.c lex.l ml.npc nasty.npc polygon.c
  29. #   rad1.npc shop.man
  30. # Wrapped by billr@saab on Fri Jun 25 16:30:15 1993
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'Imakefile'\"
  34. else
  35. echo shar: Extracting \"'Imakefile'\" \(3251 characters\)
  36. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  37. X#   @(#)Imakefile 1.29 93/06/03 XMPB  
  38. X#
  39. X
  40. X# Change these to change the installation targets
  41. X
  42. XBLASTDIR = /home/ddp/blast 
  43. X
  44. XNPCDIR = $(BLASTDIR)/npc
  45. XBINDIR = $(BLASTDIR)/bin
  46. XSAVEDIR = $(BLASTDIR)/save
  47. XBITMAPDIR = $(BLASTDIR)/bitmaps
  48. X
  49. XMANSUFFIX = 6
  50. XMANDIR = $(BLASTDIR)/man/man$(MANSUFFIX)
  51. X
  52. XEXTRA_LOAD_FLAGS =
  53. XINSTALLMODS = 4755
  54. XYACC = yacc
  55. XLEX = lex
  56. X
  57. XINSTPGMFLAGS = -m $(INSTALLMODS) -o bin -g bin
  58. X
  59. X# If you have a NCD or HP, then remove the # on the next line 
  60. X# NCDFLAG = -DNCD 
  61. X
  62. X# Adjust if default is unsuitable
  63. XCC = cc 
  64. X# Adjust for debugging or optimization relative to the default
  65. XCDEBUGFLAGS = -DBITMAPDIR="\"$(BITMAPDIR)/\"" -DSAVEDIR="\"$(SAVEDIR)/\"" -DNPCDIR="\"$(NPCDIR)/\"" $(NCDFLAG) -O2 
  66. X
  67. X# Adjust if necessary
  68. XMATHLIB = -lm
  69. XMKDIRHIER = /usr/X11/bin/mkdirhier
  70. X
  71. X
  72. X###############################
  73. X# Nothing to change below here
  74. X
  75. XSRCS = xoutput.c read_ship.c test.c disp_ship.c handle_ev.c add_host.c \
  76. X    update_win.c thrust.c ud_win.c do_stars.c radar.c stats.c weapon.c \
  77. X    error.c polygon.c damage_ship.c update_ships.c junk.c input.c \
  78. X    sintab.c costab.c calc_shields.c pcomp.c collide.c 
  79. XOBJS = xoutput.o read_ship.o test.o disp_ship.o handle_ev.o add_host.o \
  80. X    update_win.o thrust.o ud_win.o do_stars.o radar.o stats.o weapon.o \
  81. X    error.o polygon.o damage_ship.o update_ships.o junk.o input.o \
  82. X    sintab.o costab.o calc_shields.o pcomp.o collide.o 
  83. X
  84. XBMAPS = bitmaps/bigrock bitmaps/bomb bitmaps/cloud.1 bitmaps/cloud.2 \
  85. X    bitmaps/cloud.3 bitmaps/cloud.4 bitmaps/cloud.5 bitmaps/cloud.6 \
  86. X    bitmaps/debris.1 bitmaps/debris.2 bitmaps/debris.3 bitmaps/massdrive \
  87. X    bitmaps/medrock bitmaps/mine bitmaps/pulse bitmaps/rail \
  88. X    bitmaps/saturn1 bitmaps/seeker bitmaps/shortdeaddude bitmaps/smallrock \
  89. X    bitmaps/star1 bitmaps/star2 bitmaps/stipple bitmaps/atom bitmaps/hvypulse \
  90. X    bitmaps/magneto bitmaps/dunno bitmaps/dunno2
  91. X
  92. XNPCS = ml ml2  beam harry basic average nasty john rad1 rad2 rad3
  93. X
  94. XLOCAL_LIBRARIES = $(XLIB) $(MATHLIB)
  95. X
  96. X/* AllTarget(install install.man) */
  97. XAllTarget(xmpb shop npcc retire describe clear_lock)
  98. XComplexProgramTarget(xmpb) 
  99. XSingleProgramTarget(retire,retire.o save_load.o,,)
  100. XSingleProgramTarget(describe,describe.o save_load.o,,)
  101. XSingleProgramTarget(npcc,lex.yy.o y.tab.o,,-ll)
  102. XSingleProgramTarget(clear_lock,clear_lock.c save_load.o,,)
  103. XSingleProgramTarget(shop,shop_ui.o shop_stubs.o save_load.o,-L$(OPENWINHOME)/lib,-lxview -lolgx -lX11)
  104. XInstallProgram(shop,$(BINDIR))
  105. XInstallProgram(retire,$(BINDIR))
  106. XInstallProgram(describe,$(BINDIR))
  107. XInstallProgram(npcc,$(BINDIR))
  108. XInstallManPage(retire,$(MANDIR))
  109. XInstallManPage(describe,$(MANDIR))
  110. XInstallManPage(shop,$(MANDIR))
  111. X/* InstallManPage(xmpb,$(MANDIR)) */
  112. XInstallManPage(npcc,$(MANDIR))
  113. XMakeDirectories(install,$(SAVEDIR) $(NPCDIR))
  114. XInstallMultipleDestFlags(install,$(BMAPS),$(BITMAPDIR),-m 0644)
  115. X#
  116. X#
  117. X#    Rules for stuff imake doesn't know
  118. X#
  119. X
  120. Xlex.yy.o: lex.yy.c y.tab.c
  121. Xlex.yy.c: lex.l
  122. X    $(LEX) lex.l
  123. Xy.tab.c: parse.y
  124. X    $(YACC) -d parse.y
  125. Xclean::
  126. X    $(RM) lex.yy.c y.tab.c y.tab.h
  127. X
  128. Xnpcs::
  129. X    npcc $(NPCS)
  130. X
  131. Xinstall:: install.man
  132. X    cp shop.contents $(BITMAPDIR)
  133. X    chmod 644 $(BITMAPDIR)/shop.contents
  134. X    chmod 755 $(BLASTDIR)
  135. X    chmod 755 $(BINDIR) 
  136. X    chmod 755 $(MANDIR)
  137. X    chmod 755 $(MANDIR)/..
  138. X    chmod 755 $(SAVEDIR)
  139. X    chmod 755 $(NPCDIR)
  140. X    chmod 700 $(BITMAPDIR)
  141. X
  142. Xinstall:: 
  143. X    npcc $(NPCS)
  144. END_OF_FILE
  145. if test 3251 -ne `wc -c <'Imakefile'`; then
  146.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  147. fi
  148. # end of 'Imakefile'
  149. fi
  150. if test -f 'average.npc' -a "${1}" != "-c" ; then 
  151.   echo shar: Will not clobber existing file \"'average.npc'\"
  152. else
  153. echo shar: Extracting \"'average.npc'\" \(4765 characters\)
  154. sed "s/^X//" >'average.npc' <<'END_OF_FILE'
  155. XNPC
  156. XName = Average
  157. XShip = Dull
  158. XEnergyMax = 1100
  159. XLShieldMax = 700
  160. XRShieldMax = 700
  161. XBShieldMax = 600
  162. XSolar = 4
  163. XShortRange = 2
  164. XEngine = 4
  165. XRepair = 6
  166. XLongRange = 2
  167. XJammer = 2
  168. XTC = 3
  169. X
  170. XWeapons
  171. XPulse
  172. XHPulse
  173. XSeek
  174. X
  175. Xvar
  176. Xend
  177. X
  178. XState avoid
  179. X{
  180. Xvar
  181. X    count
  182. X    tmp
  183. X    lastDist
  184. Xend
  185. X
  186. X    lastDist=EnemyDist;
  187. X    set B1 =0;
  188. X    if(SolarState < 100)
  189. X        set RepairSelectedItem=Solar;
  190. X    else
  191. X    if(EngineState < 100)
  192. X        set RepairSelectedItem=Engine;
  193. X    else
  194. X        set RepairToggle = 1;
  195. X    count = 15;
  196. X    while(count)
  197. X    {
  198. X        tmp = EnemyDist;
  199. X        if(tmp && tmp >= lastDist) -> loop;
  200. X        if(!tmp)
  201. X        {
  202. X            slow();
  203. X            -> loop;
  204. X        }
  205. X        set B3 =1;
  206. X        if(EnemyAngle > 0 && EnemyAngle < 180)
  207. X            set TurnTo=(EnemyAngle+ 90)%360;
  208. X        else
  209. X            set TurnTo=(EnemyAngle- 90)%360;
  210. X        wall_check();
  211. X        count = count - 1;
  212. X    }
  213. X    slow();
  214. X    -> loop;
  215. X}
  216. X
  217. XProc wall_check
  218. X{
  219. Xvar
  220. X    r
  221. X    l
  222. X    u
  223. X    d
  224. Xend
  225. X
  226. X    r = 0;
  227. X    l = 0;
  228. X    u = 0;
  229. X    d = 0;
  230. X
  231. X    if (XPos*XVel > 45000 && XVel > 0) r = 1;
  232. X    if (XPos*XVel > 45000 && XVel < 0) l = 1;
  233. X    if (YPos*YVel > 45000 && YVel > 0) u = 1;
  234. X    if (YPos*YVel > 45000 && YVel < 0) d = 1;
  235. X
  236. X    if (r || l || u || d) slow();
  237. X    return;
  238. X}
  239. X
  240. XProc att_check
  241. X{
  242. Xvar
  243. X    num
  244. Xend
  245. X
  246. X    num=NumEnemies;
  247. X    set Target = 1;
  248. X    set SelectEnemy = 0;
  249. X    set Target= 1;
  250. X    set RepairToggle = 1;
  251. X    set Balance = 1;
  252. X    wall_check();
  253. X
  254. X    if(! EnemyAvail)
  255. X    {
  256. X        set B1 = 0;
  257. X        set B3 = 0;
  258. X        return;
  259. X    }
  260. X
  261. X    if(Energy < 200 && LShield > 400 && EnemyDist < 600)
  262. X    {
  263. X        set Grab =1;
  264. X        set RepairToggle =1;
  265. X    }
  266. X
  267. X    if(Speed > 40) slow();
  268. X    
  269. X    return;
  270. X}
  271. X
  272. XProc attack
  273. X{
  274. Xvar
  275. X    a1
  276. X    a2
  277. X    m
  278. X    a
  279. X    p
  280. X    cnt
  281. X    count
  282. Xend
  283. X
  284. X    
  285. X    a2 = EnemyAngle;
  286. X    set B2 =1;
  287. X    count = 10;
  288. X    while(EnemyDist < 1000)
  289. X    {
  290. X
  291. X        a1 = a2;
  292. X        a2 = EnemyAngle;
  293. X    
  294. X        m = EnemyDist/50 - 1;    
  295. X        if(EnemyDist > 500)
  296. X        {
  297. X             a = AngleTo(EnemyXPos+m*EnemyXVel - m*XVel,EnemyYPos+m*EnemyYVel - m*YVel);
  298. X            p = (Angle - a + 360)%360;
  299. X            if(p < 170 || p > 190)
  300. X                set TurnTo = a;
  301. X        }
  302. X        else
  303. X            set TurnTo = (EnemyAngle + (a2 - a1)*(EnemyDist/175)) % 360;
  304. X
  305. X
  306. X        m = 93 - (EnemyDist)/12;
  307. X        if((EnemyDist < 900) && Angle <= (EnemyAngle+ m) && Angle >= (EnemyAngle - m))
  308. X            set B1 = 1; 
  309. X        else
  310. X            set B1 = 0;
  311. X
  312. X        set Balance = 1;
  313. X        if(RepairItem != LongRange)
  314. X            set RepairToggle = 1;
  315. X        if(Direction - Angle > 90 || Direction - Angle < 90 && Energy > 200)
  316. X        {
  317. X            set B3 = 1;
  318. X            cnt = 3;
  319. X            while(cnt>0)
  320. X                cnt=cnt- 1;
  321. X            set B3 = 0;
  322. X        }
  323. X        count = count - 1;
  324. X        if (!count)
  325. X        {
  326. X            att_check();
  327. X            if(LongState < 50) return;
  328. X            count = 10;
  329. X        }        
  330. X    }
  331. X    set B1 = 0;
  332. X    set B3 = 0;
  333. X    return;
  334. X}
  335. X
  336. XState repair
  337. X{
  338. Xvar
  339. X    tmp
  340. Xend
  341. X
  342. X    set Jamming =1;
  343. X    if(LongState < 100 && LongState > 0)
  344. X        set RepairSelectedItem = LongRange;
  345. X    else
  346. X    if(EngineState < 100 && EngineState > 0 )
  347. X        set RepairSelectedItem = Engine;
  348. X    else
  349. X    if(SolarState < 100 && SolarState > 0)
  350. X        set RepairSelectedItem = Solar;
  351. X    else
  352. X    if(RepairState < 100 && RepairState > 0)
  353. X        set RepairSelectedItem = Repair;
  354. X    else
  355. X    if(ShortState < 100 && ShortState >0)
  356. X        set RepairSelectedItem = ShortRange;
  357. X    else
  358. X        set RepairToggle = 1;
  359. X    tmp = EnemyDist;
  360. X    if(tmp && tmp < 1000) 
  361. X        -> avoid;
  362. X    if(EngineState > 30 && Speed > 10) slow();
  363. X    if(LongState > 80 && EngineState > 60) -> loop;
  364. X    if(!LongState)
  365. X        set Quit =1;
  366. X    set Balance = 1;
  367. X    aim();
  368. X}
  369. X
  370. XProc aim
  371. X{
  372. Xvar
  373. X    aa1
  374. X    aa2
  375. X    num
  376. Xend
  377. X    num = NumEnemies;
  378. X    set Target = 1;
  379. X    set SelectEnemy = 0;
  380. X    set Target= 1;
  381. X
  382. X    aa1 = aa2;
  383. X    aa2 = EnemyAngle;
  384. X    if(aa2 == -1)
  385. X        aa2 = aa1;
  386. X    else
  387. X        set TurnTo = (EnemyAngle + (aa2 - aa1) * 4) % 360;
  388. X
  389. X    if(EnemyDist < 1000 && EnemyDist > 0) attack();
  390. X    return;
  391. X}
  392. X
  393. XProc slow
  394. X{
  395. Xvar
  396. X    oldbs
  397. Xend
  398. X
  399. X    set B1 = 0;
  400. X    set TurnTo = (Direction + 180) % 360;
  401. X    set B3 =1;
  402. X    oldbs= BShield;
  403. X    while(Speed > 5 && BShield >= oldbs)
  404. X    {
  405. X        set TurnTo = (Direction + 180) % 360;
  406. X        if(EnemyDist < 500 && EnemyDist)
  407. X        {
  408. X            attack();
  409. X            return;
  410. X        }
  411. X    }
  412. X    set B3 =0;
  413. X    return;
  414. X}
  415. X
  416. XProc wait
  417. X{
  418. Xvar w
  419. Xend
  420. X
  421. X    set B3 =0;
  422. X    w = 5;
  423. X    while (w)
  424. X    {
  425. X        aim();
  426. X        if ((Direction < (Angle + 10)) && (Direction > (Angle - 10)))
  427. X            return;
  428. X        w = w - 1;
  429. X    }
  430. X    set B3 =1;
  431. X
  432. X    return;
  433. X}
  434. X
  435. XProc seek
  436. X{
  437. Xvar 
  438. X    tmp
  439. Xend
  440. X
  441. X    if(!NumEnemies) 
  442. X        return 0;    
  443. X    set SelectEnemy = 0;
  444. X    set Target= 1;
  445. X
  446. X    aim();
  447. X    if(EnemyDist < 2000)
  448. X    {
  449. X        while(CurrWeap != Seek)
  450. X            set B2 =1;
  451. X        set B2 =0;
  452. X        set B1=1;
  453. X        set Target = 1;
  454. X    }
  455. X    else
  456. X        set B1 =0;
  457. X    tmp = EnemyDist;
  458. X    if(EnemySpeed > 30 && tmp > 800 && tmp && tmp) return 1;
  459. X
  460. X    if(EnemyDist < 1000 && EnemyDist) attack();
  461. X    if(Energy < 200 || LongState < 70) 
  462. X    {
  463. X        set B3 =0;
  464. X        return 0;
  465. X    } 
  466. X    else set B3 =1;
  467. X    if (Speed > 20 && (Direction < (Angle + 10)) && (Direction > (Angle - 10))) wait();
  468. X    if (Speed > 30)
  469. X        set B3 =0;
  470. X    return 0;
  471. X}
  472. X
  473. XState loop
  474. X{
  475. X    if(seek())
  476. X        1 -> avoid;
  477. X    if(RepairItem == Idle)
  478. X        set RepairToggle = 1;
  479. X    set Balance= 1;
  480. X
  481. X    if(LongState == -1)
  482. X        set RadarChange = 1;
  483. X
  484. X    if (Speed > 30 && EnemyDist < 2000)  slow();
  485. X    if(!LongState)
  486. X        set Quit =1;
  487. X    if (LongState < 50) 
  488. X    {
  489. X        slow();
  490. X        1 -> repair;
  491. X    }
  492. X}
  493. X
  494. XState main
  495. X{
  496. X    set B2 = 1;
  497. X    set B3 = 1; 
  498. X    -> loop;
  499. X}
  500. X
  501. XStart main
  502. END_OF_FILE
  503. if test 4765 -ne `wc -c <'average.npc'`; then
  504.     echo shar: \"'average.npc'\" unpacked with wrong size!
  505. fi
  506. # end of 'average.npc'
  507. fi
  508. if test -f 'basic.npc' -a "${1}" != "-c" ; then 
  509.   echo shar: Will not clobber existing file \"'basic.npc'\"
  510. else
  511. echo shar: Extracting \"'basic.npc'\" \(4611 characters\)
  512. sed "s/^X//" >'basic.npc' <<'END_OF_FILE'
  513. XNPC
  514. XName = Basic
  515. XShip = Standard
  516. XEnergyMax = 1000
  517. XLShieldMax = 600
  518. XRShieldMax = 600
  519. XBShieldMax = 400
  520. XSolar = 2
  521. XShortRange = 1
  522. XEngine = 3
  523. XRepair = 2
  524. XLongRange = 1
  525. XJammer = none
  526. XTC = none
  527. X
  528. XWeapons
  529. XPulse
  530. X
  531. Xvar
  532. Xend
  533. X
  534. XState avoid
  535. X{
  536. Xvar
  537. X    count
  538. X    tmp
  539. X    lastDist
  540. Xend
  541. X
  542. XEntry
  543. X{
  544. X    lastDist=EnemyDist;
  545. X    set B1 =0;
  546. X    if(SolarState < 100 && SolarState >0)
  547. X        set RepairSelectedItem=Solar;
  548. X    else
  549. X    if(EngineState < 100 && EngineState >0)
  550. X        set RepairSelectedItem=Engine;
  551. X    else
  552. X        set RepairToggle = 1;
  553. X    count = 15;
  554. X    WaitFrame;
  555. X}
  556. X    if(count)
  557. X    {
  558. X        tmp = EnemyDist;
  559. X        if(tmp && tmp >= lastDist) -> loop;
  560. X        if(!tmp)
  561. X        {
  562. X            slow();
  563. X            -> loop;
  564. X        }
  565. X        set B3 =1;
  566. X        if(EnemyAngle > 0 && EnemyAngle < 180)
  567. X            set TurnTo=(EnemyAngle+ 90)%360;
  568. X        else
  569. X            set TurnTo=(EnemyAngle- 90)%360;
  570. X        wall_check();
  571. X        count = count - 1;
  572. X    }
  573. X    else
  574. X    {
  575. X        slow();
  576. X        -> loop;
  577. X    }
  578. X}
  579. X
  580. XProc wall_check
  581. X{
  582. X    if (XPos*XVel > 45000) return 1;
  583. X    if (YPos*YVel > 45000) return 1;
  584. X    return 0;
  585. X}
  586. X
  587. XProc att_check
  588. X{
  589. X
  590. X    NumEnemies;
  591. X    set SelectEnemy = 0;
  592. X    set RepairToggle = 1;
  593. X    set Balance = 1;
  594. X    wall_check();
  595. X
  596. X    if(! EnemyAvail)
  597. X    {
  598. X        set B1 = 0;
  599. X        set B3 = 0;
  600. X        return;
  601. X    }
  602. X
  603. X    if(Energy < 200 && LShield > 400 && EnemyDist < 600)
  604. X    {
  605. X        set Grab =1;
  606. X        set RepairToggle =1;
  607. X    }
  608. X
  609. X    if(Speed > 40) slow();
  610. X    
  611. X    return;
  612. X}
  613. X
  614. XProc attack
  615. X{
  616. Xvar
  617. X    a1
  618. X    a2
  619. X    m
  620. X    a
  621. X    p
  622. X    cnt
  623. X    count
  624. Xend
  625. X
  626. X    
  627. X    a2 = EnemyAngle;
  628. X    count = 10;
  629. X    while(EnemyDist < 1000)
  630. X    {
  631. X
  632. X        a1 = a2;
  633. X        a2 = EnemyAngle;
  634. X    
  635. X        m = EnemyDist/(50+VelAtAngle(Angle)) - 1;    
  636. X        if(EnemyDist > 500)
  637. X        {
  638. X             a = AngleTo(EnemyXPos+m*EnemyXVel - m*XVel,EnemyYPos+m*EnemyYVel - m*YVel);
  639. X            p = (Angle - a + 360)%360;
  640. X            if(p < 170 || p > 190)
  641. X                set TurnTo = a;
  642. X        }
  643. X        else
  644. X            if(EnemyAngle > 300)
  645. X                set TurnTo = (EnemyAngle + (a2 - a1)*(EnemyDist/150)) % 360;
  646. X            else
  647. X                set TurnTo = (EnemyAngle + (a2 - a1)*(EnemyDist/120)) % 360;
  648. X
  649. X
  650. X        m = 40 - (EnemyDist)/30;
  651. X        if((EnemyDist < 900) && Angle <= (EnemyAngle+ m) && Angle >= (EnemyAngle - m))
  652. X            set B1 = 1; 
  653. X        else
  654. X            set B1 = 0;
  655. X
  656. X        set Balance = 1;
  657. X        if(RepairItem != LongRange)
  658. X            set RepairToggle = 1;
  659. X        if((Direction - Angle > 90 || Direction - Angle < 90) && Energy > 200)
  660. X        {
  661. X            set B3 = 1;
  662. X            cnt = 3;
  663. X            while(cnt>0)
  664. X                cnt=cnt- 1;
  665. X            set B3 = 0;
  666. X        }
  667. X        count = count - 1;
  668. X        if (!count)
  669. X        {
  670. X            att_check();
  671. X            if(LongState < 50) return;
  672. X            count = 10;
  673. X        }        
  674. X    }
  675. X    set B1 = 0;
  676. X    set B3 = 0;
  677. X    return;
  678. X}
  679. X
  680. XProc repair_which
  681. X{
  682. X    if(LongState < 100 && LongState > 0)
  683. X        set RepairSelectedItem = LongRange;
  684. X    else
  685. X    if(EngineState < 100 && EngineState > 0 )
  686. X        set RepairSelectedItem = Engine;
  687. X    else
  688. X    if(SolarState < 100 && SolarState > 0)
  689. X        set RepairSelectedItem = Solar;
  690. X    else
  691. X    if(RepairState < 100 && RepairState > 0)
  692. X        set RepairSelectedItem = Repair;
  693. X    else
  694. X    if(ShortState < 100 && ShortState >0)
  695. X        set RepairSelectedItem = ShortRange;
  696. X    else
  697. X        set RepairToggle = 1;
  698. X    return;
  699. X}
  700. X
  701. XState repair
  702. X{
  703. Xvar
  704. X    tmp
  705. Xend
  706. X
  707. X    if(!LongState && !ShortState && !CurrWeapState)
  708. X        set Quit = 1;
  709. X    repair_which();
  710. X    tmp = EnemyDist;
  711. X    if(tmp && tmp < 1000) -> avoid;
  712. X    if(EngineState > 30 && Speed > 10) slow();
  713. X    if(LongState > 80 && EngineState > 60) -> loop;
  714. X    set Balance = 1;
  715. X    aim();
  716. X}
  717. X
  718. XProc aim
  719. X{
  720. Xvar
  721. X    aa1
  722. X    aa2
  723. X    num
  724. Xend
  725. X    num = NumEnemies;
  726. X    set SelectEnemy = 0;
  727. X
  728. X    aa1 = aa2;
  729. X    aa2 = EnemyAngle;
  730. X    if(aa2 == -1)
  731. X        aa2 = aa1;
  732. X    else
  733. X        set TurnTo = (EnemyAngle + (aa2 - aa1) * 4) % 360;
  734. X
  735. X    if(EnemyDist < 1000 && EnemyDist > 0) attack();
  736. X    return;
  737. X}
  738. X
  739. XProc slow
  740. X{
  741. Xvar
  742. X    oldbs
  743. Xend
  744. X
  745. X    set B1 = 0;
  746. X    set TurnTo = (Direction + 180) % 360;
  747. X    set B3 =1;
  748. X    oldbs= BShield;
  749. X    while(Speed > 5 && BShield >= oldbs)
  750. X    {
  751. X        if(!LongState && !ShortState && !CurrWeapState)
  752. X            set Quit = 1;
  753. X        set TurnTo = (Direction + 180) % 360;
  754. X        if(EnemyDist < 500 && EnemyDist)
  755. X        {
  756. X            attack();
  757. X            return;
  758. X        }
  759. X    }
  760. X    set B3 =0;
  761. X    return;
  762. X}
  763. X
  764. XProc wait
  765. X{
  766. Xvar w
  767. Xend
  768. X
  769. X    set B3 =0;
  770. X    w = 5;
  771. X    while (w)
  772. X    {
  773. X        aim();
  774. X        if ((Direction < (Angle + 10)) && (Direction > (Angle - 10)))
  775. X            return;
  776. X        w = w - 1;
  777. X    }
  778. X    set B3 =1;
  779. X    return;
  780. X}
  781. X
  782. XProc seek
  783. X{
  784. Xvar 
  785. X    tmp
  786. Xend
  787. X
  788. X    if(!LongState && !ShortState && !CurrWeapState)
  789. X        set Quit = 1;
  790. X    if(!NumEnemies) 
  791. X        return 0;    
  792. X    set SelectEnemy = 0;
  793. X
  794. X    aim();
  795. X
  796. X    tmp = EnemyDist;
  797. X    if(EnemySpeed > 30 && tmp > 800 && tmp && tmp) return 1;
  798. X
  799. X    if(EnemyDist < 1000 && EnemyDist) attack();
  800. X    if(Energy < 200 || LongState < 70) 
  801. X    {
  802. X        set B3 =0;
  803. X        return 0;
  804. X    } 
  805. X    else set B3 =1;
  806. X    if (Speed > 6 && (Direction < (Angle + 10)) && (Direction > (Angle - 10))) wait();
  807. X    if (Speed > 15)
  808. X        set B3 =0;
  809. X    return 0;
  810. X}
  811. X
  812. XState loop
  813. X{
  814. X    if(seek())
  815. X        -> avoid;
  816. X    if(RepairItem == Idle)
  817. X        repair_which();
  818. X    set Balance= 1;
  819. X
  820. X    if (Speed > 30 && EnemyDist < 2000)  slow();
  821. X    if (LongState < 50) 
  822. X    {
  823. X        slow();
  824. X        -> repair;
  825. X    }
  826. X}
  827. X
  828. XState main
  829. X{
  830. X    set B2 = 1;
  831. X    -> loop;
  832. X}
  833. X
  834. XStart main
  835. END_OF_FILE
  836. if test 4611 -ne `wc -c <'basic.npc'`; then
  837.     echo shar: \"'basic.npc'\" unpacked with wrong size!
  838. fi
  839. # end of 'basic.npc'
  840. fi
  841. if test -f 'bitmaps/ship.0' -a "${1}" != "-c" ; then 
  842.   echo shar: Will not clobber existing file \"'bitmaps/ship.0'\"
  843. else
  844. echo shar: Extracting \"'bitmaps/ship.0'\" \(4127 characters\)
  845. sed "s/^X//" >'bitmaps/ship.0' <<'END_OF_FILE'
  846. X#define ship0_width 61
  847. X#define ship0_height 81
  848. Xstatic char ship0_bits[] = {
  849. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  850. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  851. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  852. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  853. X   0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
  854. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00,
  855. X   0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
  856. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
  857. X   0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  858. X   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00,
  859. X   0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
  860. X   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00,
  861. X   0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04,
  862. X   0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x08, 0x04, 0x00, 0x00,
  863. X   0x00, 0x00, 0x04, 0x02, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x42,
  864. X   0x08, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x11, 0x41, 0x10, 0x11, 0x00, 0x00,
  865. X   0x00, 0x00, 0x11, 0xa1, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0xa1,
  866. X   0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x91, 0xa0, 0x20, 0x11, 0x00, 0x00,
  867. X   0x00, 0x00, 0x91, 0x10, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x91, 0x10,
  868. X   0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x51, 0x10, 0x41, 0x11, 0x00, 0x00,
  869. X   0x00, 0x00, 0x51, 0x08, 0x42, 0x11, 0x00, 0x00, 0x00, 0x00, 0x51, 0x08,
  870. X   0x42, 0x11, 0x00, 0x00, 0x00, 0x00, 0x31, 0x08, 0x82, 0x11, 0x00, 0x00,
  871. X   0x00, 0x00, 0x31, 0x04, 0x84, 0x11, 0x00, 0x00, 0x00, 0x00, 0x31, 0xfc,
  872. X   0x87, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x11, 0x00, 0x00,
  873. X   0x00, 0x00, 0x11, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00,
  874. X   0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x12, 0x00, 0x00,
  875. X   0x00, 0x00, 0x09, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
  876. X   0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x14, 0x00, 0x00,
  877. X   0x00, 0x00, 0x05, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00,
  878. X   0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x18, 0x00, 0x00,
  879. X   0x00, 0x00, 0x03, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
  880. X   0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00,
  881. X   0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
  882. X   0x00, 0x10, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00,
  883. X   0x00, 0x8c, 0x00, 0x00, 0x00, 0x20, 0x06, 0x00, 0x00, 0x94, 0x00, 0x00,
  884. X   0x00, 0x20, 0x05, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0xc0, 0x04, 0x00,
  885. X   0x00, 0x44, 0x00, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x84, 0x00, 0x00,
  886. X   0x00, 0x20, 0x04, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00,
  887. X   0x00, 0x04, 0x01, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x04, 0x02, 0x00,
  888. X   0x00, 0x08, 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x08, 0x04, 0x00,
  889. X   0x00, 0xc4, 0xff, 0xff, 0xff, 0x7f, 0x04, 0x00, 0x00, 0x24, 0x00, 0x00,
  890. X   0x00, 0x80, 0x04, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00,
  891. X   0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0c, 0x00, 0x00,
  892. X   0x00, 0x00, 0x06, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
  893. X   0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
  894. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  895. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  896. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  897. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  898. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  899. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  900. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  901. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  902. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  903. END_OF_FILE
  904. if test 4127 -ne `wc -c <'bitmaps/ship.0'`; then
  905.     echo shar: \"'bitmaps/ship.0'\" unpacked with wrong size!
  906. fi
  907. # end of 'bitmaps/ship.0'
  908. fi
  909. if test -f 'bits.c' -a "${1}" != "-c" ; then 
  910.   echo shar: Will not clobber existing file \"'bits.c'\"
  911. else
  912. echo shar: Extracting \"'bits.c'\" \(3067 characters\)
  913. sed "s/^X//" >'bits.c' <<'END_OF_FILE'
  914. Xextern int euid;
  915. X
  916. Xparse_shop_contents()
  917. X{
  918. X    FILE *fp;
  919. X    char fname[160];
  920. X    int retn, i, menu_done;
  921. X    
  922. X    fname[0]=0;
  923. X    if(installed)
  924. X        strcpy(fname, BITMAPDIR);
  925. X    else
  926. X        strcpy(fname, "./");
  927. X    strcat(fname, "shop.contents");
  928. Xseteuid(euid);
  929. X    fp=fopen(fname,"r");    
  930. Xseteuid(getuid());
  931. X    if(fp==NULL) {
  932. X        fprintf(stderr,"No data file: %s\n", fname);
  933. X        exit(0);
  934. X    }
  935. X
  936. X    curr= (struct menu_p *) malloc(sizeof(struct menu_p));
  937. X    head=curr;
  938. X
  939. X    retn=1;
  940. X    while(retn) {
  941. X        fgets(curr->menu_name, 40, fp);
  942. X        curr->menu_name[strlen(curr->menu_name)-1]=0;
  943. X
  944. X        menu_done=0;
  945. X        i=0;
  946. X        while(!menu_done && retn) {
  947. X            retn=(int)fgets(curr->menu_item[i], 40, fp);
  948. X            if(retn) {
  949. X                curr->menu_item[i][strlen(curr->menu_item[i])-1]=0;
  950. X                if(!strncmp("###",curr->menu_item[i],3)) {
  951. X                    menu_done=1;
  952. X                }
  953. X                else {
  954. X                    fscanf(fp, "%[^$]%*c%d%*c", curr->descr[i], &(curr->cost[i]));
  955. X                }
  956. X                i++;
  957. X            }
  958. X        }
  959. X        curr->next=(struct menu_p *)malloc(sizeof(struct menu_p));
  960. X        curr=curr->next;
  961. X    }    
  962. X    curr->next=NULL;
  963. X    curr=head;
  964. X}
  965. X
  966. Xvalue_of_craft(dude)
  967. Xwinptr dude;
  968. X{
  969. X    int i;
  970. X    int what,pos;
  971. X
  972. X    dude->ship_value=1;
  973. X    for (i=0; i < NUM_ITEMS; i++)
  974. X    {
  975. X        if(dude->state[i]>0)
  976. X        {
  977. X            what=i;
  978. X            pos=dude->quality[i];
  979. X            dude->ship_value += cost_of_item(dude, what, pos);
  980. X        }
  981. X    }
  982. X    for (i=0; i < NO_WEAPONS; i++)
  983. X    {
  984. X        if(dude->does_have_weap[i])
  985. X        {
  986. X            what=i;
  987. X            dude->ship_value += cost_of_weap(dude, what);
  988. X        }
  989. X    }
  990. X    what=LS;
  991. X    dude->ship_value += (dude->ls_max-100)/100*cost_of_item(dude, what, pos);
  992. X    what=RS;
  993. X    dude->ship_value += (dude->rs_max-100)/100*cost_of_item(dude, what, pos);
  994. X    what=BS;
  995. X    dude->ship_value += (dude->bs_max-100)/100*cost_of_item(dude, what, pos);
  996. X    what=ENERGY;
  997. X    dude->ship_value += (dude->energy_max-100)/100*cost_of_item(dude, what, pos);
  998. X    return dude->ship_value;
  999. X}
  1000. X
  1001. Xint cost_of_item(dude,what,pos)
  1002. Xwinptr dude;
  1003. Xint what,pos;
  1004. X{
  1005. Xstruct menu_p *curr;
  1006. X
  1007. X    curr=head;
  1008. X    if(what==ENGINE) {
  1009. X        return (curr->cost[dude->quality[ENGINE]-1]);
  1010. X    }
  1011. X    curr=curr->next;
  1012. X    if(what==SOLAR) {
  1013. X        return (curr->cost[dude->quality[SOLAR]-1]);
  1014. X    }
  1015. X    curr=curr->next;
  1016. X    if(what==SHORTRR || what==LONGRR) {
  1017. X        if(what==SHORTRR)
  1018. X        {
  1019. X            return (curr->cost[dude->quality[SHORTRR]+NUMLRADS-1]);    
  1020. X        }
  1021. X        else
  1022. X        {
  1023. X            return (curr->cost[dude->quality[LONGRR]-1]);
  1024. X        }
  1025. X    }
  1026. X    curr=curr->next->next;
  1027. X    if(what==REPAIR) {
  1028. X        return (curr->cost[dude->quality[REPAIR]-1]);
  1029. X    }
  1030. X    curr=curr->next;
  1031. X    if(what==TC) {
  1032. X        return (curr->cost[0]);
  1033. X    }
  1034. X    if(what==CLOAK) {
  1035. X        return (curr->cost[dude->quality[CLOAK]-1]);
  1036. X    }
  1037. X    curr=curr->next;
  1038. X    if((what==RS) || (what==BS) || (what==LS)) {
  1039. X            return(curr->cost[what-NUM_ITEMS]);
  1040. X    }
  1041. X    curr=curr->next;
  1042. X    if(what==ENERGY) {
  1043. X        return(curr->cost[0]);
  1044. X    }
  1045. X    else
  1046. X    {
  1047. X        fprintf(stderr, "No such item!  Panic time.  I'm Bailing\n Problem could be shop.contents does not match shop_stubs.c expectations\n");
  1048. X        exit(1);
  1049. X    }
  1050. X}
  1051. X
  1052. Xcost_of_weap(dude,what)
  1053. Xwinptr dude;
  1054. Xint what;
  1055. X{
  1056. Xstruct menu_p *curr;
  1057. X
  1058. X    curr=head;
  1059. X    curr=curr->next->next->next;
  1060. X    return(curr->cost[what]);
  1061. X}
  1062. END_OF_FILE
  1063. if test 3067 -ne `wc -c <'bits.c'`; then
  1064.     echo shar: \"'bits.c'\" unpacked with wrong size!
  1065. fi
  1066. # end of 'bits.c'
  1067. fi
  1068. if test -f 'damage_ship.c' -a "${1}" != "-c" ; then 
  1069.   echo shar: Will not clobber existing file \"'damage_ship.c'\"
  1070. else
  1071. echo shar: Extracting \"'damage_ship.c'\" \(3674 characters\)
  1072. sed "s/^X//" >'damage_ship.c' <<'END_OF_FILE'
  1073. X/* damage_ship.c - ***  */
  1074. X
  1075. X#if !defined(lint)
  1076. Xstatic char sccs_id[] = "@(#)damage_ship.c 1.20 93/03/26 XMPB";
  1077. X#endif
  1078. X#include "player.h"
  1079. X
  1080. Xvoid blow_up();
  1081. X
  1082. Xextern int weap_damage_prob[NO_WEAPONS];
  1083. Xextern winptr first_win;
  1084. Xextern int num_alive; 
  1085. Xextern int num_npcs_alive;
  1086. Xextern num_npcs_windows;
  1087. X
  1088. X#define WEAP_DAMAGE
  1089. Xdamage_ship(w,shield,dam)
  1090. Xwinptr w;
  1091. Xint shield,dam;
  1092. X{
  1093. X    int r=0;
  1094. X
  1095. X    switch(shield)
  1096. X    {
  1097. X        case RSH:
  1098. X            w->rs_curr -= dam;
  1099. X            if(w->rs_curr < 0)
  1100. X            {
  1101. X                r=random_hit(w,-w->rs_curr/2);
  1102. X                w->rs_curr = 0;
  1103. X            }
  1104. X            break;
  1105. X        case LSH:
  1106. X            w->ls_curr -= dam;
  1107. X            if(w->ls_curr < 0)
  1108. X            {
  1109. X                r=random_hit(w,-w->ls_curr/2);
  1110. X                w->ls_curr = 0;
  1111. X            }
  1112. X            break;
  1113. X        case BSH:
  1114. X            w->bs_curr -= dam;
  1115. X            if(w->bs_curr < 0)
  1116. X            {
  1117. X                r=random_hit(w,-w->bs_curr/2);
  1118. X                w->bs_curr = 0;
  1119. X            }
  1120. X            break;
  1121. X        default:
  1122. X            xmpb_error("Haven't heard of that shield\n");
  1123. X            break;
  1124. X    }
  1125. X    return r;
  1126. X}
  1127. X
  1128. Xint random_hit(w,dam)
  1129. Xwinptr w;
  1130. Xint dam;
  1131. X{
  1132. X    int r;
  1133. X    int l;
  1134. X    int total;
  1135. X
  1136. X    int i;
  1137. X
  1138. X    total = 0;
  1139. X    w->damaged=2;
  1140. X
  1141. X    l = dam;
  1142. X    while(dam > 0)
  1143. X    {
  1144. X        if(dam < 5)
  1145. X         {
  1146. X            l = dam;
  1147. X            dam = 0;
  1148. X        }
  1149. X        else
  1150. X        {
  1151. X            l = 5;
  1152. X            dam -=5;
  1153. X        }
  1154. X    while(l > 0)
  1155. X    {
  1156. X        total = 0;
  1157. X        for(i=0;i<NUM_ITEMS;i++)
  1158. X        {
  1159. X            if(w->state[i] > 0)
  1160. X            {
  1161. X                total += w->prob[i];
  1162. X            }
  1163. X        }
  1164. X#ifdef WEAP_DAMAGE
  1165. X        for(i=0;i<NO_WEAPONS;i++)
  1166. X        {    
  1167. X            if(w->does_have_weap[i] && w->load_status[i] >= 0)
  1168. X                total += weap_damage_prob[i];
  1169. X        }
  1170. X#endif
  1171. X        if(total == 0 && !w->exploding)
  1172. X        {
  1173. X            blow_up(w);   
  1174. X            return 1;
  1175. X        }
  1176. X
  1177. X        if (w->exploding)
  1178. X            return 0;
  1179. X
  1180. X        r = rand()%total;
  1181. X        i =0;
  1182. X        while(r > 0)
  1183. X        {
  1184. X            if(i < NUM_ITEMS)
  1185. X            {
  1186. X                if(w->state[i] > 0)
  1187. X                    r -= w->prob[i];
  1188. X            }
  1189. X#ifdef WEAP_DAMAGE
  1190. X            else
  1191. X            {
  1192. X                if(w->does_have_weap[i-NUM_ITEMS] && w->load_status[i-NUM_ITEMS] >= 0)
  1193. X                    r -= weap_damage_prob[i-NUM_ITEMS];
  1194. X            }
  1195. X            i = (i+1)%(NUM_ITEMS+NO_WEAPONS);
  1196. X#else
  1197. X            i = (i+1)%(NUM_ITEMS);
  1198. X#endif
  1199. X        }
  1200. X        i--;
  1201. X#ifdef WEAP_DAMAGE
  1202. X        i = (i + (NUM_ITEMS+NO_WEAPONS))%(NUM_ITEMS+NO_WEAPONS);
  1203. X#else
  1204. X        i = (i + NUM_ITEMS)%NUM_ITEMS;
  1205. X#endif
  1206. X
  1207. X        if(i < NUM_ITEMS)
  1208. X        {
  1209. X            w->state[i] -= l;
  1210. X            l = 0;
  1211. X            if(w->state[i] < 0)
  1212. X            {
  1213. X                l = - w->state[i];
  1214. X                w->state[i] = 0;
  1215. X            }
  1216. X        }
  1217. X#ifdef WEAP_DAMAGE
  1218. X        else
  1219. X        {
  1220. X            if(!(rand()%10))
  1221. X            w->load_status[i-NUM_ITEMS] = -1;
  1222. X            l = 0;
  1223. X        }
  1224. X#endif
  1225. X    }
  1226. X    }
  1227. X    if(!(rand()%3))
  1228. X        add_junk(DEBRIS1+rand()%3,w->sx,w->sy,(rand()%20-10)*32768+w->xv,(rand()%20-10)*32768+w->yv,0);
  1229. X    return 0;
  1230. X}
  1231. X
  1232. Xvoid untarget(w)
  1233. Xwinptr w;
  1234. X{
  1235. X    winptr t;
  1236. X
  1237. X    t = first_win;
  1238. X    while(t)
  1239. X    {
  1240. X        if (t->targeting == w)
  1241. X        {
  1242. X            t->targeting=NULL;
  1243. X        }
  1244. X        t=t->next;
  1245. X    }
  1246. X}
  1247. X
  1248. Xvoid blow_up(w)
  1249. Xwinptr w;
  1250. X{
  1251. X    int i;
  1252. X    winptr t;
  1253. X
  1254. X    w->exploding = 500;
  1255. X    num_alive--;
  1256. X    if(w->npc)
  1257. X    {
  1258. X
  1259. X        num_npcs_alive--;
  1260. X        if(w->npcwin)
  1261. X        {
  1262. X            close_host(w);
  1263. X            w->npcwin = 0;
  1264. X/*
  1265. X            winptr t,l;
  1266. X            extern winptr first_win;
  1267. X
  1268. X             t = first_win;
  1269. X            if (t==w) {
  1270. X                first_win=w->next;
  1271. X                if(!w->npc || w->npcwin) close_host(w);
  1272. X                return;
  1273. X            }
  1274. X            else
  1275. X            {
  1276. X                while(t) 
  1277. X                {
  1278. X                    l=t;
  1279. X                    t=t->next;
  1280. X                    if(w==t) 
  1281. X                    {
  1282. X                        l->next=t->next;
  1283. X                        if(!w->npc || w->npcwin) close_host(w);
  1284. X                        return;
  1285. X                    }
  1286. X                }
  1287. X            }
  1288. X*/
  1289. X            num_npcs_windows--;
  1290. X        }
  1291. X    }
  1292. X
  1293. X    for(i=0;i<50;i++)
  1294. X    {
  1295. X        add_weapon_item(w,WEAP_PULSE,((random()%100 -50)*32768)+w->xv,((random()%100 -50)*32768)+w->yv,0,NULL,w->sx,w->sy);
  1296. X        if(i%2)
  1297. X            add_weapon_item(w,WEAP_BOMB,((random()%100 -50)*32768)+w->xv,((random()%100 -50)*32768)+w->yv,0,NULL,w->sx,w->sy);
  1298. X
  1299. X        add_junk(CLOUD1,w->sx+rand()%60-30,w->sy+rand()%60-30,w->xv,w->yv,rand()%4+1);
  1300. X    }
  1301. X    untarget(w);
  1302. X}
  1303. X    
  1304. END_OF_FILE
  1305. if test 3674 -ne `wc -c <'damage_ship.c'`; then
  1306.     echo shar: \"'damage_ship.c'\" unpacked with wrong size!
  1307. fi
  1308. # end of 'damage_ship.c'
  1309. fi
  1310. if test -f 'disp_ship.c' -a "${1}" != "-c" ; then 
  1311.   echo shar: Will not clobber existing file \"'disp_ship.c'\"
  1312. else
  1313. echo shar: Extracting \"'disp_ship.c'\" \(4617 characters\)
  1314. sed "s/^X//" >'disp_ship.c' <<'END_OF_FILE'
  1315. X/* disp_ship.c - *** Display a ship on a display  */
  1316. X
  1317. Xstatic char sccs_id[] = "@(#)disp_ship.c 1.11 93/03/26 XMPB";
  1318. X
  1319. X#include "player.h"
  1320. X
  1321. Xextern int xo[24],yo[24];    /* get the ship offsets */
  1322. Xextern winptr first_win;
  1323. Xextern int mysintab[],mycostab[];
  1324. X
  1325. Xrotate_pt(x,y,angle,x1,y1)
  1326. Xint x, y, angle, *x1, *y1;
  1327. X{
  1328. X    *x1 = (mycostab[angle]*x-mysintab[angle]*y)*3/65536;    
  1329. X    *y1 = (mycostab[angle]*y+mysintab[angle]*x)*3/65536;    
  1330. X}
  1331. X
  1332. X#define NUMSHIPLINES 14
  1333. Xint ship_lines[][2][2] =
  1334. X{
  1335. X    {{0,-24},{12,12}},
  1336. X    {{0,-24},{-12,12}},
  1337. X    {{-12,16},{12,16}},
  1338. X    {{-12,12},{-10,16}},
  1339. X    {{12,12},{10,16}},
  1340. X    {{-2,-4},{0,-12}},
  1341. X    {{2,-4},{0,-12}},
  1342. X    {{-2,-4},{2,-4}},
  1343. X    {{-12,12},{-14,11}},
  1344. X    {{12,12},{14,11}},
  1345. X    {{-14,11},{-14,20}},
  1346. X    {{14,11},{14,20}},
  1347. X    {{-14,20},{-12,16}},
  1348. X    {{14,20},{12,16}}
  1349. X};
  1350. X
  1351. X/*
  1352. X* display a ship on window m
  1353. X* x,y are the position on the screen
  1354. X* t* are whether the thrusters of the ship are on
  1355. X* and n is the picture (derived from the angle 
  1356. X*/
  1357. Xdisp_ship(m,a,x,y,t1,t2,t3,who)
  1358. Xwinptr m;
  1359. Xint a,x,y,t1,t2,t3;
  1360. Xwinptr who;
  1361. X{
  1362. X    int i;
  1363. X    int x1,x2,y1,y2;
  1364. X    int n= (int)(((float)(a)+7.5)/15.0)%24;
  1365. X    int done_jam8=0;
  1366. X
  1367. X/* 
  1368. X   the pictures are written to a hidden buffer which is OFFSET larger in
  1369. X   all directions.  This is why the x's and y's are changed by the
  1370. X   OFFSET.
  1371. X*/
  1372. X/*
  1373. X    XCopyPlane(m->theDisplay,m->sp[n].pm,m->back_buffer,m->bbgc,0,0,m->sp[n].w,
  1374. X        m->sp[n].h,x+m->sp[n].xo-40+OFFSET,y+m->sp[n].yo-40+OFFSET,1);
  1375. X*/
  1376. X
  1377. X    for(i=0;i<NUMSHIPLINES;i++)
  1378. X    {
  1379. X        rotate_pt(ship_lines[i][0][0],ship_lines[i][0][1],a,&x1,&y1);
  1380. X        rotate_pt(ship_lines[i][1][0],ship_lines[i][1][1],a,&x2,&y2);
  1381. X        if(who==m || !who->cloaking)
  1382. X            XDrawLine(m->theDisplay,m->back_buffer,m->bmgc,x+x1+OFFSET,y+y1+OFFSET,x+x2+OFFSET,y+y2+OFFSET);
  1383. X        else
  1384. X        {
  1385. X            if(rand()%100+1 > who->state[CLOAK]+10)
  1386. X                XDrawLine(m->theDisplay,m->back_buffer,m->bmgc,x+x1+OFFSET,y+y1+OFFSET,x+x2+OFFSET,y+y2+OFFSET);
  1387. X            else
  1388. X            switch(who->quality[CLOAK])
  1389. X            {
  1390. X                case 2: 
  1391. X                case 3:
  1392. X                case 4:
  1393. X                XDrawLine(m->theDisplay,m->back_buffer,m->bmgc,x+x1+OFFSET,y+y1+OFFSET,x+x2+OFFSET,y+y2+OFFSET);
  1394. X                break;
  1395. X                case 5:
  1396. X                XDrawLine(m->theDisplay,m->back_buffer,m->jam75,x+x1+OFFSET,y+y1+OFFSET,x+x2+OFFSET,y+y2+OFFSET);
  1397. X                break;
  1398. X                case 6:
  1399. X                XDrawLine(m->theDisplay,m->back_buffer,m->jam50,x+x1+OFFSET,y+y1+OFFSET,x+x2+OFFSET,y+y2+OFFSET);
  1400. X                break;
  1401. X                case 7:
  1402. X                XDrawLine(m->theDisplay,m->back_buffer,m->jam25,x+x1+OFFSET,y+y1+OFFSET,x+x2+OFFSET,y+y2+OFFSET);
  1403. X                break;
  1404. X                case 8:
  1405. X                    if(done_jam8) break;
  1406. X                    XCopyPlane(m->theDisplay,(m->spm[0].spm),m->back_buffer,m->bbgc,0,0,m->spm[0].w,m->spm[0].h,x+OFFSET,y+OFFSET,1);
  1407. X                    XCopyPlane(m->theDisplay,(m->spm[1].spm),m->back_buffer,m->bbgc,0,0,m->spm[1].w,m->spm[1].h,x+OFFSET-40,y+OFFSET+40,1);
  1408. X                    XCopyPlane(m->theDisplay,(m->spm[2].spm),m->back_buffer,m->bbgc,0,0,m->spm[2].w,m->spm[2].h,x+OFFSET+40,y+OFFSET+40,1);
  1409. X                    done_jam8=1;
  1410. X                break;
  1411. X                case 9:
  1412. X                break;
  1413. X            }
  1414. X        }
  1415. X    }
  1416. X    if(t1)
  1417. X    {
  1418. X        int xx,yy;
  1419. X        XPoint xps[3];
  1420. X
  1421. X        rotate_pt(-14,20,a,&xx,&yy);
  1422. X        xps[0].x = (short)xx+x+OFFSET;
  1423. X        xps[0].y = (short)yy+y+OFFSET;
  1424. X        rotate_pt(-8,22,a,&xx,&yy);
  1425. X        xps[1].x = (short)xx+x+OFFSET;
  1426. X        xps[1].y = (short)yy+y+OFFSET;
  1427. X        rotate_pt(-12,16,a,&xx,&yy);
  1428. X        xps[2].x = (short)xx+x+OFFSET;
  1429. X        xps[2].y = (short)yy+y+OFFSET;
  1430. X        XFillPolygon(m->theDisplay,m->back_buffer,m->fillgc,xps,3,Convex,CoordModeOrigin);
  1431. X
  1432. X/*
  1433. X        XCopyPlane(m->theDisplay,m->lt[n].pm,m->back_buffer,m->bbgc,0,0,
  1434. X            m->lt[n].w,m->lt[n].h,x+m->lt[n].xo+OFFSET,y+m->lt[n].yo+OFFSET,1);
  1435. X*/
  1436. X    }
  1437. X    if(t2)
  1438. X    {
  1439. X        int xx,yy;
  1440. X        XPoint xps[3];
  1441. X
  1442. X        rotate_pt(-6,16,a,&xx,&yy);
  1443. X        xps[0].x = (short)xx+x+OFFSET;
  1444. X        xps[0].y = (short)yy+y+OFFSET;
  1445. X        rotate_pt(0,30,a,&xx,&yy);
  1446. X        xps[1].x = (short)xx+x+OFFSET;
  1447. X        xps[1].y = (short)yy+y+OFFSET;
  1448. X        rotate_pt(6,16,a,&xx,&yy);
  1449. X        xps[2].x = (short)xx+x+OFFSET;
  1450. X        xps[2].y = (short)yy+y+OFFSET;
  1451. X        XFillPolygon(m->theDisplay,m->back_buffer,m->fillgc,xps,3,Convex,CoordModeOrigin);
  1452. X/*
  1453. X        XCopyPlane(m->theDisplay,m->mt[n].pm,m->back_buffer,m->bbgc,0,0,
  1454. X            m->mt[n].w,m->mt[n].h,x+m->mt[n].xo+OFFSET,y+m->mt[n].yo+OFFSET,1);
  1455. X*/
  1456. X    }
  1457. X    if(t3)
  1458. X    {
  1459. X        int xx,yy;
  1460. X        XPoint xps[3];
  1461. X
  1462. X        rotate_pt(14,20,a,&xx,&yy);
  1463. X        xps[0].x = (short)xx+x+OFFSET;
  1464. X        xps[0].y = (short)yy+y+OFFSET;
  1465. X        rotate_pt(8,22,a,&xx,&yy);
  1466. X        xps[1].x = (short)xx+x+OFFSET;
  1467. X        xps[1].y = (short)yy+y+OFFSET;
  1468. X        rotate_pt(12,16,a,&xx,&yy);
  1469. X        xps[2].x = (short)xx+x+OFFSET;
  1470. X        xps[2].y = (short)yy+y+OFFSET;
  1471. X        XFillPolygon(m->theDisplay,m->back_buffer,m->fillgc,xps,3,Convex,CoordModeOrigin);
  1472. X/*
  1473. X        XCopyPlane(m->theDisplay,m->rt[n].pm,m->back_buffer,m->bbgc,0,0,
  1474. X            m->rt[n].w,m->rt[n].h,x+m->rt[n].xo+OFFSET,y+m->rt[n].yo+OFFSET,1);
  1475. X*/
  1476. X    }
  1477. X    XFlush(m->theDisplay);
  1478. X}
  1479. X
  1480. END_OF_FILE
  1481. if test 4617 -ne `wc -c <'disp_ship.c'`; then
  1482.     echo shar: \"'disp_ship.c'\" unpacked with wrong size!
  1483. fi
  1484. # end of 'disp_ship.c'
  1485. fi
  1486. if test -f 'lex.l' -a "${1}" != "-c" ; then 
  1487.   echo shar: Will not clobber existing file \"'lex.l'\"
  1488. else
  1489. echo shar: Extracting \"'lex.l'\" \(3518 characters\)
  1490. sed "s/^X//" >'lex.l' <<'END_OF_FILE'
  1491. X%{
  1492. X#include <stdio.h>
  1493. X#include "y.tab.h"
  1494. X
  1495. X#define MAX_SYMB_LEN 30
  1496. Xint i;
  1497. X
  1498. Xchar id[MAX_SYMB_LEN+1];
  1499. X%}
  1500. X
  1501. X%p 4000
  1502. X%e 1500
  1503. XDIGIT   [0-9]
  1504. XWS    ("\t"|" ")
  1505. XNL  ("\n")
  1506. X
  1507. X%%
  1508. X    extern int yylval;
  1509. X    extern int errline;
  1510. X
  1511. X{WS}   {};/* eat up white space */
  1512. X"\n"  errline++;
  1513. X\-      return MINUS;
  1514. X[-]?{DIGIT}+       {yylval = atoi(yytext); return INTEGER;}
  1515. X\!        return NOT;
  1516. X\*      return TIMES;
  1517. X\/\*    comment();
  1518. X\+      return PLUS;
  1519. X\,        return COMMA;
  1520. X\/      return DIV;
  1521. X\-\>    return ARROW;
  1522. X\<\-\>   return DARROW;
  1523. X\{      return LBRACE;
  1524. X\}      return RBRACE;
  1525. X=       return EQUALS;
  1526. X;       return SEMICOLON;
  1527. X==      return EQIV;
  1528. X!=      return NOTEQ;
  1529. X\<       return LT;
  1530. X\>       return GT;
  1531. X\<=      return LTE;
  1532. X\%        return MOD;
  1533. X\>=      return GTE;
  1534. X\&\&      return AND;
  1535. X\|\|      return OR;
  1536. X\)       return RP;
  1537. X\(       return LP;
  1538. X
  1539. Xend        return END;
  1540. Xif         return IF;
  1541. Xwhile    return WHILE;
  1542. Xelse    return ELSE;
  1543. Xnone    return NONE;
  1544. Xset     return SET;
  1545. Xreturn  return RETURN;
  1546. Xvar     return VAR;
  1547. XState   return STATE;
  1548. XStart       return START;
  1549. XEntry    return ENTRY;
  1550. XProc     return PROC;
  1551. X
  1552. XPulse   return PULSE;
  1553. XBomb    return BOMB;
  1554. XSeek    return SEEK;
  1555. XLLaser  return LLASER;
  1556. XRail    return RAIL;
  1557. XMass    return MASS;
  1558. XMine    return MINE;
  1559. XAtom    return ATOM;
  1560. XHLaser    return HLASER;
  1561. XHPulse    return HPULSE;
  1562. XMagneto    return MAGNETO;
  1563. XBDeath    return BDEATH;
  1564. X
  1565. XNPC     return HEADER;
  1566. XWeapons     return WEAPONS;
  1567. XEnergyMax   return ENERGYMAX;
  1568. XLShieldMax  return LSHIELDMAX;
  1569. XRShieldMax  return RSHIELDMAX;
  1570. XBShieldMax  return BSHIELDMAX;
  1571. X
  1572. XName    return NAME;
  1573. XShip    return SHIPNAME;
  1574. X
  1575. XEngine  return ENGINEL;
  1576. XShortRange  return SHORT;
  1577. XLongRange   return LONG;
  1578. XRepair      return REPAIRL;
  1579. XTC          return TCL;
  1580. XJammer       return CLOAKL;
  1581. XSolar       return SOLARL;
  1582. XIdle        return IDLEL;
  1583. X
  1584. XBalance     return BALANCE;
  1585. XSelectEnemy return SELECTE;
  1586. XJamming        return CLOAKT;
  1587. XRadarChange return RADARCHANGE;
  1588. XTurnTo        return TURNTO;
  1589. XB1      return B1;
  1590. XB2      return B2;
  1591. XB3      return B3;
  1592. XTurnLeft   return TURNLEFT;
  1593. XTurnRight  return TURNRIGHT;
  1594. XTarget        return TARGET;
  1595. XRepairToggle return REPAIRTOGGLE;
  1596. XRepairSelectedItem    return REPAIRSELITEM;
  1597. XGrab        return GRAB;
  1598. XQuit        return QUIT;
  1599. X
  1600. XEnergy        return ENERGY;
  1601. XAngle        return ANGLE;
  1602. XLShield     return LSHIELD;
  1603. XRShield     return RSHIELD;
  1604. XBShield     return BSHIELD;
  1605. XRadarMode   return RADARMODE;
  1606. XXPos        return XPOS;
  1607. XYPos        return YPOS;
  1608. XXVel        return XVEL;
  1609. XYVel        return YVEL;
  1610. XNumEnemies    return NUMENEMIES;
  1611. XEnemyDist    return ENEMYDIST;
  1612. XCurrWeap    return CURRWEAP;
  1613. XRepairState return REPAIRSTATE;
  1614. XEngineState return ENGINESTATE;
  1615. XLongState    return LONGSTATE;
  1616. XShortState    return SHORTSTATE;
  1617. XJamState    return JAMSTATE;
  1618. XSolarState    return SOLARSTATE;
  1619. XTargetState    return TARGETSTATE;
  1620. XEnemyAngle    return ENEMYANGLE;
  1621. XEnemyDirection    return ENEMYDIRECTION;
  1622. XEnemySpeed    return ENEMYSPEED;
  1623. XEnemyXPos    return ENEMYXPOS;
  1624. XEnemyYPos    return ENEMYYPOS;
  1625. XEnemyXVel    return ENEMYXVEL;
  1626. XEnemyYVel    return ENEMYYVEL;
  1627. XSpeed        return SPEED;
  1628. XEnemyAvail  return ENEMYAVAIL;
  1629. XDirection   return DIRECTION;
  1630. XAngleTo        return ANGLETO;
  1631. XDistTo        return DISTTO;
  1632. XRepairItem  return REPAIRITEM;
  1633. XVelAtAngle    return VELATANG;
  1634. XCurrWeapState    return CURRWEAPSTATE;
  1635. XWaitFrame    return WAITFRAME;
  1636. X
  1637. X[_a-zA-Z][_A-Za-z0-9]*     {strncpy(id,yytext,MAX_SYMB_LEN); return ID;}
  1638. X.       yyerror("Unexpected character:");
  1639. X%%
  1640. X
  1641. Xcomment()
  1642. X{
  1643. X    char c;
  1644. X    int done = 0;
  1645. X
  1646. X    while(!done)
  1647. X    {
  1648. X        c = yyinput();
  1649. X        if(c == '*')
  1650. X        {
  1651. X            if((c = yyinput()) == '/')
  1652. X                done = 1;
  1653. X            else
  1654. X                if(c == '\n')
  1655. X                    errline++;
  1656. X            else if(c == 0)
  1657. X                    done = 1;
  1658. X        }
  1659. X        else
  1660. X        if(c == '\n')
  1661. X            errline++;
  1662. X        else if(c== 0)
  1663. X            done = 1;
  1664. X    }
  1665. X}
  1666. END_OF_FILE
  1667. if test 3518 -ne `wc -c <'lex.l'`; then
  1668.     echo shar: \"'lex.l'\" unpacked with wrong size!
  1669. fi
  1670. # end of 'lex.l'
  1671. fi
  1672. if test -f 'ml.npc' -a "${1}" != "-c" ; then 
  1673.   echo shar: Will not clobber existing file \"'ml.npc'\"
  1674. else
  1675. echo shar: Extracting \"'ml.npc'\" \(2596 characters\)
  1676. sed "s/^X//" >'ml.npc' <<'END_OF_FILE'
  1677. XNPC
  1678. XName = Dumbo
  1679. XShip = layer
  1680. XEnergyMax = 10000
  1681. XLShieldMax = 1200
  1682. XRShieldMax = 1200
  1683. XBShieldMax = 800
  1684. XSolar = 9
  1685. XShortRange = 1
  1686. XEngine = 2
  1687. XRepair = 9
  1688. XLongRange = 1
  1689. XJammer = 2
  1690. XTC = none
  1691. X
  1692. XWeapons
  1693. XRail
  1694. XMine
  1695. X
  1696. Xvar
  1697. X    a
  1698. X    num
  1699. Xend
  1700. X
  1701. XState Laymine
  1702. X{
  1703. X    set B3 =0;
  1704. X    while (CurrWeap!= 6)
  1705. X        set B2 =1;
  1706. X    set B2 =0;
  1707. X    set B1 =1;
  1708. X    if(XPos > 4200 && Angle==90)
  1709. X        1 -> stopright;
  1710. X    if (XPos < -4200 && Angle==270)
  1711. X        1 -> stopleft;    
  1712. X    num = NumEnemies;
  1713. X    set SelectEnemy = 0;
  1714. X    if(EnemyDist < 1000)
  1715. X        1 -> attack;
  1716. X}
  1717. X
  1718. XState stopup
  1719. X{
  1720. X    set B3 =0;
  1721. X    set TurnTo = 180;
  1722. X    while (Angle !=180);
  1723. X    set B3 =1;
  1724. X    while (YVel > 0);
  1725. X    set B3 =0;
  1726. X    1 -> main;
  1727. X}
  1728. X
  1729. XState goup
  1730. X{
  1731. X    set B3=0;
  1732. X    set TurnTo = 0;
  1733. X    while (Angle!=0);
  1734. X    set B3=1;
  1735. X    if (YVel > 20)
  1736. X        1 -> stopup;
  1737. X}
  1738. X
  1739. X
  1740. XState stopright 
  1741. X{
  1742. X    set B1 =0;
  1743. X    set TurnTo = 270;
  1744. X    while (Angle != 270);
  1745. X    set B3 = 1;
  1746. X    while (XVel>0);
  1747. X    {
  1748. X        if (XVel > 10 || YVel > 10)
  1749. X        {
  1750. X            1 -> stopright;
  1751. X        }
  1752. X        else
  1753. X        {
  1754. X            if (XVel < -10 || YVel < -10)
  1755. X            {
  1756. X                1 -> stopleft;
  1757. X            }
  1758. X        }
  1759. X    }
  1760. X    set B3 =0;
  1761. X    if(YPos < -4500)
  1762. X        1 -> goup;
  1763. X    set TurnTo = 180;
  1764. X    while (Angle != 180);
  1765. X    set B3 = 1;
  1766. X    while(YVel > -8);
  1767. X    set B3 =0;
  1768. X    set TurnTo=0;
  1769. X    while(Angle!=0);
  1770. X    set B3 =1;
  1771. X    while(YVel<-2);
  1772. X    {
  1773. X        if (XVel > 10 || YVel > 10)
  1774. X        {
  1775. X            1 -> stopright;
  1776. X        }
  1777. X        else
  1778. X        {
  1779. X            if (XVel < -10 || YVel < -10)
  1780. X            {
  1781. X                1 -> stopleft;
  1782. X            }
  1783. X        }
  1784. X    }
  1785. X    set B3 =0;
  1786. X    1 -> goleft;
  1787. X}
  1788. X
  1789. XState stopleft 
  1790. X{
  1791. X    set B1 =0;
  1792. X    set TurnTo = 90;
  1793. X    while (Angle != 90);
  1794. X    set B3 = 1;
  1795. X    while (XVel<0)
  1796. X    {
  1797. X        if (XVel > 10 || YVel > 10)
  1798. X        {
  1799. X            1 -> stopright;
  1800. X        }
  1801. X        else
  1802. X        {
  1803. X            if (XVel < -10 || YVel < -10)
  1804. X            {
  1805. X                1 -> stopleft;
  1806. X            }
  1807. X        }
  1808. X    }
  1809. X    set B3 =0;
  1810. X    set TurnTo = 180;
  1811. X    while (Angle != 180);
  1812. X    set B3 = 1;
  1813. X    while(YVel > -8);
  1814. X    set B3 =0;
  1815. X    set TurnTo=0;
  1816. X    while(Angle!=0)
  1817. X        set B3=0;
  1818. X    set B3 =1;
  1819. X    while(YVel< -2 )
  1820. X    {
  1821. X        if (XVel > 10 || YVel > 10)
  1822. X        {
  1823. X            1 -> stopright;
  1824. X        }
  1825. X        else
  1826. X        {
  1827. X            if (XVel < -10 || YVel < -10)
  1828. X            {
  1829. X                1 -> stopleft;
  1830. X            }
  1831. X        }
  1832. X    }
  1833. X    set B3 =0;
  1834. X    1 -> goright;
  1835. X}
  1836. X
  1837. XState goright
  1838. X{
  1839. X    set TurnTo = 90;
  1840. X    while (Angle!=90);
  1841. X    set B3 = 1;
  1842. X    if (XVel >= 5)
  1843. X        1 -> Laymine;
  1844. X}
  1845. X
  1846. XState goleft
  1847. X{
  1848. X    set TurnTo = 270;
  1849. X    while (Angle!=270);
  1850. X    set B3 = 1;
  1851. X    if (XVel <= -5)
  1852. X        1 -> Laymine;
  1853. X}
  1854. X
  1855. XState attack
  1856. X{
  1857. X    if(Angle > EnemyAngle)
  1858. X        set TurnTo = EnemyAngle-EnemyDist/150*1;
  1859. X    else
  1860. X        set TurnTo = EnemyAngle+EnemyDist/150*1;
  1861. X    set Balance = 1;
  1862. X    set RepairToggle = 1;
  1863. X
  1864. X    while(CurrWeap!=4)
  1865. X    {
  1866. X        set B2 =1;
  1867. X    }
  1868. X    set B2=0;
  1869. X    set B1=1;
  1870. X    if (EnemyDist> 1000)
  1871. X        1 -> main;
  1872. X}
  1873. X
  1874. XState main
  1875. X{
  1876. X    num = NumEnemies;
  1877. X    set SelectEnemy = 0;
  1878. X    if(EnemyDist < 1000)
  1879. X        1 -> attack;
  1880. X    if(XPos> 0)
  1881. X        1 -> goright;
  1882. X    else
  1883. X        1 -> goleft;
  1884. X}
  1885. X
  1886. XStart main
  1887. END_OF_FILE
  1888. if test 2596 -ne `wc -c <'ml.npc'`; then
  1889.     echo shar: \"'ml.npc'\" unpacked with wrong size!
  1890. fi
  1891. # end of 'ml.npc'
  1892. fi
  1893. if test -f 'nasty.npc' -a "${1}" != "-c" ; then 
  1894.   echo shar: Will not clobber existing file \"'nasty.npc'\"
  1895. else
  1896. echo shar: Extracting \"'nasty.npc'\" \(4690 characters\)
  1897. sed "s/^X//" >'nasty.npc' <<'END_OF_FILE'
  1898. XNPC
  1899. XName = Nasty
  1900. XShip = Bastard
  1901. XEnergyMax = 1400
  1902. XLShieldMax = 900
  1903. XRShieldMax = 900
  1904. XBShieldMax = 700
  1905. XSolar = 5
  1906. XShortRange = 5
  1907. XEngine = 5
  1908. XRepair = 7
  1909. XLongRange = 5
  1910. XJammer = 5
  1911. XTC = 3
  1912. X
  1913. XWeapons
  1914. XPulse
  1915. XHPulse
  1916. XRail
  1917. XAtom
  1918. X
  1919. Xvar
  1920. Xend
  1921. X
  1922. XState avoid
  1923. X{
  1924. Xvar
  1925. X    count
  1926. X    tmp
  1927. X    lastDist
  1928. Xend
  1929. X
  1930. X    lastDist=EnemyDist;
  1931. X    set B1 =0;
  1932. X    if(SolarState < 100)
  1933. X        set RepairSelectedItem=Solar;
  1934. X    else
  1935. X    if(EngineState < 100)
  1936. X        set RepairSelectedItem=Engine;
  1937. X    else
  1938. X        set RepairToggle = 1;
  1939. X    count = 15;
  1940. X    while(count)
  1941. X    {
  1942. X        tmp = EnemyDist;
  1943. X        if(tmp && tmp >= lastDist) -> loop;
  1944. X        if(!tmp)
  1945. X        {
  1946. X            slow();
  1947. X            -> loop;
  1948. X        }
  1949. X        set B3 =1;
  1950. X        if(EnemyAngle > 0 && EnemyAngle < 180)
  1951. X            set TurnTo=(EnemyAngle+ 90)%360;
  1952. X        else
  1953. X            set TurnTo=(EnemyAngle- 90)%360;
  1954. X        wall_check();
  1955. X        count = count - 1;
  1956. X    }
  1957. X    slow();
  1958. X    -> loop;
  1959. X}
  1960. X
  1961. XProc wall_check
  1962. X{
  1963. Xvar
  1964. X    r
  1965. X    l
  1966. X    u
  1967. X    d
  1968. Xend
  1969. X
  1970. X    r = 0;
  1971. X    l = 0;
  1972. X    u = 0;
  1973. X    d = 0;
  1974. X
  1975. X    if (XPos*XVel > 45000 && XVel > 0) r = 1;
  1976. X    if (XPos*XVel > 45000 && XVel < 0) l = 1;
  1977. X    if (YPos*YVel > 45000 && YVel > 0) u = 1;
  1978. X    if (YPos*YVel > 45000 && YVel < 0) d = 1;
  1979. X
  1980. X    if (r || l || u || d) slow();
  1981. X    return;
  1982. X}
  1983. X
  1984. XProc att_check
  1985. X{
  1986. X
  1987. X    NumEnemies;
  1988. X    set SelectEnemy = 0;
  1989. X    set RepairToggle = 1;
  1990. X    set Balance = 1;
  1991. X    wall_check();
  1992. X
  1993. X    if(! EnemyAvail)
  1994. X    {
  1995. X        set B1 = 0;
  1996. X        set B3 = 0;
  1997. X        return;
  1998. X    }
  1999. X
  2000. X    if(Energy < 200 && LShield > 400 && EnemyDist < 600)
  2001. X    {
  2002. X        set Grab =1;
  2003. X        set RepairToggle =1;
  2004. X    }
  2005. X
  2006. X    if(Speed > 40) slow();
  2007. X    
  2008. X    return;
  2009. X}
  2010. X
  2011. XProc attack
  2012. X{
  2013. Xvar
  2014. X    a1
  2015. X    a2
  2016. X    m
  2017. X    a
  2018. X    p
  2019. X    cnt
  2020. X    count
  2021. Xend
  2022. X
  2023. X    
  2024. X    a2 = EnemyAngle;
  2025. X    count = 10;
  2026. X    while(EnemyDist < 1000)
  2027. X    {
  2028. X
  2029. X        a1 = a2;
  2030. X        a2 = EnemyAngle;
  2031. X    
  2032. X        m = EnemyDist/(50+VelAtAngle(Angle)) - 1;    
  2033. X        if(EnemyDist > 500)
  2034. X        {
  2035. X             a = AngleTo(EnemyXPos+m*EnemyXVel - m*XVel,EnemyYPos+m*EnemyYVel - m*YVel);
  2036. X            p = (Angle - a + 360)%360;
  2037. X            if(p < 170 || p > 190)
  2038. X                set TurnTo = a;
  2039. X        }
  2040. X        else
  2041. X            if(EnemyAngle > 300)
  2042. X                set TurnTo = (EnemyAngle + (a2 - a1)*(EnemyDist/150)) % 360;
  2043. X            else
  2044. X                set TurnTo = (EnemyAngle + (a2 - a1)*(EnemyDist/120)) % 360;
  2045. X
  2046. X
  2047. X        m = 40 - (EnemyDist)/30;
  2048. X        if((EnemyDist < 900) && Angle <= (EnemyAngle+ m) && Angle >= (EnemyAngle - m))
  2049. X            set B1 = 1; 
  2050. X        else
  2051. X            set B1 = 0;
  2052. X
  2053. X        set Balance = 1;
  2054. X        if(RepairItem != LongRange)
  2055. X            set RepairToggle = 1;
  2056. X        if(Direction - Angle > 90 || Direction - Angle < 90 && Energy > 200)
  2057. X        {
  2058. X            set B3 = 1;
  2059. X            cnt = 2;
  2060. X            while(cnt>0)
  2061. X                cnt=cnt- 1;
  2062. X            set B3 = 0;
  2063. X        }
  2064. X        count = count - 1;
  2065. X        if (!count)
  2066. X        {
  2067. X            att_check();
  2068. X            count = 10;
  2069. X        }        
  2070. X    }
  2071. X    set B1 = 0;
  2072. X    set B3 = 0;
  2073. X    return;
  2074. X}
  2075. X
  2076. XProc repair_which
  2077. X{
  2078. X    if(LongState < 100 && LongState > 0)
  2079. X        set RepairSelectedItem = LongRange;
  2080. X    else
  2081. X    if(EngineState < 100 && EngineState > 0 )
  2082. X        set RepairSelectedItem = Engine;
  2083. X    else
  2084. X    if(SolarState < 100 && SolarState > 0)
  2085. X        set RepairSelectedItem = Solar;
  2086. X    else
  2087. X    if(RepairState < 100 && RepairState > 0)
  2088. X        set RepairSelectedItem = Repair;
  2089. X    else
  2090. X    if(ShortState < 100 && ShortState >0)
  2091. X        set RepairSelectedItem = ShortRange;
  2092. X    else
  2093. X        set RepairToggle = 1;
  2094. X    return;
  2095. X}
  2096. X
  2097. XState repair
  2098. X{
  2099. Xvar
  2100. X    tmp
  2101. Xend
  2102. X
  2103. X/*
  2104. X    if(LongState == -1)
  2105. X        set Quit = 1;
  2106. X*/
  2107. X    repair_which();
  2108. X    tmp = EnemyDist;
  2109. X    if(tmp && tmp < 1000) -> avoid;
  2110. X    if(EngineState > 30 && Speed > 10) slow();
  2111. X    if(LongState > 80 && EngineState > 60) -> loop;
  2112. X    set Balance = 1;
  2113. X    aim();
  2114. X}
  2115. X
  2116. XProc aim
  2117. X{
  2118. Xvar
  2119. X    aa1
  2120. X    aa2
  2121. X    num
  2122. Xend
  2123. X    num = NumEnemies;
  2124. X    set SelectEnemy = 0;
  2125. X
  2126. X    aa1 = aa2;
  2127. X    aa2 = EnemyAngle;
  2128. X    if(aa2 == -1)
  2129. X        aa2 = aa1;
  2130. X    else
  2131. X        set TurnTo = (EnemyAngle + (aa2 - aa1) * 4) % 360;
  2132. X
  2133. X    if(EnemyDist < 1000 && EnemyDist > 0) attack();
  2134. X    return;
  2135. X}
  2136. X
  2137. XProc slow
  2138. X{
  2139. Xvar
  2140. X    oldbs
  2141. Xend
  2142. X
  2143. X    set B1 = 0;
  2144. X    set TurnTo = (Direction + 180) % 360;
  2145. X    set B3 =1;
  2146. X    oldbs= BShield;
  2147. X    while(Speed > 5 && BShield >= oldbs)
  2148. X    {
  2149. X/*
  2150. X        if(LongState == -1)
  2151. X            set Quit = 1;
  2152. X*/
  2153. X        set TurnTo = (Direction + 180) % 360;
  2154. X        if(EnemyDist < 500 && EnemyDist)
  2155. X        {
  2156. X            attack();
  2157. X            return;
  2158. X        }
  2159. X    }
  2160. X    set B3 =0;
  2161. X    return;
  2162. X}
  2163. X
  2164. XProc wait
  2165. X{
  2166. Xvar w
  2167. Xend
  2168. X
  2169. X    set B3 =0;
  2170. X    w = 5;
  2171. X    while (w)
  2172. X    {
  2173. X        aim();
  2174. X        if ((Direction < (Angle + 10)) && (Direction > (Angle - 10)))
  2175. X            return;
  2176. X        w = w - 1;
  2177. X    }
  2178. X    set B3 =1;
  2179. X
  2180. X    return;
  2181. X}
  2182. X
  2183. XProc seek
  2184. X{
  2185. Xvar 
  2186. X    tmp
  2187. Xend
  2188. X
  2189. X/*
  2190. X    if(LongState == -1)
  2191. X        set Quit = 1;
  2192. X*/
  2193. X    if(!NumEnemies) 
  2194. X        return 0;    
  2195. X    set SelectEnemy = 0;
  2196. X
  2197. X    aim();
  2198. X
  2199. X    tmp = EnemyDist;
  2200. X    if(EnemySpeed > 30 && tmp > 800 && tmp && tmp) return 1; 
  2201. X
  2202. X    if(EnemyDist < 1000 && EnemyDist) attack();
  2203. X    if(Energy < 200 || LongState < 70) 
  2204. X    {
  2205. X        set B3 =0;
  2206. X        return 0;
  2207. X    } 
  2208. X    else set B3 =1;
  2209. X    if (Speed > 6 && (Direction < (Angle + 10)) && (Direction > (Angle - 10))) wait();
  2210. X    if (Speed > 15)
  2211. X        set B3 =0;
  2212. X    return 0;
  2213. X}
  2214. X
  2215. XState loop
  2216. X{
  2217. X    if(seek())
  2218. X        1 -> avoid;
  2219. X    if(RepairItem == Idle)
  2220. X        repair_which();
  2221. X    set Balance= 1;
  2222. X
  2223. X    if(LongState == -1)
  2224. X        set RadarChange = 1;
  2225. X
  2226. X    if (Speed > 30 && EnemyDist < 2000)  slow();
  2227. X    if (LongState < 50) {
  2228. X        slow();
  2229. X        -> repair;
  2230. X    }
  2231. X}
  2232. X
  2233. XState main
  2234. X{
  2235. X    set B2 = 1;
  2236. X    -> loop;
  2237. X}
  2238. X
  2239. XStart main
  2240. END_OF_FILE
  2241. if test 4690 -ne `wc -c <'nasty.npc'`; then
  2242.     echo shar: \"'nasty.npc'\" unpacked with wrong size!
  2243. fi
  2244. # end of 'nasty.npc'
  2245. fi
  2246. if test -f 'polygon.c' -a "${1}" != "-c" ; then 
  2247.   echo shar: Will not clobber existing file \"'polygon.c'\"
  2248. else
  2249. echo shar: Extracting \"'polygon.c'\" \(2558 characters\)
  2250. sed "s/^X//" >'polygon.c' <<'END_OF_FILE'
  2251. X/* polygon.c - *** Routines for geometric intersections */
  2252. X
  2253. Xstatic char sccs_id[] = "@(#)polygon.c 1.7 92/11/24 XMPB";
  2254. X#include <stdio.h>
  2255. X#include <math.h>
  2256. X/*
  2257. Xint line_2_point(x1,y1,x2,y2,x3,y3)
  2258. Xint x1,y1,x2,y2,x3,y3;
  2259. X{
  2260. X
  2261. X    int x2d,y2d,x3d,y3d;
  2262. X    int xbar;
  2263. X
  2264. X    x2d = x2 - x1;
  2265. X    y2d = y2 - y1;
  2266. X
  2267. X    x3d = x3 - x1;
  2268. X    y3d = y3 - y1;
  2269. X    if(y2d == 0)
  2270. X    {
  2271. X        y2d = 1;
  2272. X        y3d += 1;
  2273. X    }
  2274. X
  2275. X    xbar = y3d * x2d / y2d;
  2276. X    return(x3d - xbar);
  2277. X}
  2278. X*/
  2279. Xdouble line_2_pointf(x1,y1,x2,y2,x3,y3)
  2280. Xint x1,y1,x2,y2,x3,y3;
  2281. X{
  2282. X    double x2d,y2d,x3d,y3d;
  2283. X    double xbar;
  2284. X
  2285. X    x2d = (double)x2 - (double)x1;    
  2286. X    y2d = (double)y2 - (double)y1;    
  2287. X
  2288. X    x3d = (double)x3 - (double)x1;    
  2289. X    y3d = (double)y3 - (double)y1;    
  2290. X    y2d += 1.0;
  2291. X    y3d += 1.0;
  2292. X
  2293. X    xbar = y3d * x2d / y2d;
  2294. X    return(x3d - xbar);
  2295. X}
  2296. X/*
  2297. Xline_2_line(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,int *a,int *b,int *c,int *d)
  2298. X{
  2299. X    int t;
  2300. X    *c = line_2_point(x1,y1,x2,y2,x3,y3);
  2301. X    *d = line_2_point(x1,y1,x2,y2,x4,y4);
  2302. X    t = (*c)^(*d);
  2303. X    if(t >= 0) return 0;
  2304. X    *a = line_2_point(x3,y3,x4,y4,x1,y1);
  2305. X    *b = line_2_point(x3,y3,x4,y4,x2,y2);
  2306. X    t = (*a)^(*b);
  2307. X    if(t >= 0) return 0;
  2308. X    return 1;
  2309. X}
  2310. X*/
  2311. X
  2312. Xdouble line_2_linef(x1,y1,x2,y2,x3,y3,x4,y4)
  2313. Xint x1,y1,x2,y2,x3,y3,x4,y4;
  2314. X{
  2315. X    double a,b,c,d;
  2316. X
  2317. X    c = line_2_pointf(x1,y1,x2,y2,x3,y3);        
  2318. X    d = line_2_pointf(x1,y1,x2,y2,x4,y4);        
  2319. X    if(c*d > 0.0)
  2320. X        return -3.0;
  2321. X
  2322. X    a = line_2_pointf(x3,y3,x4,y4,x1,y1);        
  2323. X    b = line_2_pointf(x3,y3,x4,y4,x2,y2);        
  2324. X    if(a*b > 0.0)
  2325. X        return -3.0;
  2326. X
  2327. X    return ((a)/(b-a));
  2328. X}
  2329. X
  2330. X
  2331. Xint line_2_circle(x1,y1,x2,y2,x3,y3,r)
  2332. Xint x1,y1,x2,y2,x3,y3,r;
  2333. X{
  2334. X    double c2,m2;
  2335. X    double m,c;
  2336. X    double r2;
  2337. X    double ret;
  2338. X    double ret2;
  2339. X
  2340. X    if(x1 == x2)
  2341. X    {
  2342. X        if((x1 > x3+r) || (x1 < x3-r))
  2343. X            return 0;
  2344. X        if((y2 < y3-r) && (y1 < y3-r))
  2345. X            return 0;
  2346. X        if((y2 > y3+r) && (y1 > y3+r))
  2347. X            return 0;
  2348. X        return 1;
  2349. X    }
  2350. X    else
  2351. X    {
  2352. X        r2 = (double)r*(double)r;
  2353. X        m = (double)(y2-y1)/(double)(x2-x1);
  2354. X        
  2355. X        m2 = m*m;
  2356. X
  2357. X        c = (double)y1 - m*(double)x1;
  2358. X
  2359. X        ret = (2*x3*m)*(y3-c)+m2*(r2-x3*x3)-(c-y3)*(c-y3)+r2;
  2360. X        if(ret < 0.0)
  2361. X            return 0;
  2362. X        ret2 = ret;
  2363. X        ret = (-(2*m*c-2*m*y3-2*x3) + sqrt(ret))/2.0/(m2+1) ;
  2364. X        ret2 = (-(2*m*c-2*m*y3-2*x3) - sqrt(ret2))/2.0/(m2+1) ;
  2365. X
  2366. X        if(x1 < x2)
  2367. X        {
  2368. X            if(((int)ret <= x2 && (int)ret >= x1)||
  2369. X            ((int)ret2 <= x2 && (int)ret2 >= x1))
  2370. X            {
  2371. X                if(ret < ret2) return ret;
  2372. X                return ret2;
  2373. X            }
  2374. X            return 0;
  2375. X        }
  2376. X        else
  2377. X        {
  2378. X            if(((int)ret <= x1 && (int)ret >= x2)||
  2379. X            ((int)ret2 <= x1 && (int)ret2 >= x2))
  2380. X            {
  2381. X                if(ret > ret2) return ret;
  2382. X                return ret2;
  2383. X            }
  2384. X            return 0;
  2385. X        }
  2386. X            
  2387. X    }
  2388. X}
  2389. X        
  2390. END_OF_FILE
  2391. if test 2558 -ne `wc -c <'polygon.c'`; then
  2392.     echo shar: \"'polygon.c'\" unpacked with wrong size!
  2393. fi
  2394. # end of 'polygon.c'
  2395. fi
  2396. if test -f 'rad1.npc' -a "${1}" != "-c" ; then 
  2397.   echo shar: Will not clobber existing file \"'rad1.npc'\"
  2398. else
  2399. echo shar: Extracting \"'rad1.npc'\" \(3358 characters\)
  2400. sed "s/^X//" >'rad1.npc' <<'END_OF_FILE'
  2401. XNPC
  2402. XName = rad1npc
  2403. XShip = Oldsmobile
  2404. XEnergyMax  = 1000
  2405. XLShieldMax =  600
  2406. XRShieldMax =  600
  2407. XBShieldMax =  400
  2408. XSolar = 2
  2409. XShortRange = 1
  2410. XEngine = 3
  2411. XRepair = 2
  2412. XLongRange = 1
  2413. XJammer = none
  2414. XTC = none
  2415. X
  2416. XWeapons
  2417. XPulse
  2418. X
  2419. Xvar
  2420. Xend
  2421. X
  2422. XProc evadeWall
  2423. X{
  2424. Xvar 
  2425. X    u
  2426. X    d
  2427. X    l
  2428. X    r
  2429. X    angto
  2430. Xend
  2431. X    l = 0;
  2432. X    u = 0;
  2433. X    d = 0;
  2434. X    r = 0;
  2435. X
  2436. X    if (XPos*XVel > 50000 && XVel > 0) r = 1;
  2437. X    if (XPos*XVel > 50000 && XVel < 0) l = 1;
  2438. X    if (YPos*YVel > 50000 && YVel > 0) u = 1;
  2439. X    if (YPos*YVel > 50000 && YVel < 0) d = 1;
  2440. X
  2441. X    if (r && u) 
  2442. X    {
  2443. X        angto=225;
  2444. X        set TurnTo = 225;
  2445. X        set B3 = 1;
  2446. X        return;
  2447. X    }
  2448. X    if (r && d) 
  2449. X    {
  2450. X        angto=315;
  2451. X        set TurnTo = 315;
  2452. X        set B3 = 1;
  2453. X        return;
  2454. X    }
  2455. X    if (l && u) 
  2456. X    {
  2457. X        angto=135;
  2458. X        set TurnTo = 135;
  2459. X        set B3 = 1;
  2460. X        return;
  2461. X    }
  2462. X    if (l && d) 
  2463. X    {
  2464. X        angto=45;
  2465. X        set TurnTo = 45;
  2466. X        set B3 = 1;
  2467. X        return;
  2468. X    }
  2469. X    if (r)
  2470. X    {
  2471. X        angto=270;
  2472. X        set TurnTo = 270;
  2473. X        set B3 = 1;
  2474. X        return;
  2475. X    }
  2476. X    if (l)
  2477. X    {
  2478. X        angto=90;
  2479. X        set TurnTo = 90;
  2480. X        set B3 = 1;
  2481. X        return;
  2482. X    }
  2483. X    if (d)
  2484. X    {
  2485. X        angto=0;
  2486. X        set TurnTo = 0;
  2487. X        set B3 = 1;
  2488. X        return;
  2489. X    }
  2490. X    if (u)
  2491. X    {
  2492. X        angto=180;
  2493. X        set TurnTo = 180;
  2494. X        set B3 = 1;
  2495. X        return;
  2496. X    }
  2497. X
  2498. X    return;
  2499. X}
  2500. X
  2501. X
  2502. XProc attack
  2503. X{
  2504. Xvar
  2505. X        num
  2506. X    a1
  2507. X    a2
  2508. X    a3
  2509. Xend
  2510. X    set B3 = 0;
  2511. X    a2 = EnemyAngle;
  2512. X    a3 = EnemyAngle;
  2513. X    while(EnemyDist < 1000)
  2514. X    {
  2515. X        num=NumEnemies;
  2516. X        set SelectEnemy = 0;
  2517. X        set RepairToggle = 1;
  2518. X        set Balance = 1;
  2519. X
  2520. X        if((EnemySpeed < 20) && (Speed < 10))
  2521. X            set B3 = 1;
  2522. X        else
  2523. X            set B3 = 0;
  2524. X
  2525. X        if(Energy < 250)
  2526. X        {
  2527. X            set B1 = 0;
  2528. X            set B3 = 0;
  2529. X            return; 
  2530. X        }
  2531. X
  2532. X        a1 = a2;
  2533. X        a2 = a3;
  2534. X        a3 = EnemyAngle;
  2535. X
  2536. X        set TurnTo = (EnemyAngle + 
  2537. X            ((a3 - a2) + (a3 - a2 - a2 + a1)) * (Speed / 8 + 1)) % 360;
  2538. X        if(((Angle - EnemyAngle) % 360 > - 30) && ((Angle - EnemyAngle) % 360 < 30))  
  2539. X        {
  2540. X            set B1 = 1;
  2541. X            set B3 = 1;
  2542. X        }
  2543. X        else
  2544. X        {
  2545. X            set B1 = 0; 
  2546. X            set B3 = 0;
  2547. X        }
  2548. X    }
  2549. X    set B1 = 0;
  2550. X    set B3 = 0;
  2551. X    return;
  2552. X}
  2553. X
  2554. XProc slowDown
  2555. X{
  2556. X    set TurnTo = (Direction + 180) % 360;
  2557. X    set B3 = 1;
  2558. X    while(Speed > 15)
  2559. X    {
  2560. X        if(Angle != (Direction + 180) % 360)
  2561. X            set TurnTo = Direction + 180;
  2562. X    }
  2563. X    set B3 = 0;
  2564. X    return;
  2565. X}
  2566. X
  2567. XProc repair
  2568. X{
  2569. Xvar
  2570. X    num
  2571. Xend
  2572. X    slowDown();
  2573. X    while((Energy < 250) && ((RShield < 300) || (LShield < 300)))
  2574. X    {
  2575. X        num = NumEnemies;
  2576. X        set SelectEnemy = 0;
  2577. X        if(EnemyDist < 1000)
  2578. X            return;
  2579. X    }
  2580. X    return;
  2581. X}
  2582. X
  2583. XProc aim
  2584. X{
  2585. Xvar
  2586. X    num
  2587. Xend
  2588. X}
  2589. X
  2590. X
  2591. XProc thrust
  2592. X{
  2593. Xvar
  2594. X    num
  2595. X    i
  2596. X    aa1
  2597. X    aa2
  2598. X    aa3
  2599. Xend
  2600. X    num = NumEnemies;
  2601. X    set SelectEnemy = 0;
  2602. X    aa2 = EnemyAngle;
  2603. X    aa3 = EnemyAngle;
  2604. X
  2605. X    i = 0;
  2606. X    while (i < 3)
  2607. X    {
  2608. X        num = NumEnemies;
  2609. X        set SelectEnemy = 0;
  2610. X
  2611. X        aa1 = aa2;
  2612. X        aa2 = aa3;
  2613. X        aa3 = EnemyAngle;
  2614. X        if((Energy < 250) && ((RShield < 300) || (LShield < 300)))
  2615. X        {
  2616. X            if(EnemyDist < 1000)
  2617. X            {
  2618. X                set TurnTo = (EnemyAngle + 180 +
  2619. X                    ((aa3 - aa2) + (aa3 - aa2 - aa2 + aa1)) *
  2620. X                    (Speed / 8 + 1)) % 360;
  2621. X                set B3 = 1;
  2622. X            }
  2623. X            else
  2624. X                repair();
  2625. X        }
  2626. X        else
  2627. X        {
  2628. X            set TurnTo = (EnemyAngle +
  2629. X                ((aa3 - aa2) + (aa3 - aa2 - aa2 + aa1)) *
  2630. X                (Speed / 8 + 1)) % 360;
  2631. X                attack();
  2632. X        }
  2633. X
  2634. X        if(Energy > 600)
  2635. X            set B3 = 1;
  2636. X        else
  2637. X            set B3 = 0;
  2638. X        i = i + 1;
  2639. X    }
  2640. X    return;
  2641. X}
  2642. X
  2643. X
  2644. XProc drift
  2645. X{
  2646. Xvar
  2647. X    i
  2648. Xend
  2649. X    set B3 = 0;
  2650. X    i = 0;
  2651. X    while (i < 5)
  2652. X        i = i + 1;
  2653. X    return;
  2654. X}
  2655. X
  2656. X
  2657. XProc seek
  2658. X{
  2659. X    if(NumEnemies > 0)
  2660. X        thrust();
  2661. X    drift();
  2662. X    return;
  2663. X}
  2664. X
  2665. X
  2666. XState loop
  2667. X{
  2668. X    set RepairToggle = 1;
  2669. X    set Balance= 1;
  2670. X
  2671. X    if ((XPos*XVel > 50000 && XVel > 0) ||
  2672. X        (XPos*XVel > 50000 && XVel < 0) ||
  2673. X        (YPos*YVel > 50000 && YVel > 0) ||
  2674. X        (YPos*YVel > 50000 && YVel < 0))
  2675. X        evadeWall();
  2676. X    else
  2677. X        seek();
  2678. X}
  2679. X
  2680. XState main
  2681. X{
  2682. X    set B2 = 1;
  2683. X    1 -> loop;
  2684. X}
  2685. X
  2686. XStart main
  2687. END_OF_FILE
  2688. if test 3358 -ne `wc -c <'rad1.npc'`; then
  2689.     echo shar: \"'rad1.npc'\" unpacked with wrong size!
  2690. fi
  2691. # end of 'rad1.npc'
  2692. fi
  2693. if test -f 'shop.man' -a "${1}" != "-c" ; then 
  2694.   echo shar: Will not clobber existing file \"'shop.man'\"
  2695. else
  2696. echo shar: Extracting \"'shop.man'\" \(4738 characters\)
  2697. sed "s/^X//" >'shop.man' <<'END_OF_FILE'
  2698. X.TH Xmpb 6
  2699. X.SH NAME
  2700. Xshop - xmpb shop program
  2701. X.SH SYPNOSIS
  2702. X.ta 4n
  2703. X\fIshop\fR Name
  2704. X
  2705. X.SH DESCRIPTION
  2706. X
  2707. X    The shop program is part of the xmpb package.
  2708. X
  2709. X    The shop allows you to buy, sell or repair your current ship.
  2710. XTo run the shop, type:
  2711. X
  2712. X        shop Name      (where Name is the name of your character)
  2713. X
  2714. XThen you will be presented with a small window, which is a security check.
  2715. XWhen you have correctly typed in your password, then the shop will open up.
  2716. X
  2717. XWhen you get into the shop, you will see a series of buttons on the top, 
  2718. Xtwo areas underneath this, labelled: "Items in the shop:" and 
  2719. X"Items in your ship:" The Items in your ship area will be filled with a list 
  2720. Xof all the items that your ship has left, and what state they are in.  If you
  2721. Xdidn't lose any items, then you should have the top five lines filled with
  2722. XSolar Panels, Short Range Radar, Engine, Repair System, and Long Range Radar.
  2723. X
  2724. XIf one of these items is missing, then it is probably a good idea to get
  2725. Xanother, as each of these items are REALLY useful when playing the game.
  2726. XBelow this you might have a Jammer and/or a Targeting Computer.  And below that
  2727. Xyou will have the values of your left, right and bottom shields and your Energy.
  2728. X
  2729. XAt any stage you can click on one of the items and see how much it is worth,
  2730. Xand how much it would cost to repair (if it is damaged).  To repair the item, 
  2731. Xclick on the button labelled "Repair", situated below the Items in your ship
  2732. Xlist.  This will deduct the cost and repair the item for you.
  2733. X
  2734. XIf you want to get rid of the item, then you can sell it.  (Click on the
  2735. XButton marked "Sell" beside the Repair button).
  2736. X
  2737. XBeside the Sell Button is the Button marked Show Weapons.  When you click 
  2738. Xon this button, then the Items in your ship area will show which weapons
  2739. Xyou own.  And the button will then change to a "Show Items" button.  Clicking
  2740. Xon this will allow you to go back to viewing the items.
  2741. X
  2742. XWhen looking at weapons in your ship, you can click on one and see how 
  2743. Xmuch it is worth and/or sell it.
  2744. X
  2745. XNow to the interesting bit.  Buying bigger and better items and weapons :^)
  2746. X
  2747. XEach of the top buttons: Engines, Solar Panels, Radar, Weapons, Repair 
  2748. XSystems, Miscellaneous, Shields and Energy is a menu.  Click on any of them 
  2749. Xand a series of options will be displayed.  Choose one, and in the items in 
  2750. Xthe shop area, The details of the item chosen will appear.  The cost will be 
  2751. Xdisplayed down the bottom.  If you have enough money, the Buy button, will
  2752. Xlet you buy the item.
  2753. X
  2754. XIf you already have one of these items:  (E.g.  I have an Engine(3) and
  2755. Xdecide to Buy and Engine(4), then the Buy button will put up a notice telling
  2756. Xyou that you already have one.  If you still wish to buy the item (as I would
  2757. Xin this case), then I click OK and the shop will sell off the exisiting item,
  2758. Xthe Engine(3), and buy the new item: the Engine(4).  Clicking CANCEL will 
  2759. Xstop the purchase.
  2760. X
  2761. XFinally of course there is the Quit button, which amazingly enough will quit
  2762. Xthe shop.  Avoid using the Quit given by your window manager, as the quit button
  2763. Xdoes some cleaning up before finishing.
  2764. X
  2765. X
  2766. XFor those interested (Programmers):
  2767. X
  2768. XThe    shop has a text file called: shop.contents that lists all the items, 
  2769. Xtheir descriptions and the cost of them.  This means that if you feel one of
  2770. Xthe items is too dear, too cheap etc.  You can change this file and balance
  2771. Xthe game out.  (This of course can only be done by the person installing the
  2772. Xgame, so choose someone vaguely trustworthy).
  2773. X
  2774. XOther programming tips:  Don't even look at the code, it is real ugly.  I
  2775. Xwhipped it up real fast and with several design changes whilst coding.  BUT the
  2776. Xthing works :^)
  2777. X
  2778. X.SH TROUBLESHOOTING
  2779. X
  2780. X    If the shop doesn't run:
  2781. X
  2782. X
  2783. X    Usage: Shop Name  -  this means that you haven't given the shop 1 parameter
  2784. X                         which should be the Name of the character.
  2785. X
  2786. X
  2787. X    No such player: No such file or directory
  2788. X    Exiting...
  2789. X
  2790. X- This is because the name given is not the same as the one you typed
  2791. Xin when you play xmpb.  Watch out for extra spaces.  Or of course,
  2792. Xthe character might not exist (? Maybe you retired it ?)
  2793. X
  2794. XYou cannot execute the shop when you have an active xmpb window.
  2795. XQuit your xmpb window and then run the shop
  2796. X
  2797. X- This means that you cannot run a game of xmpb and the shop at the
  2798. Xsame time.  If you want to go to the shop, then you should quit
  2799. Xthe current game.  If this message occurs even when you have 
  2800. Xfinished xmpb, then I have stuffed up, and you need to 
  2801. Xuse the program: clear_lock
  2802. X
  2803. X.SH BUGS
  2804. X
  2805. XHmmm,  probably heaps.  But at the moment I have ironed out all the ones
  2806. XI know about, so fingers crossed.  
  2807. X
  2808. XThe shop icon is atrocious.   Still that is what you get for one too many
  2809. Xbeers and no better design.
  2810. X
  2811. X.SH AUTHORS
  2812. X.br
  2813. X    Shane Hyde
  2814. X.br
  2815. X    Damien De Paoli
  2816. END_OF_FILE
  2817. if test 4738 -ne `wc -c <'shop.man'`; then
  2818.     echo shar: \"'shop.man'\" unpacked with wrong size!
  2819. fi
  2820. # end of 'shop.man'
  2821. fi
  2822. echo shar: End of archive 6 \(of 8\).
  2823. cp /dev/null ark6isdone
  2824. MISSING=""
  2825. for I in 1 2 3 4 5 6 7 8 ; do
  2826.     if test ! -f ark${I}isdone ; then
  2827.     MISSING="${MISSING} ${I}"
  2828.     fi
  2829. done
  2830. if test "${MISSING}" = "" ; then
  2831.     echo You have unpacked all 8 archives.
  2832.     rm -f ark[1-9]isdone
  2833. else
  2834.     echo You still need to unpack the following archives:
  2835.     echo "        " ${MISSING}
  2836. fi
  2837. ##  End of shell archive.
  2838. exit 0
  2839.