]> git.pond.sub.org Git - empserver/blob - src/lib/commands/bomb.c
ddfb3d2b48c67816162384a61c76fa9a09893a4a
[empserver] / src / lib / commands / bomb.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2012, 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         return RET_SYN;
113     tx = ax;
114     ty = ay;
115     (void)pathtoxy(flightpath, &tx, &ty, fcost);
116     pr("target sector is %s\n", xyas(tx, ty, player->cnum));
117     getsect(tx, ty, &target);
118     ap_to_target = strlen(flightpath);
119     if (flightpath[ap_to_target - 1] == 'h')
120         ap_to_target--;
121     pr("range to target is %d\n", ap_to_target);
122     /*
123      * select planes within range
124      */
125     pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 2,
126             P_B | P_T, P_M | P_O);
127     pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 2,
128             P_ESC | P_F, P_M | P_O);
129     /*
130      * now arm and equip the bombers, transports, whatever.
131      */
132     pln_arm(&bomb_list, 2 * ap_to_target, mission, NULL);
133     if (QEMPTY(&bomb_list)) {
134         pr("No planes could be equipped for the mission.\n");
135         return RET_FAIL;
136     }
137     pln_arm(&esc_list, 2 * ap_to_target, 'e', NULL);
138     ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0);
139     if (QEMPTY(&bomb_list)) {
140         pr("No planes got through fighter defenses\n");
141     } else if (target.sct_type == SCT_SANCT) {
142         pr("You can't bomb that sector!\n");
143     } else {
144         switch (mission) {
145         case 'p':
146             pin_bomb(&bomb_list, &target);
147             for (qp = bomb_list.q_forw; qp != &bomb_list; qp = next) {
148                 next = qp->q_forw;
149                 plp = (struct plist *)qp;
150                 changed_plane_aborts(plp);
151             }
152             for (qp = esc_list.q_forw; qp != &esc_list; qp = next) {
153                 next = qp->q_forw;
154                 plp = (struct plist *)qp;
155                 changed_plane_aborts(plp);
156             }
157             break;
158         case 's':
159             nreport(player->cnum, N_SCT_BOMB, target.sct_own, 1);
160             strat_bomb(&bomb_list, &target);
161             break;
162         default:
163             CANT_REACH();
164         }
165     }
166     pln_put(&bomb_list);
167     pln_put(&esc_list);
168     return RET_OK;
169 }
170
171 static void
172 pin_bomb(struct emp_qelem *list, struct sctstr *target)
173 {
174     struct dchrstr *dcp;
175     int nplanes;
176     int nships;
177     int type;
178     int bad;
179     char *p;
180     int nsubs;
181     int nunits;
182     char buf[1024];
183     int i;
184
185     bad = 0;
186     type = target->sct_type;
187     dcp = &dchr[type];
188     pr("Target sector is a %s constructed %s\n",
189        effadv((int)target->sct_effic), dcp->d_name);
190     nsubs = 0;
191     nships = shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
192     if (pln_caps(list) & P_A) {
193         nsubs = shipsatxy(target->sct_x, target->sct_y, M_SUB, 0, 1);
194         if (nsubs > 0)
195             pr("Some subs are present in the sector.\n");
196     }
197     nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
198     nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0);
199   retry:
200     p = getstring("Bomb what? (ship, plane, land unit, efficiency, commodities) ",
201                   buf);
202     if (!p)
203        return;
204     if (!*p) {
205         bad++;
206         if (bad > 2)
207             return;
208         goto retry;
209     }
210     switch (*p) {
211     case 'l':
212         if (nunits == 0) {
213             pr("no units there\n");
214             goto retry;
215         }
216         land_bomb(list, target);
217         break;
218     case 'p':
219         if (nplanes == 0) {
220             pr("no planes there\n");
221             goto retry;
222         }
223         plane_bomb(list, target);
224         break;
225     case 's':
226         if (nships == 0) {
227             if (pln_caps(list) & P_A) {
228                 if (nsubs == 0) {
229                     pr("no ships there\n");
230                     goto retry;
231                 }
232             } else {
233                 pr("no ships there\n");
234                 goto retry;
235             }
236         }
237         ship_bomb(list, target);
238         break;
239     case 'c':
240         for (i = 0; i < nbomb; i++) {
241             if (!target->sct_item[bombcomm[i]])
242                 continue;
243             break;
244         }
245         if (i >= nbomb) {
246             pr("No bombable commodities in %s\n",
247                xyas(target->sct_x, target->sct_y, player->cnum));
248             goto retry;
249         }
250         comm_bomb(list, target);
251         break;
252     case 'e':
253         eff_bomb(list, target);
254         break;
255     case 'q':
256         pr("Aborting mission.\n");
257         return;
258     default:
259         pr("Bad target type.\n");
260         goto retry;
261     }
262 }
263
264 static void
265 eff_bomb(struct emp_qelem *list, struct sctstr *target)
266 {
267     struct plist *plp;
268     struct emp_qelem *qp, *next;
269     struct sctstr sect;
270     int oldeff, dam = 0;
271
272     for (qp = list->q_forw; qp != list; qp = next) {
273         next = qp->q_forw;
274         plp = (struct plist *)qp;
275         if (changed_plane_aborts(plp))
276             continue;
277         dam += pln_damage(&plp->plane, 'p', 1);
278     }
279     getsect(target->sct_x, target->sct_y, &sect);
280     target = &sect;
281     oldeff = target->sct_effic;
282     target->sct_effic = effdamage(target->sct_effic, dam);
283     target->sct_avail = effdamage(target->sct_avail, dam);
284     target->sct_road = effdamage(target->sct_road, dam);
285     target->sct_rail = effdamage(target->sct_rail, dam);
286     target->sct_defense = effdamage(target->sct_defense, dam);
287     pr("did %d%% damage to efficiency in %s\n",
288        oldeff - target->sct_effic,
289        xyas(target->sct_x, target->sct_y, player->cnum));
290     if (target->sct_own)
291         wu(0, target->sct_own,
292            "%s bombing raid did %d%% damage in %s\n",
293            cname(player->cnum), oldeff - target->sct_effic,
294            xyas(target->sct_x, target->sct_y, target->sct_own));
295     bridge_damaged(target);
296     putsect(&sect);
297     collateral_damage(target->sct_x, target->sct_y, dam);
298 }
299
300 static void
301 comm_bomb(struct emp_qelem *list, struct sctstr *target)
302 {
303     struct plist *plp;
304     double b;
305     int i;
306     int amt, before;
307     struct ichrstr *ip;
308     struct emp_qelem *qp, *next;
309     struct sctstr sect;
310     int dam = 0;
311
312     for (i = 0; i < nbomb; i++) {
313         if (target->sct_item[bombcomm[i]] == 0)
314             continue;
315         if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
316             continue;
317         ip = &ichr[bombcomm[i]];
318         pr("some %s\n", ip->i_name);
319     }
320     for (;;) {
321         ip = whatitem(NULL, "commodity to bomb? ");
322         if (player->aborted)
323             return;
324         if (!ip)
325             continue;
326
327         for (i = 0; i < nbomb; i++) {
328             if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
329                 continue;
330             if (&ichr[bombcomm[i]] == ip)
331                 break;
332         }
333         if (i == nbomb) {
334             pr("You can't bomb %s!\n", ip->i_name);
335             for (i = 0; i < nbomb; i++) {
336                 if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
337                     continue;
338                 pr("%s%s", i == 0 ? "Bombable: " : ", ",
339                    ichr[bombcomm[i]].i_name);
340             }
341             pr("\n");
342         } else
343             break;
344     }
345     for (qp = list->q_forw; qp != list; qp = next) {
346         next = qp->q_forw;
347         plp = (struct plist *)qp;
348         if (changed_plane_aborts(plp))
349             continue;
350         dam += pln_damage(&plp->plane, 'p', 1);
351     }
352     getsect(target->sct_x, target->sct_y, &sect);
353     target = &sect;
354     before = target->sct_item[ip->i_uid];
355     target->sct_item[ip->i_uid] = amt = commdamage(before, dam, ip->i_uid);
356     if (before > 0.0)
357         b = 100.0 * (1.0 - (double)amt / (double)before);
358     else
359         b = 0.0;
360     pr("did %.2f%% damage to %s in %s\n",
361        b, ip->i_name, xyas(target->sct_x, target->sct_y, player->cnum));
362     nreport(player->cnum, N_SCT_BOMB, target->sct_own, 1);
363     if (target->sct_own != 0)
364         wu(0, target->sct_own,
365            "%s precision bombing raid did %.2f%% damage to %s in %s\n",
366            cname(player->cnum), b, ip->i_name,
367            xyas(target->sct_x, target->sct_y, target->sct_own));
368     putsect(&sect);
369     collateral_damage(target->sct_x, target->sct_y, dam);
370 }
371
372 static void
373 ship_bomb(struct emp_qelem *list, struct sctstr *target)
374 {
375     struct plist *plp;
376     struct mchrstr *mcp;
377     int dam;
378     char *q;
379     int n;
380     struct emp_qelem *qp, *next;
381     int shipno;
382     struct shpstr ship;
383     int nships = 0;
384     struct shiplist *head = NULL;
385     char buf[1024];
386     char prompt[128];
387     int hitchance;
388     int flak;
389     int gun;
390
391     for (qp = list->q_forw; qp != list; qp = next) {
392         next = qp->q_forw;
393         free_shiplist(&head);
394         plp = (struct plist *)qp;
395         if (changed_plane_aborts(plp))
396             continue;
397         if (plp->pcp->pl_flags & P_A)
398             nships = asw_shipsatxy(target->sct_x, target->sct_y, 0, 0,
399                                    &plp->plane, &head);
400         else
401             nships = shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
402         if (nships == 0) {
403             pr("%s could not find any ships!\n", prplane(&plp->plane));
404             continue;
405         }
406         (void)sprintf(prompt, "%s, %d bombs.  Target ('~' to skip)? ",
407                       prplane(&plp->plane), plp->load);
408         shipno = -1;
409         while (shipno < 0) {
410             if (!(q = getstring(prompt, buf)))
411                 goto out;
412             if (*q == 0)
413                 continue;
414             if (*q == '~')
415                 break;
416             if (*q == '?') {
417                 if (plp->pcp->pl_flags & P_A)
418                     print_shiplist(head);
419                 else
420                     shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
421                 continue;
422             }
423             n = atoi(q);
424             if (n < 0)
425                 continue;
426             if ((!(plp->pcp->pl_flags & P_A) || on_shiplist(n, head)) &&
427                 getship(n, &ship) && ship.shp_own &&
428                 ship.shp_x == target->sct_x && ship.shp_y == target->sct_y)
429                 shipno = n;
430             else
431                 pr("Ship #%d not spotted\n", n);
432         }
433         if (shipno < 0)
434             continue;
435         if ((plp->pcp->pl_flags & P_A) && !on_shiplist(shipno, head))
436             continue;
437         if (changed_plane_aborts(plp))
438             continue;
439
440         gun = shp_usable_guns(&ship);
441         mcp = &mchr[(int)ship.shp_type];
442         if (gun > 0 && !(mcp->m_flags & M_SUB)) {
443             flak = (int)(techfact(ship.shp_tech, gun) * 2.0);
444             mpr(ship.shp_own, "Flak! Firing %d guns from ship %s\n",
445                 flak, prship(&ship));
446             if (pinflak_planedamage(&plp->plane, plp->pcp, ship.shp_own, flak))
447                 continue;
448         }
449
450         if (nuk_on_plane(&plp->plane) >= 0)
451             hitchance = 100;
452         else {
453             hitchance = pln_hitchance(&plp->plane,
454                                       shp_hardtarget(&ship), EF_SHIP);
455             pr("%d%% hitchance...", hitchance);
456         }
457         if (roll(100) <= hitchance) {
458             /* pinbombing is more accurate than normal bombing */
459             dam = 2 * pln_damage(&plp->plane, 'p', 1);
460         } else {
461             pr("splash\n");
462             /* Bombs that miss have to land somewhere! */
463             dam = pln_damage(&plp->plane, 'p', 0);
464             collateral_damage(target->sct_x, target->sct_y, dam);
465             continue;
466         }
467         if (mcp->m_flags & M_SUB)
468             nreport(player->cnum, N_SUB_BOMB, ship.shp_own, 1);
469         else
470             nreport(player->cnum, N_SHP_BOMB, ship.shp_own, 1);
471         if (ship.shp_own) {
472             wu(0, ship.shp_own, "%s bombs did %d damage to %s at %s\n",
473                cname(player->cnum), dam,
474                prship(&ship),
475                xyas(target->sct_x, target->sct_y, ship.shp_own));
476         }
477         pr("\n");
478         check_retreat_and_do_shipdamage(&ship, dam);
479         if (ship.shp_rflags & RET_BOMBED)
480             if (((ship.shp_rflags & RET_INJURED) == 0) || !dam)
481                 retreat_ship(&ship, 'b');
482         putship(ship.shp_uid, &ship);
483         getship(ship.shp_uid, &ship);
484         if (!ship.shp_own) {
485             pr("%s at %s sunk!\n",
486                prship(&ship),
487                xyas(target->sct_x, target->sct_y, player->cnum));
488         }
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) &&
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 (roll(100) <= hitchance) {
558             /* pinbombing is more accurate than normal bombing */
559             dam = 2 * pln_damage(&plp->plane, 'p', 1);
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);
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);
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 (roll(100) <= hitchance) {
667             dam = 2 * pln_damage(&plp->plane, 'p', 1);
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         check_retreat_and_do_landdamage(&land, dam);
681
682         if (land.lnd_rflags & RET_BOMBED)
683             if (((land.lnd_rflags & RET_INJURED) == 0) || !dam)
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', 1);
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 }