2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2013, 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-2012
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] = relations_with(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 = relations_with(cn, victim);
191 other_act[cn] = rel <= HOSTILE;
192 plane_act[cn] = mission == MI_SINTERDICT
193 ? 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 * Perform support missions in X,Y against VICTIM for ACTEE.
236 * MISSION is either MI_OSUPPORT or MI_DSUPPORT.
237 * Return total damage.
240 dosupport(coord x, coord y, natid victim, natid actee, int mission)
243 unsigned char act[MAXNOC];
244 struct genlist mi[MAXNOC];
248 memset(mi, 0, sizeof(mi));
250 for (cn = 1; cn < MAXNOC; cn++) {
251 act[cn] = feels_like_helping(cn, actee, victim);
252 emp_initque((struct emp_qelem *)&mi[cn]);
255 build_mission_list(mi, act, act, x, y, MI_SUPPORT);
256 build_mission_list(mi, act, act, x, y, mission);
258 for (cn = 1; cn < MAXNOC; cn++) {
259 if (QEMPTY(&mi[cn].queue))
262 newdam = perform_mission(x, y, victim, &mi[cn].queue, MI_SUPPORT,
263 "", SECT_HARDTARGET);
271 build_mission_list(struct genlist mi[],
272 unsigned char other_act[], unsigned char plane_act[],
273 coord x, coord y, int mission)
275 build_mission_list_type(mi, other_act, x, y, mission, EF_LAND);
276 build_mission_list_type(mi, other_act, x, y, mission, EF_SHIP);
277 build_mission_list_type(mi, plane_act, x, y, mission, EF_PLANE);
281 build_mission_list_type(struct genlist mi[], unsigned char act[],
282 coord x, coord y, int mission, int type)
287 union empobj_storage item;
289 snxtitem_all(&ni, type);
290 while (nxtitem(&ni, &item)) {
291 gp = (struct empobj *)&item;
299 if ((gp->mission != mission) && (mission != MI_SINTERDICT))
302 if ((gp->mission != mission) && (mission == MI_SINTERDICT) &&
303 (gp->mission != MI_INTERDICT))
306 if (!in_oparea(gp, x, y))
309 glp = malloc(sizeof(struct genlist));
310 memset(glp, 0, sizeof(struct genlist));
311 glp->thing = malloc(sizeof(item));
312 memcpy(glp->thing, &item, sizeof(item));
313 emp_insque(&glp->queue, &mi[gp->own].queue);
318 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
324 snxtitem_all(&ni, EF_PLANE);
325 while (nxtitem(&ni, &plane)) {
326 if (plane.pln_own != cn)
328 if (plane.pln_mission != MI_ESCORT)
330 if (!in_oparea((struct empobj *)&plane, x, y))
332 plp = malloc(sizeof(struct plist));
334 plp->pstage = PLG_HEALTHY;
335 plp->pcp = &plchr[(int)plane.pln_type];
337 emp_insque(&plp->queue, escorts);
342 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
343 int mission, char *s, int hardtarget)
345 struct emp_qelem *qp, missiles, bombers;
348 struct plchrstr *pcp;
350 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
352 emp_initque(&missiles);
353 emp_initque(&bombers);
355 for (qp = list->q_forw; qp != list; ) {
356 glp = (struct genlist *)qp;
359 if (glp->thing->ef_type == EF_LAND) {
360 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
361 x, y, victim, mission, s,
363 } else if (glp->thing->ef_type == EF_SHIP) {
364 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
365 x, y, victim, mission, s,
367 } else if (glp->thing->ef_type == EF_PLANE) {
368 pcp = &plchr[glp->thing->type];
369 if ((pcp->pl_flags & P_M)
370 && (hardtarget != SECT_HARDTARGET
371 || (pcp->pl_flags & P_MAR)))
372 ; /* units have their own missile interdiction */
374 /* save planes for later */
375 plp = malloc(sizeof(struct plist));
377 plp->pstage = PLG_HEALTHY;
379 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
380 if (plp->pcp->pl_flags & P_M)
381 emp_insque(&plp->queue, &missiles);
383 emp_insque(&plp->queue, &bombers);
393 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
394 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
395 hardtarget, targeting_ships);
400 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
401 natid victim, int mission, char *s,
406 if (mission == MI_SINTERDICT)
409 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
411 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
414 range = roundrange(lnd_fire_range(lp));
419 putland(lp->lnd_uid, lp);
423 if (targeting_ships) {
424 if (chance(lnd_acc(lp) / 100.0))
425 dam2 = ldround(dam2 / 2.0, 1);
428 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
430 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
432 "%s fires at %s %s at %s\n",
433 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
435 mpr(victim, "%s %s fires at you at %s\n",
436 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
438 return tally_dam(dam, dam2);
442 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
443 natid victim, int mission, char *s,
446 struct mchrstr *mcp = &mchr[sp->shp_type];
447 double vrange, hitchance;
450 md = mapdist(x, y, sp->shp_x, sp->shp_y);
452 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
453 && md > ship_max_interdiction_range)
456 if (mission == MI_SINTERDICT) {
457 if (!(mcp->m_flags & M_SONAR))
459 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
461 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
462 vrange *= sp->shp_effic / 200.0;
465 /* can't look all the time */
469 if (mcp->m_flags & M_SUB) {
470 if (!targeting_ships)
471 return dam; /* subs interdict only ships */
472 range = roundrange(torprange(sp));
475 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
477 dam2 = shp_torp(sp, 1);
478 putship(sp->shp_uid, sp);
481 hitchance = shp_torp_hitchance(sp, md);
484 "%s locking on %s %s in %s\n",
485 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
487 "\tEffective torpedo range is %d.0\n", range);
489 "\tWhooosh... Hitchance = %d%%\n",
490 (int)(hitchance * 100));
492 if (!chance(hitchance)) {
493 wu(0, sp->shp_own, "\tMissed\n");
495 "Incoming torpedo sighted @ %s missed (whew)!\n",
497 return tally_dam(dam, 0);
499 wu(0, sp->shp_own, "\tBOOM!...\n");
500 nreport(victim, N_TORP_SHIP, 0, 1);
502 "\tTorpedo hit %s %s for %d damage\n",
503 cname(victim), s, dam2);
506 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
507 xyas(x, y, victim), dam2);
509 range = roundrange(shp_fire_range(sp));
512 if (mission == MI_SINTERDICT)
513 dam2 = shp_dchrg(sp);
516 putship(sp->shp_uid, sp);
520 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
522 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
524 "%s fires at %s %s at %s\n",
525 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
527 mpr(victim, "%s %s fires at you at %s\n",
528 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
531 return tally_dam(dam, dam2);
535 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
536 natid victim, int hardtarget)
538 int performed, air_dam, sublaunch, dam2;
539 struct emp_qelem *qp, *newqp;
543 * Missiles, except for interdiction of ships or land units,
544 * because that happens elsewhere, in shp_missile_interdiction()
545 * and lnd_missile_interdiction().
547 performed = air_dam = 0;
548 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
550 plp = (struct plist *)qp;
553 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
554 || (plp->pcp->pl_flags & P_MAR))
555 && mission_pln_equip(plp, NULL, 'p') >= 0) {
556 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
560 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
561 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
563 dam2 = pln_damage(&plp->plane, 'p', 1);
566 plp->plane.pln_effic = 0;
567 putplane(plp->plane.pln_uid, &plp->plane);
573 return performed ? tally_dam(dam, air_dam) : dam;
577 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
578 natid victim, int mission, char *s, int hardtarget,
581 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
583 int plane_owner, performed, air_dam;
586 emp_initque(&escorts);
592 plp = (struct plist *)bombers->q_forw;
593 plane_owner = plp->plane.pln_own;
596 * If there are planes performing an
597 * interdict or support mission, find
598 * some escorts for them, if possible.
599 * Up to 2 per bomber, if possible.
601 find_escorts(x, y, plane_owner, &escorts);
603 if (mission == MI_SINTERDICT)
604 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
606 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
608 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
610 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
611 plp = (struct plist *)qp;
612 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
613 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
616 performed = air_dam = 0;
617 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
621 air = (struct airport *)qp;
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 if (path_find(air->x, air->y, x, y, plane_owner, MOB_FLY) < 0)
634 md = path_find_route(buf, sizeof(buf), air->x, air->y, x, y);
635 if (md >= sizeof(buf))
638 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
641 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
644 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
645 mission_name(mission),
646 xyas(air->x, air->y, plane_owner),
647 xyas(x, y, plane_owner));
648 if (air->own && (air->own != plane_owner)) {
649 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
650 cname(plane_owner), mission_name(mission),
651 xyas(air->x, air->y, air->own),
652 xyas(x, y, air->own));
655 ac_encounter(&b, &e, air->x, air->y, buf, 0);
659 air_damage(&b, x, y, mission, victim, s, hardtarget);
667 nreport(plane_owner, N_SHP_BOMB, victim, 1);
669 nreport(plane_owner, N_SCT_BOMB, victim, 1);
673 while (qp != (&escorts)) {
680 qp = bombers->q_forw;
681 while (qp != bombers) {
688 return performed ? tally_dam(dam, air_dam) : dam;
692 cando(int mission, int type)
696 if (type == EF_PLANE)
700 if (type == EF_PLANE)
704 if ((type == EF_PLANE) || (type == EF_SHIP))
712 if (type == EF_PLANE)
725 mission_name(int mission)
729 return "an interdiction";
733 return "an offensive support";
735 return "a defensive support";
741 return "a sub interdiction";
743 return "an air defense";
746 return "a mysterious";
750 * Maximum distance GP can perform its mission.
751 * Note: this has nothing to do with the radius of the op-area.
752 * oprange() governs where the unit *can* strike, the op-area governs
753 * where the player wants it to strike.
756 oprange(struct empobj *gp)
758 switch (gp->ef_type) {
760 return ldround(shp_fire_range((struct shpstr *)gp), 1);
762 if (gp->mission == MI_RESERVE)
763 return lnd_reaction_range((struct lndstr *)gp);
764 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
766 /* missiles go one way, so we can use all the range */
767 if (plchr[(int)gp->type].pl_flags & P_M)
768 return ((struct plnstr *)gp)->pln_range;
769 return ((struct plnstr *)gp)->pln_range / 2;
776 * Does GP's mission op area cover X,Y?
779 in_oparea(struct empobj *gp, coord x, coord y)
781 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
782 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
786 * Remove all planes who cannot go on
787 * the mission from the plane list.
790 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
793 struct emp_qelem *qp, *next;
795 struct plchrstr *pcp;
798 for (qp = list->q_forw; qp != list; qp = next) {
800 plp = (struct plist *)qp;
804 if (pp->pln_effic < 40) {
810 if (pp->pln_mobil < 1) {
817 if (ontradingblock(EF_PLANE, pp)) {
824 if (!pln_capable(pp, wantflags, nowantflags)) {
830 if (!pln_airbase_ok(pp, 0, 0)) {
836 if (pcp->pl_flags & P_A) {
837 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
844 putplane(pp->pln_uid, pp);
849 * Arm only the planes at x,y
852 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
853 int mission, struct ichrstr *ip)
855 struct emp_qelem *qp;
856 struct emp_qelem *next;
860 for (qp = list->q_forw; qp != list; qp = next) {
862 plp = (struct plist *)qp;
870 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
871 || mission_pln_equip(plp, ip, mission) < 0) {
877 pp->pln_flags |= PLN_LAUNCHED;
878 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
879 putplane(pp->pln_uid, pp);
884 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
886 struct plchrstr *pcp;
897 if (pp->pln_ship >= 0) {
898 getship(pp->pln_ship, &ship);
899 plp->pstage = ship.shp_pstage;
900 item = ship.shp_item;
901 } else if (pp->pln_land >= 0) {
902 getland(pp->pln_land, &land);
903 plp->pstage = land.lnd_pstage;
904 item = land.lnd_item;
906 getsect(pp->pln_x, pp->pln_y, §);
907 plp->pstage = sect.sct_pstage;
908 item = sect.sct_item;
910 if (pcp->pl_fuel > item[I_PETROL]) {
913 item[I_PETROL] -= pcp->pl_fuel;
917 case 'p': /* pinpoint bomb */
920 case 'i': /* missile interception */
924 case 'e': /* escort */
925 case 0: /* plane interception */
933 if (itype != I_NONE) {
934 needed = load / ichr[itype].i_lbs;
937 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
939 if (itype == I_SHELL && item[itype] < needed) {
940 if (pp->pln_ship >= 0)
941 shp_supply(&ship, I_SHELL, needed);
942 else if (pp->pln_land >= 0)
943 lnd_supply(&land, I_SHELL, needed);
945 sct_supply(§, I_SHELL, needed);
947 if (item[itype] < needed)
949 item[itype] -= needed;
953 if (pp->pln_ship >= 0)
954 putship(ship.shp_uid, &ship);
955 else if (pp->pln_land >= 0)
956 putland(land.lnd_uid, &land);
963 * Return 1 if this x,y pair is in the list
966 find_airport(struct emp_qelem *airp, coord x, coord y)
968 struct emp_qelem *qp;
971 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
972 a = (struct airport *)qp;
973 if ((a->x == x) && (a->y == y))
980 /* #*# This needs to be changed to include acc's -KHS */
982 add_airport(struct emp_qelem *airp, coord x, coord y)
987 a = malloc(sizeof(struct airport));
991 getsect(x, y, §);
992 a->own = sect.sct_own;
994 emp_insque((struct emp_qelem *)a, airp);
998 * Take all the planes in list 1 that
999 * are at x,y, and put them into list 2.
1002 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1004 struct emp_qelem *qp, *next;
1007 for (qp = l1->q_forw; qp != l1; qp = next) {
1009 plp = (struct plist *)qp;
1011 if (plp->plane.pln_x != x)
1013 if (plp->plane.pln_y != y)
1022 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1023 natid victim, char *s, int hardtarget)
1025 struct emp_qelem *qp;
1028 int newdam, dam = 0;
1031 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1032 plp = (struct plist *)qp;
1035 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1041 if (plp->pcp->pl_flags & P_A) {
1042 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1044 "\t%s detects sub movement in %s\n",
1045 prplane(pp), xyas(x, y, pp->pln_own));
1048 if (relations_with(pp->pln_own, victim) > HOSTILE) {
1050 "\t%s tracks %s %s at %s\n",
1051 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1055 "\t%s depth-charging %s %s in %s\n",
1056 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1059 "\t%s pinbombing %s %s in %s\n",
1060 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1062 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1063 if (nuk_on_plane(&plp->plane) >= 0)
1065 else if (hardtarget != SECT_HARDTARGET)
1066 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1067 if (roll(100) <= hitchance) {
1068 newdam = pln_damage(&plp->plane, 'p', 1);
1070 "\t\thit %s %s for %d damage\n",
1071 cname(victim), s, newdam);
1074 newdam = pln_damage(&plp->plane, 'p', 0);
1075 wu(0, pp->pln_own, "missed\n");
1076 if (mission == MI_SINTERDICT) {
1078 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1079 xyas(x, y, victim));
1080 } else if (*s == 's') {
1081 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1082 s, xyas(x, y, victim));
1084 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1085 s, xyas(x, y, victim));
1087 /* Now, even though we missed, the bombs
1089 collateral_damage(x, y, newdam);
1092 /* use up missiles */
1093 if (plp->pcp->pl_flags & P_M)