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");
131 while ((dir = *path++) && !QEMPTY(bomb_list)) {
132 if ((val = diridx(dir)) == DIR_STOP)
134 /* XXX using xnorm is probably bad */
135 x = xnorm(x + diroff[val][0]);
136 y = ynorm(y + diroff[val][1]);
137 getsect(x, y, §);
139 if (mission_flags & PM_R) {
140 flags = plane_caps(bomb_list);
142 setcont(plane_owner, sect.sct_own, FOUND_FLY);
143 if (sect.sct_type == SCT_WATER) {
144 PR(plane_owner, "flying over %s at %s\n",
145 dchr[sect.sct_type].d_name, xyas(x, y, plane_owner));
146 if (mission_flags & PM_S)
147 plane_sweep(bomb_list, x, y);
149 plane_sona(bomb_list, x, y, &head);
150 changed += map_set(plane_owner,
151 sect.sct_x, sect.sct_y,
152 dchr[sect.sct_type].d_mnem, 0);
153 } else if (flags & P_S) {
154 satdisp_sect(§, flags & P_I ? 10 : 50);
156 /* This is borrowed from lookout */
157 if (sect.sct_own == plane_owner)
158 PR(plane_owner, "Your ");
160 PR(plane_owner, "%s (#%d) ",
161 cname(sect.sct_own), sect.sct_own);
162 PR(plane_owner, "%s", dchr[sect.sct_type].d_name);
163 changed += map_set(plane_owner,
164 sect.sct_x, sect.sct_y,
165 dchr[sect.sct_type].d_mnem, 0);
166 PR(plane_owner, " %d%% efficient ",
167 (sect.sct_own == plane_owner) ?
168 sect.sct_effic : roundintby((int)sect.sct_effic, 25));
169 civ = sect.sct_item[I_CIVIL];
170 mil = sect.sct_item[I_MILIT];
172 PR(plane_owner, "with %s%d civ ",
173 (sect.sct_own == plane_owner) ?
175 (sect.sct_own == plane_owner) ?
176 civ : roundintby(civ, 25));
178 PR(plane_owner, "with %s%d mil ",
179 (sect.sct_own == plane_owner) ?
181 (sect.sct_own == plane_owner) ?
182 mil : roundintby(mil, 25));
183 PR(plane_owner, "@ %s\n", xyas(x, y, plane_owner));
186 satdisp_units(sect.sct_x, sect.sct_y);
188 PR(plane_owner, "flying over %s at %s\n",
189 dchr[sect.sct_type].d_name, xyas(x, y, plane_owner));
190 changed += map_set(plane_owner, sect.sct_x, sect.sct_y,
191 dchr[sect.sct_type].d_mnem, 0);
194 evaded = do_evade(bomb_list, esc_list);
198 if (sect.sct_own != 0 && sect.sct_own != plane_owner
199 && getrel(getnatp(sect.sct_own), plane_owner) != ALLIED) {
200 overfly[sect.sct_own]++;
201 PR(sect.sct_own, "%s planes spotted over %s\n",
202 cname(plane_owner), xyas(x, y, sect.sct_own));
204 setcont(sect.sct_own, plane_owner, FOUND_FLY);
208 if (unfriendly[sect.sct_own])
209 ac_doflak(bomb_list, §);
210 /* If bombers left, fire flak from units and ships */
211 if (!QEMPTY(bomb_list))
212 ac_landflak(bomb_list, x, y);
213 if (!QEMPTY(bomb_list))
214 ac_shipflak(bomb_list, x, y);
215 /* mission planes aborted due to flak -- don't send escorts */
216 if (QEMPTY(bomb_list))
220 air_defense(x, y, plane_owner, bomb_list, esc_list);
222 if (sect.sct_own == 0 || sect.sct_own == plane_owner)
225 if (unfriendly[sect.sct_own]) {
226 if (!gotilist[sect.sct_own]) {
227 getilist(&ilist[sect.sct_own], sect.sct_own);
228 gotilist[sect.sct_own]++;
230 ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
235 /* Let's report all of the overflights even if aborted */
236 for (cn = 1; cn < MAXNOC; cn++) {
237 if (plane_owner == cn)
240 nreport(plane_owner, N_OVFLY_SECT, cn, overfly[cn]);
242 /* If the map changed, update it */
244 writemap(player->cnum);
245 /* Now, if the bomber and escort lists are empty, we are done */
246 if (QEMPTY(bomb_list) && QEMPTY(esc_list))
249 /* Something made it through */
250 /* Go figure out if there are ships in this sector, and who's they are */
251 memset(nats, 0, sizeof(nats));
252 snxtitem_xy(&ni, EF_SHIP, x, y);
253 while (nxtitem(&ni, &ship)) {
254 if (mchr[(int)ship.shp_type].m_flags & M_SUB)
256 nats[ship.shp_own]++;
258 /* Go figure out if there are units in this sector, and who's they are */
259 memset(lnats, 0, sizeof(lnats));
260 snxtitem_xy(&ni, EF_LAND, x, y);
261 while (nxtitem(&ni, &land)) {
262 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
264 lnats[land.lnd_own]++;
267 /* Now, let's make life a little rougher. */
268 for (cn = 1; cn < MAXNOC && !QEMPTY(bomb_list); cn++) {
269 if (plane_owner == cn)
272 PR(plane_owner, "Flying over %s ships in %s\n",
273 cname(cn), xyas(x, y, plane_owner));
274 PR(cn, "%s planes spotted over ships in %s\n",
275 cname(plane_owner), xyas(x, y, cn));
277 if (lnats[cn] != 0) {
278 PR(plane_owner, "Flying over %s land units in %s\n",
279 cname(cn), xyas(x, y, plane_owner));
280 PR(cn, "%s planes spotted over land units in %s\n",
281 cname(plane_owner), xyas(x, y, cn));
283 if (nats[cn] || lnats[cn]) {
285 setcont(cn, plane_owner, FOUND_FLY);
286 if (unfriendly[cn] && !evaded) {
288 getilist(&ilist[cn], cn);
291 ac_intercept(bomb_list, esc_list, &ilist[cn], cn, x, y);
296 free_shiplist(&head);
297 for (cn = 1; cn < MAXNOC; cn++) {
304 plane_caps(struct emp_qelem *list)
306 struct emp_qelem *qp;
311 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
312 plp = (struct plist *)qp;
313 fl |= plp->pcp->pl_flags;
320 sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list,
321 natid def_own, natid plane_owner, coord x, coord y,
324 struct emp_qelem *aqp;
325 struct emp_qelem *anext;
326 struct emp_qelem *dqp;
327 struct emp_qelem *dnext;
332 for (aqp = att_list->q_forw,
333 dqp = def_list->q_forw;
334 aqp != att_list && dqp != def_list; aqp = anext) {
336 aplp = (struct plist *)aqp;
337 if (aplp->pcp->pl_cost < 1000)
339 for (; dqp != def_list; dqp = dnext) {
341 dplp = (struct plist *)dqp;
342 if (!(dplp->pcp->pl_flags & P_M))
345 if (dplp->plane.pln_range <
346 mapdist(x, y, dplp->plane.pln_x, dplp->plane.pln_y))
348 if (CANT_HAPPEN(dplp->plane.pln_flags & PLN_LAUNCHED)
349 || mission_pln_equip(dplp, 0, P_F, 0) < 0) {
354 dplp->plane.pln_flags |= PLN_LAUNCHED;
355 putplane(dplp->plane.pln_uid, &dplp->plane);
358 PR(plane_owner, "%s launches SAMs!\n", cname(def_own));
359 PR(def_own, "Launching SAMs at %s planes over %s!\n",
360 cname(plane_owner), xyas(x, y, def_own));
361 ac_combat_headers(plane_owner, def_own);
369 PR(plane_owner, "\n");
372 if (delete_missiles) {
373 for (; dqp != def_list; dqp = dnext) {
375 dplp = (struct plist *)dqp;
376 if (!(dplp->pcp->pl_flags & P_M))
386 ac_intercept(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
387 struct emp_qelem *def_list, natid def_own, coord x, coord y)
392 struct emp_qelem *next;
393 struct emp_qelem *qp;
394 struct emp_qelem int_list;
399 plp = (struct plist *)bomb_list->q_forw;
400 plane_owner = plp->plane.pln_own;
402 sam_intercept(bomb_list, def_list, def_own, plane_owner, x, y, 0);
403 sam_intercept(esc_list, def_list, def_own, plane_owner, x, y, 0);
406 for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw)
408 for (qp = esc_list->q_forw; qp != esc_list; qp = qp->q_forw)
413 emp_initque(&int_list);
415 for (qp = def_list->q_forw; qp != def_list; qp = next) {
417 plp = (struct plist *)qp;
419 /* SAMs interdict separately */
420 if (plp->pcp->pl_flags & P_M)
422 dist = mapdist(x, y, pp->pln_x, pp->pln_y) * 2;
423 if (pp->pln_range < dist)
425 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
426 || mission_pln_equip(plp, 0, P_F, 0) < 0) {
431 /* got one; delete from def_list, add to int_list */
433 emp_insque(qp, &int_list);
434 pp->pln_flags |= PLN_LAUNCHED;
435 pp->pln_mobil -= pln_mobcost(dist, pp, P_F);
436 putplane(pp->pln_uid, pp);
438 if (icount > att_count)
443 PR(plane_owner, "%d %s fighter%s rising to intercept!\n",
444 icount, cname(def_own), icount == 1 ? " is" : "s are");
445 PR(def_own, "%d fighter%s intercepting %s planes over %s!\n",
446 icount, icount == 1 ? " is" : "s are", cname(plane_owner),
447 xyas(x, y, def_own));
448 ac_combat_headers(plane_owner, def_own);
449 ac_airtoair(esc_list, &int_list);
450 ac_airtoair(bomb_list, &int_list);
451 PR(plane_owner, "\n");
457 ac_combat_headers(natid plane_owner, natid def_own)
460 " %-10.10s %-10.10s strength int odds damage results\n",
461 cname(plane_owner), cname(def_own));
463 " %-10.10s %-10.10s strength int odds damage results\n",
464 cname(def_own), cname(plane_owner));
471 ac_airtoair(struct emp_qelem *att_list, struct emp_qelem *int_list)
473 struct plist *attacker;
474 struct plist *interceptor;
475 struct emp_qelem *att;
476 struct emp_qelem *in;
480 struct emp_qelem *att_next;
481 struct emp_qelem *in_next;
483 att = att_list->q_forw;
484 in = int_list->q_forw;
487 if (QEMPTY(att_list) || QEMPTY(int_list)) {
491 while (more_att || more_int) {
492 in_next = in->q_forw;
493 att_next = att->q_forw;
494 attacker = (struct plist *)att;
495 interceptor = (struct plist *)in;
496 nplanes = attacker->plane.pln_effic;
497 if (nplanes > interceptor->plane.pln_effic)
498 nplanes = interceptor->plane.pln_effic;
499 ac_dog(attacker, interceptor);
502 if (att == att_list) {
504 if (QEMPTY(att_list))
509 if (in == int_list) {
511 if (QEMPTY(int_list))
520 ac_dog(struct plist *ap, struct plist *dp)
525 natid att_own, def_own;
530 att_own = ap->plane.pln_own;
531 def_own = dp->plane.pln_own;
533 PR(att_own, " %3.3s #%-4d %3.3s #%-4d",
535 ap->plane.pln_uid, dp->pcp->pl_name, dp->plane.pln_uid);
537 PR(def_own, " %3.3s #%-4d %3.3s #%-4d",
539 dp->plane.pln_uid, ap->pcp->pl_name, ap->plane.pln_uid);
540 att = pln_att(&ap->plane);
542 att = pln_def(&ap->plane);
543 att = att * ap->plane.pln_effic / 100;
544 att = MAX(att, ap->pcp->pl_def / 2);
546 def = pln_def(&dp->plane) * dp->plane.pln_effic / 100;
547 def = MAX(def, dp->pcp->pl_def / 2);
549 if ((ap->pcp->pl_flags & P_F) && ap->bombs != 0)
551 if ((dp->pcp->pl_flags & P_F) && dp->bombs != 0)
553 att += ap->pcp->pl_stealth / 25.0;
554 def += dp->pcp->pl_stealth / 25.0;
563 odds = ((double)att / ((double)def + (double)att));
566 intensity = roll(20) + roll(20) + roll(20) + roll(20) + 1;
568 PR(att_own, " %3d/%-3d %3d %3.2f ", att, def, intensity, odds);
569 PR(def_own, " %3d/%-3d %3d %3.2f ", def, att, intensity, odds);
573 while ((intensity--) > 0) {
577 if ((dp->plane.pln_effic - ddam) < PLANE_MINEFF)
581 if ((ap->plane.pln_effic - adam) < PLANE_MINEFF)
586 if (dp->pcp->pl_flags & P_M)
589 PR(att_own, "%3d/%-3d", adam, ddam);
590 PR(def_own, "%3d/%-3d", ddam, adam);
591 ac_planedamage(ap, def_own, adam, def_own, 1, 0, mesg);
592 strncpy(temp, mesg, 14);
593 ac_planedamage(dp, att_own, ddam, att_own, 1, 0, mesg);
594 PR(att_own, "%-13.13s %-13.13s\n", temp, mesg);
595 PR(def_own, "%-13.13s %-13.13s\n", mesg, temp);
598 setcont(att_own, def_own, FOUND_FLY);
599 setcont(def_own, att_own, FOUND_FLY);
604 * zap plane associated with plp.
605 * Damaging country is "from", damage is "dam".
606 * def_own is the country on the other side of the conflict from the plane
607 * owner. The only time def_own != from is when the interceptor is getting
610 * NOTE: This routine removes the appropriate plane element from the
611 * queue if it gets destroyed. That means that the caller must assume
612 * that the current queue pointer is invalid on return from the ac_planedamage
613 * call. (this has caused bugs in the past)
616 ac_planedamage(struct plist *plp, natid from, int dam, natid other,
617 int checkabort, int show, char *mesg)
627 plane_owner = pp->pln_own;
629 sprintf(dmess, " no damage");
634 memset(dmess, 0, sizeof(dmess));
638 if (eff < PLANE_MINEFF) {
639 sprintf(dmess, " shot down");
641 } else if (eff < 80 && chance((80 - eff) / 100.0) && checkabort) {
642 sprintf(dmess, " aborted @%2d%%", eff);
644 } else if (show == 0) {
645 sprintf(dmess, " cleared");
648 if ((plp->pcp->pl_flags & P_M) == 0) {
650 PR(plane_owner, " %s %s takes %d%s.\n",
651 cname(pp->pln_own), prplane(pp), dam, dmess);
653 PR(other, " %s %s takes %d%s.\n",
654 cname(pp->pln_own), prplane(pp), dam, dmess);
657 if (show && checkabort == 1) {
658 PR(plane_owner, "\n");
664 pp->pln_mobil -= MIN(32 + pp->pln_mobil, dam / 2);
666 if (disp == 1 && from != 0 && (plp->pcp->pl_flags & P_M) == 0)
667 nreport(from, N_DOWN_PLANE, pp->pln_own, 1);
670 putplane(pp->pln_uid, pp);
675 ac_doflak(struct emp_qelem *list, struct sctstr *from)
682 plp = (struct plist *)list->q_forw;
683 plane_owner = plp->plane.pln_own;
685 gun = MIN(FLAK_GUN_MAX, from->sct_item[I_GUN]);
686 shell = from->sct_item[I_SHELL];
687 if (gun > shell * 2) {
688 shell += supply_commod(from->sct_own, from->sct_x, from->sct_y,
689 I_SHELL, (gun + 1) / 2 - shell);
690 from->sct_item[I_SHELL] = shell;
696 gun = roundavg(tfact(from->sct_own, 2.0 * gun));
698 PR(plane_owner, "firing %d flak guns in %s...\n",
699 gun, xyas(from->sct_x, from->sct_y, plane_owner));
700 if (from->sct_own != 0)
701 PR(from->sct_own, "firing %d flak guns in %s...\n",
702 gun, xyas(from->sct_x, from->sct_y, from->sct_own));
703 ac_fireflak(list, from->sct_own, gun);
708 ac_shipflak(struct emp_qelem *list, coord x, coord y)
713 double flak, total, ngun;
721 plp = (struct plist *)list->q_forw;
722 plane_owner = plp->plane.pln_own;
724 memset(nats, 0, sizeof(nats));
726 snxtitem_xy(&ni, EF_SHIP, x, y);
727 while (!QEMPTY(list) && nxtitem(&ni, &ship)) {
728 if (ship.shp_own == 0 || ship.shp_own == plane_owner)
730 mcp = &mchr[(int)ship.shp_type];
731 if (mcp->m_flags & M_SUB)
733 rel = getrel(getnatp(ship.shp_own), plane_owner);
737 gun = shp_usable_guns(&ship);
739 shell = ship.shp_item[I_SHELL];
741 shell = supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
743 ship.shp_item[I_SHELL] = shell;
744 putship(ship.shp_uid, &ship);
747 if (gun == 0 || shell == 0)
749 flak = gun * (ship.shp_effic / 100.0);
751 total += techfact(ship.shp_tech, flak * 2.0);
753 if (!nats[ship.shp_own]) {
754 /* First time here, print the message */
755 PR(ship.shp_own, "%s planes spotted over ships in %s\n",
756 cname(plane_owner), xyas(x, y, ship.shp_own));
757 PR(plane_owner, "Flying over %s ships in %s\n",
758 cname(ship.shp_own), xyas(x, y, plane_owner));
759 nats[ship.shp_own] = 1;
761 PR(ship.shp_own, "firing %.0f flak guns from %s...\n",
762 flak, prship(&ship));
766 /* Limit to FLAK_GUN_MAX guns of average tech factor */
767 if (ngun > FLAK_GUN_MAX)
768 total *= FLAK_GUN_MAX / ngun;
770 gun = roundavg(total);
772 PR(plane_owner, "Flak! Ships firing %d flak guns...\n", gun);
773 ac_fireflak(list, from, gun);
778 ac_landflak(struct emp_qelem *list, coord x, coord y)
783 double flak, total, ngun;
791 plp = (struct plist *)list->q_forw;
792 plane_owner = plp->plane.pln_own;
794 memset(nats, 0, sizeof(nats));
796 snxtitem_xy(&ni, EF_LAND, x, y);
797 while (!QEMPTY(list) && nxtitem(&ni, &land)) {
798 if (land.lnd_own == 0 || land.lnd_own == plane_owner)
800 lcp = &lchr[(int)land.lnd_type];
801 aaf = lnd_aaf(&land);
802 if ((lcp->l_flags & L_FLAK) == 0 || aaf == 0)
804 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
806 rel = getrel(getnatp(land.lnd_own), plane_owner);
809 flak = aaf * 1.5 * land.lnd_effic / 100.0;
811 total += techfact(land.lnd_tech, flak * 2.0);
813 if (!nats[land.lnd_own]) {
814 /* First time here, print the message */
815 PR(land.lnd_own, "%s planes spotted over land units in %s\n",
816 cname(plane_owner), xyas(x, y, land.lnd_own));
817 PR(plane_owner, "Flying over %s land units in %s\n",
818 cname(land.lnd_own), xyas(x, y, plane_owner));
819 nats[land.lnd_own] = 1;
821 PR(land.lnd_own, "firing flak guns from unit %s (aa rating %d)\n",
826 /* Limit to FLAK_GUN_MAX guns of average tech factor */
827 if (ngun > FLAK_GUN_MAX)
828 total *= FLAK_GUN_MAX / ngun;
830 gun = roundavg(total);
832 PR(plane_owner, "Flak! Land units firing %d flak guns...\n", gun);
833 ac_fireflak(list, from, gun);
838 * Called from shipflak, landflak, and doflak.
841 ac_fireflak(struct emp_qelem *list, natid from, int guns)
845 struct emp_qelem *qp;
846 struct emp_qelem *next;
849 plp = (struct plist *)list->q_forw;
851 for (qp = list->q_forw; qp != list; qp = next) {
853 plp = (struct plist *)qp;
854 n = ac_flak_dam(guns, pln_def(&plp->plane), plp->pcp->pl_flags);
855 ac_planedamage(plp, from, n, 0, 2, 1, msg);
860 * Calculate flak damage
863 ac_flak_dam(int guns, int def, int pl_flags)
867 /* <-7 -7 -6 -5 -4 */
868 static float flaktable[18] = { 0.132f, 0.20f, 0.20f, 0.25f, 0.30f,
869 /* -3 -2 -1 0 +1 +2 +3 +4 */
870 0.35f, 0.40f, 0.45f, 0.50f, 0.50f, 0.55f, 0.60f, 0.65f,
871 /* +5 +6 +7 +8 >+8 */
872 0.70f,0.75f, 0.80f, 0.85f, 1.1305f };
873 enum { FLAK_MAX = sizeof(flaktable)/sizeof(flaktable[0]) - 1 };
876 if ((pl_flags & P_T) == 0)
884 mult = flaktable[FLAK_MAX];
889 mult = flaktable[flak];
892 dam = (int)((roll(8) + 2) * mult);
899 * Get a list of planes available for interception duties.
902 getilist(struct emp_qelem *list, natid own)
904 struct plchrstr *pcp;
910 snxtitem_all(&ni, EF_PLANE);
911 while (nxtitem(&ni, &plane)) {
912 if (plane.pln_own != own)
914 pcp = &plchr[(int)plane.pln_type];
915 if ((pcp->pl_flags & P_F) == 0)
917 if (plane.pln_flags & PLN_LAUNCHED)
919 if (plane.pln_mission != 0)
921 if (plane.pln_mobil <= 0)
923 if (plane.pln_effic < 40)
925 if (!pln_airbase_ok(&plane, 0, 0))
928 ip = malloc(sizeof(*ip));
931 ip->pcp = &plchr[(int)plane.pln_type];
933 emp_insque(&ip->queue, list);
938 do_evade(struct emp_qelem *bomb_list, struct emp_qelem *esc_list)
940 struct emp_qelem *qp;
945 for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw) {
946 plp = (struct plist *)qp;
947 if (evade > plp->pcp->pl_stealth / 100.0)
948 evade = plp->pcp->pl_stealth / 100.0;
950 for (qp = esc_list->q_forw; qp != esc_list; qp = qp->q_forw) {
951 plp = (struct plist *)qp;
952 if (evade > plp->pcp->pl_stealth / 100.0)
953 evade = plp->pcp->pl_stealth / 100.0;