2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2010, 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 * mission.c: Mission subroutines for planes/ships/units
30 * Known contributors to this file:
32 * Steve McClure, 1996-2000
33 * Markus Armbruster, 2003-2009
48 #include "prototypes.h"
53 struct emp_qelem queue; /* list of units */
54 struct empobj *thing; /* thing's struct */
58 struct emp_qelem queue;
63 static void add_airport(struct emp_qelem *, coord, coord);
64 static int air_damage(struct emp_qelem *, coord, coord, int, natid,
66 static void build_mission_list(struct genlist *, coord, coord, int, natid);
67 static void build_mission_list_type(struct genlist *, coord, coord, int,
69 static void divide(struct emp_qelem *, struct emp_qelem *, coord, coord);
70 static int dosupport(coord, coord, natid, natid, int);
71 static int find_airport(struct emp_qelem *, coord, coord);
72 static void mission_pln_arm(struct emp_qelem *, coord, coord, int,
73 int, struct ichrstr *);
74 static void mission_pln_sel(struct emp_qelem *, int, int, int);
75 static int perform_mission_land(int, struct lndstr *, coord, coord,
76 natid, int, char *, int);
77 static int perform_mission_ship(int, struct shpstr *, coord, coord,
78 natid, int, char *, int);
79 static int perform_mission_msl(int, struct emp_qelem *, coord, coord,
81 static int perform_mission_bomb(int, struct emp_qelem *, coord, coord,
82 natid, int, char *, int, int);
83 static int perform_mission(coord, coord, natid, struct emp_qelem *,
87 tally_dam(int dam, int newdam)
89 return dam < 0 ? newdam : dam + newdam;
93 * Interdict commodities & transported planes
96 ground_interdict(coord x, coord y, natid victim, char *s)
99 int dam = 0, newdam, rel;
100 struct genlist mi[MAXNOC];
102 memset(mi, 0, sizeof(mi));
103 for (cn = 1; cn < MAXNOC; cn++)
104 emp_initque((struct emp_qelem *)&mi[cn]);
106 build_mission_list(mi, x, y, MI_INTERDICT, victim);
108 for (cn = 1; cn < MAXNOC; cn++) {
109 rel = getrel(getnatp(cn), victim);
113 if (QEMPTY(&mi[cn].queue))
116 newdam = perform_mission(x, y, victim, &mi[cn].queue,
117 MI_INTERDICT, s, SECT_HARDTARGET);
120 mpr(victim, "%s interdiction mission does %d damage!\n",
125 collateral_damage(x, y, dam);
131 collateral_damage(coord x, coord y, int dam)
139 getsect(x, y, §);
141 coll = ldround((double)dam * collateral_dam, 1);
144 mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
145 xyas(x, y, sect.sct_own), coll);
146 sectdamage(§, coll);
154 only_subs(struct emp_qelem *list)
156 struct emp_qelem *qp;
159 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
160 glp = (struct genlist *)qp;
162 if (glp->thing->ef_type != EF_SHIP)
164 if (!(mchr[glp->thing->type].m_flags & M_SUB))
168 /* They were all subs! */
174 * Interdict ships & land units
177 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
180 int cn, newdam, osubs;
182 struct genlist mi[MAXNOC];
184 memset(mi, 0, sizeof(mi));
185 for (cn = 1; cn < MAXNOC; cn++)
186 emp_initque((struct emp_qelem *)&mi[cn]);
188 build_mission_list(mi, x, y, mission, victim);
190 for (cn = 1; cn < MAXNOC; cn++) {
193 if (mission == MI_SINTERDICT) {
194 if (getrel(getnatp(cn), victim) >= FRIENDLY)
196 } else if (getrel(getnatp(cn), victim) > HOSTILE)
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 dosupport(coord x, coord y, natid victim, natid actee, int mission)
237 struct genlist mi[MAXNOC];
241 memset(mi, 0, sizeof(mi));
242 for (cn = 1; cn < MAXNOC; cn++)
243 emp_initque((struct emp_qelem *)&mi[cn]);
245 build_mission_list(mi, x, y, MI_SUPPORT, victim);
246 build_mission_list(mi, x, y, mission, victim);
248 for (cn = 1; cn < MAXNOC; cn++) {
249 rel = getrel(getnatp(cn), actee);
250 if ((cn != actee) && (rel != ALLIED))
252 rel = getrel(getnatp(cn), victim);
253 if ((cn != actee) && (rel != AT_WAR))
256 if (QEMPTY(&mi[cn].queue))
259 newdam = perform_mission(x, y, victim, &mi[cn].queue, MI_SUPPORT,
260 "", SECT_HARDTARGET);
268 build_mission_list(struct genlist *mi, coord x, coord y, int mission,
271 build_mission_list_type(mi, x, y, mission, EF_LAND, victim);
272 build_mission_list_type(mi, x, y, mission, EF_SHIP, victim);
273 build_mission_list_type(mi, x, y, mission, EF_PLANE, victim);
277 build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
278 int type, natid victim)
283 union empobj_storage item;
286 snxtitem_all(&ni, type);
287 while (nxtitem(&ni, &item)) {
288 gp = (struct empobj *)&item;
296 if ((gp->mission != mission) && (mission != MI_SINTERDICT))
299 if ((gp->mission != mission) && (mission == MI_SINTERDICT) &&
300 (gp->mission != MI_INTERDICT))
303 relat = getrel(getnatp(gp->own), victim);
304 if (mission == MI_SINTERDICT) {
305 if (relat >= FRIENDLY)
307 else if (type != EF_PLANE && relat > HOSTILE)
309 } else if (relat > HOSTILE)
312 if (!in_oparea(gp, x, y))
315 glp = malloc(sizeof(struct genlist));
316 memset(glp, 0, sizeof(struct genlist));
317 glp->thing = malloc(sizeof(item));
318 memcpy(glp->thing, &item, sizeof(item));
319 emp_insque(&glp->queue, &mi[gp->own].queue);
324 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
330 snxtitem_all(&ni, EF_PLANE);
331 while (nxtitem(&ni, &plane)) {
332 if (plane.pln_own != cn)
334 if (plane.pln_mission != MI_ESCORT)
336 if (!in_oparea((struct empobj *)&plane, x, y))
338 plp = malloc(sizeof(struct plist));
339 memset(plp, 0, sizeof(struct plist));
340 plp->pcp = &plchr[(int)plane.pln_type];
342 emp_insque(&plp->queue, escorts);
347 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
348 int mission, char *s, int hardtarget)
350 struct emp_qelem *qp, missiles, bombers;
353 struct plchrstr *pcp;
355 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
357 emp_initque(&missiles);
358 emp_initque(&bombers);
360 for (qp = list->q_forw; qp != list; ) {
361 glp = (struct genlist *)qp;
364 if (glp->thing->ef_type == EF_LAND) {
365 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
366 x, y, victim, mission, s,
368 } else if (glp->thing->ef_type == EF_SHIP) {
369 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
370 x, y, victim, mission, s,
372 } else if (glp->thing->ef_type == EF_PLANE) {
373 pcp = &plchr[glp->thing->type];
374 if (pcp->pl_flags & P_M)
375 /* units have their own missile interdiction */
376 if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
379 /* save planes for later */
380 plp = malloc(sizeof(struct plist));
382 memset(plp, 0, sizeof(struct plist));
384 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
385 if (plp->pcp->pl_flags & P_M)
386 emp_insque(&plp->queue, &missiles);
388 emp_insque(&plp->queue, &bombers);
397 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
398 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
399 hardtarget, targeting_ships);
404 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
405 natid victim, int mission, char *s,
410 if (mission == MI_SINTERDICT)
413 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
415 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
418 range = roundrange(lnd_fire_range(lp));
423 putland(lp->lnd_uid, lp);
427 if (targeting_ships) {
428 if (chance(lnd_acc(lp) / 100.0))
429 dam2 = ldround(dam2 / 2.0, 1);
432 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
434 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
436 "%s fires at %s %s at %s\n",
437 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
439 mpr(victim, "%s %s fires at you at %s\n",
440 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
442 return tally_dam(dam, dam2);
446 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
447 natid victim, int mission, char *s,
450 struct mchrstr *mcp = &mchr[sp->shp_type];
451 double vrange, hitchance;
454 md = mapdist(x, y, sp->shp_x, sp->shp_y);
456 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
457 && md > ship_max_interdiction_range)
460 if (mission == MI_SINTERDICT) {
461 if (!(mcp->m_flags & M_SONAR))
463 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
465 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
466 vrange *= sp->shp_effic / 200.0;
469 /* can't look all the time */
473 if (mcp->m_flags & M_SUB) {
474 if (!targeting_ships)
475 return dam; /* subs interdict only ships */
476 range = roundrange(torprange(sp));
479 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
481 dam2 = shp_torp(sp, 1);
482 putship(sp->shp_uid, sp);
485 hitchance = shp_torp_hitchance(sp, md);
488 "%s locking on %s %s in %s\n",
489 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
491 "\tEffective torpedo range is %d.0\n", range);
493 "\tWhooosh... Hitchance = %d%%\n",
494 (int)(hitchance * 100));
496 if (!chance(hitchance)) {
497 wu(0, sp->shp_own, "\tMissed\n");
499 "Incoming torpedo sighted @ %s missed (whew)!\n",
501 return tally_dam(dam, 0);
503 wu(0, sp->shp_own, "\tBOOM!...\n");
504 nreport(victim, N_TORP_SHIP, 0, 1);
506 "\tTorpedo hit %s %s for %d damage\n",
507 cname(victim), s, dam2);
510 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
511 xyas(x, y, victim), dam2);
513 range = roundrange(shp_fire_range(sp));
516 if (mission == MI_SINTERDICT)
517 dam2 = shp_dchrg(sp);
520 putship(sp->shp_uid, sp);
524 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
526 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
528 "%s fires at %s %s at %s\n",
529 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
531 mpr(victim, "%s %s fires at you at %s\n",
532 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
535 return tally_dam(dam, dam2);
539 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
540 natid victim, int hardtarget)
542 int performed, air_dam, sublaunch, dam2;
543 struct emp_qelem *qp, *newqp;
547 * Missiles, except for interdiction of ships or land units,
548 * because that happens elsewhere, in shp_missile_interdiction()
549 * and lnd_missile_interdiction().
551 performed = air_dam = 0;
552 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
554 plp = (struct plist *)qp;
557 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
558 || (plp->pcp->pl_flags & P_MAR))
559 && mission_pln_equip(plp, NULL, 'p') >= 0) {
560 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
564 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
565 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
567 dam2 = pln_damage(&plp->plane, 'p', 1);
570 plp->plane.pln_effic = 0;
571 putplane(plp->plane.pln_uid, &plp->plane);
577 return performed ? tally_dam(dam, air_dam) : dam;
581 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
582 natid victim, int mission, char *s, int hardtarget,
585 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
587 int plane_owner, performed, air_dam, md;
589 emp_initque(&escorts);
595 plp = (struct plist *)bombers->q_forw;
596 plane_owner = plp->plane.pln_own;
599 * If there are planes performing an
600 * interdict or support mission, find
601 * some escorts for them, if possible.
602 * Up to 2 per bomber, if possible.
604 find_escorts(x, y, plane_owner, &escorts);
606 if (mission == MI_SINTERDICT)
607 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
609 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
611 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
613 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
614 plp = (struct plist *)qp;
615 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
616 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
619 performed = air_dam = 0;
620 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
625 air = (struct airport *)qp;
626 md = mapdist(x, y, air->x, air->y);
631 /* Split off the bombers at this base into b */
632 divide(bombers, &b, air->x, air->y);
634 /* Split off the escorts at this base into e */
635 divide(&escorts, &e, air->x, air->y);
637 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
642 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
644 pp = BestAirPath(buf, air->x, air->y, x, y);
645 if (CANT_HAPPEN(!pp))
648 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
649 mission_name(mission),
650 xyas(air->x, air->y, plane_owner),
651 xyas(x, y, plane_owner));
652 if (air->own && (air->own != plane_owner)) {
653 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
654 cname(plane_owner), mission_name(mission),
655 xyas(air->x, air->y, air->own),
656 xyas(x, y, air->own));
659 ac_encounter(&b, &e, air->x, air->y, pp, 0);
663 air_damage(&b, x, y, mission, victim, s, hardtarget);
671 nreport(plane_owner, N_SHP_BOMB, victim, 1);
673 nreport(plane_owner, N_SCT_BOMB, victim, 1);
677 while (qp != (&escorts)) {
684 qp = bombers->q_forw;
685 while (qp != bombers) {
692 return performed ? tally_dam(dam, air_dam) : dam;
696 cando(int mission, int type)
700 if (type == EF_PLANE)
704 if (type == EF_PLANE)
708 if ((type == EF_PLANE) || (type == EF_SHIP))
716 if (type == EF_PLANE)
729 mission_name(int mission)
733 return "an interdiction";
737 return "an offensive support";
739 return "a defensive support";
745 return "a sub interdiction";
747 return "an air defense";
750 return "a mysterious";
754 * Maximum distance GP can perform its mission.
755 * Note: this has nothing to do with the radius of the op-area.
756 * oprange() governs where the unit *can* strike, the op-area governs
757 * where the player wants it to strike.
760 oprange(struct empobj *gp)
762 switch (gp->ef_type) {
764 return ldround(shp_fire_range((struct shpstr *)gp), 1);
766 if (gp->mission == MI_RESERVE)
767 return lnd_reaction_range((struct lndstr *)gp);
768 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
770 /* missiles go one way, so we can use all the range */
771 if (plchr[(int)gp->type].pl_flags & P_M)
772 return ((struct plnstr *)gp)->pln_range;
773 return ((struct plnstr *)gp)->pln_range / 2;
780 * Does GP's mission op area cover X,Y?
783 in_oparea(struct empobj *gp, coord x, coord y)
785 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
786 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
790 * Remove all planes who cannot go on
791 * the mission from the plane list.
794 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
797 struct emp_qelem *qp, *next;
799 struct plchrstr *pcp;
802 for (qp = list->q_forw; qp != list; qp = next) {
804 plp = (struct plist *)qp;
808 if (pp->pln_effic < 40) {
814 if (pp->pln_mobil < 1) {
821 if (ontradingblock(EF_PLANE, pp)) {
828 if (!pln_capable(pp, wantflags, nowantflags)) {
834 if (!pln_airbase_ok(pp, 0, 0)) {
840 if (pcp->pl_flags & P_A) {
841 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
848 putplane(pp->pln_uid, pp);
853 * Arm only the planes at x,y
856 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
857 int mission, struct ichrstr *ip)
859 struct emp_qelem *qp;
860 struct emp_qelem *next;
864 for (qp = list->q_forw; qp != list; qp = next) {
866 plp = (struct plist *)qp;
874 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
875 || mission_pln_equip(plp, ip, mission) < 0) {
881 pp->pln_flags |= PLN_LAUNCHED;
882 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
883 putplane(pp->pln_uid, pp);
888 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
890 struct plchrstr *pcp;
901 if (pp->pln_ship >= 0) {
902 getship(pp->pln_ship, &ship);
903 item = ship.shp_item;
904 } else if (pp->pln_land >= 0) {
905 getland(pp->pln_land, &land);
906 item = land.lnd_item;
908 getsect(pp->pln_x, pp->pln_y, §);
909 item = sect.sct_item;
911 if (pcp->pl_fuel > item[I_PETROL]) {
914 item[I_PETROL] -= pcp->pl_fuel;
918 case 'p': /* pinpoint bomb */
921 case 'i': /* missile interception */
925 case 'e': /* escort */
926 case 0: /* plane interception */
934 if (itype != I_NONE) {
935 needed = load / ichr[itype].i_lbs;
938 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
940 if (itype == I_SHELL && item[itype] < needed) {
941 if (pp->pln_ship >= 0)
942 shp_supply(&ship, I_SHELL, needed);
943 else if (pp->pln_land >= 0)
944 lnd_supply(&land, I_SHELL, needed);
946 sct_supply(§, I_SHELL, needed);
948 if (item[itype] < needed)
950 item[itype] -= needed;
954 if (pp->pln_ship >= 0)
955 putship(ship.shp_uid, &ship);
956 else if (pp->pln_land >= 0)
957 putland(land.lnd_uid, &land);
964 * Return 1 if this x,y pair is in the list
967 find_airport(struct emp_qelem *airp, coord x, coord y)
969 struct emp_qelem *qp;
972 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
973 a = (struct airport *)qp;
974 if ((a->x == x) && (a->y == y))
981 /* #*# This needs to be changed to include acc's -KHS */
983 add_airport(struct emp_qelem *airp, coord x, coord y)
988 a = malloc(sizeof(struct airport));
992 getsect(x, y, §);
993 a->own = sect.sct_own;
995 emp_insque((struct emp_qelem *)a, airp);
999 * Take all the planes in list 1 that
1000 * are at x,y, and put them into list 2.
1003 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1005 struct emp_qelem *qp, *next;
1008 for (qp = l1->q_forw; qp != l1; qp = next) {
1010 plp = (struct plist *)qp;
1012 if (plp->plane.pln_x != x)
1014 if (plp->plane.pln_y != y)
1023 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1024 natid victim, char *s, int hardtarget)
1026 struct emp_qelem *qp;
1029 int newdam, dam = 0;
1032 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1033 plp = (struct plist *)qp;
1036 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1042 if (plp->pcp->pl_flags & P_A) {
1043 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1045 "\t%s detects sub movement in %s\n",
1046 prplane(pp), xyas(x, y, pp->pln_own));
1049 if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) {
1051 "\t%s tracks %s %s at %s\n",
1052 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1056 "\t%s depth-charging %s %s in %s\n",
1057 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1060 "\t%s pinbombing %s %s in %s\n",
1061 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1063 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1064 if (nuk_on_plane(&plp->plane) >= 0)
1066 else if (hardtarget != SECT_HARDTARGET)
1067 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1068 if (roll(100) <= hitchance) {
1069 newdam = pln_damage(&plp->plane, 'p', 1);
1071 "\t\thit %s %s for %d damage\n",
1072 cname(victim), s, newdam);
1075 newdam = pln_damage(&plp->plane, 'p', 0);
1076 wu(0, pp->pln_own, "missed\n");
1077 if (mission == MI_SINTERDICT) {
1079 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1080 xyas(x, y, victim));
1081 } else if (*s == 's') {
1082 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1083 s, xyas(x, y, victim));
1085 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1086 s, xyas(x, y, victim));
1088 /* Now, even though we missed, the bombs
1090 collateral_damage(x, y, newdam);
1093 /* use up missiles */
1094 if (plp->pcp->pl_flags & P_M)