2 * events.c -- event-queue handling
4 * This isn't a real event queue a la BSD Trek yet -- you can only have one
5 * event of each type active at any given time. Mostly these means we can
6 * only have one FDISTR/FENSLV/FREPRO sequence going at any given time;
7 * BSD Trek, from which we swiped the idea, can have up to 5.
12 event *unschedule(int evtype)
13 /* remove an event from the schedule */
15 game.future[evtype].date = FOREVER;
16 return &game.future[evtype];
19 int is_scheduled(int evtype)
20 /* is an event of specified type scheduled */
22 return game.future[evtype].date != FOREVER;
25 extern double scheduled(int evtype)
26 /* when will this event happen? */
28 return game.future[evtype].date;
31 event *schedule(int evtype, double offset)
32 /* schedule an event of specified type */
34 game.future[evtype].date = game.state.date + offset;
35 return &game.future[evtype];
38 void postpone(int evtype, double offset)
39 /* poistpone a scheduled event */
41 game.future[evtype].date += offset;
44 static bool cancelrest(void)
45 /* rest period is interrupted by event */
49 proutn(_("Mr. Spock- \"Captain, shall we cancel the rest period?\""));
61 /* run through the event queue looking for things to do */
63 int evcode, i=0, j, k, l;
64 double fintim = game.state.date + game.optime, datemin, xtime, repair, yank=0;
65 bool radio_was_broken, ictbeam = false, istract = false;
66 struct quadrant *pdest, *q;
71 prout("=== EVENTS from %.2f to %.2f:", game.state.date, fintim);
72 for (i = 1; i < NEVENTS; i++) {
74 case FSNOVA: proutn("=== Supernova "); break;
75 case FTBEAM: proutn("=== T Beam "); break;
76 case FSNAP: proutn("=== Snapshot "); break;
77 case FBATTAK: proutn("=== Base Attack "); break;
78 case FCDBAS: proutn("=== Base Destroy "); break;
79 case FSCMOVE: proutn("=== SC Move "); break;
80 case FSCDBAS: proutn("=== SC Base Destroy "); break;
81 case FDSPROB: proutn("=== Probe Move "); break;
82 case FDISTR: proutn("=== Distress Call "); break;
83 case FENSLV: proutn("=== Enlavement "); break;
84 case FREPRO: proutn("=== Klingon Build "); break;
87 prout("%.2f", scheduled(i));
94 radio_was_broken = damaged(DRADIO);
98 /* Select earliest extraneous event, evcode==0 if no events */
103 for (l = 1; l < NEVENTS; l++)
104 if (game.future[l].date < datemin) {
107 prout("== Event %d fires", evcode);
108 datemin = game.future[l].date;
110 xtime = datemin-game.state.date;
111 game.state.date = datemin;
112 /* Decrement Federation resources and recompute remaining time */
113 game.state.remres -= (game.state.remkl+4*game.state.remcom)*xtime;
114 game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);
115 if (game.state.remtime <=0) {
119 /* Any crew left alive? */
120 if (game.state.crew <=0) {
124 /* Is life support adequate? */
125 if (damaged(DLIFSUP) && game.condition != docked) {
126 if (game.lsupres < xtime && game.damage[DLIFSUP] > game.lsupres) {
130 game.lsupres -= xtime;
131 if (game.damage[DLIFSUP] <= xtime)
132 game.lsupres = game.inlsr;
136 if (game.condition == docked)
137 repair /= game.docfac;
138 /* Don't fix Deathray here */
139 for (l=0; l<NDEVICES; l++)
140 if (game.damage[l] > 0.0 && l != DDRAY)
141 game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);
142 /* If radio repaired, update star chart and attack reports */
143 if (radio_was_broken && !damaged(DRADIO)) {
144 prout(_("Lt. Uhura- \"Captain, the sub-space radio is working and"));
145 prout(_(" surveillance reports are coming in."));
152 prout(_(" The star chart is now up to date.\""));
155 /* Cause extraneous event EVCODE to occur */
156 game.optime -= xtime;
158 case FSNOVA: /* Supernova */
160 supernova(false, NULL);
161 schedule(FSNOVA, expran(0.5*game.intime));
162 if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
165 case FSPY: /* Check with spy to see if S.C. should tractor beam */
166 if (game.state.nscrem == 0 ||
167 ictbeam || istract ||
168 game.condition==docked || game.isatb==1 || game.iscate) return;
170 (game.energy < 2000 && game.torps < 4 && game.shield < 1250) ||
171 (damaged(DPHASER) && (damaged(DPHOTON) || game.torps < 4)) ||
173 (game.energy < 2500 || damaged(DPHASER)) &&
174 (game.torps < 5 || damaged(DPHOTON)))) {
175 /* Tractor-beam her! */
177 yank = distance(game.state.kscmdr, game.quadrant);
178 /********* fall through to FTBEAM code ***********/
182 case FTBEAM: /* Tractor beam */
183 if (evcode==FTBEAM) {
184 if (game.state.remcom == 0) {
188 i = Rand()*game.state.remcom+1.0;
189 yank = square(game.state.kcmdr[i].x-game.quadrant.x) + square(game.state.kcmdr[i].y-game.quadrant.y);
190 if (istract || game.condition == docked || yank == 0) {
191 /* Drats! Have to reschedule */
193 game.optime + expran(1.5*game.intime/game.state.remcom));
197 /* tractor beaming cases merge here */
200 game.optime = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */
205 prout(_(" caught in long range tractor beam--"));
206 /* If Kirk & Co. screwing around on planet, handle */
207 atover(true); /* atover(true) is Grab */
210 if (game.icraft) { /* Caught in Galileo? */
214 /* Check to see if shuttle is aboard */
215 if (game.iscraft == offship) {
218 prout(_("Galileo, left on the planet surface, is captured"));
219 prout(_("by aliens and made into a flying McDonald's."));
220 game.damage[DSHUTTL] = -10;
221 game.iscraft = removed;
224 prout(_("Galileo, left on the planet surface, is well hidden."));
228 game.quadrant = game.state.kscmdr;
230 game.quadrant = game.state.kcmdr[i];
231 game.sector = randplace(QUADSIZE);
233 proutn(_(" is pulled to "));
234 proutn(cramlc(quadrant, game.quadrant));
236 prout(cramlc(sector, game.sector));
238 prout(_("(Remainder of rest/repair period cancelled.)"));
239 game.resting = false;
242 if (!damaged(DSHIELD) && game.shield > 0) {
243 doshield(true); /* raise shields */
247 prout(_("(Shields not currently useable.)"));
250 /* Adjust finish time to time of tractor beaming */
251 fintim = game.state.date+game.optime;
253 if (game.state.remcom <= 0)
256 schedule(FTBEAM, game.optime+expran(1.5*game.intime/game.state.remcom));
258 case FSNAP: /* Snapshot of the universe (for time warp) */
259 game.snapsht = game.state;
260 game.state.snap = true;
261 schedule(FSNAP, expran(0.5 * game.intime));
263 case FBATTAK: /* Commander attacks starbase */
264 if (game.state.remcom==0 || game.state.rembase==0) {
271 for (j = 1; j <= game.state.rembase; j++) {
272 for (k = 1; k <= game.state.remcom; k++)
273 if (same(game.state.baseq[j], game.state.kcmdr[k]) &&
274 !same(game.state.baseq[j], game.quadrant) &&
275 !same(game.state.baseq[j], game.state.kscmdr)) {
282 if (j>game.state.rembase) {
283 /* no match found -- try later */
284 schedule(FBATTAK, expran(0.3*game.intime));
288 /* commander + starbase combination found -- launch attack */
289 game.battle = game.state.baseq[j];
290 schedule(FCDBAS, 1.0+3.0*Rand());
291 if (game.isatb) /* extra time if SC already attacking */
292 postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date);
293 game.future[FBATTAK].date = game.future[FCDBAS].date + expran(0.3*game.intime);
294 game.iseenit = false;
295 if (!damaged(DRADIO) && game.condition != docked)
296 break; /* No warning :-( */
300 proutn(_("Lt. Uhura- \"Captain, the starbase in "));
301 prout(cramlc(quadrant, game.battle));
302 prout(_(" reports that it is under attack and that it can"));
303 proutn(_(" hold out only until stardate %d"),
304 (int)scheduled(FCDBAS));
309 case FSCDBAS: /* Supercommander destroys base */
312 if (!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].starbase)
313 break; /* WAS RETURN! */
315 game.battle = game.state.kscmdr;
317 case FCDBAS: /* Commander succeeds in destroying base */
318 if (evcode==FCDBAS) {
320 /* find the lucky pair */
321 for (i = 1; i <= game.state.remcom; i++)
322 if (same(game.state.kcmdr[i], game.battle))
324 if (i > game.state.remcom || game.state.rembase == 0 ||
325 !game.state.galaxy[game.battle.x][game.battle.y].starbase) {
326 /* No action to take after all */
327 invalidate(game.battle);
331 /* Code merges here for any commander destroying base */
332 /* Not perfect, but will have to do */
333 /* Handle case where base is in same quadrant as starship */
334 if (same(game.battle, game.quadrant)) {
335 game.state.chart[game.battle.x][game.battle.y].starbase = false;
336 game.quad[game.base.x][game.base.y] = IHDOT;
337 game.base.x=game.base.y=0;
340 prout(_("Spock- \"Captain, I believe the starbase has been destroyed.\""));
342 else if (game.state.rembase != 1 &&
343 (!damaged(DRADIO) || game.condition == docked)) {
344 /* Get word via subspace radio */
347 prout(_("Lt. Uhura- \"Captain, Starfleet Command reports that"));
348 proutn(_(" the starbase in "));
349 proutn(cramlc(quadrant, game.battle));
350 prout(_(" has been destroyed by"));
352 prout(_("the Klingon Super-Commander"));
354 prout(_("a Klingon Commander"));
355 game.state.chart[game.battle.x][game.battle.y].starbase = false;
357 /* Remove Starbase from galaxy */
358 game.state.galaxy[game.battle.x][game.battle.y].starbase = false;
359 for (i = 1; i <= game.state.rembase; i++)
360 if (same(game.state.baseq[i], game.battle))
361 game.state.baseq[i] = game.state.baseq[game.state.rembase];
362 game.state.rembase--;
363 if (game.isatb == 2) {
364 /* reinstate a commander's base attack */
369 invalidate(game.battle);
371 case FSCMOVE: /* Supercommander moves */
372 schedule(FSCMOVE, 0.2777);
373 if (!game.ientesc && !istract && game.isatb != 1 &&
374 (!game.iscate || !game.justin))
377 case FDSPROB: /* Move deep space probe */
378 schedule(FDSPROB, 0.01);
379 game.probex += game.probeinx;
380 game.probey += game.probeiny;
381 i = (int)(game.probex/QUADSIZE +0.05);
382 j = (int)(game.probey/QUADSIZE + 0.05);
383 if (game.probec.x != i || game.probec.y != j) {
386 if (!VALID_QUADRANT(i, j) ||
387 game.state.galaxy[game.probec.x][game.probec.y].supernova) {
388 // Left galaxy or ran into supernova
389 if (!damaged(DRADIO) || game.condition == docked) {
392 proutn(_("Lt. Uhura- \"The deep space probe "));
393 if (!VALID_QUADRANT(j, i))
394 proutn(_("has left the galaxy"));
396 proutn(_("is no longer transmitting"));
402 if (!damaged(DRADIO) || game.condition == docked) {
405 proutn(_("Lt. Uhura- \"The deep space probe is now in "));
406 proutn(cramlc(quadrant, game.probec));
410 pdest = &game.state.galaxy[game.probec.x][game.probec.y];
411 /* Update star chart if Radio is working or have access to
413 if (!damaged(DRADIO) || game.condition == docked) {
414 struct page *chp = &game.state.chart[game.probec.x][game.probec.y];
416 chp->klingons = pdest->klingons;
417 chp->starbase = pdest->starbase;
418 chp->stars = pdest->stars;
419 pdest->charted = true;
421 game.proben--; // One less to travel
422 if (game.proben == 0 && game.isarmed && pdest->stars) {
423 /* lets blow the sucker! */
424 supernova(true, &game.probec);
426 if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
430 case FDISTR: /* inhabited system issues distress call */
432 /* try a whole bunch of times to find something suitable */
435 // need a quadrant which is not the current one,
436 // which has some stars which are inhabited and
437 // not already under attack, which is not
438 // supernova'ed, and which has some Klingons in it
439 w = randplace(GALSIZE);
440 q = &game.state.galaxy[w.x][w.y];
442 (same(game.quadrant, w) || q->planet == NOPLANET ||
443 game.state.planets[q->planet].inhabited == UNINHABITED ||
444 q->supernova || q->status!=secure || q->klingons<=0));
446 /* can't seem to find one; ignore this call */
448 prout("=== Couldn't find location for distress event.");
452 /* got one!! Schedule its enslavement */
453 ev = schedule(FENSLV, expran(game.intime));
455 q->status = distressed;
457 /* tell the captain about it if we can */
458 if (!damaged(DRADIO) || game.condition == docked)
460 prout(_("Uhura- Captain, %s in %s reports it is under attack"),
461 systnames[q->planet], cramlc(quadrant, w));
462 prout(_("by a Klingon invasion fleet."));
467 case FENSLV: /* starsystem is enslaved */
468 ev = unschedule(FENSLV);
469 /* see if current distress call still active */
470 q = &game.state.galaxy[ev->quadrant.x][ev->quadrant.y];
471 if (q->klingons <= 0) {
475 q->status = enslaved;
477 /* play stork and schedule the first baby */
478 ev2 = schedule(FREPRO, expran(2.0 * game.intime));
479 ev2->quadrant = ev->quadrant;
481 /* report the disaster if we can */
482 if (!damaged(DRADIO) || game.condition == docked)
484 prout(_("Uhura- We've lost contact with starsystem %s"),
485 systnames[q->planet]);
486 prout(_("in %s.\n"), cramlc(quadrant, ev->quadrant));
489 case FREPRO: /* Klingon reproduces */
490 // If we ever switch to a real event queue, we'll need to
491 // explicitly retrieve and restore the x and y.
492 ev = schedule(FREPRO, expran(1.0 * game.intime));
493 /* see if current distress call still active */
494 q = &game.state.galaxy[ev->quadrant.x][ev->quadrant.y];
495 if (q->klingons <= 0) {
499 if (game.state.remkl >=MAXKLGAME)
500 break; /* full right now */
501 /* reproduce one Klingon */
503 if (game.klhere >= MAXKLQUAD) {
504 /* this quadrant not ok, pick an adjacent one */
505 for (i = w.x - 1; i <= w.x + 1; i++)
507 for (j = w.y - 1; j <= w.y + 1; j++)
509 if (!VALID_QUADRANT(i, j))
511 q = &game.state.galaxy[w.x][w.y];
512 /* check for this quad ok (not full & no snova) */
513 if (q->klingons >= MAXKLQUAD || q->supernova)
518 break; /* search for eligible quadrant failed */
524 /* deliver the child */
527 if (same(game.quadrant, w))
528 newkling(++game.klhere);
530 /* recompute time left */
531 game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);
532 /* report the disaster if we can */
533 if (!damaged(DRADIO) || game.condition == docked)
535 if (same(game.quadrant, w)) {
536 prout(_("Spock- sensors indicate the Klingons have"));
537 prout(_("launched a warship from %s."), systnames[q->planet]);
539 prout(_("Uhura- Starfleet reports increased Klingon activity"));
540 if (q->planet != NOPLANET)
541 proutn(_("near %s"), systnames[q->planet]);
542 prout(_("in %s.\n"), cramlc(quadrant, w));
555 double temp, delay, origTime;
562 proutn(_("How long? "));
569 origTime = delay = aaitem;
572 if (delay >= game.state.remtime || game.nenhere != 0) {
573 proutn(_("Are you sure? "));
578 /* Alternate resting periods (events) with attacks */
583 game.resting = false;
585 prout(_("%d stardates left."), (int)game.state.remtime);
588 temp = game.optime = delay;
591 double rtime = 1.0 + Rand();
596 if (game.optime < delay)
605 /* Repair Deathray if long rest at starbase */
606 if (origTime-delay >= 9.99 && game.condition == docked)
607 game.damage[DDRAY] = 0.0;
609 // leave if quadrant supernovas
610 (!game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova);
612 game.resting = false;
617 * A nova occurs. It is the result of having a star hit with a
618 * photon torpedo, or possibly of a probe warhead going off.
619 * Stars that go nova cause stars which surround them to undergo
620 * the same probabilistic process. Klingons next to them are
621 * destroyed. And if the starship is next to it, it gets zapped.
622 * If the zap is too much, it gets destroyed.
627 static double course[] =
628 {0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5};
629 int bot, top, top2, hits[QUADSIZE+1][3], kount, icx, icy, mm, nn, j;
630 int iquad, iquad1, i, ll;
634 /* Wow! We've supernova'ed */
635 supernova(false, &nov);
639 /* handle initial nova */
640 game.quad[nov.x][nov.y] = IHDOT;
641 crmena(false, IHSTAR, sector, nov);
643 game.state.galaxy[game.quadrant.x][game.quadrant.y].stars--;
646 /* Set up stack to recursively trigger adjacent stars */
647 bot = top = top2 = 1;
653 for (mm = bot; mm <= top; mm++)
654 for (nn = 1; nn <= 3; nn++) /* nn,j represents coordinates around current */
655 for (j = 1; j <= 3; j++) {
658 scratch.x = hits[mm][1]+nn-2;
659 scratch.y = hits[mm][2]+j-2;
660 if (!VALID_SECTOR(scratch.y, scratch.x))
662 iquad = game.quad[scratch.x][scratch.y];
664 // case IHDOT: /* Empty space ends reaction
671 case IHSTAR: /* Affect another star */
673 /* This star supernovas */
674 supernova(false, &scratch);
678 hits[top2][1]=scratch.x;
679 hits[top2][2]=scratch.y;
680 game.state.galaxy[game.quadrant.x][game.quadrant.y].stars -= 1;
682 crmena(true, IHSTAR, sector, scratch);
684 game.quad[scratch.x][scratch.y] = IHDOT;
686 case IHP: /* Destroy planet */
687 game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NOPLANET;
688 game.state.nplankl++;
689 crmena(true, IHP, sector, scratch);
690 prout(_(" destroyed."));
691 game.state.planets[game.iplnet].pclass = destroyed;
693 invalidate(game.plnet);
698 game.quad[scratch.x][scratch.y] = IHDOT;
700 case IHB: /* Destroy base */
701 game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = false;
702 for (i = 1; i <= game.state.rembase; i++)
703 if (same(game.state.baseq[i], game.quadrant))
705 game.state.baseq[i] = game.state.baseq[game.state.rembase];
706 game.state.rembase--;
707 invalidate(game.base);
710 crmena(true, IHB, sector, scratch);
711 prout(_(" destroyed."));
712 game.quad[scratch.x][scratch.y] = IHDOT;
714 case IHE: /* Buffet ship */
716 prout(_("***Starship buffeted by nova."));
718 if (game.shield >= 2000.0)
719 game.shield -= 2000.0;
721 double diff = 2000.0 - game.shield;
725 prout(_("***Shields knocked out."));
726 game.damage[DSHIELD] += 0.005*game.damfac*Rand()*diff;
730 game.energy -= 2000.0;
731 if (game.energy <= 0) {
735 /* add in course nova contributes to kicking starship*/
736 icx += game.sector.x-hits[mm][1];
737 icy += game.sector.y-hits[mm][2];
740 case IHK: /* kill klingon */
741 deadkl(scratch,iquad, scratch);
743 case IHC: /* Damage/destroy big enemies */
746 for (ll = 1; ll <= game.nenhere; ll++)
747 if (same(game.ks[ll], scratch))
749 game.kpower[ll] -= 800.0; /* If firepower is lost, die */
750 if (game.kpower[ll] <= 0.0) {
751 deadkl(scratch, iquad, scratch);
754 newc.x = scratch.x + scratch.x - hits[mm][1];
755 newc.y = scratch.y + scratch.y - hits[mm][2];
756 crmena(true, iquad, sector, scratch);
757 proutn(_(" damaged"));
758 if (!VALID_SECTOR(newc.x, newc.y)) {
759 /* can't leave quadrant */
763 iquad1 = game.quad[newc.x][newc.y];
764 if (iquad1 == IHBLANK) {
765 proutn(_(", blasted into "));
766 crmena(false, IHBLANK, sector, newc);
768 deadkl(scratch, iquad, newc);
771 if (iquad1 != IHDOT) {
772 /* can't move into something else */
776 proutn(_(", buffeted to "));
777 proutn(cramlc(sector, newc));
778 game.quad[scratch.x][scratch.y] = IHDOT;
779 game.quad[newc.x][newc.y] = iquad;
781 game.kdist[ll] = game.kavgd[ll] = distance(game.sector, newc);
794 /* Starship affected by nova -- kick it away. */
795 game.dist = kount*0.1;
797 icx = (icx < 0 ? -1 : 1);
799 icy = (icy < 0 ? -1 : 1);
800 game.direc = course[3*(icx+1)+icy+2];
801 if (game.direc == 0.0)
803 if (game.dist == 0.0)
805 game.optime = 10.0*game.dist/16.0;
807 prout(_("Force of nova displaces starship."));
809 game.optime = 10.0*game.dist/16.0;
814 void supernova(bool induced, coord *w)
815 /* star goes supernova */
817 int num = 0, nrmdead, npdead = 0, kldead, loop;
824 /* Scheduled supernova -- select star */
825 /* logic changed here so that we won't favor quadrants in top
827 for (nq.x = 1; nq.x <= GALSIZE; nq.x++)
828 for (nq.y = 1; nq.y <= GALSIZE; nq.y++)
829 stars += game.state.galaxy[nq.x][nq.y].stars;
831 return; /* nothing to supernova exists */
832 num = Rand()*stars + 1;
833 for (nq.x = 1; nq.x <= GALSIZE; nq.x++) {
834 for (nq.y = 1; nq.y <= GALSIZE; nq.y++) {
835 num -= game.state.galaxy[nq.x][nq.y].stars;
843 proutn("=== Super nova here?");
849 if (!same(nq, game.quadrant) || game.justin) {
850 /* it isn't here, or we just entered (treat as enroute) */
851 if (!damaged(DRADIO) || game.condition == docked) {
853 prout(_("Message from Starfleet Command Stardate %.2f"), game.state.date);
854 prout(_(" Supernova in %s; caution advised."),
855 cramlc(quadrant, nq));
860 /* we are in the quadrant! */
861 num = Rand()* game.state.galaxy[nq.x][nq.y].stars + 1;
862 for (ns.x = 1; ns.x <= QUADSIZE; ns.x++) {
863 for (ns.y = 1; ns.y <= QUADSIZE; ns.y++) {
864 if (game.quad[ns.x][ns.y]==IHSTAR) {
875 prouts(_("***RED ALERT! RED ALERT!"));
877 prout(_("***Incipient supernova detected at %s"), cramlc(sector, ns));
878 if (square(ns.x-game.sector.x) + square(ns.y-game.sector.y) <= 2.1) {
879 proutn(_("Emergency override attempts t"));
880 prouts("***************");
887 /* destroy any Klingons in supernovaed quadrant */
888 kldead = game.state.galaxy[nq.x][nq.y].klingons;
889 game.state.galaxy[nq.x][nq.y].klingons = 0;
890 if (same(nq, game.state.kscmdr)) {
891 /* did in the Supercommander! */
892 game.state.nscrem = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = 0;
897 if (game.state.remcom) {
898 int maxloop = game.state.remcom, l;
899 for (l = 1; l <= maxloop; l++) {
900 if (same(game.state.kcmdr[l], nq)) {
901 game.state.kcmdr[l] = game.state.kcmdr[game.state.remcom];
902 invalidate(game.state.kcmdr[game.state.remcom]);
905 if (game.state.remcom==0)
911 game.state.remkl -= kldead;
912 /* destroy Romulans and planets in supernovaed quadrant */
913 nrmdead = game.state.galaxy[nq.x][nq.y].romulans;
914 game.state.galaxy[nq.x][nq.y].romulans = 0;
915 game.state.nromrem -= nrmdead;
916 /* Destroy planets */
917 for (loop = 0; loop < game.inplan; loop++) {
918 if (same(game.state.planets[loop].w, nq)) {
919 game.state.planets[loop].pclass = destroyed;
923 /* Destroy any base in supernovaed quadrant */
924 if (game.state.rembase) {
925 int maxloop = game.state.rembase, loop;
926 for (loop = 1; loop <= maxloop; loop++)
927 if (same(game.state.baseq[loop], nq)) {
928 game.state.baseq[loop] = game.state.baseq[game.state.rembase];
929 invalidate(game.state.baseq[game.state.rembase]);
930 game.state.rembase--;
934 /* If starship caused supernova, tally up destruction */
936 game.state.starkl += game.state.galaxy[nq.x][nq.y].stars;
937 game.state.basekl += game.state.galaxy[nq.x][nq.y].starbase;
938 game.state.nplankl += npdead;
940 /* mark supernova in galaxy and in star chart */
941 if (same(game.quadrant, nq) || !damaged(DRADIO) || game.condition == docked)
942 game.state.galaxy[nq.x][nq.y].supernova = true;
943 /* If supernova destroys last Klingons give special message */
944 if ((game.state.remkl + game.state.remcom + game.state.nscrem)==0 && !same(nq, game.quadrant)) {
947 prout(_("Lucky you!"));
948 proutn(_("A supernova in %s has just destroyed the last Klingons."),
949 cramlc(quadrant, nq));
953 /* if some Klingons remain, continue or die in supernova */