1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32: #include <sys/cdefs.h>
33: #ifndef lint
34: #if 0
35: static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93";
36: #else
37: __RCSID("$NetBSD: kill.c,v 1.7 2003/08/07 09:37:52 agc Exp $");
38: #endif
39: #endif
40:
41: #include <stdio.h>
42: #include "trek.h"
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60: void
61: killk(ix, iy)
62: int ix, iy;
63: {
64: int i;
65:
66: printf(" *** Klingon at %d,%d destroyed ***\n", ix, iy);
67:
68:
69: Now.klings -= 1;
70: Sect[ix][iy] = EMPTY;
71: Quad[Ship.quadx][Ship.quady].klings -= 1;
72:
73: Quad[Ship.quadx][Ship.quady].scanned -= 100;
74: Game.killk += 1;
75:
76:
77: for (i = 0; i < Etc.nkling; i++)
78: if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y)
79: {
80:
81: Etc.nkling -= 1;
82: for (; i < Etc.nkling; i++)
83: Etc.klingon[i] = Etc.klingon[i+1];
84: break;
85: }
86:
87:
88: if (Now.klings <= 0)
89: win();
90:
91:
92: Now.time = Now.resource / Now.klings;
93: return;
94: }
95:
96:
97:
98:
99:
100:
101: void
102: killb(qx, qy)
103: int qx, qy;
104: {
105: struct quad *q;
106: struct xy *b;
107:
108: q = &Quad[qx][qy];
109:
110: if (q->bases <= 0)
111: return;
112: if (!damaged(SSRADIO)) {
113:
114: if (q->scanned < 1000)
115: q->scanned -= 10;
116: else
117: if (q->scanned > 1000)
118: q->scanned = -1;
119: }
120: q->bases = 0;
121: Now.bases -= 1;
122: for (b = Now.base; ; b++)
123: if (qx == b->x && qy == b->y)
124: break;
125: *b = Now.base[Now.bases];
126: if (qx == Ship.quadx && qy == Ship.quady)
127: {
128: Sect[Etc.starbase.x][Etc.starbase.y] = EMPTY;
129: if (Ship.cond == DOCKED)
130: undock(0);
131: printf("Starbase at %d,%d destroyed\n", Etc.starbase.x, Etc.starbase.y);
132: }
133: else
134: {
135: if (!damaged(SSRADIO))
136: {
137: printf("Uhura: Starfleet command reports that the starbase in\n");
138: printf(" quadrant %d,%d has been destroyed\n", qx, qy);
139: }
140: else
141: schedule(E_KATSB | E_GHOST, 1e50, qx, qy, 0);
142: }
143: }
144:
145:
146:
147:
148:
149:
150: void
151: kills(x, y, f)
152: int x, y;
153: int f;
154: {
155: struct quad *q;
156: struct event *e;
157: const char *name;
158:
159: if (f)
160: {
161:
162: q = &Quad[Ship.quadx][Ship.quady];
163: Sect[x][y] = EMPTY;
164: name = systemname(q);
165: if (name == 0)
166: return;
167: printf("Inhabited starsystem %s at %d,%d destroyed\n",
168: name, x, y);
169: if (f < 0)
170: Game.killinhab += 1;
171: }
172: else
173: {
174:
175: q = &Quad[x][y];
176: }
177: if (q->qsystemname & Q_DISTRESSED)
178: {
179:
180: e = &Event[q->qsystemname & Q_SYSTEM];
181: printf("Distress call for %s invalidated\n",
182: Systemname[e->systemname]);
183: unschedule(e);
184: }
185: q->qsystemname = 0;
186: q->stars -= 1;
187: }
188:
189:
190:
191:
192:
193:
194: void
195: killd(x, y, f)
196: int x, y;
197: int f;
198: {
199: struct event *e;
200: int i;
201: struct quad *q;
202:
203: q = &Quad[x][y];
204: for (i = 0; i < MAXEVENTS; i++)
205: {
206: e = &Event[i];
207: if (e->x != x || e->y != y)
208: continue;
209: switch (e->evcode)
210: {
211: case E_KDESB:
212: if (f)
213: {
214: printf("Distress call for starbase in %d,%d nullified\n",
215: x, y);
216: unschedule(e);
217: }
218: break;
219:
220: case E_ENSLV:
221: case E_REPRO:
222: if (f)
223: {
224: printf("Distress call for %s in quadrant %d,%d nullified\n",
225: Systemname[e->systemname], x, y);
226: q->qsystemname = e->systemname;
227: unschedule(e);
228: }
229: else
230: {
231: e->evcode |= E_GHOST;
232: }
233: }
234: }
235: }