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[],
67 unsigned char[], unsigned char[],
69 static void build_mission_list_type(struct genlist[], unsigned char[],
70 coord, coord, int, int);
71 static void divide(struct emp_qelem *, struct emp_qelem *, coord, coord);
72 static int dosupport(coord, coord, natid, natid, int);
73 static int find_airport(struct emp_qelem *, coord, coord);
74 static void mission_pln_arm(struct emp_qelem *, coord, coord, int,
75 int, struct ichrstr *);
76 static void mission_pln_sel(struct emp_qelem *, int, int, int);
77 static int perform_mission_land(int, struct lndstr *, coord, coord,
78 natid, int, char *, int);
79 static int perform_mission_ship(int, struct shpstr *, coord, coord,
80 natid, int, char *, int);
81 static int perform_mission_msl(int, struct emp_qelem *, coord, coord,
83 static int perform_mission_bomb(int, struct emp_qelem *, coord, coord,
84 natid, int, char *, int, int);
85 static int perform_mission(coord, coord, natid, struct emp_qelem *,
89 tally_dam(int dam, int newdam)
91 return dam < 0 ? newdam : dam + newdam;
95 * Interdict commodities & transported planes
98 ground_interdict(coord x, coord y, natid victim, char *s)
102 unsigned char act[MAXNOC];
103 struct genlist mi[MAXNOC];
105 memset(mi, 0, sizeof(mi));
107 for (cn = 1; cn < MAXNOC; cn++) {
108 act[cn] = getrel(getnatp(cn), victim) <= HOSTILE;
109 emp_initque((struct emp_qelem *)&mi[cn]);
112 build_mission_list(mi, act, act, x, y, MI_INTERDICT);
114 for (cn = 1; cn < MAXNOC; cn++) {
115 if (QEMPTY(&mi[cn].queue))
118 newdam = perform_mission(x, y, victim, &mi[cn].queue,
119 MI_INTERDICT, s, SECT_HARDTARGET);
122 mpr(victim, "%s interdiction mission does %d damage!\n",
127 collateral_damage(x, y, dam);
133 collateral_damage(coord x, coord y, int dam)
141 getsect(x, y, §);
143 coll = ldround((double)dam * collateral_dam, 1);
146 mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
147 xyas(x, y, sect.sct_own), coll);
148 sectdamage(§, coll);
156 only_subs(struct emp_qelem *list)
158 struct emp_qelem *qp;
161 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
162 glp = (struct genlist *)qp;
164 if (glp->thing->ef_type != EF_SHIP)
166 if (!(mchr[glp->thing->type].m_flags & M_SUB))
170 /* They were all subs! */
176 * Interdict ships & land units
179 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
182 int cn, rel, newdam, osubs;
184 unsigned char plane_act[MAXNOC], other_act[MAXNOC];
185 struct genlist mi[MAXNOC];
187 memset(mi, 0, sizeof(mi));
188 other_act[0] = plane_act[0] = 0;
189 for (cn = 1; cn < MAXNOC; cn++) {
190 rel = getrel(getnatp(cn), victim);
191 other_act[cn] = rel <= HOSTILE;
192 plane_act[cn] = mission == MI_SINTERDICT
193 ? cn != victim && rel <= NEUTRAL : other_act[cn];
194 emp_initque((struct emp_qelem *)&mi[cn]);
197 build_mission_list(mi, other_act, plane_act, x, y, mission);
199 for (cn = 1; cn < MAXNOC; cn++) {
200 if (QEMPTY(&mi[cn].queue))
203 osubs = only_subs(&mi[cn].queue);
204 newdam = perform_mission(x, y, victim, &mi[cn].queue,
205 mission, s, hardtarget);
206 dam = tally_dam(dam, newdam);
208 mpr(victim, "%s interdiction mission does %d damage!\n",
209 osubs ? "Enemy" : cname(cn), newdam);
212 collateral_damage(x, y, dam);
217 * Perform a mission against victim, on behalf of actee
220 off_support(coord x, coord y, natid victim, natid actee)
222 return dosupport(x, y, victim, actee, MI_OSUPPORT);
226 * Perform a mission against victim, on behalf of actee
229 def_support(coord x, coord y, natid victim, natid actee)
231 return dosupport(x, y, victim, actee, MI_DSUPPORT);
235 dosupport(coord x, coord y, natid victim, natid actee, int mission)
238 unsigned char act[MAXNOC];
239 struct genlist mi[MAXNOC];
243 memset(mi, 0, sizeof(mi));
245 for (cn = 1; cn < MAXNOC; cn++) {
246 act[cn] = (cn == actee
247 || (getrel(getnatp(cn), actee) == ALLIED
248 && getrel(getnatp(cn), victim) == AT_WAR));
249 emp_initque((struct emp_qelem *)&mi[cn]);
252 build_mission_list(mi, act, act, x, y, MI_SUPPORT);
253 build_mission_list(mi, act, act, x, y, mission);
255 for (cn = 1; cn < MAXNOC; cn++) {
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[],
269 unsigned char other_act[], unsigned char plane_act[],
270 coord x, coord y, int mission)
272 build_mission_list_type(mi, other_act, x, y, mission, EF_LAND);
273 build_mission_list_type(mi, other_act, x, y, mission, EF_SHIP);
274 build_mission_list_type(mi, plane_act, x, y, mission, EF_PLANE);
278 build_mission_list_type(struct genlist mi[], unsigned char act[],
279 coord x, coord y, int mission, int type)
284 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 if (!in_oparea(gp, x, y))
306 glp = malloc(sizeof(struct genlist));
307 memset(glp, 0, sizeof(struct genlist));
308 glp->thing = malloc(sizeof(item));
309 memcpy(glp->thing, &item, sizeof(item));
310 emp_insque(&glp->queue, &mi[gp->own].queue);
315 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
321 snxtitem_all(&ni, EF_PLANE);
322 while (nxtitem(&ni, &plane)) {
323 if (plane.pln_own != cn)
325 if (plane.pln_mission != MI_ESCORT)
327 if (!in_oparea((struct empobj *)&plane, x, y))
329 plp = malloc(sizeof(struct plist));
330 memset(plp, 0, sizeof(struct plist));
331 plp->pcp = &plchr[(int)plane.pln_type];
333 emp_insque(&plp->queue, escorts);
338 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
339 int mission, char *s, int hardtarget)
341 struct emp_qelem *qp, missiles, bombers;
344 struct plchrstr *pcp;
346 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
348 emp_initque(&missiles);
349 emp_initque(&bombers);
351 for (qp = list->q_forw; qp != list; ) {
352 glp = (struct genlist *)qp;
355 if (glp->thing->ef_type == EF_LAND) {
356 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
357 x, y, victim, mission, s,
359 } else if (glp->thing->ef_type == EF_SHIP) {
360 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
361 x, y, victim, mission, s,
363 } else if (glp->thing->ef_type == EF_PLANE) {
364 pcp = &plchr[glp->thing->type];
365 if ((pcp->pl_flags & P_M)
366 && (hardtarget != SECT_HARDTARGET
367 || (pcp->pl_flags & P_MAR)))
368 ; /* units have their own missile interdiction */
370 /* save planes for later */
371 plp = malloc(sizeof(struct plist));
373 memset(plp, 0, sizeof(struct plist));
375 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
376 if (plp->pcp->pl_flags & P_M)
377 emp_insque(&plp->queue, &missiles);
379 emp_insque(&plp->queue, &bombers);
389 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
390 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
391 hardtarget, targeting_ships);
396 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
397 natid victim, int mission, char *s,
402 if (mission == MI_SINTERDICT)
405 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
407 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
410 range = roundrange(lnd_fire_range(lp));
415 putland(lp->lnd_uid, lp);
419 if (targeting_ships) {
420 if (chance(lnd_acc(lp) / 100.0))
421 dam2 = ldround(dam2 / 2.0, 1);
424 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
426 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
428 "%s fires at %s %s at %s\n",
429 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
431 mpr(victim, "%s %s fires at you at %s\n",
432 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
434 return tally_dam(dam, dam2);
438 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
439 natid victim, int mission, char *s,
442 struct mchrstr *mcp = &mchr[sp->shp_type];
443 double vrange, hitchance;
446 md = mapdist(x, y, sp->shp_x, sp->shp_y);
448 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
449 && md > ship_max_interdiction_range)
452 if (mission == MI_SINTERDICT) {
453 if (!(mcp->m_flags & M_SONAR))
455 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
457 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
458 vrange *= sp->shp_effic / 200.0;
461 /* can't look all the time */
465 if (mcp->m_flags & M_SUB) {
466 if (!targeting_ships)
467 return dam; /* subs interdict only ships */
468 range = roundrange(torprange(sp));
471 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
473 dam2 = shp_torp(sp, 1);
474 putship(sp->shp_uid, sp);
477 hitchance = shp_torp_hitchance(sp, md);
480 "%s locking on %s %s in %s\n",
481 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
483 "\tEffective torpedo range is %d.0\n", range);
485 "\tWhooosh... Hitchance = %d%%\n",
486 (int)(hitchance * 100));
488 if (!chance(hitchance)) {
489 wu(0, sp->shp_own, "\tMissed\n");
491 "Incoming torpedo sighted @ %s missed (whew)!\n",
493 return tally_dam(dam, 0);
495 wu(0, sp->shp_own, "\tBOOM!...\n");
496 nreport(victim, N_TORP_SHIP, 0, 1);
498 "\tTorpedo hit %s %s for %d damage\n",
499 cname(victim), s, dam2);
502 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
503 xyas(x, y, victim), dam2);
505 range = roundrange(shp_fire_range(sp));
508 if (mission == MI_SINTERDICT)
509 dam2 = shp_dchrg(sp);
512 putship(sp->shp_uid, sp);
516 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
518 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
520 "%s fires at %s %s at %s\n",
521 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
523 mpr(victim, "%s %s fires at you at %s\n",
524 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
527 return tally_dam(dam, dam2);
531 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
532 natid victim, int hardtarget)
534 int performed, air_dam, sublaunch, dam2;
535 struct emp_qelem *qp, *newqp;
539 * Missiles, except for interdiction of ships or land units,
540 * because that happens elsewhere, in shp_missile_interdiction()
541 * and lnd_missile_interdiction().
543 performed = air_dam = 0;
544 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
546 plp = (struct plist *)qp;
549 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
550 || (plp->pcp->pl_flags & P_MAR))
551 && mission_pln_equip(plp, NULL, 'p') >= 0) {
552 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
556 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
557 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
559 dam2 = pln_damage(&plp->plane, 'p', 1);
562 plp->plane.pln_effic = 0;
563 putplane(plp->plane.pln_uid, &plp->plane);
569 return performed ? tally_dam(dam, air_dam) : dam;
573 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
574 natid victim, int mission, char *s, int hardtarget,
577 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
579 int plane_owner, performed, air_dam, md;
581 emp_initque(&escorts);
587 plp = (struct plist *)bombers->q_forw;
588 plane_owner = plp->plane.pln_own;
591 * If there are planes performing an
592 * interdict or support mission, find
593 * some escorts for them, if possible.
594 * Up to 2 per bomber, if possible.
596 find_escorts(x, y, plane_owner, &escorts);
598 if (mission == MI_SINTERDICT)
599 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
601 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
603 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
605 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
606 plp = (struct plist *)qp;
607 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
608 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
611 performed = air_dam = 0;
612 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
617 air = (struct airport *)qp;
618 md = mapdist(x, y, air->x, air->y);
623 /* Split off the bombers at this base into b */
624 divide(bombers, &b, air->x, air->y);
626 /* Split off the escorts at this base into e */
627 divide(&escorts, &e, air->x, air->y);
629 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
634 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
636 pp = BestAirPath(buf, air->x, air->y, x, y);
637 if (CANT_HAPPEN(!pp))
640 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
641 mission_name(mission),
642 xyas(air->x, air->y, plane_owner),
643 xyas(x, y, plane_owner));
644 if (air->own && (air->own != plane_owner)) {
645 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
646 cname(plane_owner), mission_name(mission),
647 xyas(air->x, air->y, air->own),
648 xyas(x, y, air->own));
651 ac_encounter(&b, &e, air->x, air->y, pp, 0);
655 air_damage(&b, x, y, mission, victim, s, hardtarget);
663 nreport(plane_owner, N_SHP_BOMB, victim, 1);
665 nreport(plane_owner, N_SCT_BOMB, victim, 1);
669 while (qp != (&escorts)) {
676 qp = bombers->q_forw;
677 while (qp != bombers) {
684 return performed ? tally_dam(dam, air_dam) : dam;
688 cando(int mission, int type)
692 if (type == EF_PLANE)
696 if (type == EF_PLANE)
700 if ((type == EF_PLANE) || (type == EF_SHIP))
708 if (type == EF_PLANE)
721 mission_name(int mission)
725 return "an interdiction";
729 return "an offensive support";
731 return "a defensive support";
737 return "a sub interdiction";
739 return "an air defense";
742 return "a mysterious";
746 * Maximum distance GP can perform its mission.
747 * Note: this has nothing to do with the radius of the op-area.
748 * oprange() governs where the unit *can* strike, the op-area governs
749 * where the player wants it to strike.
752 oprange(struct empobj *gp)
754 switch (gp->ef_type) {
756 return ldround(shp_fire_range((struct shpstr *)gp), 1);
758 if (gp->mission == MI_RESERVE)
759 return lnd_reaction_range((struct lndstr *)gp);
760 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
762 /* missiles go one way, so we can use all the range */
763 if (plchr[(int)gp->type].pl_flags & P_M)
764 return ((struct plnstr *)gp)->pln_range;
765 return ((struct plnstr *)gp)->pln_range / 2;
772 * Does GP's mission op area cover X,Y?
775 in_oparea(struct empobj *gp, coord x, coord y)
777 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
778 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
782 * Remove all planes who cannot go on
783 * the mission from the plane list.
786 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
789 struct emp_qelem *qp, *next;
791 struct plchrstr *pcp;
794 for (qp = list->q_forw; qp != list; qp = next) {
796 plp = (struct plist *)qp;
800 if (pp->pln_effic < 40) {
806 if (pp->pln_mobil < 1) {
813 if (ontradingblock(EF_PLANE, pp)) {
820 if (!pln_capable(pp, wantflags, nowantflags)) {
826 if (!pln_airbase_ok(pp, 0, 0)) {
832 if (pcp->pl_flags & P_A) {
833 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
840 putplane(pp->pln_uid, pp);
845 * Arm only the planes at x,y
848 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
849 int mission, struct ichrstr *ip)
851 struct emp_qelem *qp;
852 struct emp_qelem *next;
856 for (qp = list->q_forw; qp != list; qp = next) {
858 plp = (struct plist *)qp;
866 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
867 || mission_pln_equip(plp, ip, mission) < 0) {
873 pp->pln_flags |= PLN_LAUNCHED;
874 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
875 putplane(pp->pln_uid, pp);
880 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
882 struct plchrstr *pcp;
893 if (pp->pln_ship >= 0) {
894 getship(pp->pln_ship, &ship);
895 item = ship.shp_item;
896 } else if (pp->pln_land >= 0) {
897 getland(pp->pln_land, &land);
898 item = land.lnd_item;
900 getsect(pp->pln_x, pp->pln_y, §);
901 item = sect.sct_item;
903 if (pcp->pl_fuel > item[I_PETROL]) {
906 item[I_PETROL] -= pcp->pl_fuel;
910 case 'p': /* pinpoint bomb */
913 case 'i': /* missile interception */
917 case 'e': /* escort */
918 case 0: /* plane interception */
926 if (itype != I_NONE) {
927 needed = load / ichr[itype].i_lbs;
930 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
932 if (itype == I_SHELL && item[itype] < needed) {
933 if (pp->pln_ship >= 0)
934 shp_supply(&ship, I_SHELL, needed);
935 else if (pp->pln_land >= 0)
936 lnd_supply(&land, I_SHELL, needed);
938 sct_supply(§, I_SHELL, needed);
940 if (item[itype] < needed)
942 item[itype] -= needed;
946 if (pp->pln_ship >= 0)
947 putship(ship.shp_uid, &ship);
948 else if (pp->pln_land >= 0)
949 putland(land.lnd_uid, &land);
956 * Return 1 if this x,y pair is in the list
959 find_airport(struct emp_qelem *airp, coord x, coord y)
961 struct emp_qelem *qp;
964 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
965 a = (struct airport *)qp;
966 if ((a->x == x) && (a->y == y))
973 /* #*# This needs to be changed to include acc's -KHS */
975 add_airport(struct emp_qelem *airp, coord x, coord y)
980 a = malloc(sizeof(struct airport));
984 getsect(x, y, §);
985 a->own = sect.sct_own;
987 emp_insque((struct emp_qelem *)a, airp);
991 * Take all the planes in list 1 that
992 * are at x,y, and put them into list 2.
995 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
997 struct emp_qelem *qp, *next;
1000 for (qp = l1->q_forw; qp != l1; qp = next) {
1002 plp = (struct plist *)qp;
1004 if (plp->plane.pln_x != x)
1006 if (plp->plane.pln_y != y)
1015 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1016 natid victim, char *s, int hardtarget)
1018 struct emp_qelem *qp;
1021 int newdam, dam = 0;
1024 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1025 plp = (struct plist *)qp;
1028 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1034 if (plp->pcp->pl_flags & P_A) {
1035 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1037 "\t%s detects sub movement in %s\n",
1038 prplane(pp), xyas(x, y, pp->pln_own));
1041 if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) {
1043 "\t%s tracks %s %s at %s\n",
1044 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1048 "\t%s depth-charging %s %s in %s\n",
1049 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1052 "\t%s pinbombing %s %s in %s\n",
1053 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1055 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1056 if (nuk_on_plane(&plp->plane) >= 0)
1058 else if (hardtarget != SECT_HARDTARGET)
1059 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1060 if (roll(100) <= hitchance) {
1061 newdam = pln_damage(&plp->plane, 'p', 1);
1063 "\t\thit %s %s for %d damage\n",
1064 cname(victim), s, newdam);
1067 newdam = pln_damage(&plp->plane, 'p', 0);
1068 wu(0, pp->pln_own, "missed\n");
1069 if (mission == MI_SINTERDICT) {
1071 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1072 xyas(x, y, victim));
1073 } else if (*s == 's') {
1074 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1075 s, xyas(x, y, victim));
1077 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1078 s, xyas(x, y, victim));
1080 /* Now, even though we missed, the bombs
1082 collateral_damage(x, y, newdam);
1085 /* use up missiles */
1086 if (plp->pcp->pl_flags & P_M)