X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/77e3814f0c0e3dea4d0032e25666f77e6f83bfff..bdafda27046fab8d24e4e422b04574856b8b1d28:/trek/attack.c diff --git a/trek/attack.c b/trek/attack.c index 61c23ed0..a9bc4e20 100644 --- a/trek/attack.c +++ b/trek/attack.c @@ -1,6 +1,8 @@ +/* $NetBSD: attack.c,v 1.9 2009/05/24 22:55:03 dholland Exp $ */ + /* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,11 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,11 +29,18 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char sccsid[] = "@(#)attack.c 5.4 (Berkeley) 6/1/90"; +#if 0 +static char sccsid[] = "@(#)attack.c 8.1 (Berkeley) 5/31/93"; +#else +__RCSID("$NetBSD: attack.c,v 1.9 2009/05/24 22:55:03 dholland Exp $"); +#endif #endif /* not lint */ -# include "trek.h" +#include +#include +#include "trek.h" /* ** Klingon Attack Routine @@ -65,17 +70,19 @@ static char sccsid[] = "@(#)attack.c 5.4 (Berkeley) 6/1/90"; ** entry for the particular device. ** ** Casualties can also occur. +** +** resting -- set if attack while resting */ -attack(resting) -int resting; /* set if attack while resting */ +void +attack(int resting) { - register int hit, i, l; - int maxhit, tothit, shldabsb; - double chgfac, propor, extradm; - double dustfac, tothe; - int cas; - int hitflag; + int hit, i, l; + int maxhit, tothit, shldabsb; + double chgfac, propor, extradm; + double dustfac, tothe; + int cas; + int hitflag; if (Move.free) return; @@ -85,10 +92,10 @@ int resting; /* set if attack while resting */ return; /* move before attack */ klmove(0); - if (Ship.cond == DOCKED) - { + if (Ship.cond == DOCKED) { if (!resting) - printf("Starbase shields protect the %s\n", Ship.shipname); + printf("Starbase shields protect the %s\n", + Ship.shipname); return; } /* setup shield effectiveness */ @@ -99,13 +106,11 @@ int resting; /* set if attack while resting */ hitflag = 0; /* let each Klingon do his damndest */ - for (i = 0; i < Etc.nkling; i++) - { + for (i = 0; i < Etc.nkling; i++) { /* if he's low on power he won't attack */ if (Etc.klingon[i].power < 20) continue; - if (!hitflag) - { + if (!hitflag) { printf("\nStardate %.2f: Klingon attack:\n", Now.date); hitflag++; @@ -116,11 +121,11 @@ int resting; /* set if attack while resting */ hit = Etc.klingon[i].power * pow(dustfac, tothe) * Param.hitfac; /* deplete his energy */ dustfac = Etc.klingon[i].power; - Etc.klingon[i].power = dustfac * Param.phasfac * (1.0 + (franf() - 0.5) * 0.2); + Etc.klingon[i].power = dustfac * Param.phasfac * + (1.0 + (franf() - 0.5) * 0.2); /* see how much of hit shields will absorb */ shldabsb = 0; - if (Ship.shldup || Move.shldchg) - { + if (Ship.shldup || Move.shldchg) { propor = Ship.shield; propor /= Param.shield; shldabsb = propor * chgfac * hit; @@ -129,9 +134,10 @@ int resting; /* set if attack while resting */ Ship.shield -= shldabsb; } /* actually do the hit */ - printf("HIT: %d units", hit); + printf("\aHIT: %d units", hit); if (!damaged(SRSCAN)) - printf(" from %d,%d", Etc.klingon[i].x, Etc.klingon[i].y); + printf(" from %d,%d", + Etc.klingon[i].x, Etc.klingon[i].y); cas = (shldabsb * 100) / hit; hit -= shldabsb; if (shldabsb > 0) @@ -144,22 +150,22 @@ int resting; /* set if attack while resting */ maxhit = hit; Ship.energy -= hit; /* see if damages occurred */ - if (hit >= (15 - Game.skill) * (25 - ranf(12))) - { - printf("CRITICAL HIT!!!\n"); + if (hit >= (15 - Game.skill) * (25 - ranf(12))) { + printf("\aCRITICAL HIT!!!\a\n"); /* select a device from probability vector */ cas = ranf(1000); for (l = 0; cas >= 0; l++) cas -= Param.damprob[l]; l -= 1; /* compute amount of damage */ - extradm = (hit * Param.damfac[l]) / (75 + ranf(25)) + 0.5; + extradm = (hit * Param.damfac[l]) / + (75 + ranf(25)) + 0.5; /* damage the device */ damage(l, extradm); - if (damaged(SHIELD)) - { + if (damaged(SHIELD)) { if (Ship.shldup) - printf("Sulu: Shields knocked down, captain.\n"); + printf("Sulu: Shields knocked down, " + "captain.\n"); Ship.shldup = 0; Move.shldchg = 0; } @@ -169,12 +175,11 @@ int resting; /* set if attack while resting */ } /* see what our casualities are like */ - if (maxhit >= 200 || tothit >= 500) - { + if (maxhit >= 200 || tothit >= 500) { cas = tothit * 0.015 * franf(); - if (cas >= 2) - { - printf("McCoy: we suffered %d casualties in that attack.\n", + if (cas >= 2) { + printf("McCoy: we suffered %d casualties in that " + "attack.\n", cas); Game.deaths += cas; Ship.crew -= cas;