2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2009, 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(struct genlist *, coord, coord, natid, natid);
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 *, int,
87 * Interdict commodities & transported planes
90 ground_interdict(coord x, coord y, natid victim, char *s)
93 int dam = 0, newdam, rel;
94 struct genlist mi[MAXNOC];
97 memset(mi, 0, sizeof(mi));
98 for (z = 1; z < MAXNOC; z++)
99 emp_initque((struct emp_qelem *)&mi[z]);
101 build_mission_list(mi, x, y, MI_INTERDICT, victim);
103 for (cn = 1; cn < MAXNOC; cn++) {
104 rel = getrel(getnatp(cn), victim);
108 if (QEMPTY(&mi[cn].queue))
111 newdam = perform_mission(x, y, victim, &mi[cn].queue,
112 MI_INTERDICT, s, SECT_HARDTARGET);
115 mpr(victim, "%s interdiction mission does %d damage!\n",
119 collateral_damage(x, y, dam);
125 collateral_damage(coord x, coord y, int dam)
133 getsect(x, y, §);
135 coll = ldround((double)dam * collateral_dam, 1);
138 mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
139 xyas(x, y, sect.sct_own), coll);
140 sectdamage(§, coll);
148 only_subs(struct emp_qelem *list)
150 struct emp_qelem *qp;
153 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
154 glp = (struct genlist *)qp;
156 if (glp->thing->ef_type != EF_SHIP)
158 if (!(mchr[glp->thing->type].m_flags & M_SUB))
162 /* They were all subs! */
168 * Interdict ships & land units
171 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
176 struct genlist mi[MAXNOC];
180 memset(mi, 0, sizeof(mi));
181 for (z = 1; z < MAXNOC; z++)
182 emp_initque((struct emp_qelem *)&mi[z]);
184 build_mission_list(mi, x, y, mission, victim);
186 for (cn = 1; cn < MAXNOC; cn++) {
189 if (mission == MI_SINTERDICT) {
190 if (getrel(getnatp(cn), victim) >= FRIENDLY)
192 } else if (getrel(getnatp(cn), victim) > HOSTILE)
195 if (QEMPTY(&mi[cn].queue))
198 osubs = only_subs(&mi[cn].queue);
199 newdam = perform_mission(x, y, victim, &mi[cn].queue,
200 mission, s, hardtarget);
203 /* If only subs responded, then we don't know who's
205 mpr(victim, "%s interdiction mission does %d damage!\n",
206 osubs ? "Enemy" : cname(cn), newdam);
210 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)
222 struct genlist mi[MAXNOC];
225 memset(mi, 0, sizeof(mi));
226 for (z = 1; z < MAXNOC; z++)
227 emp_initque((struct emp_qelem *)&mi[z]);
229 build_mission_list(mi, x, y, MI_SUPPORT, victim);
230 build_mission_list(mi, x, y, MI_OSUPPORT, victim);
232 dam = dosupport(mi, x, y, victim, actee);
237 * Perform a mission against victim, on behalf of actee
240 def_support(coord x, coord y, natid victim, natid actee)
243 struct genlist mi[MAXNOC];
246 memset(mi, 0, sizeof(mi));
247 for (z = 1; z < MAXNOC; z++)
248 emp_initque((struct emp_qelem *)&mi[z]);
250 build_mission_list(mi, x, y, MI_SUPPORT, victim);
251 build_mission_list(mi, x, y, MI_DSUPPORT, victim);
253 dam = dosupport(mi, x, y, victim, actee);
258 dosupport(struct genlist *mi, coord x, coord y, natid victim, natid actee)
264 for (cn = 1; cn < MAXNOC; cn++) {
265 rel = getrel(getnatp(cn), actee);
266 if ((cn != actee) && (rel != ALLIED))
268 rel = getrel(getnatp(cn), victim);
269 if ((cn != actee) && (rel != AT_WAR))
272 if (QEMPTY(&mi[cn].queue))
275 dam += perform_mission(x, y, victim, &mi[cn].queue, MI_SUPPORT,
276 "", SECT_HARDTARGET);
282 build_mission_list(struct genlist *mi, coord x, coord y, int mission,
285 build_mission_list_type(mi, x, y, mission, EF_LAND, victim);
286 build_mission_list_type(mi, x, y, mission, EF_SHIP, victim);
287 build_mission_list_type(mi, x, y, mission, EF_PLANE, victim);
291 build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
292 int type, natid victim)
297 union empobj_storage item;
301 snxtitem_all(&ni, type);
302 while (nxtitem(&ni, &item)) {
303 gp = (struct empobj *)&item;
311 if ((gp->mission != mission) && (mission != MI_SINTERDICT))
314 if ((gp->mission != mission) && (mission == MI_SINTERDICT) &&
315 (gp->mission != MI_INTERDICT))
318 relat = getrel(getnatp(gp->own), victim);
319 if (mission == MI_SINTERDICT) {
320 if (relat >= FRIENDLY)
322 else if (type != EF_PLANE && relat > HOSTILE)
324 } else if (relat > HOSTILE)
327 if (!in_oparea(gp, x, y))
331 if (mission != MI_AIR_DEFENSE) {
332 getsect(x, y, §);
333 if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) {
336 * If the owner of the unit isn't at war
337 * with the victim, and doesn't own the
338 * sect being acted upon, and isn't the
339 * old owner of that sect, bounce them.
341 if (sect.sct_type != SCT_WATER &&
342 sect.sct_own != gp->own &&
343 sect.sct_oldown != gp->own)
349 glp = malloc(sizeof(struct genlist));
350 memset(glp, 0, sizeof(struct genlist));
351 glp->thing = malloc(sizeof(item));
352 memcpy(glp->thing, &item, sizeof(item));
353 emp_insque(&glp->queue, &mi[gp->own].queue);
358 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
364 snxtitem_all(&ni, EF_PLANE);
365 while (nxtitem(&ni, &plane)) {
366 if (plane.pln_own != cn)
368 if (plane.pln_mission != MI_ESCORT)
370 if (!in_oparea((struct empobj *)&plane, x, y))
372 plp = malloc(sizeof(struct plist));
373 memset(plp, 0, sizeof(struct plist));
374 plp->pcp = &plchr[(int)plane.pln_type];
376 emp_insque(&plp->queue, escorts);
381 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
382 int mission, char *s, int hardtarget)
384 struct emp_qelem *qp, missiles, bombers;
387 struct plchrstr *pcp;
389 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
391 emp_initque(&missiles);
392 emp_initque(&bombers);
394 for (qp = list->q_forw; qp != list; ) {
395 glp = (struct genlist *)qp;
398 if (glp->thing->ef_type == EF_LAND) {
399 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
400 x, y, victim, mission, s,
402 } else if (glp->thing->ef_type == EF_SHIP) {
403 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
404 x, y, victim, mission, s,
406 } else if (glp->thing->ef_type == EF_PLANE) {
407 pcp = &plchr[glp->thing->type];
408 if (pcp->pl_flags & P_M)
409 /* units have their own missile interdiction */
410 if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
413 /* save planes for later */
414 plp = malloc(sizeof(struct plist));
416 memset(plp, 0, sizeof(struct plist));
418 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
419 if (plp->pcp->pl_flags & P_M)
420 emp_insque(&plp->queue, &missiles);
422 emp_insque(&plp->queue, &bombers);
431 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
432 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
433 hardtarget, targeting_ships);
439 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
440 natid victim, int mission, char *s,
445 if (mission == MI_SINTERDICT)
448 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
450 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
453 range = roundrange(lnd_fire_range(lp));
458 putland(lp->lnd_uid, lp);
462 if (targeting_ships) {
463 if (chance(lnd_acc(lp) / 100.0))
464 dam2 = ldround(dam2 / 2.0, 1);
467 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
469 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
471 "%s fires at %s %s at %s\n",
472 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
474 mpr(victim, "%s %s fires at you at %s\n",
475 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
481 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
482 natid victim, int mission, char *s,
485 struct mchrstr *mcp = &mchr[sp->shp_type];
486 double vrange, hitchance;
489 md = mapdist(x, y, sp->shp_x, sp->shp_y);
491 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
492 && md > ship_max_interdiction_range)
495 if (mission == MI_SINTERDICT) {
496 if (!(mcp->m_flags & M_SONAR))
498 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
500 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
501 vrange *= sp->shp_effic / 200.0;
504 /* can't look all the time */
508 if (mcp->m_flags & M_SUB) {
509 if (!targeting_ships)
510 return dam; /* subs interdict only ships */
511 range = roundrange(torprange(sp));
514 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
516 dam2 = shp_torp(sp, 1);
517 putship(sp->shp_uid, sp);
520 hitchance = shp_torp_hitchance(sp, md);
523 "%s locking on %s %s in %s\n",
524 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
526 "\tEffective torpedo range is %d.0\n", range);
528 "\tWhooosh... Hitchance = %d%%\n",
529 (int)(hitchance * 100));
531 if (!chance(hitchance)) {
532 wu(0, sp->shp_own, "\tMissed\n");
534 "Incoming torpedo sighted @ %s missed (whew)!\n",
538 wu(0, sp->shp_own, "\tBOOM!...\n");
539 nreport(victim, N_TORP_SHIP, 0, 1);
541 "\tTorpedo hit %s %s for %d damage\n",
542 cname(victim), s, dam2);
545 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
546 xyas(x, y, victim), dam2);
548 range = roundrange(shp_fire_range(sp));
551 if (mission == MI_SINTERDICT)
552 dam2 = shp_dchrg(sp);
555 putship(sp->shp_uid, sp);
559 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
561 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
563 "%s fires at %s %s at %s\n",
564 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
566 mpr(victim, "%s %s fires at you at %s\n",
567 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
574 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
575 natid victim, int hardtarget)
578 struct emp_qelem *qp, *newqp;
583 * Missiles, except for interdiction of ships or land units,
584 * because that happens elsewhere, in shp_missile_interdiction()
585 * and lnd_missile_interdiction().
588 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
590 plp = (struct plist *)qp;
593 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
594 || (plp->pcp->pl_flags & P_MAR))
595 && mission_pln_equip(plp, NULL, 'p') >= 0) {
596 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
599 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
600 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
602 dam2 = pln_damage(&plp->plane, 'p', 1);
605 plp->plane.pln_effic = 0;
606 putplane(plp->plane.pln_uid, &plp->plane);
611 return dam + air_dam;
615 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
616 natid victim, int mission, char *s, int hardtarget,
619 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
621 int plane_owner, air_dam, md;
623 emp_initque(&escorts);
629 plp = (struct plist *)bombers->q_forw;
630 plane_owner = plp->plane.pln_own;
633 * If there are planes performing an
634 * interdict or support mission, find
635 * some escorts for them, if possible.
636 * Up to 2 per bomber, if possible.
638 find_escorts(x, y, plane_owner, &escorts);
640 if (mission == MI_SINTERDICT)
641 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
643 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
645 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
647 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
648 plp = (struct plist *)qp;
649 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
650 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
654 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
659 air = (struct airport *)qp;
660 md = mapdist(x, y, air->x, air->y);
665 /* Split off the bombers at this base into b */
666 divide(bombers, &b, air->x, air->y);
668 /* Split off the escorts at this base into e */
669 divide(&escorts, &e, air->x, air->y);
671 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
676 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
678 pp = BestAirPath(buf, air->x, air->y, x, y);
679 if (CANT_HAPPEN(!pp))
681 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
682 mission_name(mission),
683 xyas(air->x, air->y, plane_owner),
684 xyas(x, y, plane_owner));
685 if (air->own && (air->own != plane_owner)) {
686 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
687 cname(plane_owner), mission_name(mission),
688 xyas(air->x, air->y, air->own),
689 xyas(x, y, air->own));
692 ac_encounter(&b, &e, air->x, air->y, pp, 0);
696 air_damage(&b, x, y, mission, victim, s, hardtarget);
704 nreport(plane_owner, N_SHP_BOMB, victim, 1);
706 nreport(plane_owner, N_SCT_BOMB, victim, 1);
710 while (qp != (&escorts)) {
717 qp = bombers->q_forw;
718 while (qp != bombers) {
725 return dam + air_dam;
729 cando(int mission, int type)
733 if (type == EF_PLANE)
737 if (type == EF_PLANE)
741 if ((type == EF_PLANE) || (type == EF_SHIP))
749 if (type == EF_PLANE)
762 mission_name(int mission)
766 return "an interdiction";
770 return "an offensive support";
772 return "a defensive support";
778 return "a sub interdiction";
780 return "an air defense";
783 return "a mysterious";
787 * Maximum distance GP can perform its mission.
788 * Note: this has nothing to do with the radius of the op-area.
789 * oprange() governs where the unit *can* strike, the op-area governs
790 * where the player wants it to strike.
793 oprange(struct empobj *gp)
795 switch (gp->ef_type) {
797 return ldround(shp_fire_range((struct shpstr *)gp), 1);
799 if (gp->mission == MI_RESERVE)
800 return lnd_reaction_range((struct lndstr *)gp);
801 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
803 /* missiles go one way, so we can use all the range */
804 if (plchr[(int)gp->type].pl_flags & P_M)
805 return ((struct plnstr *)gp)->pln_range;
806 return ((struct plnstr *)gp)->pln_range / 2;
813 * Does GP's mission op area cover X,Y?
816 in_oparea(struct empobj *gp, coord x, coord y)
818 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
819 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
823 * Remove all planes who cannot go on
824 * the mission from the plane list.
827 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
830 struct emp_qelem *qp, *next;
832 struct plchrstr *pcp;
835 for (qp = list->q_forw; qp != list; qp = next) {
837 plp = (struct plist *)qp;
841 if (pp->pln_effic < 40) {
847 if (pp->pln_mobil < 1) {
854 if (ontradingblock(EF_PLANE, pp)) {
861 if (!pln_capable(pp, wantflags, nowantflags)) {
867 if (!pln_airbase_ok(pp, 0, 0)) {
873 if (pcp->pl_flags & P_A) {
874 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
881 putplane(pp->pln_uid, pp);
886 * Arm only the planes at x,y
889 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
890 int mission, struct ichrstr *ip)
892 struct emp_qelem *qp;
893 struct emp_qelem *next;
897 for (qp = list->q_forw; qp != list; qp = next) {
899 plp = (struct plist *)qp;
907 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
908 || mission_pln_equip(plp, ip, mission) < 0) {
914 pp->pln_flags |= PLN_LAUNCHED;
915 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
916 putplane(pp->pln_uid, pp);
921 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
923 struct plchrstr *pcp;
934 if (pp->pln_ship >= 0) {
935 getship(pp->pln_ship, &ship);
936 item = ship.shp_item;
937 } else if (pp->pln_land >= 0) {
938 getland(pp->pln_land, &land);
939 item = land.lnd_item;
941 getsect(pp->pln_x, pp->pln_y, §);
942 item = sect.sct_item;
944 if (pcp->pl_fuel > item[I_PETROL]) {
947 item[I_PETROL] -= pcp->pl_fuel;
951 case 'p': /* pinpoint bomb */
954 case 'i': /* missile interception */
958 case 'e': /* escort */
959 case 0: /* plane interception */
967 if (itype != I_NONE) {
968 needed = load / ichr[itype].i_lbs;
971 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
973 if (itype == I_SHELL && item[itype] < needed) {
974 if (pp->pln_ship >= 0)
975 shp_supply(&ship, I_SHELL, needed);
976 else if (pp->pln_land >= 0)
977 lnd_supply(&land, I_SHELL, needed);
979 sct_supply(§, I_SHELL, needed);
981 if (item[itype] < needed)
983 item[itype] -= needed;
987 if (pp->pln_ship >= 0)
988 putship(ship.shp_uid, &ship);
989 else if (pp->pln_land >= 0)
990 putland(land.lnd_uid, &land);
997 * Return 1 if this x,y pair is in the list
1000 find_airport(struct emp_qelem *airp, coord x, coord y)
1002 struct emp_qelem *qp;
1005 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
1006 a = (struct airport *)qp;
1007 if ((a->x == x) && (a->y == y))
1014 /* #*# This needs to be changed to include acc's -KHS */
1016 add_airport(struct emp_qelem *airp, coord x, coord y)
1021 a = malloc(sizeof(struct airport));
1025 getsect(x, y, §);
1026 a->own = sect.sct_own;
1028 emp_insque((struct emp_qelem *)a, airp);
1032 * Take all the planes in list 1 that
1033 * are at x,y, and put them into list 2.
1036 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1038 struct emp_qelem *qp, *next;
1041 for (qp = l1->q_forw; qp != l1; qp = next) {
1043 plp = (struct plist *)qp;
1045 if (plp->plane.pln_x != x)
1047 if (plp->plane.pln_y != y)
1056 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1057 natid victim, char *s, int hardtarget)
1059 struct emp_qelem *qp;
1062 int newdam, dam = 0;
1065 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1066 plp = (struct plist *)qp;
1069 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1076 if (plp->pcp->pl_flags & P_A) {
1077 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1079 "\t%s detects sub movement in %s\n",
1080 prplane(pp), xyas(x, y, pp->pln_own));
1083 if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) {
1085 "\t%s tracks %s %s at %s\n",
1086 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1090 "\t%s depth-charging %s %s in %s\n",
1091 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1094 "\t%s pinbombing %s %s in %s\n",
1095 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1097 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1098 if (nuk_on_plane(&plp->plane) >= 0)
1100 else if (hardtarget != SECT_HARDTARGET)
1101 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1102 if (roll(100) <= hitchance) {
1103 newdam = pln_damage(&plp->plane, 'p', 1);
1105 "\t\thit %s %s for %d damage\n",
1106 cname(victim), s, newdam);
1109 newdam = pln_damage(&plp->plane, 'p', 0);
1110 wu(0, pp->pln_own, "missed\n");
1111 if (mission == MI_SINTERDICT) {
1113 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1114 xyas(x, y, victim));
1115 } else if (*s == 's') {
1116 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1117 s, xyas(x, y, victim));
1119 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1120 s, xyas(x, y, victim));
1122 /* Now, even though we missed, the bombs
1124 collateral_damage(x, y, newdam);
1127 /* use up missiles */
1128 if (plp->pcp->pl_flags & P_M)