1 /* @(#)kill.c 8.1 (Berkeley) 5/31/93 */
2 /* $NetBSD: kill.c,v 1.11 2009/05/24 22:55:03 dholland Exp $ */
5 * Copyright (c) 1980, 1993
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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
40 ** This file handles the killing off of almost anything.
44 ** Handle a Klingon's death
46 ** The Klingon at the sector given by the parameters is killed
47 ** and removed from the Klingon list. Notice that it is not
48 ** removed from the event list; this is done later, when the
49 ** the event is to be caught. Also, the time left is recomputed,
50 ** and the game is won if that was the last klingon.
58 printf(" *** Klingon at %d,%d destroyed ***\n", ix
, iy
);
60 /* remove the scoundrel */
63 Quad
[Ship
.quadx
][Ship
.quady
].klings
-= 1;
64 /* %%% IS THIS SAFE???? %%% */
65 Quad
[Ship
.quadx
][Ship
.quady
].scanned
-= 100;
68 /* find the Klingon in the Klingon list */
69 for (i
= 0; i
< Etc
.nkling
; i
++)
70 if (ix
== Etc
.klingon
[i
].x
&& iy
== Etc
.klingon
[i
].y
) {
71 /* purge him from the list */
73 for (; i
< Etc
.nkling
; i
++)
74 Etc
.klingon
[i
] = Etc
.klingon
[i
+1];
78 /* find out if that was the last one */
82 /* recompute time left */
83 Now
.time
= Now
.resource
/ Now
.klings
;
89 ** handle a starbase's death
102 if (!damaged(SSRADIO
)) {
103 /* then update starchart */
104 if (q
->scanned
< 1000)
107 if (q
->scanned
> 1000)
112 for (b
= Now
.base
; ; b
++)
113 if (qx
== b
->x
&& qy
== b
->y
)
115 *b
= Now
.base
[Now
.bases
];
116 if (qx
== Ship
.quadx
&& qy
== Ship
.quady
) {
117 Sect
[Etc
.starbase
.x
][Etc
.starbase
.y
] = EMPTY
;
118 if (Ship
.cond
== DOCKED
)
120 printf("Starbase at %d,%d destroyed\n",
121 Etc
.starbase
.x
, Etc
.starbase
.y
);
123 if (!damaged(SSRADIO
)) {
124 printf("Uhura: Starfleet command reports that the "
126 printf(" quadrant %d,%d has been destroyed\n",
130 schedule(E_KATSB
| E_GHOST
, TOOLARGE
, qx
, qy
, 0);
136 ** kill an inhabited starsystem
138 ** x, y are quad coords if f == 0, else sector coords
139 ** f != 0 -- this quad; f < 0 -- Enterprise's fault
143 kills(int x
, int y
, int f
)
150 /* current quadrant */
151 q
= &Quad
[Ship
.quadx
][Ship
.quady
];
153 name
= systemname(q
);
156 printf("Inhabited starsystem %s at %d,%d destroyed\n",
161 /* different quadrant */
164 if (q
->qsystemname
& Q_DISTRESSED
) {
165 /* distressed starsystem */
166 e
= &Event
[q
->qsystemname
& Q_SYSTEM
];
167 printf("Distress call for %s invalidated\n",
168 Systemname
[e
->systemname
]);
177 ** "kill" a distress call
179 ** x, y are quadrant coordinates
180 ** f is set if user is to be informed
184 killd(int x
, int y
, int f
)
191 for (i
= 0; i
< MAXEVENTS
; i
++) {
193 if (e
->x
!= x
|| e
->y
!= y
)
198 printf("Distress call for starbase in "
208 printf("Distress call for %s in quadrant "
210 Systemname
[e
->systemname
], x
, y
);
211 q
->qsystemname
= e
->systemname
;
214 e
->evcode
|= E_GHOST
;