2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
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.
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, see <http://www.gnu.org/licenses/>.
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.
27 * mission.c: Mission subroutines for planes/ships/units
29 * Known contributors to this file:
31 * Steve McClure, 1996-2000
32 * Markus Armbruster, 2003-2011
47 #include "prototypes.h"
52 struct emp_qelem queue; /* list of units */
53 struct empobj *thing; /* thing's struct */
57 struct emp_qelem queue;
62 static void add_airport(struct emp_qelem *, coord, coord);
63 static int air_damage(struct emp_qelem *, coord, coord, int, natid,
65 static void build_mission_list(struct genlist[],
66 unsigned char[], unsigned char[],
68 static void build_mission_list_type(struct genlist[], unsigned char[],
69 coord, coord, int, int);
70 static void divide(struct emp_qelem *, struct emp_qelem *, coord, coord);
71 static int dosupport(coord, coord, natid, natid, int);
72 static int find_airport(struct emp_qelem *, coord, coord);
73 static void mission_pln_arm(struct emp_qelem *, coord, coord, int,
74 int, struct ichrstr *);
75 static void mission_pln_sel(struct emp_qelem *, int, int, int);
76 static int perform_mission_land(int, struct lndstr *, coord, coord,
77 natid, int, char *, int);
78 static int perform_mission_ship(int, struct shpstr *, coord, coord,
79 natid, int, char *, int);
80 static int perform_mission_msl(int, struct emp_qelem *, coord, coord,
82 static int perform_mission_bomb(int, struct emp_qelem *, coord, coord,
83 natid, int, char *, int, int);
84 static int perform_mission(coord, coord, natid, struct emp_qelem *,
88 tally_dam(int dam, int newdam)
90 return dam < 0 ? newdam : dam + newdam;
94 * Interdict commodities & transported planes
97 ground_interdict(coord x, coord y, natid victim, char *s)
101 unsigned char act[MAXNOC];
102 struct genlist mi[MAXNOC];
104 memset(mi, 0, sizeof(mi));
106 for (cn = 1; cn < MAXNOC; cn++) {
107 act[cn] = relations_with(cn, victim) <= HOSTILE;
108 emp_initque((struct emp_qelem *)&mi[cn]);
111 build_mission_list(mi, act, act, x, y, MI_INTERDICT);
113 for (cn = 1; cn < MAXNOC; cn++) {
114 if (QEMPTY(&mi[cn].queue))
117 newdam = perform_mission(x, y, victim, &mi[cn].queue,
118 MI_INTERDICT, s, SECT_HARDTARGET);
121 mpr(victim, "%s interdiction mission does %d damage!\n",
126 collateral_damage(x, y, dam);
132 collateral_damage(coord x, coord y, int dam)
140 getsect(x, y, §);
142 coll = ldround((double)dam * collateral_dam, 1);
145 mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
146 xyas(x, y, sect.sct_own), coll);
147 sectdamage(§, coll);
155 only_subs(struct emp_qelem *list)
157 struct emp_qelem *qp;
160 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
161 glp = (struct genlist *)qp;
163 if (glp->thing->ef_type != EF_SHIP)
165 if (!(mchr[glp->thing->type].m_flags & M_SUB))
169 /* They were all subs! */
175 * Interdict ships & land units
178 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
181 int cn, rel, newdam, osubs;
183 unsigned char plane_act[MAXNOC], other_act[MAXNOC];
184 struct genlist mi[MAXNOC];
186 memset(mi, 0, sizeof(mi));
187 other_act[0] = plane_act[0] = 0;
188 for (cn = 1; cn < MAXNOC; cn++) {
189 rel = relations_with(cn, victim);
190 other_act[cn] = rel <= HOSTILE;
191 plane_act[cn] = mission == MI_SINTERDICT
192 ? rel <= NEUTRAL : other_act[cn];
193 emp_initque((struct emp_qelem *)&mi[cn]);
196 build_mission_list(mi, other_act, plane_act, x, y, mission);
198 for (cn = 1; cn < MAXNOC; cn++) {
199 if (QEMPTY(&mi[cn].queue))
202 osubs = only_subs(&mi[cn].queue);
203 newdam = perform_mission(x, y, victim, &mi[cn].queue,
204 mission, s, hardtarget);
205 dam = tally_dam(dam, newdam);
207 mpr(victim, "%s interdiction mission does %d damage!\n",
208 osubs ? "Enemy" : cname(cn), newdam);
211 collateral_damage(x, y, dam);
216 * Perform a mission against victim, on behalf of actee
219 off_support(coord x, coord y, natid victim, natid actee)
221 return dosupport(x, y, victim, actee, MI_OSUPPORT);
225 * Perform a mission against victim, on behalf of actee
228 def_support(coord x, coord y, natid victim, natid actee)
230 return dosupport(x, y, victim, actee, MI_DSUPPORT);
234 * Perform support missions in X,Y against VICTIM for ACTEE.
235 * MISSION is either MI_OSUPPORT or MI_DSUPPORT.
236 * Return total damage.
239 dosupport(coord x, coord y, natid victim, natid actee, int mission)
242 unsigned char act[MAXNOC];
243 struct genlist mi[MAXNOC];
247 memset(mi, 0, sizeof(mi));
249 for (cn = 1; cn < MAXNOC; cn++) {
250 act[cn] = feels_like_helping(cn, actee, victim);
251 emp_initque((struct emp_qelem *)&mi[cn]);
254 build_mission_list(mi, act, act, x, y, MI_SUPPORT);
255 build_mission_list(mi, act, act, x, y, mission);
257 for (cn = 1; cn < MAXNOC; cn++) {
258 if (QEMPTY(&mi[cn].queue))
261 newdam = perform_mission(x, y, victim, &mi[cn].queue, MI_SUPPORT,
262 "", SECT_HARDTARGET);
270 build_mission_list(struct genlist mi[],
271 unsigned char other_act[], unsigned char plane_act[],
272 coord x, coord y, int mission)
274 build_mission_list_type(mi, other_act, x, y, mission, EF_LAND);
275 build_mission_list_type(mi, other_act, x, y, mission, EF_SHIP);
276 build_mission_list_type(mi, plane_act, x, y, mission, EF_PLANE);
280 build_mission_list_type(struct genlist mi[], unsigned char act[],
281 coord x, coord y, int mission, int type)
286 union empobj_storage item;
288 snxtitem_all(&ni, type);
289 while (nxtitem(&ni, &item)) {
290 gp = (struct empobj *)&item;
298 if ((gp->mission != mission) && (mission != MI_SINTERDICT))
301 if ((gp->mission != mission) && (mission == MI_SINTERDICT) &&
302 (gp->mission != MI_INTERDICT))
305 if (!in_oparea(gp, x, y))
308 glp = malloc(sizeof(struct genlist));
309 memset(glp, 0, sizeof(struct genlist));
310 glp->thing = malloc(sizeof(item));
311 memcpy(glp->thing, &item, sizeof(item));
312 emp_insque(&glp->queue, &mi[gp->own].queue);
317 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
323 snxtitem_all(&ni, EF_PLANE);
324 while (nxtitem(&ni, &plane)) {
325 if (plane.pln_own != cn)
327 if (plane.pln_mission != MI_ESCORT)
329 if (!in_oparea((struct empobj *)&plane, x, y))
331 plp = malloc(sizeof(struct plist));
332 memset(plp, 0, sizeof(struct plist));
333 plp->pcp = &plchr[(int)plane.pln_type];
335 emp_insque(&plp->queue, escorts);
340 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
341 int mission, char *s, int hardtarget)
343 struct emp_qelem *qp, missiles, bombers;
346 struct plchrstr *pcp;
348 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
350 emp_initque(&missiles);
351 emp_initque(&bombers);
353 for (qp = list->q_forw; qp != list; ) {
354 glp = (struct genlist *)qp;
357 if (glp->thing->ef_type == EF_LAND) {
358 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
359 x, y, victim, mission, s,
361 } else if (glp->thing->ef_type == EF_SHIP) {
362 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
363 x, y, victim, mission, s,
365 } else if (glp->thing->ef_type == EF_PLANE) {
366 pcp = &plchr[glp->thing->type];
367 if ((pcp->pl_flags & P_M)
368 && (hardtarget != SECT_HARDTARGET
369 || (pcp->pl_flags & P_MAR)))
370 ; /* units have their own missile interdiction */
372 /* save planes for later */
373 plp = malloc(sizeof(struct plist));
375 memset(plp, 0, sizeof(struct plist));
377 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
378 if (plp->pcp->pl_flags & P_M)
379 emp_insque(&plp->queue, &missiles);
381 emp_insque(&plp->queue, &bombers);
391 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
392 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
393 hardtarget, targeting_ships);
398 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
399 natid victim, int mission, char *s,
404 if (mission == MI_SINTERDICT)
407 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
409 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
412 range = roundrange(lnd_fire_range(lp));
417 putland(lp->lnd_uid, lp);
421 if (targeting_ships) {
422 if (chance(lnd_acc(lp) / 100.0))
423 dam2 = ldround(dam2 / 2.0, 1);
426 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
428 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
430 "%s fires at %s %s at %s\n",
431 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
433 mpr(victim, "%s %s fires at you at %s\n",
434 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
436 return tally_dam(dam, dam2);
440 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
441 natid victim, int mission, char *s,
444 struct mchrstr *mcp = &mchr[sp->shp_type];
445 double vrange, hitchance;
448 md = mapdist(x, y, sp->shp_x, sp->shp_y);
450 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
451 && md > ship_max_interdiction_range)
454 if (mission == MI_SINTERDICT) {
455 if (!(mcp->m_flags & M_SONAR))
457 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
459 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
460 vrange *= sp->shp_effic / 200.0;
463 /* can't look all the time */
467 if (mcp->m_flags & M_SUB) {
468 if (!targeting_ships)
469 return dam; /* subs interdict only ships */
470 range = roundrange(torprange(sp));
473 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
475 dam2 = shp_torp(sp, 1);
476 putship(sp->shp_uid, sp);
479 hitchance = shp_torp_hitchance(sp, md);
482 "%s locking on %s %s in %s\n",
483 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
485 "\tEffective torpedo range is %d.0\n", range);
487 "\tWhooosh... Hitchance = %d%%\n",
488 (int)(hitchance * 100));
490 if (!chance(hitchance)) {
491 wu(0, sp->shp_own, "\tMissed\n");
493 "Incoming torpedo sighted @ %s missed (whew)!\n",
495 return tally_dam(dam, 0);
497 wu(0, sp->shp_own, "\tBOOM!...\n");
498 nreport(victim, N_TORP_SHIP, 0, 1);
500 "\tTorpedo hit %s %s for %d damage\n",
501 cname(victim), s, dam2);
504 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
505 xyas(x, y, victim), dam2);
507 range = roundrange(shp_fire_range(sp));
510 if (mission == MI_SINTERDICT)
511 dam2 = shp_dchrg(sp);
514 putship(sp->shp_uid, sp);
518 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
520 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
522 "%s fires at %s %s at %s\n",
523 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
525 mpr(victim, "%s %s fires at you at %s\n",
526 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
529 return tally_dam(dam, dam2);
533 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
534 natid victim, int hardtarget)
536 int performed, air_dam, sublaunch, dam2;
537 struct emp_qelem *qp, *newqp;
541 * Missiles, except for interdiction of ships or land units,
542 * because that happens elsewhere, in shp_missile_interdiction()
543 * and lnd_missile_interdiction().
545 performed = air_dam = 0;
546 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
548 plp = (struct plist *)qp;
551 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
552 || (plp->pcp->pl_flags & P_MAR))
553 && mission_pln_equip(plp, NULL, 'p') >= 0) {
554 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
558 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
559 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
561 dam2 = pln_damage(&plp->plane, 'p', 1);
564 plp->plane.pln_effic = 0;
565 putplane(plp->plane.pln_uid, &plp->plane);
571 return performed ? tally_dam(dam, air_dam) : dam;
575 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
576 natid victim, int mission, char *s, int hardtarget,
579 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
581 int plane_owner, performed, air_dam;
584 emp_initque(&escorts);
590 plp = (struct plist *)bombers->q_forw;
591 plane_owner = plp->plane.pln_own;
594 * If there are planes performing an
595 * interdict or support mission, find
596 * some escorts for them, if possible.
597 * Up to 2 per bomber, if possible.
599 find_escorts(x, y, plane_owner, &escorts);
601 if (mission == MI_SINTERDICT)
602 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
604 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
606 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
608 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
609 plp = (struct plist *)qp;
610 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
611 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
614 performed = air_dam = 0;
615 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
619 air = (struct airport *)qp;
624 /* Split off the bombers at this base into b */
625 divide(bombers, &b, air->x, air->y);
627 /* Split off the escorts at this base into e */
628 divide(&escorts, &e, air->x, air->y);
630 if (path_find(air->x, air->y, x, y, plane_owner, MOB_FLY) < 0)
632 md = path_find_route(buf, sizeof(buf), air->x, air->y, x, y);
633 if (md >= sizeof(buf))
636 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
639 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
642 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
643 mission_name(mission),
644 xyas(air->x, air->y, plane_owner),
645 xyas(x, y, plane_owner));
646 if (air->own && (air->own != plane_owner)) {
647 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
648 cname(plane_owner), mission_name(mission),
649 xyas(air->x, air->y, air->own),
650 xyas(x, y, air->own));
653 ac_encounter(&b, &e, air->x, air->y, buf, 0);
657 air_damage(&b, x, y, mission, victim, s, hardtarget);
665 nreport(plane_owner, N_SHP_BOMB, victim, 1);
667 nreport(plane_owner, N_SCT_BOMB, victim, 1);
671 while (qp != (&escorts)) {
678 qp = bombers->q_forw;
679 while (qp != bombers) {
686 return performed ? tally_dam(dam, air_dam) : dam;
690 cando(int mission, int type)
694 if (type == EF_PLANE)
698 if (type == EF_PLANE)
702 if ((type == EF_PLANE) || (type == EF_SHIP))
710 if (type == EF_PLANE)
723 mission_name(int mission)
727 return "an interdiction";
731 return "an offensive support";
733 return "a defensive support";
739 return "a sub interdiction";
741 return "an air defense";
744 return "a mysterious";
748 * Maximum distance GP can perform its mission.
749 * Note: this has nothing to do with the radius of the op-area.
750 * oprange() governs where the unit *can* strike, the op-area governs
751 * where the player wants it to strike.
754 oprange(struct empobj *gp)
756 switch (gp->ef_type) {
758 return ldround(shp_fire_range((struct shpstr *)gp), 1);
760 if (gp->mission == MI_RESERVE)
761 return lnd_reaction_range((struct lndstr *)gp);
762 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
764 /* missiles go one way, so we can use all the range */
765 if (plchr[(int)gp->type].pl_flags & P_M)
766 return ((struct plnstr *)gp)->pln_range;
767 return ((struct plnstr *)gp)->pln_range / 2;
774 * Does GP's mission op area cover X,Y?
777 in_oparea(struct empobj *gp, coord x, coord y)
779 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
780 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
784 * Remove all planes who cannot go on
785 * the mission from the plane list.
788 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
791 struct emp_qelem *qp, *next;
793 struct plchrstr *pcp;
796 for (qp = list->q_forw; qp != list; qp = next) {
798 plp = (struct plist *)qp;
802 if (pp->pln_effic < 40) {
808 if (pp->pln_mobil < 1) {
815 if (ontradingblock(EF_PLANE, pp)) {
822 if (!pln_capable(pp, wantflags, nowantflags)) {
828 if (!pln_airbase_ok(pp, 0, 0)) {
834 if (pcp->pl_flags & P_A) {
835 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
842 putplane(pp->pln_uid, pp);
847 * Arm only the planes at x,y
850 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
851 int mission, struct ichrstr *ip)
853 struct emp_qelem *qp;
854 struct emp_qelem *next;
858 for (qp = list->q_forw; qp != list; qp = next) {
860 plp = (struct plist *)qp;
868 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
869 || mission_pln_equip(plp, ip, mission) < 0) {
875 pp->pln_flags |= PLN_LAUNCHED;
876 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
877 putplane(pp->pln_uid, pp);
882 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
884 struct plchrstr *pcp;
895 if (pp->pln_ship >= 0) {
896 getship(pp->pln_ship, &ship);
897 item = ship.shp_item;
898 } else if (pp->pln_land >= 0) {
899 getland(pp->pln_land, &land);
900 item = land.lnd_item;
902 getsect(pp->pln_x, pp->pln_y, §);
903 item = sect.sct_item;
905 if (pcp->pl_fuel > item[I_PETROL]) {
908 item[I_PETROL] -= pcp->pl_fuel;
912 case 'p': /* pinpoint bomb */
915 case 'i': /* missile interception */
919 case 'e': /* escort */
920 case 0: /* plane interception */
928 if (itype != I_NONE) {
929 needed = load / ichr[itype].i_lbs;
932 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
934 if (itype == I_SHELL && item[itype] < needed) {
935 if (pp->pln_ship >= 0)
936 shp_supply(&ship, I_SHELL, needed);
937 else if (pp->pln_land >= 0)
938 lnd_supply(&land, I_SHELL, needed);
940 sct_supply(§, I_SHELL, needed);
942 if (item[itype] < needed)
944 item[itype] -= needed;
948 if (pp->pln_ship >= 0)
949 putship(ship.shp_uid, &ship);
950 else if (pp->pln_land >= 0)
951 putland(land.lnd_uid, &land);
958 * Return 1 if this x,y pair is in the list
961 find_airport(struct emp_qelem *airp, coord x, coord y)
963 struct emp_qelem *qp;
966 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
967 a = (struct airport *)qp;
968 if ((a->x == x) && (a->y == y))
975 /* #*# This needs to be changed to include acc's -KHS */
977 add_airport(struct emp_qelem *airp, coord x, coord y)
982 a = malloc(sizeof(struct airport));
986 getsect(x, y, §);
987 a->own = sect.sct_own;
989 emp_insque((struct emp_qelem *)a, airp);
993 * Take all the planes in list 1 that
994 * are at x,y, and put them into list 2.
997 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
999 struct emp_qelem *qp, *next;
1002 for (qp = l1->q_forw; qp != l1; qp = next) {
1004 plp = (struct plist *)qp;
1006 if (plp->plane.pln_x != x)
1008 if (plp->plane.pln_y != y)
1017 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1018 natid victim, char *s, int hardtarget)
1020 struct emp_qelem *qp;
1023 int newdam, dam = 0;
1026 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1027 plp = (struct plist *)qp;
1030 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1036 if (plp->pcp->pl_flags & P_A) {
1037 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1039 "\t%s detects sub movement in %s\n",
1040 prplane(pp), xyas(x, y, pp->pln_own));
1043 if (relations_with(pp->pln_own, victim) > HOSTILE) {
1045 "\t%s tracks %s %s at %s\n",
1046 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1050 "\t%s depth-charging %s %s in %s\n",
1051 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1054 "\t%s pinbombing %s %s in %s\n",
1055 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1057 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1058 if (nuk_on_plane(&plp->plane) >= 0)
1060 else if (hardtarget != SECT_HARDTARGET)
1061 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1062 if (roll(100) <= hitchance) {
1063 newdam = pln_damage(&plp->plane, 'p', 1);
1065 "\t\thit %s %s for %d damage\n",
1066 cname(victim), s, newdam);
1069 newdam = pln_damage(&plp->plane, 'p', 0);
1070 wu(0, pp->pln_own, "missed\n");
1071 if (mission == MI_SINTERDICT) {
1073 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1074 xyas(x, y, victim));
1075 } else if (*s == 's') {
1076 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1077 s, xyas(x, y, victim));
1079 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1080 s, xyas(x, y, victim));
1082 /* Now, even though we missed, the bombs
1084 collateral_damage(x, y, newdam);
1087 /* use up missiles */
1088 if (plp->pcp->pl_flags & P_M)