1 /* $OpenBSD: ram.c,v 1.5 2009/10/27 23:59:27 deraadt Exp $ */ 2 /* $NetBSD: ram.c,v 1.3 1995/04/22 10:59:19 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1980, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 #include <stdio.h> 34 #include <unistd.h> 35 #include "trek.h" 36 37 /* 38 ** RAM SOME OBJECT 39 ** 40 ** You have run into some sort of object. It may be a Klingon, 41 ** a star, or a starbase. If you run into a star, you are really 42 ** stupid, because there is no hope for you. 43 ** 44 ** If you run into something else, you destroy that object. You 45 ** also rack up incredible damages. 46 */ 47 48 void 49 ram(ix, iy) 50 int ix, iy; 51 { 52 int i; 53 char c; 54 55 printf("\07RED ALERT\07: collision imminent\n"); 56 c = Sect[ix][iy]; 57 switch (c) 58 { 59 60 case KLINGON: 61 printf("%s rams Klingon at %d,%d\n", Ship.shipname, ix, iy); 62 killk(ix, iy); 63 break; 64 65 case STAR: 66 case INHABIT: 67 printf("Yeoman Rand: Captain, isn't it getting hot in here?\n"); 68 sleep(2); 69 printf("Spock: Hull temperature approaching 550 Degrees Kelvin.\n"); 70 lose(L_STAR); 71 72 case BASE: 73 printf("You ran into the starbase at %d,%d\n", ix, iy); 74 killb(Ship.quadx, Ship.quady); 75 /* don't penalize the captain if it wasn't his fault */ 76 if (!damaged(SINS)) 77 Game.killb += 1; 78 break; 79 } 80 sleep(2); 81 printf("%s heavily damaged\n", Ship.shipname); 82 83 /* select the number of deaths to occur */ 84 i = 10 + ranf(20 * Game.skill); 85 Game.deaths += i; 86 Ship.crew -= i; 87 printf("McCoy: Take it easy Jim; we had %d casualties.\n", i); 88 89 /* damage devices with an 80% probability */ 90 for (i = 0; i < NDEV; i++) 91 { 92 if (ranf(100) < 20) 93 continue; 94 damage(i, (2.5 * (franf() + franf()) + 1.0) * Param.damfac[i]); 95 } 96 97 /* no chance that your shields remained up in all that */ 98 Ship.shldup = 0; 99 } 100