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