2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)kill.c 8.1 (Berkeley) 5/31/93
30 * $FreeBSD: src/games/trek/kill.c,v 1.4 1999/11/30 03:49:49 billf Exp $
31 * $DragonFly: src/games/trek/kill.c,v 1.3 2006/09/07 21:19:44 pavalos Exp $
39 ** This file handles the killing off of almost anything.
43 ** Handle a Klingon's death
45 ** The Klingon at the sector given by the parameters is killed
46 ** and removed from the Klingon list. Notice that it is not
47 ** removed from the event list; this is done later, when the
48 ** the event is to be caught. Also, the time left is recomputed,
49 ** and the game is won if that was the last klingon.
57 printf(" *** Klingon at %d,%d destroyed ***\n", ix
, iy
);
59 /* remove the scoundrel */
62 Quad
[Ship
.quadx
][Ship
.quady
].klings
-= 1;
63 /* %%% IS THIS SAFE???? %%% */
64 Quad
[Ship
.quadx
][Ship
.quady
].scanned
-= 100;
67 /* find the Klingon in the Klingon list */
68 for (i
= 0; i
< Etc
.nkling
; i
++)
69 if (ix
== Etc
.klingon
[i
].x
&& iy
== Etc
.klingon
[i
].y
) {
70 /* purge him from the list */
72 for (; i
< Etc
.nkling
; i
++)
73 bmove(&Etc
.klingon
[i
+1], &Etc
.klingon
[i
], sizeof Etc
.klingon
[i
]);
77 /* find out if that was the last one */
81 /* recompute time left */
82 Now
.time
= Now
.resource
/ Now
.klings
;
88 ** handle a starbase's death
101 if (!damaged(SSRADIO
)) {
102 /* then update starchart */
103 if (q
->scanned
< 1000)
106 if (q
->scanned
> 1000)
111 for (b
= Now
.base
; ; b
++)
112 if (qx
== b
->x
&& qy
== b
->y
)
114 bmove(&Now
.base
[Now
.bases
], b
, sizeof *b
);
115 if (qx
== Ship
.quadx
&& qy
== Ship
.quady
) {
116 Sect
[Etc
.starbase
.x
][Etc
.starbase
.y
] = EMPTY
;
117 if (Ship
.cond
== DOCKED
)
119 printf("Starbase at %d,%d destroyed\n", Etc
.starbase
.x
, Etc
.starbase
.y
);
121 if (!damaged(SSRADIO
)) {
122 printf("Uhura: Starfleet command reports that the starbase in\n");
123 printf(" quadrant %d,%d has been destroyed\n", qx
, qy
);
126 schedule(E_KATSB
| E_GHOST
, TOOLARGE
, qx
, qy
, 0);
132 ** kill an inhabited starsystem
134 ** x, y are quad coords if f == 0, else sector coords
135 ** f != 0 -- this quad; f < 0 -- Enterprise's fault
139 kills(int x
, int y
, int f
)
146 /* current quadrant */
147 q
= &Quad
[Ship
.quadx
][Ship
.quady
];
149 name
= systemname(q
);
152 printf("Inhabited starsystem %s at %d,%d destroyed\n",
157 /* different quadrant */
160 if (q
->qsystemname
& Q_DISTRESSED
) {
161 /* distressed starsystem */
162 e
= &Event
[q
->qsystemname
& Q_SYSTEM
];
163 printf("Distress call for %s invalidated\n",
164 Systemname
[e
->systemname
]);
173 ** "kill" a distress call
175 ** x, y are quadrant coordinates
176 ** f is set if user is to be informed
180 killd(int x
, int y
, int f
)
187 for (i
= 0; i
< MAXEVENTS
; i
++) {
189 if (e
->x
!= x
|| e
->y
!= y
)
194 printf("Distress call for starbase in %d,%d nullified\n",
203 printf("Distress call for %s in quadrant %d,%d nullified\n",
204 Systemname
[e
->systemname
], x
, y
);
205 q
->qsystemname
= e
->systemname
;
208 e
->evcode
|= E_GHOST
;