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];
96 memset(mi, 0, sizeof(mi));
97 for (cn = 1; cn < MAXNOC; cn++)
98 emp_initque((struct emp_qelem *)&mi[cn]);
100 build_mission_list(mi, x, y, MI_INTERDICT, victim);
102 for (cn = 1; cn < MAXNOC; cn++) {
103 rel = getrel(getnatp(cn), victim);
107 if (QEMPTY(&mi[cn].queue))
110 newdam = perform_mission(x, y, victim, &mi[cn].queue,
111 MI_INTERDICT, s, SECT_HARDTARGET);
114 mpr(victim, "%s interdiction mission does %d damage!\n",
118 collateral_damage(x, y, dam);
124 collateral_damage(coord x, coord y, int dam)
132 getsect(x, y, §);
134 coll = ldround((double)dam * collateral_dam, 1);
137 mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
138 xyas(x, y, sect.sct_own), coll);
139 sectdamage(§, coll);
147 only_subs(struct emp_qelem *list)
149 struct emp_qelem *qp;
152 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
153 glp = (struct genlist *)qp;
155 if (glp->thing->ef_type != EF_SHIP)
157 if (!(mchr[glp->thing->type].m_flags & M_SUB))
161 /* They were all subs! */
167 * Interdict ships & land units
170 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
175 struct genlist mi[MAXNOC];
178 memset(mi, 0, sizeof(mi));
179 for (cn = 1; cn < MAXNOC; cn++)
180 emp_initque((struct emp_qelem *)&mi[cn]);
182 build_mission_list(mi, x, y, mission, victim);
184 for (cn = 1; cn < MAXNOC; cn++) {
187 if (mission == MI_SINTERDICT) {
188 if (getrel(getnatp(cn), victim) >= FRIENDLY)
190 } else if (getrel(getnatp(cn), victim) > HOSTILE)
193 if (QEMPTY(&mi[cn].queue))
196 osubs = only_subs(&mi[cn].queue);
197 newdam = perform_mission(x, y, victim, &mi[cn].queue,
198 mission, s, hardtarget);
201 /* If only subs responded, then we don't know who's
203 mpr(victim, "%s interdiction mission does %d damage!\n",
204 osubs ? "Enemy" : cname(cn), newdam);
208 collateral_damage(x, y, dam);
214 * Perform a mission against victim, on behalf of actee
217 off_support(coord x, coord y, natid victim, natid actee)
220 struct genlist mi[MAXNOC];
223 memset(mi, 0, sizeof(mi));
224 for (cn = 1; cn < MAXNOC; cn++)
225 emp_initque((struct emp_qelem *)&mi[cn]);
227 build_mission_list(mi, x, y, MI_SUPPORT, victim);
228 build_mission_list(mi, x, y, MI_OSUPPORT, victim);
230 dam = dosupport(mi, x, y, victim, actee);
235 * Perform a mission against victim, on behalf of actee
238 def_support(coord x, coord y, natid victim, natid actee)
241 struct genlist mi[MAXNOC];
244 memset(mi, 0, sizeof(mi));
245 for (cn = 1; cn < MAXNOC; cn++)
246 emp_initque((struct emp_qelem *)&mi[cn]);
248 build_mission_list(mi, x, y, MI_SUPPORT, victim);
249 build_mission_list(mi, x, y, MI_DSUPPORT, victim);
251 dam = dosupport(mi, x, y, victim, actee);
256 dosupport(struct genlist *mi, coord x, coord y, natid victim, natid actee)
262 for (cn = 1; cn < MAXNOC; cn++) {
263 rel = getrel(getnatp(cn), actee);
264 if ((cn != actee) && (rel != ALLIED))
266 rel = getrel(getnatp(cn), victim);
267 if ((cn != actee) && (rel != AT_WAR))
270 if (QEMPTY(&mi[cn].queue))
273 dam += perform_mission(x, y, victim, &mi[cn].queue, MI_SUPPORT,
274 "", SECT_HARDTARGET);
280 build_mission_list(struct genlist *mi, coord x, coord y, int mission,
283 build_mission_list_type(mi, x, y, mission, EF_LAND, victim);
284 build_mission_list_type(mi, x, y, mission, EF_SHIP, victim);
285 build_mission_list_type(mi, x, y, mission, EF_PLANE, victim);
289 build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
290 int type, natid victim)
295 union empobj_storage item;
299 snxtitem_all(&ni, type);
300 while (nxtitem(&ni, &item)) {
301 gp = (struct empobj *)&item;
309 if ((gp->mission != mission) && (mission != MI_SINTERDICT))
312 if ((gp->mission != mission) && (mission == MI_SINTERDICT) &&
313 (gp->mission != MI_INTERDICT))
316 relat = getrel(getnatp(gp->own), victim);
317 if (mission == MI_SINTERDICT) {
318 if (relat >= FRIENDLY)
320 else if (type != EF_PLANE && relat > HOSTILE)
322 } else if (relat > HOSTILE)
325 if (!in_oparea(gp, x, y))
329 if (mission != MI_AIR_DEFENSE) {
330 getsect(x, y, §);
331 if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) {
334 * If the owner of the unit isn't at war
335 * with the victim, and doesn't own the
336 * sect being acted upon, and isn't the
337 * old owner of that sect, bounce them.
339 if (sect.sct_type != SCT_WATER &&
340 sect.sct_own != gp->own &&
341 sect.sct_oldown != gp->own)
347 glp = malloc(sizeof(struct genlist));
348 memset(glp, 0, sizeof(struct genlist));
349 glp->thing = malloc(sizeof(item));
350 memcpy(glp->thing, &item, sizeof(item));
351 emp_insque(&glp->queue, &mi[gp->own].queue);
356 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
362 snxtitem_all(&ni, EF_PLANE);
363 while (nxtitem(&ni, &plane)) {
364 if (plane.pln_own != cn)
366 if (plane.pln_mission != MI_ESCORT)
368 if (!in_oparea((struct empobj *)&plane, x, y))
370 plp = malloc(sizeof(struct plist));
371 memset(plp, 0, sizeof(struct plist));
372 plp->pcp = &plchr[(int)plane.pln_type];
374 emp_insque(&plp->queue, escorts);
379 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
380 int mission, char *s, int hardtarget)
382 struct emp_qelem *qp, missiles, bombers;
385 struct plchrstr *pcp;
387 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
389 emp_initque(&missiles);
390 emp_initque(&bombers);
392 for (qp = list->q_forw; qp != list; ) {
393 glp = (struct genlist *)qp;
396 if (glp->thing->ef_type == EF_LAND) {
397 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
398 x, y, victim, mission, s,
400 } else if (glp->thing->ef_type == EF_SHIP) {
401 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
402 x, y, victim, mission, s,
404 } else if (glp->thing->ef_type == EF_PLANE) {
405 pcp = &plchr[glp->thing->type];
406 if (pcp->pl_flags & P_M)
407 /* units have their own missile interdiction */
408 if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
411 /* save planes for later */
412 plp = malloc(sizeof(struct plist));
414 memset(plp, 0, sizeof(struct plist));
416 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
417 if (plp->pcp->pl_flags & P_M)
418 emp_insque(&plp->queue, &missiles);
420 emp_insque(&plp->queue, &bombers);
429 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
430 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
431 hardtarget, targeting_ships);
437 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
438 natid victim, int mission, char *s,
443 if (mission == MI_SINTERDICT)
446 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
448 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
451 range = roundrange(lnd_fire_range(lp));
456 putland(lp->lnd_uid, lp);
460 if (targeting_ships) {
461 if (chance(lnd_acc(lp) / 100.0))
462 dam2 = ldround(dam2 / 2.0, 1);
465 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
467 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
469 "%s fires at %s %s at %s\n",
470 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
472 mpr(victim, "%s %s fires at you at %s\n",
473 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
479 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
480 natid victim, int mission, char *s,
483 struct mchrstr *mcp = &mchr[sp->shp_type];
484 double vrange, hitchance;
487 md = mapdist(x, y, sp->shp_x, sp->shp_y);
489 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
490 && md > ship_max_interdiction_range)
493 if (mission == MI_SINTERDICT) {
494 if (!(mcp->m_flags & M_SONAR))
496 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
498 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
499 vrange *= sp->shp_effic / 200.0;
502 /* can't look all the time */
506 if (mcp->m_flags & M_SUB) {
507 if (!targeting_ships)
508 return dam; /* subs interdict only ships */
509 range = roundrange(torprange(sp));
512 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
514 dam2 = shp_torp(sp, 1);
515 putship(sp->shp_uid, sp);
518 hitchance = shp_torp_hitchance(sp, md);
521 "%s locking on %s %s in %s\n",
522 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
524 "\tEffective torpedo range is %d.0\n", range);
526 "\tWhooosh... Hitchance = %d%%\n",
527 (int)(hitchance * 100));
529 if (!chance(hitchance)) {
530 wu(0, sp->shp_own, "\tMissed\n");
532 "Incoming torpedo sighted @ %s missed (whew)!\n",
536 wu(0, sp->shp_own, "\tBOOM!...\n");
537 nreport(victim, N_TORP_SHIP, 0, 1);
539 "\tTorpedo hit %s %s for %d damage\n",
540 cname(victim), s, dam2);
543 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
544 xyas(x, y, victim), dam2);
546 range = roundrange(shp_fire_range(sp));
549 if (mission == MI_SINTERDICT)
550 dam2 = shp_dchrg(sp);
553 putship(sp->shp_uid, sp);
557 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
559 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
561 "%s fires at %s %s at %s\n",
562 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
564 mpr(victim, "%s %s fires at you at %s\n",
565 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
572 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
573 natid victim, int hardtarget)
576 struct emp_qelem *qp, *newqp;
581 * Missiles, except for interdiction of ships or land units,
582 * because that happens elsewhere, in shp_missile_interdiction()
583 * and lnd_missile_interdiction().
586 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
588 plp = (struct plist *)qp;
591 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
592 || (plp->pcp->pl_flags & P_MAR))
593 && mission_pln_equip(plp, NULL, 'p') >= 0) {
594 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
597 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
598 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
600 dam2 = pln_damage(&plp->plane, 'p', 1);
603 plp->plane.pln_effic = 0;
604 putplane(plp->plane.pln_uid, &plp->plane);
609 return dam + air_dam;
613 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
614 natid victim, int mission, char *s, int hardtarget,
617 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
619 int plane_owner, air_dam, md;
621 emp_initque(&escorts);
627 plp = (struct plist *)bombers->q_forw;
628 plane_owner = plp->plane.pln_own;
631 * If there are planes performing an
632 * interdict or support mission, find
633 * some escorts for them, if possible.
634 * Up to 2 per bomber, if possible.
636 find_escorts(x, y, plane_owner, &escorts);
638 if (mission == MI_SINTERDICT)
639 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
641 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
643 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
645 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
646 plp = (struct plist *)qp;
647 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
648 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
652 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
657 air = (struct airport *)qp;
658 md = mapdist(x, y, air->x, air->y);
663 /* Split off the bombers at this base into b */
664 divide(bombers, &b, air->x, air->y);
666 /* Split off the escorts at this base into e */
667 divide(&escorts, &e, air->x, air->y);
669 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
674 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
676 pp = BestAirPath(buf, air->x, air->y, x, y);
677 if (CANT_HAPPEN(!pp))
679 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
680 mission_name(mission),
681 xyas(air->x, air->y, plane_owner),
682 xyas(x, y, plane_owner));
683 if (air->own && (air->own != plane_owner)) {
684 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
685 cname(plane_owner), mission_name(mission),
686 xyas(air->x, air->y, air->own),
687 xyas(x, y, air->own));
690 ac_encounter(&b, &e, air->x, air->y, pp, 0);
694 air_damage(&b, x, y, mission, victim, s, hardtarget);
702 nreport(plane_owner, N_SHP_BOMB, victim, 1);
704 nreport(plane_owner, N_SCT_BOMB, victim, 1);
708 while (qp != (&escorts)) {
715 qp = bombers->q_forw;
716 while (qp != bombers) {
723 return dam + air_dam;
727 cando(int mission, int type)
731 if (type == EF_PLANE)
735 if (type == EF_PLANE)
739 if ((type == EF_PLANE) || (type == EF_SHIP))
747 if (type == EF_PLANE)
760 mission_name(int mission)
764 return "an interdiction";
768 return "an offensive support";
770 return "a defensive support";
776 return "a sub interdiction";
778 return "an air defense";
781 return "a mysterious";
785 * Maximum distance GP can perform its mission.
786 * Note: this has nothing to do with the radius of the op-area.
787 * oprange() governs where the unit *can* strike, the op-area governs
788 * where the player wants it to strike.
791 oprange(struct empobj *gp)
793 switch (gp->ef_type) {
795 return ldround(shp_fire_range((struct shpstr *)gp), 1);
797 if (gp->mission == MI_RESERVE)
798 return lnd_reaction_range((struct lndstr *)gp);
799 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
801 /* missiles go one way, so we can use all the range */
802 if (plchr[(int)gp->type].pl_flags & P_M)
803 return ((struct plnstr *)gp)->pln_range;
804 return ((struct plnstr *)gp)->pln_range / 2;
811 * Does GP's mission op area cover X,Y?
814 in_oparea(struct empobj *gp, coord x, coord y)
816 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
817 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
821 * Remove all planes who cannot go on
822 * the mission from the plane list.
825 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
828 struct emp_qelem *qp, *next;
830 struct plchrstr *pcp;
833 for (qp = list->q_forw; qp != list; qp = next) {
835 plp = (struct plist *)qp;
839 if (pp->pln_effic < 40) {
845 if (pp->pln_mobil < 1) {
852 if (ontradingblock(EF_PLANE, pp)) {
859 if (!pln_capable(pp, wantflags, nowantflags)) {
865 if (!pln_airbase_ok(pp, 0, 0)) {
871 if (pcp->pl_flags & P_A) {
872 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
879 putplane(pp->pln_uid, pp);
884 * Arm only the planes at x,y
887 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
888 int mission, struct ichrstr *ip)
890 struct emp_qelem *qp;
891 struct emp_qelem *next;
895 for (qp = list->q_forw; qp != list; qp = next) {
897 plp = (struct plist *)qp;
905 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
906 || mission_pln_equip(plp, ip, mission) < 0) {
912 pp->pln_flags |= PLN_LAUNCHED;
913 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
914 putplane(pp->pln_uid, pp);
919 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
921 struct plchrstr *pcp;
932 if (pp->pln_ship >= 0) {
933 getship(pp->pln_ship, &ship);
934 item = ship.shp_item;
935 } else if (pp->pln_land >= 0) {
936 getland(pp->pln_land, &land);
937 item = land.lnd_item;
939 getsect(pp->pln_x, pp->pln_y, §);
940 item = sect.sct_item;
942 if (pcp->pl_fuel > item[I_PETROL]) {
945 item[I_PETROL] -= pcp->pl_fuel;
949 case 'p': /* pinpoint bomb */
952 case 'i': /* missile interception */
956 case 'e': /* escort */
957 case 0: /* plane interception */
965 if (itype != I_NONE) {
966 needed = load / ichr[itype].i_lbs;
969 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
971 if (itype == I_SHELL && item[itype] < needed) {
972 if (pp->pln_ship >= 0)
973 shp_supply(&ship, I_SHELL, needed);
974 else if (pp->pln_land >= 0)
975 lnd_supply(&land, I_SHELL, needed);
977 sct_supply(§, I_SHELL, needed);
979 if (item[itype] < needed)
981 item[itype] -= needed;
985 if (pp->pln_ship >= 0)
986 putship(ship.shp_uid, &ship);
987 else if (pp->pln_land >= 0)
988 putland(land.lnd_uid, &land);
995 * Return 1 if this x,y pair is in the list
998 find_airport(struct emp_qelem *airp, coord x, coord y)
1000 struct emp_qelem *qp;
1003 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
1004 a = (struct airport *)qp;
1005 if ((a->x == x) && (a->y == y))
1012 /* #*# This needs to be changed to include acc's -KHS */
1014 add_airport(struct emp_qelem *airp, coord x, coord y)
1019 a = malloc(sizeof(struct airport));
1023 getsect(x, y, §);
1024 a->own = sect.sct_own;
1026 emp_insque((struct emp_qelem *)a, airp);
1030 * Take all the planes in list 1 that
1031 * are at x,y, and put them into list 2.
1034 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1036 struct emp_qelem *qp, *next;
1039 for (qp = l1->q_forw; qp != l1; qp = next) {
1041 plp = (struct plist *)qp;
1043 if (plp->plane.pln_x != x)
1045 if (plp->plane.pln_y != y)
1054 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1055 natid victim, char *s, int hardtarget)
1057 struct emp_qelem *qp;
1060 int newdam, dam = 0;
1063 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1064 plp = (struct plist *)qp;
1067 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1074 if (plp->pcp->pl_flags & P_A) {
1075 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1077 "\t%s detects sub movement in %s\n",
1078 prplane(pp), xyas(x, y, pp->pln_own));
1081 if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) {
1083 "\t%s tracks %s %s at %s\n",
1084 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1088 "\t%s depth-charging %s %s in %s\n",
1089 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1092 "\t%s pinbombing %s %s in %s\n",
1093 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1095 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1096 if (nuk_on_plane(&plp->plane) >= 0)
1098 else if (hardtarget != SECT_HARDTARGET)
1099 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1100 if (roll(100) <= hitchance) {
1101 newdam = pln_damage(&plp->plane, 'p', 1);
1103 "\t\thit %s %s for %d damage\n",
1104 cname(victim), s, newdam);
1107 newdam = pln_damage(&plp->plane, 'p', 0);
1108 wu(0, pp->pln_own, "missed\n");
1109 if (mission == MI_SINTERDICT) {
1111 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1112 xyas(x, y, victim));
1113 } else if (*s == 's') {
1114 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1115 s, xyas(x, y, victim));
1117 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1118 s, xyas(x, y, victim));
1120 /* Now, even though we missed, the bombs
1122 collateral_damage(x, y, newdam);
1125 /* use up missiles */
1126 if (plp->pcp->pl_flags & P_M)