1 /* $NetBSD: kill.c,v 1.7 2003/08/07 09:37:52 agc Exp $ */
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93";
37 __RCSID("$NetBSD: kill.c,v 1.7 2003/08/07 09:37:52 agc Exp $");
47 ** This file handles the killing off of almost anything.
51 ** Handle a Klingon's death
53 ** The Klingon at the sector given by the parameters is killed
54 ** and removed from the Klingon list. Notice that it is not
55 ** removed from the event list; this is done later, when the
56 ** the event is to be caught. Also, the time left is recomputed,
57 ** and the game is won if that was the last klingon.
66 printf(" *** Klingon at %d,%d destroyed ***\n", ix
, iy
);
68 /* remove the scoundrel */
71 Quad
[Ship
.quadx
][Ship
.quady
].klings
-= 1;
72 /* %%% IS THIS SAFE???? %%% */
73 Quad
[Ship
.quadx
][Ship
.quady
].scanned
-= 100;
76 /* find the Klingon in the Klingon list */
77 for (i
= 0; i
< Etc
.nkling
; i
++)
78 if (ix
== Etc
.klingon
[i
].x
&& iy
== Etc
.klingon
[i
].y
)
80 /* purge him from the list */
82 for (; i
< Etc
.nkling
; i
++)
83 Etc
.klingon
[i
] = Etc
.klingon
[i
+1];
87 /* find out if that was the last one */
91 /* recompute time left */
92 Now
.time
= Now
.resource
/ Now
.klings
;
98 ** handle a starbase's death
112 if (!damaged(SSRADIO
)) {
113 /* then update starchart */
114 if (q
->scanned
< 1000)
117 if (q
->scanned
> 1000)
122 for (b
= Now
.base
; ; b
++)
123 if (qx
== b
->x
&& qy
== b
->y
)
125 *b
= Now
.base
[Now
.bases
];
126 if (qx
== Ship
.quadx
&& qy
== Ship
.quady
)
128 Sect
[Etc
.starbase
.x
][Etc
.starbase
.y
] = EMPTY
;
129 if (Ship
.cond
== DOCKED
)
131 printf("Starbase at %d,%d destroyed\n", Etc
.starbase
.x
, Etc
.starbase
.y
);
135 if (!damaged(SSRADIO
))
137 printf("Uhura: Starfleet command reports that the starbase in\n");
138 printf(" quadrant %d,%d has been destroyed\n", qx
, qy
);
141 schedule(E_KATSB
| E_GHOST
, 1e50
, qx
, qy
, 0);
147 ** kill an inhabited starsystem
152 int x
, y
; /* quad coords if f == 0, else sector coords */
153 int f
; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */
161 /* current quadrant */
162 q
= &Quad
[Ship
.quadx
][Ship
.quady
];
164 name
= systemname(q
);
167 printf("Inhabited starsystem %s at %d,%d destroyed\n",
174 /* different quadrant */
177 if (q
->qsystemname
& Q_DISTRESSED
)
179 /* distressed starsystem */
180 e
= &Event
[q
->qsystemname
& Q_SYSTEM
];
181 printf("Distress call for %s invalidated\n",
182 Systemname
[e
->systemname
]);
191 ** "kill" a distress call
196 int x
, y
; /* quadrant coordinates */
197 int f
; /* set if user is to be informed */
204 for (i
= 0; i
< MAXEVENTS
; i
++)
207 if (e
->x
!= x
|| e
->y
!= y
)
214 printf("Distress call for starbase in %d,%d nullified\n",
224 printf("Distress call for %s in quadrant %d,%d nullified\n",
225 Systemname
[e
->systemname
], x
, y
);
226 q
->qsystemname
= e
->systemname
;
231 e
->evcode
|= E_GHOST
;