]> git.pond.sub.org Git - empserver/blob - src/lib/commands/bomb.c
20ab1891a76c749e04469d556789a41ff358f5fd
[empserver] / src / lib / commands / bomb.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2015, 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     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, 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', "");
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', "");
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 (pct_chance(hitchance)) {
459             /* pinbombing is more accurate than normal bombing */
460             dam = 2 * pln_damage(&plp->plane, 'p', "");
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         shipdamage(&ship, dam);
480         if (ship.shp_effic < SHIP_MINEFF)
481             pr("%s at %s sunk!\n",
482                prship(&ship),
483                xyas(target->sct_x, target->sct_y, player->cnum));
484         if (dam && (ship.shp_rflags & RET_INJURED))
485             retreat_ship(&ship, 'i');
486         else if (ship.shp_rflags & RET_BOMBED)
487             retreat_ship(&ship, 'b');
488         putship(ship.shp_uid, &ship);
489         collateral_damage(target->sct_x, target->sct_y, dam / 2);
490     }
491 out:
492     free_shiplist(&head);
493 }
494
495 static void
496 plane_bomb(struct emp_qelem *list, struct sctstr *target)
497 {
498     int dam;
499     char *q;
500     int n;
501     natid own;
502     struct plnstr plane;
503     struct emp_qelem *qp, *next;
504     int planeno;
505     struct plist *plp;
506     char prompt[128];
507     char buf[1024];
508     int hitchance;
509     int nplanes;
510
511     for (qp = list->q_forw; qp != list; qp = next) {
512         next = qp->q_forw;
513         plp = (struct plist *)qp;
514         if (changed_plane_aborts(plp))
515             continue;
516         nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
517         if (nplanes == 0) {
518             pr("%s could not find any planes!\n", prplane(&plp->plane));
519             continue;
520         }
521         (void)sprintf(prompt, "%s, %d bombs.  Target ('~' to skip)? ",
522                       prplane(&plp->plane), plp->load);
523         planeno = -1;
524         while (planeno < 0) {
525             if (!(q = getstring(prompt, buf)))
526                 return;
527             if (*q == 0)
528                 continue;
529             if (*q == '~')
530                 break;
531             if (*q == '?') {
532                 planesatxy(target->sct_x, target->sct_y, 0, 0);
533                 continue;
534             }
535             n = atoi(q);
536             if (n < 0)
537                 continue;
538             if (getplane(n, &plane) && plane.pln_own &&
539                 plane.pln_x == target->sct_x &&
540                 plane.pln_y == target->sct_y &&
541                 plane.pln_ship < 0 && plane.pln_land < 0 &&
542                 !(plane.pln_flags & PLN_LAUNCHED))
543                 planeno = n;
544             else
545                 pr("Plane #%d not spotted\n", n);
546         }
547         if (planeno < 0)
548             continue;
549         if (changed_plane_aborts(plp))
550             continue;
551         if (nuk_on_plane(&plp->plane) >= 0)
552             hitchance = 100;
553         else {
554             hitchance = pln_hitchance(&plp->plane, 0, EF_PLANE);
555             pr("%d%% hitchance...", hitchance);
556         }
557         if (pct_chance(hitchance)) {
558             /* pinbombing is more accurate than normal bombing */
559             dam = 2 * pln_damage(&plp->plane, 'p', "");
560         } else {
561             pr("thud\n");
562             /* Bombs that miss have to land somewhere! */
563             dam = pln_damage(&plp->plane, 'p', 0);
564             collateral_damage(target->sct_x, target->sct_y, dam);
565             continue;
566         }
567         if (dam > 100)
568             dam = 100;
569         own = plane.pln_own;
570         if (dam > plane.pln_effic)
571             plane.pln_effic = 0;
572         else
573             plane.pln_effic -= dam;
574         plane.pln_mobil = (dam * plane.pln_mobil / 100.0);
575         if (own == player->cnum) {
576             pr("%s reports %d%% damage\n", prplane(&plane), dam);
577         } else {
578             if (own != 0)
579                 wu(0, own,
580                    "%s pinpoint bombing raid did %d%% damage to %s\n",
581                    cname(player->cnum), dam, prplane(&plane));
582         }
583         nreport(player->cnum, N_DOWN_PLANE, own, 1);
584         if (own != 0)
585             wu(0, own, "%s bombs did %d%% damage to %s at %s\n",
586                cname(player->cnum), dam, prplane(&plane),
587                xyas(target->sct_x, target->sct_y, own));
588         putplane(plane.pln_uid, &plane);
589         collateral_damage(target->sct_x, target->sct_y, dam);
590     }
591 }
592
593 static void
594 land_bomb(struct emp_qelem *list, struct sctstr *target)
595 {
596     int dam;
597     char *q;
598     int n;
599     natid own;
600     char prompt[128];
601     char buf[1024];
602     struct lndstr land;
603     struct emp_qelem *qp, *next;
604     int unitno;
605     int aaf, flak, hitchance;
606     struct plist *plp;
607     int nunits;
608
609     for (qp = list->q_forw; qp != list; qp = next) {
610         next = qp->q_forw;
611         plp = (struct plist *)qp;
612         if (changed_plane_aborts(plp))
613             continue;
614         nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
615         if (nunits == 0) {
616             pr("%s could not find any units!\n", prplane(&plp->plane));
617             continue;
618         }
619         (void)sprintf(prompt, "%s, %d bombs.  Target ('~' to skip)? ",
620                       prplane(&plp->plane), plp->load);
621         unitno = -1;
622         while (unitno < 0) {
623             if (!(q = getstring(prompt, buf)))
624                 return;
625             if (*q == 0)
626                 continue;
627             if (*q == '~')
628                 break;
629             if (*q == '?') {
630                 unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
631                 continue;
632             }
633             n = atoi(q);
634             if (n < 0)
635                 continue;
636             if (getland(n, &land) && land.lnd_own &&
637                 land.lnd_ship < 0 && land.lnd_land < 0 &&
638                 land.lnd_x == target->sct_x && land.lnd_y == target->sct_y)
639                 unitno = n;
640             else
641                 pr("Unit #%d not spotted\n", n);
642         }
643         if (unitno < 0)
644             continue;
645         if (changed_plane_aborts(plp))
646             continue;
647
648         aaf = lnd_aaf(&land);
649         if (aaf) {
650             flak = roundavg(techfact(land.lnd_tech,
651                                      aaf * 3.0 * land.lnd_effic / 100.0));
652             mpr(land.lnd_own,
653                 "Flak! Firing flak guns from unit %s (aa rating %d)\n",
654                 prland(&land), aaf);
655             if (pinflak_planedamage(&plp->plane, plp->pcp, land.lnd_own, flak))
656                 continue;
657         }
658
659         if (nuk_on_plane(&plp->plane) >= 0)
660             hitchance = 100;
661         else {
662             hitchance = pln_hitchance(&plp->plane,
663                                       lnd_hardtarget(&land), EF_LAND);
664             pr("%d%% hitchance...", hitchance);
665         }
666         if (pct_chance(hitchance)) {
667             dam = 2 * pln_damage(&plp->plane, 'p', "");
668         } else {
669             pr("thud\n");
670             /* Bombs that miss have to land somewhere! */
671             dam = pln_damage(&plp->plane, 'p', 0);
672             collateral_damage(target->sct_x, target->sct_y, dam);
673             continue;
674         }
675         if (dam > 100)
676             dam = 100;
677         own = land.lnd_own;
678         mpr(own, "%s pinpoint bombing raid did %d damage to %s\n",
679             cname(player->cnum), dam, prland(&land));
680         landdamage(&land, dam);
681         if (dam && (land.lnd_rflags & RET_INJURED))
682             retreat_land(&land, 'i');
683         else if (land.lnd_rflags & RET_BOMBED)
684             retreat_land(&land, 'b');
685         nreport(player->cnum, N_UNIT_BOMB, own, 1);
686         putland(land.lnd_uid, &land);
687         collateral_damage(target->sct_x, target->sct_y, dam);
688     }
689 }
690
691 static void
692 strat_bomb(struct emp_qelem *list, struct sctstr *target)
693 {
694     struct plist *plp;
695     int dam = 0;
696     struct emp_qelem *qp;
697     struct sctstr sect;
698     struct nukstr nuke;
699
700     for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
701         plp = (struct plist *)qp;
702         if (getnuke(nuk_on_plane(&plp->plane), &nuke))
703             detonate(&nuke, target->sct_x, target->sct_y,
704                      plp->plane.pln_flags & PLN_AIRBURST);
705         else
706             dam += pln_damage(&plp->plane, 's', "");
707     }
708     if (dam <= 0)
709         return;
710     getsect(target->sct_x, target->sct_y, &sect);
711     target = &sect;
712     if (target->sct_own)
713         wu(0, target->sct_own, "%s bombing raid did %d damage in %s\n",
714            cname(player->cnum), PERCENT_DAMAGE(dam),
715            xyas(target->sct_x, target->sct_y, target->sct_own));
716
717     sectdamage(target, dam);
718
719     pr("did %d damage in %s\n", PERCENT_DAMAGE(dam),
720        xyas(target->sct_x, target->sct_y, player->cnum));
721     putsect(&sect);
722 }
723
724 static int
725 changed_plane_aborts(struct plist *plp)
726 {
727     if (check_plane_ok(&plp->plane))
728         return 0;
729     getplane(plp->plane.pln_uid, &plp->plane);
730     pln_put1(plp);
731     return 1;
732 }
733
734 static int
735 pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
736                     int flak)
737 {
738     int disp;
739     char dmess[14];
740     int dam;
741
742     dam = ac_flak_dam(flak, pln_def(pp), pcp->pl_flags);
743     if (dam <= 0)
744         return 0;
745     disp = ac_damage_plane(pp, from, dam, 1, dmess);
746     mpr(pp->pln_own, "    Flak! %s takes %d%s%s.\n",
747         prplane(pp), dam, *dmess ? " --" : "", dmess);
748
749     putplane(pp->pln_uid, pp);
750     return disp > 0;
751 }