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