]> git.pond.sub.org Git - empserver/blob - src/lib/commands/bomb.c
Update copyright notice
[empserver] / src / lib / commands / bomb.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                Ken Stevens, Steve McClure, Markus Armbruster
5  *
6  *  Empire is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  *  ---
20  *
21  *  See files README, COPYING and CREDITS in the root of the source
22  *  tree for related information and legal notices.  It is expected
23  *  that future projects/authors will amend these files as needed.
24  *
25  *  ---
26  *
27  *  bomb.c: Fly bombing missions
28  *
29  *  Known contributors to this file:
30  *     Dave Pare, 1986
31  *     Ken Stevens, 1995
32  *     Steve McClure, 1998-2000
33  *     Markus Armbruster, 2004-2015
34  */
35
36 #include <config.h>
37
38 #include <ctype.h>
39 #include "chance.h"
40 #include "commands.h"
41 #include "damage.h"
42 #include "item.h"
43 #include "land.h"
44 #include "news.h"
45 #include "nuke.h"
46 #include "optlist.h"
47 #include "path.h"
48 #include "plane.h"
49 #include "retreat.h"
50 #include "ship.h"
51
52 static void pin_bomb(struct emp_qelem *, struct sctstr *);
53 static void eff_bomb(struct emp_qelem *, struct sctstr *);
54 static void comm_bomb(struct emp_qelem *, struct sctstr *);
55 static void ship_bomb(struct emp_qelem *, struct sctstr *);
56 static void plane_bomb(struct emp_qelem *, struct sctstr *);
57 static void land_bomb(struct emp_qelem *, struct sctstr *);
58 static void strat_bomb(struct emp_qelem *, struct sctstr *);
59 static int changed_plane_aborts(struct plist *);
60 static int pinflak_planedamage(struct plnstr *, struct plchrstr *,
61                                natid, int);
62
63 static i_type bombcomm[] = {
64     I_CIVIL,
65     I_MILIT,
66     I_SHELL,
67     I_GUN,
68     I_PETROL,
69     I_IRON,
70     I_DUST,
71     I_BAR,
72     I_FOOD,
73     I_OIL,
74     I_LCM,
75     I_HCM,
76     I_UW,
77     I_RAD
78 };
79 static int nbomb = sizeof(bombcomm) / sizeof(*bombcomm);
80
81 int
82 bomb(void)
83 {
84     char *p;
85     coord tx, ty;
86     coord ax, ay;
87     int ap_to_target;
88     char flightpath[MAX_PATH_LEN];
89     struct nstr_item ni_bomb;
90     struct nstr_item ni_esc;
91     struct sctstr target;
92     struct emp_qelem bomb_list;
93     struct emp_qelem esc_list;
94     struct sctstr ap_sect;
95     char mission;
96     struct plist *plp;
97     struct emp_qelem *qp, *next;
98     char buf[1024];
99
100     if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
101         return RET_SYN;
102     p = getstarg(player->argp[3], "pinpoint, or strategic? ", buf);
103     if (!p || !*p)
104         return RET_SYN;
105     mission = *p;
106     if (!strchr("ps", mission))
107         return RET_SYN;
108     if (!get_assembly_point(player->argp[4], &ap_sect, buf))
109         return RET_SYN;
110     ax = ap_sect.sct_x;
111     ay = ap_sect.sct_y;
112     if (!getpath(flightpath, player->argp[5], ax, ay, 0, 0, MOB_FLY))
113         return RET_SYN;
114     tx = ax;
115     ty = ay;
116     (void)pathtoxy(flightpath, &tx, &ty, fcost);
117     pr("target sector is %s\n", xyas(tx, ty, player->cnum));
118     getsect(tx, ty, &target);
119     ap_to_target = strlen(flightpath);
120     pr("range to target is %d\n", ap_to_target);
121     /*
122      * select planes within range
123      */
124     pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 2,
125             P_B | P_T, P_M | P_O);
126     pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 2,
127             P_ESC | P_F, P_M | P_O);
128     /*
129      * now arm and equip the bombers, transports, whatever.
130      */
131     pln_arm(&bomb_list, 2 * ap_to_target, mission, NULL);
132     if (QEMPTY(&bomb_list)) {
133         pr("No planes could be equipped for the mission.\n");
134         return RET_FAIL;
135     }
136     pln_arm(&esc_list, 2 * ap_to_target, 'e', NULL);
137     ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0);
138     if (QEMPTY(&bomb_list)) {
139         pr("No planes got through fighter defenses\n");
140     } else if (target.sct_type == SCT_SANCT) {
141         pr("You can't bomb that sector!\n");
142     } else {
143         switch (mission) {
144         case 'p':
145             pin_bomb(&bomb_list, &target);
146             for (qp = bomb_list.q_forw; qp != &bomb_list; qp = next) {
147                 next = qp->q_forw;
148                 plp = (struct plist *)qp;
149                 changed_plane_aborts(plp);
150             }
151             for (qp = esc_list.q_forw; qp != &esc_list; qp = next) {
152                 next = qp->q_forw;
153                 plp = (struct plist *)qp;
154                 changed_plane_aborts(plp);
155             }
156             break;
157         case 's':
158             nreport(player->cnum, N_SCT_BOMB, target.sct_own, 1);
159             strat_bomb(&bomb_list, &target);
160             break;
161         default:
162             CANT_REACH();
163         }
164     }
165     pln_put(&bomb_list);
166     pln_put(&esc_list);
167     return RET_OK;
168 }
169
170 static void
171 pin_bomb(struct emp_qelem *list, struct sctstr *target)
172 {
173     struct dchrstr *dcp;
174     int nplanes;
175     int nships;
176     int type;
177     int bad;
178     char *p;
179     int nsubs;
180     int nunits;
181     char buf[1024];
182     int i;
183
184     bad = 0;
185     type = target->sct_type;
186     dcp = &dchr[type];
187     pr("Target sector is a %s constructed %s\n",
188        effadv((int)target->sct_effic), dcp->d_name);
189     nsubs = 0;
190     nships = shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
191     if (pln_caps(list) & P_A) {
192         nsubs = shipsatxy(target->sct_x, target->sct_y, M_SUB, 0, 1);
193         if (nsubs > 0)
194             pr("Some subs are present in the sector.\n");
195     }
196     nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
197     nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
198   retry:
199     p = getstring("Bomb what? (ship, plane, land unit, efficiency, commodities) ",
200                   buf);
201     if (!p)
202        return;
203     if (!*p) {
204         bad++;
205         if (bad > 2)
206             return;
207         goto retry;
208     }
209     switch (*p) {
210     case 'l':
211         if (nunits == 0) {
212             pr("no units there\n");
213             goto retry;
214         }
215         land_bomb(list, target);
216         break;
217     case 'p':
218         if (nplanes == 0) {
219             pr("no planes there\n");
220             goto retry;
221         }
222         plane_bomb(list, target);
223         break;
224     case 's':
225         if (nships == 0) {
226             if (pln_caps(list) & P_A) {
227                 if (nsubs == 0) {
228                     pr("no ships there\n");
229                     goto retry;
230                 }
231             } else {
232                 pr("no ships there\n");
233                 goto retry;
234             }
235         }
236         ship_bomb(list, target);
237         break;
238     case 'c':
239         for (i = 0; i < nbomb; i++) {
240             if (!target->sct_item[bombcomm[i]])
241                 continue;
242             break;
243         }
244         if (i >= nbomb) {
245             pr("No bombable commodities in %s\n",
246                xyas(target->sct_x, target->sct_y, player->cnum));
247             goto retry;
248         }
249         comm_bomb(list, target);
250         break;
251     case 'e':
252         eff_bomb(list, target);
253         break;
254     case 'q':
255         pr("Aborting mission.\n");
256         return;
257     default:
258         pr("Bad target type.\n");
259         goto retry;
260     }
261 }
262
263 static void
264 eff_bomb(struct emp_qelem *list, struct sctstr *target)
265 {
266     struct plist *plp;
267     struct emp_qelem *qp, *next;
268     struct sctstr sect;
269     int oldeff, dam = 0;
270
271     for (qp = list->q_forw; qp != list; qp = next) {
272         next = qp->q_forw;
273         plp = (struct plist *)qp;
274         if (changed_plane_aborts(plp))
275             continue;
276         dam += pln_damage(&plp->plane, 'p', "");
277     }
278     getsect(target->sct_x, target->sct_y, &sect);
279     target = &sect;
280     oldeff = target->sct_effic;
281     target->sct_effic = effdamage(target->sct_effic, dam);
282     target->sct_avail = effdamage(target->sct_avail, dam);
283     target->sct_road = effdamage(target->sct_road, dam);
284     target->sct_rail = effdamage(target->sct_rail, dam);
285     target->sct_defense = effdamage(target->sct_defense, dam);
286     pr("did %d%% damage to efficiency in %s\n",
287        oldeff - target->sct_effic,
288        xyas(target->sct_x, target->sct_y, player->cnum));
289     if (target->sct_own != player->cnum)
290         mpr(target->sct_own,
291             "%s bombing raid did %d%% damage in %s\n",
292             cname(player->cnum), oldeff - target->sct_effic,
293             xyas(target->sct_x, target->sct_y, target->sct_own));
294     bridge_damaged(target);
295     putsect(&sect);
296     collateral_damage(target->sct_x, target->sct_y, dam);
297 }
298
299 static void
300 comm_bomb(struct emp_qelem *list, struct sctstr *target)
301 {
302     struct plist *plp;
303     double b;
304     int i;
305     int amt, before;
306     struct ichrstr *ip;
307     struct emp_qelem *qp, *next;
308     struct sctstr sect;
309     int dam = 0;
310
311     for (i = 0; i < nbomb; i++) {
312         if (target->sct_item[bombcomm[i]] == 0)
313             continue;
314         if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
315             continue;
316         ip = &ichr[bombcomm[i]];
317         pr("some %s\n", ip->i_name);
318     }
319     for (;;) {
320         ip = whatitem(NULL, "commodity to bomb? ");
321         if (player->aborted)
322             return;
323         if (!ip)
324             continue;
325
326         for (i = 0; i < nbomb; i++) {
327             if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
328                 continue;
329             if (&ichr[bombcomm[i]] == ip)
330                 break;
331         }
332         if (i == nbomb) {
333             pr("You can't bomb %s!\n", ip->i_name);
334             for (i = 0; i < nbomb; i++) {
335                 if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
336                     continue;
337                 pr("%s%s", i == 0 ? "Bombable: " : ", ",
338                    ichr[bombcomm[i]].i_name);
339             }
340             pr("\n");
341         } else
342             break;
343     }
344     for (qp = list->q_forw; qp != list; qp = next) {
345         next = qp->q_forw;
346         plp = (struct plist *)qp;
347         if (changed_plane_aborts(plp))
348             continue;
349         dam += pln_damage(&plp->plane, 'p', "");
350     }
351     getsect(target->sct_x, target->sct_y, &sect);
352     target = &sect;
353     before = target->sct_item[ip->i_uid];
354     target->sct_item[ip->i_uid] = amt = commdamage(before, dam, ip->i_uid);
355     if (before > 0.0)
356         b = 100.0 * (1.0 - (double)amt / (double)before);
357     else
358         b = 0.0;
359     pr("did %.2f%% damage to %s in %s\n",
360        b, ip->i_name, xyas(target->sct_x, target->sct_y, player->cnum));
361     nreport(player->cnum, N_SCT_BOMB, target->sct_own, 1);
362     if (target->sct_own != player->cnum)
363         mpr(target->sct_own,
364             "%s precision bombing raid did %.2f%% damage to %s in %s\n",
365             cname(player->cnum), b, ip->i_name,
366             xyas(target->sct_x, target->sct_y, target->sct_own));
367     putsect(&sect);
368     collateral_damage(target->sct_x, target->sct_y, dam);
369 }
370
371 static void
372 ship_bomb(struct emp_qelem *list, struct sctstr *target)
373 {
374     struct plist *plp;
375     struct mchrstr *mcp;
376     int dam;
377     char *q;
378     int n;
379     struct emp_qelem *qp, *next;
380     int shipno;
381     struct shpstr ship;
382     int nships = 0;
383     struct shiplist *head = NULL;
384     char buf[1024];
385     char prompt[128];
386     int hitchance;
387     int flak;
388     int gun;
389
390     for (qp = list->q_forw; qp != list; qp = next) {
391         next = qp->q_forw;
392         free_shiplist(&head);
393         plp = (struct plist *)qp;
394         if (changed_plane_aborts(plp))
395             continue;
396         if (plp->pcp->pl_flags & P_A)
397             nships = asw_shipsatxy(target->sct_x, target->sct_y, 0, 0,
398                                    &plp->plane, &head);
399         else
400             nships = shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
401         if (nships == 0) {
402             pr("%s could not find any ships!\n", prplane(&plp->plane));
403             continue;
404         }
405         (void)sprintf(prompt, "%s, %d bombs.  Target ('~' to skip)? ",
406                       prplane(&plp->plane), plp->load);
407         shipno = -1;
408         while (shipno < 0) {
409             if (!(q = getstring(prompt, buf)))
410                 goto out;
411             if (*q == 0)
412                 continue;
413             if (*q == '~')
414                 break;
415             if (*q == '?') {
416                 if (plp->pcp->pl_flags & P_A)
417                     print_shiplist(head);
418                 else
419                     shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
420                 continue;
421             }
422             n = atoi(q);
423             if (n < 0)
424                 continue;
425             if ((!(plp->pcp->pl_flags & P_A) || on_shiplist(n, head)) &&
426                 getship(n, &ship) && ship.shp_own &&
427                 ship.shp_x == target->sct_x && ship.shp_y == target->sct_y)
428                 shipno = n;
429             else
430                 pr("Ship #%d not spotted\n", n);
431         }
432         if (shipno < 0)
433             continue;
434         if ((plp->pcp->pl_flags & P_A) && !on_shiplist(shipno, head))
435             continue;
436         if (changed_plane_aborts(plp))
437             continue;
438
439         gun = shp_usable_guns(&ship);
440         mcp = &mchr[(int)ship.shp_type];
441         if (gun > 0 && !(mcp->m_flags & M_SUB)) {
442             flak = (int)(techfact(ship.shp_tech, gun) * 2.0);
443             mpr(ship.shp_own, "Flak! Firing %d guns from ship %s\n",
444                 flak, prship(&ship));
445             if (pinflak_planedamage(&plp->plane, plp->pcp, ship.shp_own, flak))
446                 continue;
447         }
448
449         if (nuk_on_plane(&plp->plane) >= 0)
450             hitchance = 100;
451         else {
452             hitchance = pln_hitchance(&plp->plane,
453                                       shp_hardtarget(&ship), EF_SHIP);
454             pr("%d%% hitchance...", hitchance);
455         }
456         if (pct_chance(hitchance)) {
457             /* pinbombing is more accurate than normal bombing */
458             dam = 2 * pln_damage(&plp->plane, 'p', "");
459         } else {
460             pr("splash\n");
461             /* Bombs that miss have to land somewhere! */
462             dam = pln_damage(&plp->plane, 'p', 0);
463             collateral_damage(target->sct_x, target->sct_y, dam);
464             continue;
465         }
466         if (mcp->m_flags & M_SUB)
467             nreport(player->cnum, N_SUB_BOMB, ship.shp_own, 1);
468         else
469             nreport(player->cnum, N_SHP_BOMB, ship.shp_own, 1);
470         if (ship.shp_own != player->cnum) {
471             mpr(ship.shp_own, "%s bombs did %d damage to %s at %s\n",
472                 cname(player->cnum), dam,
473                 prship(&ship),
474                 xyas(target->sct_x, target->sct_y, ship.shp_own));
475         }
476         shipdamage(&ship, dam);
477         if (ship.shp_effic < SHIP_MINEFF)
478             pr("%s at %s sunk!\n",
479                prship(&ship),
480                xyas(target->sct_x, target->sct_y, player->cnum));
481         if (dam && (ship.shp_rflags & RET_INJURED))
482             retreat_ship(&ship, ship.shp_own, 'i');
483         else if (ship.shp_rflags & RET_BOMBED)
484             retreat_ship(&ship, ship.shp_own, 'b');
485         putship(ship.shp_uid, &ship);
486         collateral_damage(target->sct_x, target->sct_y, dam / 2);
487     }
488 out:
489     free_shiplist(&head);
490 }
491
492 static void
493 plane_bomb(struct emp_qelem *list, struct sctstr *target)
494 {
495     int dam;
496     char *q;
497     int n;
498     natid own;
499     struct plnstr plane;
500     struct emp_qelem *qp, *next;
501     int planeno;
502     struct plist *plp;
503     char prompt[128];
504     char buf[1024];
505     int hitchance;
506     int nplanes;
507
508     for (qp = list->q_forw; qp != list; qp = next) {
509         next = qp->q_forw;
510         plp = (struct plist *)qp;
511         if (changed_plane_aborts(plp))
512             continue;
513         nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
514         if (nplanes == 0) {
515             pr("%s could not find any planes!\n", prplane(&plp->plane));
516             continue;
517         }
518         (void)sprintf(prompt, "%s, %d bombs.  Target ('~' to skip)? ",
519                       prplane(&plp->plane), plp->load);
520         planeno = -1;
521         while (planeno < 0) {
522             if (!(q = getstring(prompt, buf)))
523                 return;
524             if (*q == 0)
525                 continue;
526             if (*q == '~')
527                 break;
528             if (*q == '?') {
529                 planesatxy(target->sct_x, target->sct_y, 0, 0);
530                 continue;
531             }
532             n = atoi(q);
533             if (n < 0)
534                 continue;
535             if (getplane(n, &plane) && plane.pln_own &&
536                 plane.pln_x == target->sct_x &&
537                 plane.pln_y == target->sct_y &&
538                 plane.pln_ship < 0 && plane.pln_land < 0 &&
539                 !(plane.pln_flags & PLN_LAUNCHED))
540                 planeno = n;
541             else
542                 pr("Plane #%d not spotted\n", n);
543         }
544         if (planeno < 0)
545             continue;
546         if (changed_plane_aborts(plp))
547             continue;
548         if (nuk_on_plane(&plp->plane) >= 0)
549             hitchance = 100;
550         else {
551             hitchance = pln_hitchance(&plp->plane, 0, EF_PLANE);
552             pr("%d%% hitchance...", hitchance);
553         }
554         if (pct_chance(hitchance)) {
555             /* pinbombing is more accurate than normal bombing */
556             dam = 2 * pln_damage(&plp->plane, 'p', "");
557         } else {
558             pr("thud\n");
559             /* Bombs that miss have to land somewhere! */
560             dam = pln_damage(&plp->plane, 'p', 0);
561             collateral_damage(target->sct_x, target->sct_y, dam);
562             continue;
563         }
564         if (dam > 100)
565             dam = 100;
566         own = plane.pln_own;
567         if (dam > plane.pln_effic)
568             plane.pln_effic = 0;
569         else
570             plane.pln_effic -= dam;
571         plane.pln_mobil = damage(plane.pln_mobil, dam);
572         mpr(own, "%s bombs did %d%% damage to %s at %s\n",
573                cname(player->cnum), dam, prplane(&plane),
574                xyas(target->sct_x, target->sct_y, own));
575         nreport(player->cnum, N_DOWN_PLANE, own, 1);
576         putplane(plane.pln_uid, &plane);
577         collateral_damage(target->sct_x, target->sct_y, dam);
578     }
579 }
580
581 static void
582 land_bomb(struct emp_qelem *list, struct sctstr *target)
583 {
584     int dam;
585     char *q;
586     int n;
587     natid own;
588     char prompt[128];
589     char buf[1024];
590     struct lndstr land;
591     struct emp_qelem *qp, *next;
592     int unitno;
593     int aaf, flak, hitchance;
594     struct plist *plp;
595     int nunits;
596
597     for (qp = list->q_forw; qp != list; qp = next) {
598         next = qp->q_forw;
599         plp = (struct plist *)qp;
600         if (changed_plane_aborts(plp))
601             continue;
602         nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
603         if (nunits == 0) {
604             pr("%s could not find any units!\n", prplane(&plp->plane));
605             continue;
606         }
607         (void)sprintf(prompt, "%s, %d bombs.  Target ('~' to skip)? ",
608                       prplane(&plp->plane), plp->load);
609         unitno = -1;
610         while (unitno < 0) {
611             if (!(q = getstring(prompt, buf)))
612                 return;
613             if (*q == 0)
614                 continue;
615             if (*q == '~')
616                 break;
617             if (*q == '?') {
618                 unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
619                 continue;
620             }
621             n = atoi(q);
622             if (n < 0)
623                 continue;
624             if (getland(n, &land) && land.lnd_own &&
625                 land.lnd_ship < 0 && land.lnd_land < 0 &&
626                 land.lnd_x == target->sct_x && land.lnd_y == target->sct_y)
627                 unitno = n;
628             else
629                 pr("Unit #%d not spotted\n", n);
630         }
631         if (unitno < 0)
632             continue;
633         if (changed_plane_aborts(plp))
634             continue;
635
636         aaf = lnd_aaf(&land);
637         if (aaf) {
638             flak = roundavg(techfact(land.lnd_tech,
639                                      aaf * 3.0 * land.lnd_effic / 100.0));
640             mpr(land.lnd_own,
641                 "Flak! Firing flak guns from unit %s (aa rating %d)\n",
642                 prland(&land), aaf);
643             if (pinflak_planedamage(&plp->plane, plp->pcp, land.lnd_own, flak))
644                 continue;
645         }
646
647         if (nuk_on_plane(&plp->plane) >= 0)
648             hitchance = 100;
649         else {
650             hitchance = pln_hitchance(&plp->plane,
651                                       lnd_hardtarget(&land), EF_LAND);
652             pr("%d%% hitchance...", hitchance);
653         }
654         if (pct_chance(hitchance)) {
655             dam = 2 * pln_damage(&plp->plane, 'p', "");
656         } else {
657             pr("thud\n");
658             /* Bombs that miss have to land somewhere! */
659             dam = pln_damage(&plp->plane, 'p', 0);
660             collateral_damage(target->sct_x, target->sct_y, dam);
661             continue;
662         }
663         if (dam > 100)
664             dam = 100;
665         own = land.lnd_own;
666         if (own != player->cnum)
667             mpr(own, "%s bombs did %d%% damage to %s at %s\n",
668                 cname(player->cnum), dam, prland(&land),
669                 xyas(target->sct_x, target->sct_y, own));
670         landdamage(&land, dam);
671         if (dam && (land.lnd_rflags & RET_INJURED))
672             retreat_land(&land, own, 'i');
673         else if (land.lnd_rflags & RET_BOMBED)
674             retreat_land(&land, own, 'b');
675         nreport(player->cnum, N_UNIT_BOMB, own, 1);
676         putland(land.lnd_uid, &land);
677         collateral_damage(target->sct_x, target->sct_y, dam);
678     }
679 }
680
681 static void
682 strat_bomb(struct emp_qelem *list, struct sctstr *target)
683 {
684     struct plist *plp;
685     int dam = 0;
686     struct emp_qelem *qp;
687     struct sctstr sect;
688     struct nukstr nuke;
689
690     for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
691         plp = (struct plist *)qp;
692         if (getnuke(nuk_on_plane(&plp->plane), &nuke))
693             detonate(&nuke, target->sct_x, target->sct_y,
694                      plp->plane.pln_flags & PLN_AIRBURST);
695         else
696             dam += pln_damage(&plp->plane, 's', "");
697     }
698     if (dam <= 0)
699         return;
700     getsect(target->sct_x, target->sct_y, &sect);
701     target = &sect;
702     if (target->sct_own != player->cnum)
703         mpr(target->sct_own, "%s bombing raid did %d damage in %s\n",
704             cname(player->cnum), PERCENT_DAMAGE(dam),
705             xyas(target->sct_x, target->sct_y, target->sct_own));
706
707     sectdamage(target, dam);
708
709     pr("did %d damage in %s\n", PERCENT_DAMAGE(dam),
710        xyas(target->sct_x, target->sct_y, player->cnum));
711     putsect(&sect);
712 }
713
714 static int
715 changed_plane_aborts(struct plist *plp)
716 {
717     if (check_plane_ok(&plp->plane))
718         return 0;
719     getplane(plp->plane.pln_uid, &plp->plane);
720     pln_put1(plp);
721     return 1;
722 }
723
724 static int
725 pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
726                     int flak)
727 {
728     int disp;
729     char dmess[14];
730     int dam;
731
732     dam = ac_flak_dam(flak, pln_def(pp), pcp->pl_flags);
733     if (dam <= 0)
734         return 0;
735     disp = ac_damage_plane(pp, from, dam, 1, dmess);
736     mpr(pp->pln_own, "    Flak! %s takes %d%s%s.\n",
737         prplane(pp), dam, *dmess ? " --" : "", dmess);
738
739     putplane(pp->pln_uid, pp);
740     return disp > 0;
741 }