2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
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.
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.
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
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.
28 * aircombat.c: Deal with air to air combat
30 * Known contributors to this file:
32 * Thomas Ruschak, 1992
34 * Markus Armbruster, 2006-2008
50 #include "prototypes.h"
55 #define FLAK_GUN_MAX 14
57 static int plane_caps(struct emp_qelem *);
58 static void ac_intercept(struct emp_qelem *, struct emp_qelem *,
59 struct emp_qelem *, natid, coord, coord);
60 static void ac_dog(struct plist *, struct plist *);
61 static void ac_planedamage(struct plist *, natid, int, natid, int,
63 static void ac_doflak(struct emp_qelem *, struct sctstr *);
64 static void ac_landflak(struct emp_qelem *, coord, coord);
65 static void ac_shipflak(struct emp_qelem *, coord, coord);
66 static void ac_fireflak(struct emp_qelem *, natid, int);
67 static void getilist(struct emp_qelem *, natid);
68 static int do_evade(struct emp_qelem *, struct emp_qelem *);
71 ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
72 coord x, coord y, char *path, int mission_flags,
81 int unfriendly[MAXNOC];
84 struct emp_qelem ilist[MAXNOC];
92 struct natstr *mynatp;
95 struct shiplist *head = NULL;
97 /* We want to only intercept once per sector per owner. So, if we overfly
98 a sector, and then overfly some land units or ships, we don't want to
99 potentially intercept 3 times. */
101 plp = (struct plist *)bomb_list->q_forw;
102 plane_owner = plp->plane.pln_own;
104 memset(overfly, 0, sizeof(overfly));
105 memset(gotilist, 0, sizeof(gotilist));
106 memset(unfriendly, 0, sizeof(unfriendly));
107 for (cn = 1; cn < MAXNOC; cn++) {
108 if ((mynatp = getnatp(cn)) == 0)
110 rel = getrel(mynatp, plane_owner);
113 if (plane_owner == cn)
117 if (mission_flags & PM_R) {
118 flags = plane_caps(bomb_list);
120 PR(plane_owner, "\nSPY Plane report\n");
123 } else if (flags & P_A) {
124 PR(plane_owner, "\nAnti-Sub Patrol report\n");
126 PR(plane_owner, "\nReconnaissance report\n");
132 getsect(x, y, §);
134 if (mission_flags & PM_R) {
135 flags = plane_caps(bomb_list);
137 setcont(plane_owner, sect.sct_own, FOUND_FLY);
138 if (sect.sct_type == SCT_WATER) {
139 PR(plane_owner, "flying over %s at %s\n",
140 dchr[sect.sct_type].d_name, xyas(x, y, plane_owner));
141 if (mission_flags & PM_S)
142 plane_sweep(bomb_list, x, y);
144 plane_sona(bomb_list, x, y, &head);
145 changed += map_set(plane_owner,
146 sect.sct_x, sect.sct_y,
147 dchr[sect.sct_type].d_mnem, 0);
148 } else if (flags & P_S) {
149 satdisp_sect(§, flags & P_I ? 10 : 50);
151 /* This is borrowed from lookout */
152 if (sect.sct_own == plane_owner)
153 PR(plane_owner, "Your ");
155 PR(plane_owner, "%s (#%d) ",
156 cname(sect.sct_own), sect.sct_own);
157 PR(plane_owner, "%s", dchr[sect.sct_type].d_name);
158 changed += map_set(plane_owner,
159 sect.sct_x, sect.sct_y,
160 dchr[sect.sct_type].d_mnem, 0);
161 PR(plane_owner, " %d%% efficient ",
162 (sect.sct_own == plane_owner) ?
163 sect.sct_effic : roundintby((int)sect.sct_effic, 25));
164 civ = sect.sct_item[I_CIVIL];
165 mil = sect.sct_item[I_MILIT];
167 PR(plane_owner, "with %s%d civ ",
168 (sect.sct_own == plane_owner) ?
170 (sect.sct_own == plane_owner) ?
171 civ : roundintby(civ, 25));
173 PR(plane_owner, "with %s%d mil ",
174 (sect.sct_own == plane_owner) ?
176 (sect.sct_own == plane_owner) ?
177 mil : roundintby(mil, 25));
178 PR(plane_owner, "@ %s\n", xyas(x, y, plane_owner));
181 satdisp_units(sect.sct_x, sect.sct_y);
183 PR(plane_owner, "flying over %s at %s\n",
184 dchr[sect.sct_type].d_name, xyas(x, y, plane_owner));
185 changed += map_set(plane_owner, sect.sct_x, sect.sct_y,
186 dchr[sect.sct_type].d_mnem, 0);
189 evaded = do_evade(bomb_list, esc_list);
191 if (sect.sct_own != 0 && sect.sct_own != plane_owner
192 && getrel(getnatp(sect.sct_own), plane_owner) != ALLIED) {
193 overfly[sect.sct_own]++;
194 PR(sect.sct_own, "%s planes spotted over %s\n",
195 cname(plane_owner), xyas(x, y, sect.sct_own));
197 setcont(sect.sct_own, plane_owner, FOUND_FLY);
201 if (unfriendly[sect.sct_own])
202 ac_doflak(bomb_list, §);
203 /* If bombers left, fire flak from units and ships */
204 if (!QEMPTY(bomb_list))
205 ac_landflak(bomb_list, x, y);
206 if (!QEMPTY(bomb_list))
207 ac_shipflak(bomb_list, x, y);
208 /* mission planes aborted due to flak -- don't send escorts */
209 if (QEMPTY(bomb_list))
213 air_defense(x, y, plane_owner, bomb_list, esc_list);
215 if (unfriendly[sect.sct_own]) {
216 if (!gotilist[sect.sct_own]) {
217 getilist(&ilist[sect.sct_own], sect.sct_own);
218 gotilist[sect.sct_own]++;
220 ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
226 if (!dir || QEMPTY(bomb_list) || (val = diridx(dir)) == DIR_STOP)
228 x = xnorm(x + diroff[val][0]);
229 y = ynorm(y + diroff[val][1]);
232 /* Let's report all of the overflights even if aborted */
233 for (cn = 1; cn < MAXNOC; cn++) {
234 if (plane_owner == cn)
237 nreport(plane_owner, N_OVFLY_SECT, cn, overfly[cn]);
239 /* If the map changed, update it */
241 writemap(player->cnum);
242 /* Now, if the bomber and escort lists are empty, we are done */
243 if (QEMPTY(bomb_list) && QEMPTY(esc_list))
246 /* Something made it through */
247 /* Go figure out if there are ships in this sector, and who's they are */
248 memset(nats, 0, sizeof(nats));
249 snxtitem_xy(&ni, EF_SHIP, x, y);
250 while (nxtitem(&ni, &ship)) {
251 if (mchr[(int)ship.shp_type].m_flags & M_SUB)
253 nats[ship.shp_own]++;
255 /* Go figure out if there are units in this sector, and who's they are */
256 memset(lnats, 0, sizeof(lnats));
257 snxtitem_xy(&ni, EF_LAND, x, y);
258 while (nxtitem(&ni, &land)) {
259 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
261 lnats[land.lnd_own]++;
264 /* Now, let's make life a little rougher. */
265 for (cn = 1; cn < MAXNOC && !QEMPTY(bomb_list); cn++) {
266 if (plane_owner == cn)
269 PR(plane_owner, "Flying over %s ships in %s\n",
270 cname(cn), xyas(x, y, plane_owner));
271 PR(cn, "%s planes spotted over ships in %s\n",
272 cname(plane_owner), xyas(x, y, cn));
274 if (lnats[cn] != 0) {
275 PR(plane_owner, "Flying over %s land units in %s\n",
276 cname(cn), xyas(x, y, plane_owner));
277 PR(cn, "%s planes spotted over land units in %s\n",
278 cname(plane_owner), xyas(x, y, cn));
280 if (nats[cn] || lnats[cn]) {
282 setcont(cn, plane_owner, FOUND_FLY);
283 if (unfriendly[cn] && !evaded) {
285 getilist(&ilist[cn], cn);
288 ac_intercept(bomb_list, esc_list, &ilist[cn], cn, x, y);
293 free_shiplist(&head);
294 for (cn = 1; cn < MAXNOC; cn++) {
301 plane_caps(struct emp_qelem *list)
303 struct emp_qelem *qp;
308 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
309 plp = (struct plist *)qp;
310 fl |= plp->pcp->pl_flags;
317 sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list,
318 natid def_own, natid plane_owner, coord x, coord y,
321 struct emp_qelem *aqp;
322 struct emp_qelem *anext;
323 struct emp_qelem *dqp;
324 struct emp_qelem *dnext;
329 for (aqp = att_list->q_forw,
330 dqp = def_list->q_forw;
331 aqp != att_list && dqp != def_list; aqp = anext) {
333 aplp = (struct plist *)aqp;
334 if (aplp->pcp->pl_cost < 1000)
336 for (; dqp != def_list; dqp = dnext) {
338 dplp = (struct plist *)dqp;
339 if (!(dplp->pcp->pl_flags & P_M))
342 if (dplp->plane.pln_range <
343 mapdist(x, y, dplp->plane.pln_x, dplp->plane.pln_y))
345 if (CANT_HAPPEN(dplp->plane.pln_flags & PLN_LAUNCHED)
346 || mission_pln_equip(dplp, 0, P_F, 0) < 0) {
351 dplp->plane.pln_flags |= PLN_LAUNCHED;
352 putplane(dplp->plane.pln_uid, &dplp->plane);
355 PR(plane_owner, "%s launches SAMs!\n", cname(def_own));
356 PR(def_own, "Launching SAMs at %s planes over %s!\n",
357 cname(plane_owner), xyas(x, y, def_own));
358 ac_combat_headers(plane_owner, def_own);
366 PR(plane_owner, "\n");
369 if (delete_missiles) {
370 for (; dqp != def_list; dqp = dnext) {
372 dplp = (struct plist *)dqp;
373 if (!(dplp->pcp->pl_flags & P_M))
383 ac_intercept(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
384 struct emp_qelem *def_list, natid def_own, coord x, coord y)
389 struct emp_qelem *next;
390 struct emp_qelem *qp;
391 struct emp_qelem int_list;
396 plp = (struct plist *)bomb_list->q_forw;
397 plane_owner = plp->plane.pln_own;
399 sam_intercept(bomb_list, def_list, def_own, plane_owner, x, y, 0);
400 sam_intercept(esc_list, def_list, def_own, plane_owner, x, y, 0);
403 for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw)
405 for (qp = esc_list->q_forw; qp != esc_list; qp = qp->q_forw)
410 emp_initque(&int_list);
412 for (qp = def_list->q_forw; qp != def_list; qp = next) {
414 plp = (struct plist *)qp;
416 /* SAMs interdict separately */
417 if (plp->pcp->pl_flags & P_M)
419 dist = mapdist(x, y, pp->pln_x, pp->pln_y) * 2;
420 if (pp->pln_range < dist)
422 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
423 || mission_pln_equip(plp, 0, P_F, 0) < 0) {
428 /* got one; delete from def_list, add to int_list */
430 emp_insque(qp, &int_list);
431 pp->pln_flags |= PLN_LAUNCHED;
432 pp->pln_mobil -= pln_mobcost(dist, pp, P_F);
433 putplane(pp->pln_uid, pp);
435 if (icount > att_count)
440 PR(plane_owner, "%d %s fighter%s rising to intercept!\n",
441 icount, cname(def_own), icount == 1 ? " is" : "s are");
442 PR(def_own, "%d fighter%s intercepting %s planes over %s!\n",
443 icount, icount == 1 ? " is" : "s are", cname(plane_owner),
444 xyas(x, y, def_own));
445 ac_combat_headers(plane_owner, def_own);
446 ac_airtoair(esc_list, &int_list);
447 ac_airtoair(bomb_list, &int_list);
448 PR(plane_owner, "\n");
454 ac_combat_headers(natid plane_owner, natid def_own)
457 " %-10.10s %-10.10s strength int odds damage results\n",
458 cname(plane_owner), cname(def_own));
460 " %-10.10s %-10.10s strength int odds damage results\n",
461 cname(def_own), cname(plane_owner));
468 ac_airtoair(struct emp_qelem *att_list, struct emp_qelem *int_list)
470 struct plist *attacker;
471 struct plist *interceptor;
472 struct emp_qelem *att;
473 struct emp_qelem *in;
477 struct emp_qelem *att_next;
478 struct emp_qelem *in_next;
480 att = att_list->q_forw;
481 in = int_list->q_forw;
484 if (QEMPTY(att_list) || QEMPTY(int_list)) {
488 while (more_att || more_int) {
489 in_next = in->q_forw;
490 att_next = att->q_forw;
491 attacker = (struct plist *)att;
492 interceptor = (struct plist *)in;
493 nplanes = attacker->plane.pln_effic;
494 if (nplanes > interceptor->plane.pln_effic)
495 nplanes = interceptor->plane.pln_effic;
496 ac_dog(attacker, interceptor);
499 if (att == att_list) {
501 if (QEMPTY(att_list))
506 if (in == int_list) {
508 if (QEMPTY(int_list))
517 ac_dog(struct plist *ap, struct plist *dp)
522 natid att_own, def_own;
527 att_own = ap->plane.pln_own;
528 def_own = dp->plane.pln_own;
530 PR(att_own, " %3.3s #%-4d %3.3s #%-4d",
532 ap->plane.pln_uid, dp->pcp->pl_name, dp->plane.pln_uid);
534 PR(def_own, " %3.3s #%-4d %3.3s #%-4d",
536 dp->plane.pln_uid, ap->pcp->pl_name, ap->plane.pln_uid);
537 att = pln_att(&ap->plane);
539 att = pln_def(&ap->plane);
540 att = att * ap->plane.pln_effic / 100;
541 att = MAX(att, ap->pcp->pl_def / 2);
543 def = pln_def(&dp->plane) * dp->plane.pln_effic / 100;
544 def = MAX(def, dp->pcp->pl_def / 2);
546 if ((ap->pcp->pl_flags & P_F) && ap->bombs != 0)
548 if ((dp->pcp->pl_flags & P_F) && dp->bombs != 0)
550 att += ap->pcp->pl_stealth / 25.0;
551 def += dp->pcp->pl_stealth / 25.0;
560 odds = ((double)att / ((double)def + (double)att));
563 intensity = roll(20) + roll(20) + roll(20) + roll(20) + 1;
565 PR(att_own, " %3d/%-3d %3d %3.2f ", att, def, intensity, odds);
566 PR(def_own, " %3d/%-3d %3d %3.2f ", def, att, intensity, odds);
570 while ((intensity--) > 0) {
574 if ((dp->plane.pln_effic - ddam) < PLANE_MINEFF)
578 if ((ap->plane.pln_effic - adam) < PLANE_MINEFF)
583 if (dp->pcp->pl_flags & P_M)
586 PR(att_own, "%3d/%-3d", adam, ddam);
587 PR(def_own, "%3d/%-3d", ddam, adam);
588 ac_planedamage(ap, def_own, adam, def_own, 1, 0, mesg);
589 strncpy(temp, mesg, 14);
590 ac_planedamage(dp, att_own, ddam, att_own, 1, 0, mesg);
591 PR(att_own, "%-13.13s %-13.13s\n", temp, mesg);
592 PR(def_own, "%-13.13s %-13.13s\n", mesg, temp);
595 setcont(att_own, def_own, FOUND_FLY);
596 setcont(def_own, att_own, FOUND_FLY);
601 * zap plane associated with plp.
602 * Damaging country is "from", damage is "dam".
603 * def_own is the country on the other side of the conflict from the plane
604 * owner. The only time def_own != from is when the interceptor is getting
607 * NOTE: This routine removes the appropriate plane element from the
608 * queue if it gets destroyed. That means that the caller must assume
609 * that the current queue pointer is invalid on return from the ac_planedamage
610 * call. (this has caused bugs in the past)
613 ac_planedamage(struct plist *plp, natid from, int dam, natid other,
614 int checkabort, int show, char *mesg)
624 plane_owner = pp->pln_own;
626 sprintf(dmess, " no damage");
631 memset(dmess, 0, sizeof(dmess));
635 if (eff < PLANE_MINEFF) {
636 sprintf(dmess, " shot down");
638 } else if (eff < 80 && chance((80 - eff) / 100.0) && checkabort) {
639 sprintf(dmess, " aborted @%2d%%", eff);
641 } else if (show == 0) {
642 sprintf(dmess, " cleared");
645 if ((plp->pcp->pl_flags & P_M) == 0) {
647 PR(plane_owner, " %s %s takes %d%s.\n",
648 cname(pp->pln_own), prplane(pp), dam, dmess);
650 PR(other, " %s %s takes %d%s.\n",
651 cname(pp->pln_own), prplane(pp), dam, dmess);
654 if (show && checkabort == 1) {
655 PR(plane_owner, "\n");
661 pp->pln_mobil -= MIN(32 + pp->pln_mobil, dam / 2);
663 if (disp == 1 && from != 0 && (plp->pcp->pl_flags & P_M) == 0)
664 nreport(from, N_DOWN_PLANE, pp->pln_own, 1);
667 putplane(pp->pln_uid, pp);
672 ac_doflak(struct emp_qelem *list, struct sctstr *from)
679 plp = (struct plist *)list->q_forw;
680 plane_owner = plp->plane.pln_own;
682 gun = MIN(FLAK_GUN_MAX, from->sct_item[I_GUN]);
683 shell = from->sct_item[I_SHELL];
684 if (gun > shell * 2) {
685 shell += supply_commod(from->sct_own, from->sct_x, from->sct_y,
686 I_SHELL, (gun + 1) / 2 - shell);
687 from->sct_item[I_SHELL] = shell;
693 gun = roundavg(tfact(from->sct_own, 2.0 * gun));
695 PR(plane_owner, "firing %d flak guns in %s...\n",
696 gun, xyas(from->sct_x, from->sct_y, plane_owner));
697 if (from->sct_own != 0)
698 PR(from->sct_own, "firing %d flak guns in %s...\n",
699 gun, xyas(from->sct_x, from->sct_y, from->sct_own));
700 ac_fireflak(list, from->sct_own, gun);
705 ac_shipflak(struct emp_qelem *list, coord x, coord y)
710 double flak, total, ngun;
718 plp = (struct plist *)list->q_forw;
719 plane_owner = plp->plane.pln_own;
721 memset(nats, 0, sizeof(nats));
723 snxtitem_xy(&ni, EF_SHIP, x, y);
724 while (!QEMPTY(list) && nxtitem(&ni, &ship)) {
725 if (ship.shp_own == 0 || ship.shp_own == plane_owner)
727 mcp = &mchr[(int)ship.shp_type];
728 if (mcp->m_flags & M_SUB)
730 rel = getrel(getnatp(ship.shp_own), plane_owner);
734 gun = shp_usable_guns(&ship);
736 shell = ship.shp_item[I_SHELL];
738 shell = supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
740 ship.shp_item[I_SHELL] = shell;
741 putship(ship.shp_uid, &ship);
744 if (gun == 0 || shell == 0)
746 flak = gun * (ship.shp_effic / 100.0);
748 total += techfact(ship.shp_tech, flak * 2.0);
750 if (!nats[ship.shp_own]) {
751 /* First time here, print the message */
752 PR(ship.shp_own, "%s planes spotted over ships in %s\n",
753 cname(plane_owner), xyas(x, y, ship.shp_own));
754 PR(plane_owner, "Flying over %s ships in %s\n",
755 cname(ship.shp_own), xyas(x, y, plane_owner));
756 nats[ship.shp_own] = 1;
758 PR(ship.shp_own, "firing %.0f flak guns from %s...\n",
759 flak, prship(&ship));
763 /* Limit to FLAK_GUN_MAX guns of average tech factor */
764 if (ngun > FLAK_GUN_MAX)
765 total *= FLAK_GUN_MAX / ngun;
767 gun = roundavg(total);
769 PR(plane_owner, "Flak! Ships firing %d flak guns...\n", gun);
770 ac_fireflak(list, from, gun);
775 ac_landflak(struct emp_qelem *list, coord x, coord y)
780 double flak, total, ngun;
788 plp = (struct plist *)list->q_forw;
789 plane_owner = plp->plane.pln_own;
791 memset(nats, 0, sizeof(nats));
793 snxtitem_xy(&ni, EF_LAND, x, y);
794 while (!QEMPTY(list) && nxtitem(&ni, &land)) {
795 if (land.lnd_own == 0 || land.lnd_own == plane_owner)
797 lcp = &lchr[(int)land.lnd_type];
798 aaf = lnd_aaf(&land);
799 if ((lcp->l_flags & L_FLAK) == 0 || aaf == 0)
801 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
803 rel = getrel(getnatp(land.lnd_own), plane_owner);
806 flak = aaf * 1.5 * land.lnd_effic / 100.0;
808 total += techfact(land.lnd_tech, flak * 2.0);
810 if (!nats[land.lnd_own]) {
811 /* First time here, print the message */
812 PR(land.lnd_own, "%s planes spotted over land units in %s\n",
813 cname(plane_owner), xyas(x, y, land.lnd_own));
814 PR(plane_owner, "Flying over %s land units in %s\n",
815 cname(land.lnd_own), xyas(x, y, plane_owner));
816 nats[land.lnd_own] = 1;
818 PR(land.lnd_own, "firing flak guns from unit %s (aa rating %d)\n",
823 /* Limit to FLAK_GUN_MAX guns of average tech factor */
824 if (ngun > FLAK_GUN_MAX)
825 total *= FLAK_GUN_MAX / ngun;
827 gun = roundavg(total);
829 PR(plane_owner, "Flak! Land units firing %d flak guns...\n", gun);
830 ac_fireflak(list, from, gun);
835 * Called from shipflak, landflak, and doflak.
838 ac_fireflak(struct emp_qelem *list, natid from, int guns)
842 struct emp_qelem *qp;
843 struct emp_qelem *next;
846 plp = (struct plist *)list->q_forw;
848 for (qp = list->q_forw; qp != list; qp = next) {
850 plp = (struct plist *)qp;
851 n = ac_flak_dam(guns, pln_def(&plp->plane), plp->pcp->pl_flags);
852 ac_planedamage(plp, from, n, 0, 2, 1, msg);
857 * Calculate flak damage
860 ac_flak_dam(int guns, int def, int pl_flags)
864 /* <-7 -7 -6 -5 -4 */
865 static float flaktable[18] = { 0.132f, 0.20f, 0.20f, 0.25f, 0.30f,
866 /* -3 -2 -1 0 +1 +2 +3 +4 */
867 0.35f, 0.40f, 0.45f, 0.50f, 0.50f, 0.55f, 0.60f, 0.65f,
868 /* +5 +6 +7 +8 >+8 */
869 0.70f,0.75f, 0.80f, 0.85f, 1.1305f };
870 enum { FLAK_MAX = sizeof(flaktable)/sizeof(flaktable[0]) - 1 };
873 if ((pl_flags & P_T) == 0)
881 mult = flaktable[FLAK_MAX];
886 mult = flaktable[flak];
889 dam = (int)((roll(8) + 2) * mult);
896 * Get a list of planes available for interception duties.
899 getilist(struct emp_qelem *list, natid own)
901 struct plchrstr *pcp;
907 snxtitem_all(&ni, EF_PLANE);
908 while (nxtitem(&ni, &plane)) {
909 if (plane.pln_own != own)
911 pcp = &plchr[(int)plane.pln_type];
912 if ((pcp->pl_flags & P_F) == 0)
914 if (plane.pln_flags & PLN_LAUNCHED)
916 if (plane.pln_mission != 0)
918 if (plane.pln_mobil <= 0)
920 if (plane.pln_effic < 40)
922 if (!pln_airbase_ok(&plane, 0, 0))
925 ip = malloc(sizeof(*ip));
928 ip->pcp = &plchr[(int)plane.pln_type];
930 emp_insque(&ip->queue, list);
935 do_evade(struct emp_qelem *bomb_list, struct emp_qelem *esc_list)
937 struct emp_qelem *qp;
942 for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw) {
943 plp = (struct plist *)qp;
944 if (evade > plp->pcp->pl_stealth / 100.0)
945 evade = plp->pcp->pl_stealth / 100.0;
947 for (qp = esc_list->q_forw; qp != esc_list; qp = qp->q_forw) {
948 plp = (struct plist *)qp;
949 if (evade > plp->pcp->pl_stealth / 100.0)
950 evade = plp->pcp->pl_stealth / 100.0;