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, md;
583 emp_initque(&escorts);
589 plp = (struct plist *)bombers->q_forw;
590 plane_owner = plp->plane.pln_own;
593 * If there are planes performing an
594 * interdict or support mission, find
595 * some escorts for them, if possible.
596 * Up to 2 per bomber, if possible.
598 find_escorts(x, y, plane_owner, &escorts);
600 if (mission == MI_SINTERDICT)
601 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
603 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
605 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
607 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
608 plp = (struct plist *)qp;
609 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
610 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
613 performed = air_dam = 0;
614 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
620 air = (struct airport *)qp;
621 md = mapdist(x, y, air->x, air->y);
626 /* Split off the bombers at this base into b */
627 divide(bombers, &b, air->x, air->y);
629 /* Split off the escorts at this base into e */
630 divide(&escorts, &e, air->x, air->y);
632 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
637 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
639 if (path_find(air->x, air->y, x, y, 0, MOB_FLY) < 0)
642 len = path_find_route(buf, 100, air->x, air->y, x, y);
651 if (CANT_HAPPEN(!pp))
654 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
655 mission_name(mission),
656 xyas(air->x, air->y, plane_owner),
657 xyas(x, y, plane_owner));
658 if (air->own && (air->own != plane_owner)) {
659 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
660 cname(plane_owner), mission_name(mission),
661 xyas(air->x, air->y, air->own),
662 xyas(x, y, air->own));
665 ac_encounter(&b, &e, air->x, air->y, pp, 0);
669 air_damage(&b, x, y, mission, victim, s, hardtarget);
677 nreport(plane_owner, N_SHP_BOMB, victim, 1);
679 nreport(plane_owner, N_SCT_BOMB, victim, 1);
683 while (qp != (&escorts)) {
690 qp = bombers->q_forw;
691 while (qp != bombers) {
698 return performed ? tally_dam(dam, air_dam) : dam;
702 cando(int mission, int type)
706 if (type == EF_PLANE)
710 if (type == EF_PLANE)
714 if ((type == EF_PLANE) || (type == EF_SHIP))
722 if (type == EF_PLANE)
735 mission_name(int mission)
739 return "an interdiction";
743 return "an offensive support";
745 return "a defensive support";
751 return "a sub interdiction";
753 return "an air defense";
756 return "a mysterious";
760 * Maximum distance GP can perform its mission.
761 * Note: this has nothing to do with the radius of the op-area.
762 * oprange() governs where the unit *can* strike, the op-area governs
763 * where the player wants it to strike.
766 oprange(struct empobj *gp)
768 switch (gp->ef_type) {
770 return ldround(shp_fire_range((struct shpstr *)gp), 1);
772 if (gp->mission == MI_RESERVE)
773 return lnd_reaction_range((struct lndstr *)gp);
774 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
776 /* missiles go one way, so we can use all the range */
777 if (plchr[(int)gp->type].pl_flags & P_M)
778 return ((struct plnstr *)gp)->pln_range;
779 return ((struct plnstr *)gp)->pln_range / 2;
786 * Does GP's mission op area cover X,Y?
789 in_oparea(struct empobj *gp, coord x, coord y)
791 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
792 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
796 * Remove all planes who cannot go on
797 * the mission from the plane list.
800 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
803 struct emp_qelem *qp, *next;
805 struct plchrstr *pcp;
808 for (qp = list->q_forw; qp != list; qp = next) {
810 plp = (struct plist *)qp;
814 if (pp->pln_effic < 40) {
820 if (pp->pln_mobil < 1) {
827 if (ontradingblock(EF_PLANE, pp)) {
834 if (!pln_capable(pp, wantflags, nowantflags)) {
840 if (!pln_airbase_ok(pp, 0, 0)) {
846 if (pcp->pl_flags & P_A) {
847 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
854 putplane(pp->pln_uid, pp);
859 * Arm only the planes at x,y
862 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
863 int mission, struct ichrstr *ip)
865 struct emp_qelem *qp;
866 struct emp_qelem *next;
870 for (qp = list->q_forw; qp != list; qp = next) {
872 plp = (struct plist *)qp;
880 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
881 || mission_pln_equip(plp, ip, mission) < 0) {
887 pp->pln_flags |= PLN_LAUNCHED;
888 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
889 putplane(pp->pln_uid, pp);
894 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
896 struct plchrstr *pcp;
907 if (pp->pln_ship >= 0) {
908 getship(pp->pln_ship, &ship);
909 item = ship.shp_item;
910 } else if (pp->pln_land >= 0) {
911 getland(pp->pln_land, &land);
912 item = land.lnd_item;
914 getsect(pp->pln_x, pp->pln_y, §);
915 item = sect.sct_item;
917 if (pcp->pl_fuel > item[I_PETROL]) {
920 item[I_PETROL] -= pcp->pl_fuel;
924 case 'p': /* pinpoint bomb */
927 case 'i': /* missile interception */
931 case 'e': /* escort */
932 case 0: /* plane interception */
940 if (itype != I_NONE) {
941 needed = load / ichr[itype].i_lbs;
944 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
946 if (itype == I_SHELL && item[itype] < needed) {
947 if (pp->pln_ship >= 0)
948 shp_supply(&ship, I_SHELL, needed);
949 else if (pp->pln_land >= 0)
950 lnd_supply(&land, I_SHELL, needed);
952 sct_supply(§, I_SHELL, needed);
954 if (item[itype] < needed)
956 item[itype] -= needed;
960 if (pp->pln_ship >= 0)
961 putship(ship.shp_uid, &ship);
962 else if (pp->pln_land >= 0)
963 putland(land.lnd_uid, &land);
970 * Return 1 if this x,y pair is in the list
973 find_airport(struct emp_qelem *airp, coord x, coord y)
975 struct emp_qelem *qp;
978 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
979 a = (struct airport *)qp;
980 if ((a->x == x) && (a->y == y))
987 /* #*# This needs to be changed to include acc's -KHS */
989 add_airport(struct emp_qelem *airp, coord x, coord y)
994 a = malloc(sizeof(struct airport));
998 getsect(x, y, §);
999 a->own = sect.sct_own;
1001 emp_insque((struct emp_qelem *)a, airp);
1005 * Take all the planes in list 1 that
1006 * are at x,y, and put them into list 2.
1009 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1011 struct emp_qelem *qp, *next;
1014 for (qp = l1->q_forw; qp != l1; qp = next) {
1016 plp = (struct plist *)qp;
1018 if (plp->plane.pln_x != x)
1020 if (plp->plane.pln_y != y)
1029 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1030 natid victim, char *s, int hardtarget)
1032 struct emp_qelem *qp;
1035 int newdam, dam = 0;
1038 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1039 plp = (struct plist *)qp;
1042 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1048 if (plp->pcp->pl_flags & P_A) {
1049 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1051 "\t%s detects sub movement in %s\n",
1052 prplane(pp), xyas(x, y, pp->pln_own));
1055 if (relations_with(pp->pln_own, victim) > HOSTILE) {
1057 "\t%s tracks %s %s at %s\n",
1058 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1062 "\t%s depth-charging %s %s in %s\n",
1063 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1066 "\t%s pinbombing %s %s in %s\n",
1067 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1069 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1070 if (nuk_on_plane(&plp->plane) >= 0)
1072 else if (hardtarget != SECT_HARDTARGET)
1073 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1074 if (roll(100) <= hitchance) {
1075 newdam = pln_damage(&plp->plane, 'p', 1);
1077 "\t\thit %s %s for %d damage\n",
1078 cname(victim), s, newdam);
1081 newdam = pln_damage(&plp->plane, 'p', 0);
1082 wu(0, pp->pln_own, "missed\n");
1083 if (mission == MI_SINTERDICT) {
1085 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1086 xyas(x, y, victim));
1087 } else if (*s == 's') {
1088 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1089 s, xyas(x, y, victim));
1091 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1092 s, xyas(x, y, victim));
1094 /* Now, even though we missed, the bombs
1096 collateral_damage(x, y, newdam);
1099 /* use up missiles */
1100 if (plp->pcp->pl_flags & P_M)