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 void *cp; /* pointer to desc of thing */
55 struct empobj *thing; /* thing's struct */
59 struct emp_qelem queue;
64 static void add_airport(struct emp_qelem *, coord, coord);
65 static int air_damage(struct emp_qelem *, coord, coord, int, natid,
67 static void build_mission_list(struct genlist *, coord, coord, int, natid);
68 static void build_mission_list_type(struct genlist *, coord, coord, int,
70 static void divide(struct emp_qelem *, struct emp_qelem *, coord, coord);
71 static int dosupport(struct genlist *, coord, coord, natid, natid);
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 *, int,
88 * Interdict commodities & transported planes
91 ground_interdict(coord x, coord y, natid victim, char *s)
94 int dam = 0, newdam, rel;
95 struct genlist mi[MAXNOC];
98 memset(mi, 0, sizeof(mi));
99 for (z = 1; z < MAXNOC; z++)
100 emp_initque((struct emp_qelem *)&mi[z]);
102 build_mission_list(mi, x, y, MI_INTERDICT, victim);
104 for (cn = 1; cn < MAXNOC; cn++) {
105 rel = getrel(getnatp(cn), victim);
109 if (QEMPTY(&mi[cn].queue))
112 newdam = perform_mission(x, y, victim, &mi[cn].queue,
113 MI_INTERDICT, s, SECT_HARDTARGET);
116 mpr(victim, "%s interdiction mission does %d damage!\n",
120 collateral_damage(x, y, dam);
126 collateral_damage(coord x, coord y, int dam)
134 getsect(x, y, §);
136 coll = ldround((double)dam * collateral_dam, 1);
139 mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
140 xyas(x, y, sect.sct_own), coll);
141 sectdamage(§, coll);
149 only_subs(struct emp_qelem *list)
151 struct emp_qelem *qp;
155 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
156 glp = (struct genlist *)qp;
158 if (glp->thing->ef_type != EF_SHIP)
161 if (!(mcp->m_flags & M_SUB))
165 /* They were all subs! */
171 * Interdict ships & land units
174 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
179 struct genlist mi[MAXNOC];
183 memset(mi, 0, sizeof(mi));
184 for (z = 1; z < MAXNOC; z++)
185 emp_initque((struct emp_qelem *)&mi[z]);
187 build_mission_list(mi, x, y, mission, victim);
189 for (cn = 1; cn < MAXNOC; cn++) {
192 if (mission == MI_SINTERDICT) {
193 if (getrel(getnatp(cn), victim) >= FRIENDLY)
195 } else if (getrel(getnatp(cn), victim) > HOSTILE)
198 if (QEMPTY(&mi[cn].queue))
201 osubs = only_subs(&mi[cn].queue);
202 newdam = perform_mission(x, y, victim, &mi[cn].queue,
203 mission, s, hardtarget);
206 /* If only subs responded, then we don't know who's
208 mpr(victim, "%s interdiction mission does %d damage!\n",
209 osubs ? "Enemy" : cname(cn), newdam);
213 collateral_damage(x, y, dam);
219 * Perform a mission against victim, on behalf of actee
222 off_support(coord x, coord y, natid victim, natid actee)
225 struct genlist mi[MAXNOC];
228 memset(mi, 0, sizeof(mi));
229 for (z = 1; z < MAXNOC; z++)
230 emp_initque((struct emp_qelem *)&mi[z]);
232 build_mission_list(mi, x, y, MI_SUPPORT, victim);
233 build_mission_list(mi, x, y, MI_OSUPPORT, victim);
235 dam = dosupport(mi, x, y, victim, actee);
240 * Perform a mission against victim, on behalf of actee
243 def_support(coord x, coord y, natid victim, natid actee)
246 struct genlist mi[MAXNOC];
249 memset(mi, 0, sizeof(mi));
250 for (z = 1; z < MAXNOC; z++)
251 emp_initque((struct emp_qelem *)&mi[z]);
253 build_mission_list(mi, x, y, MI_SUPPORT, victim);
254 build_mission_list(mi, x, y, MI_DSUPPORT, victim);
256 dam = dosupport(mi, x, y, victim, actee);
261 dosupport(struct genlist *mi, coord x, coord y, natid victim, natid actee)
267 for (cn = 1; cn < MAXNOC; cn++) {
268 rel = getrel(getnatp(cn), actee);
269 if ((cn != actee) && (rel != ALLIED))
271 rel = getrel(getnatp(cn), victim);
272 if ((cn != actee) && (rel != AT_WAR))
275 if (QEMPTY(&mi[cn].queue))
278 dam += perform_mission(x, y, victim, &mi[cn].queue, MI_SUPPORT,
279 "", SECT_HARDTARGET);
285 build_mission_list(struct genlist *mi, coord x, coord y, int mission,
288 build_mission_list_type(mi, x, y, mission, EF_LAND, victim);
289 build_mission_list_type(mi, x, y, mission, EF_SHIP, victim);
290 build_mission_list_type(mi, x, y, mission, EF_PLANE, victim);
294 build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
295 int type, natid victim)
300 union empobj_storage item;
304 snxtitem_all(&ni, type);
305 while (nxtitem(&ni, &item)) {
306 gp = (struct empobj *)&item;
314 if ((gp->mission != mission) && (mission != MI_SINTERDICT))
317 if ((gp->mission != mission) && (mission == MI_SINTERDICT) &&
318 (gp->mission != MI_INTERDICT))
321 relat = getrel(getnatp(gp->own), victim);
322 if (mission == MI_SINTERDICT) {
323 if (relat >= FRIENDLY)
325 else if (type != EF_PLANE && relat > HOSTILE)
327 } else if (relat > HOSTILE)
330 if (!in_oparea(gp, x, y))
334 if (mission != MI_AIR_DEFENSE) {
335 getsect(x, y, §);
336 if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) {
339 * If the owner of the unit isn't at war
340 * with the victim, and doesn't own the
341 * sect being acted upon, and isn't the
342 * old owner of that sect, bounce them.
344 if (sect.sct_type != SCT_WATER &&
345 sect.sct_own != gp->own &&
346 sect.sct_oldown != gp->own)
352 glp = malloc(sizeof(struct genlist));
353 memset(glp, 0, sizeof(struct genlist));
354 glp->cp = get_empobj_chr(gp);
355 glp->thing = malloc(sizeof(item));
356 memcpy(glp->thing, &item, sizeof(item));
357 emp_insque(&glp->queue, &mi[gp->own].queue);
362 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
368 snxtitem_all(&ni, EF_PLANE);
369 while (nxtitem(&ni, &plane)) {
370 if (plane.pln_own != cn)
372 if (plane.pln_mission != MI_ESCORT)
374 if (!in_oparea((struct empobj *)&plane, x, y))
376 plp = malloc(sizeof(struct plist));
377 memset(plp, 0, sizeof(struct plist));
378 plp->pcp = &plchr[(int)plane.pln_type];
380 emp_insque(&plp->queue, escorts);
385 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
386 int mission, char *s, int hardtarget)
388 struct emp_qelem *qp, missiles, bombers;
392 struct plchrstr *pcp;
394 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
396 getsect(x, y, §);
398 emp_initque(&missiles);
399 emp_initque(&bombers);
401 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
402 glp = (struct genlist *)qp;
404 if (glp->thing->ef_type == EF_LAND) {
405 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
406 x, y, victim, mission, s,
408 } else if (glp->thing->ef_type == EF_SHIP) {
409 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
410 x, y, victim, mission, s,
412 } else if (glp->thing->ef_type == EF_PLANE) {
414 if (pcp->pl_flags & P_M)
415 /* units have their own missile interdiction */
416 if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
419 /* save planes for later */
420 plp = malloc(sizeof(struct plist));
422 memset(plp, 0, sizeof(struct plist));
424 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
425 if (plp->pcp->pl_flags & P_M)
426 emp_insque(&plp->queue, &missiles);
428 emp_insque(&plp->queue, &bombers);
435 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
436 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
437 hardtarget, targeting_ships);
441 glp = (struct genlist *)qp;
452 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
453 natid victim, int mission, char *s,
458 if (mission == MI_SINTERDICT)
461 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
463 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
466 range = roundrange(lnd_fire_range(lp));
471 putland(lp->lnd_uid, lp);
475 if (targeting_ships) {
476 if (chance(lnd_acc(lp) / 100.0))
477 dam2 = ldround(dam2 / 2.0, 1);
480 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
482 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
484 "%s fires at %s %s at %s\n",
485 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
487 mpr(victim, "%s %s fires at you at %s\n",
488 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
494 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
495 natid victim, int mission, char *s,
498 struct mchrstr *mcp = &mchr[sp->shp_type];
499 double vrange, hitchance;
502 md = mapdist(x, y, sp->shp_x, sp->shp_y);
504 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
505 && md > ship_max_interdiction_range)
508 if (mission == MI_SINTERDICT) {
509 if (!(mcp->m_flags & M_SONAR))
511 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
513 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
514 vrange *= sp->shp_effic / 200.0;
517 /* can't look all the time */
521 if (mcp->m_flags & M_SUB) {
522 if (!targeting_ships)
523 return dam; /* subs interdict only ships */
524 range = roundrange(torprange(sp));
527 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
529 dam2 = shp_torp(sp, 1);
530 putship(sp->shp_uid, sp);
533 hitchance = shp_torp_hitchance(sp, md);
536 "%s locking on %s %s in %s\n",
537 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
539 "\tEffective torpedo range is %d.0\n", range);
541 "\tWhooosh... Hitchance = %d%%\n",
542 (int)(hitchance * 100));
544 if (!chance(hitchance)) {
545 wu(0, sp->shp_own, "\tMissed\n");
547 "Incoming torpedo sighted @ %s missed (whew)!\n",
551 wu(0, sp->shp_own, "\tBOOM!...\n");
552 nreport(victim, N_TORP_SHIP, 0, 1);
554 "\tTorpedo hit %s %s for %d damage\n",
555 cname(victim), s, dam2);
558 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
559 xyas(x, y, victim), dam2);
561 range = roundrange(shp_fire_range(sp));
564 if (mission == MI_SINTERDICT)
565 dam2 = shp_dchrg(sp);
568 putship(sp->shp_uid, sp);
572 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
574 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
576 "%s fires at %s %s at %s\n",
577 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
579 mpr(victim, "%s %s fires at you at %s\n",
580 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
587 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
588 natid victim, int hardtarget)
591 struct emp_qelem *qp, *newqp;
596 * Missiles, except for interdiction of ships or land units,
597 * because that happens elsewhere, in shp_missile_interdiction()
598 * and lnd_missile_interdiction().
601 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
603 plp = (struct plist *)qp;
606 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
607 || (plp->pcp->pl_flags & P_MAR))
608 && mission_pln_equip(plp, NULL, 'p') >= 0) {
609 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
612 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
613 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
615 dam2 = pln_damage(&plp->plane, 'p', 1);
618 plp->plane.pln_effic = 0;
619 putplane(plp->plane.pln_uid, &plp->plane);
624 return dam + air_dam;
628 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
629 natid victim, int mission, char *s, int hardtarget,
632 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
634 int plane_owner, air_dam, md;
636 emp_initque(&escorts);
642 plp = (struct plist *)bombers->q_forw;
643 plane_owner = plp->plane.pln_own;
646 * If there are planes performing an
647 * interdict or support mission, find
648 * some escorts for them, if possible.
649 * Up to 2 per bomber, if possible.
651 find_escorts(x, y, plane_owner, &escorts);
653 if (mission == MI_SINTERDICT)
654 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
656 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
658 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
660 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
661 plp = (struct plist *)qp;
662 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
663 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
667 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
672 air = (struct airport *)qp;
673 md = mapdist(x, y, air->x, air->y);
678 /* Split off the bombers at this base into b */
679 divide(bombers, &b, air->x, air->y);
681 /* Split off the escorts at this base into e */
682 divide(&escorts, &e, air->x, air->y);
684 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
689 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
691 pp = BestAirPath(buf, air->x, air->y, x, y);
692 if (CANT_HAPPEN(!pp))
694 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
695 mission_name(mission),
696 xyas(air->x, air->y, plane_owner),
697 xyas(x, y, plane_owner));
698 if (air->own && (air->own != plane_owner)) {
699 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
700 cname(plane_owner), mission_name(mission),
701 xyas(air->x, air->y, air->own),
702 xyas(x, y, air->own));
705 ac_encounter(&b, &e, air->x, air->y, pp, 0);
709 air_damage(&b, x, y, mission, victim, s, hardtarget);
717 nreport(plane_owner, N_SHP_BOMB, victim, 1);
719 nreport(plane_owner, N_SCT_BOMB, victim, 1);
723 while (qp != (&escorts)) {
730 qp = bombers->q_forw;
731 while (qp != bombers) {
738 return dam + air_dam;
742 cando(int mission, int type)
746 if (type == EF_PLANE)
750 if (type == EF_PLANE)
754 if ((type == EF_PLANE) || (type == EF_SHIP))
762 if (type == EF_PLANE)
775 mission_name(int mission)
779 return "an interdiction";
783 return "an offensive support";
785 return "a defensive support";
791 return "a sub interdiction";
793 return "an air defense";
796 return "a mysterious";
800 * Maximum distance GP can perform its mission.
801 * Note: this has nothing to do with the radius of the op-area.
802 * oprange() governs where the unit *can* strike, the op-area governs
803 * where the player wants it to strike.
806 oprange(struct empobj *gp)
808 switch (gp->ef_type) {
810 return ldround(shp_fire_range((struct shpstr *)gp), 1);
812 if (gp->mission == MI_RESERVE)
813 return lnd_reaction_range((struct lndstr *)gp);
814 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
816 /* missiles go one way, so we can use all the range */
817 if (plchr[(int)gp->type].pl_flags & P_M)
818 return ((struct plnstr *)gp)->pln_range;
819 return ((struct plnstr *)gp)->pln_range / 2;
826 * Does GP's mission op area cover X,Y?
829 in_oparea(struct empobj *gp, coord x, coord y)
831 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
832 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
836 * Remove all planes who cannot go on
837 * the mission from the plane list.
840 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
843 struct emp_qelem *qp, *next;
845 struct plchrstr *pcp;
848 for (qp = list->q_forw; qp != list; qp = next) {
850 plp = (struct plist *)qp;
854 if (pp->pln_effic < 40) {
860 if (pp->pln_mobil < 1) {
867 if (ontradingblock(EF_PLANE, pp)) {
874 if (!pln_capable(pp, wantflags, nowantflags)) {
880 if (!pln_airbase_ok(pp, 0, 0)) {
886 if (pcp->pl_flags & P_A) {
887 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
894 putplane(pp->pln_uid, pp);
899 * Arm only the planes at x,y
902 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
903 int mission, struct ichrstr *ip)
905 struct emp_qelem *qp;
906 struct emp_qelem *next;
910 for (qp = list->q_forw; qp != list; qp = next) {
912 plp = (struct plist *)qp;
920 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
921 || mission_pln_equip(plp, ip, mission) < 0) {
927 pp->pln_flags |= PLN_LAUNCHED;
928 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
929 putplane(pp->pln_uid, pp);
934 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
936 struct plchrstr *pcp;
947 if (pp->pln_ship >= 0) {
948 getship(pp->pln_ship, &ship);
949 item = ship.shp_item;
950 } else if (pp->pln_land >= 0) {
951 getland(pp->pln_land, &land);
952 item = land.lnd_item;
954 getsect(pp->pln_x, pp->pln_y, §);
955 item = sect.sct_item;
957 if (pcp->pl_fuel > item[I_PETROL]) {
960 item[I_PETROL] -= pcp->pl_fuel;
964 case 'p': /* pinpoint bomb */
967 case 'i': /* missile interception */
971 case 'e': /* escort */
972 case 0: /* plane interception */
980 if (itype != I_NONE) {
981 needed = load / ichr[itype].i_lbs;
984 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
986 if (itype == I_SHELL && item[itype] < needed) {
987 if (pp->pln_ship >= 0)
988 shp_supply(&ship, I_SHELL, needed);
989 else if (pp->pln_land >= 0)
990 lnd_supply(&land, I_SHELL, needed);
992 sct_supply(§, I_SHELL, needed);
994 if (item[itype] < needed)
996 item[itype] -= needed;
1000 if (pp->pln_ship >= 0)
1001 putship(ship.shp_uid, &ship);
1002 else if (pp->pln_land >= 0)
1003 putland(land.lnd_uid, &land);
1010 * Return 1 if this x,y pair is in the list
1013 find_airport(struct emp_qelem *airp, coord x, coord y)
1015 struct emp_qelem *qp;
1018 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
1019 a = (struct airport *)qp;
1020 if ((a->x == x) && (a->y == y))
1027 /* #*# This needs to be changed to include acc's -KHS */
1029 add_airport(struct emp_qelem *airp, coord x, coord y)
1034 a = malloc(sizeof(struct airport));
1038 getsect(x, y, §);
1039 a->own = sect.sct_own;
1041 emp_insque((struct emp_qelem *)a, airp);
1045 * Take all the planes in list 1 that
1046 * are at x,y, and put them into list 2.
1049 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1051 struct emp_qelem *qp, *next;
1054 for (qp = l1->q_forw; qp != l1; qp = next) {
1056 plp = (struct plist *)qp;
1058 if (plp->plane.pln_x != x)
1060 if (plp->plane.pln_y != y)
1069 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1070 natid victim, char *s, int hardtarget)
1072 struct emp_qelem *qp;
1075 int newdam, dam = 0;
1078 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1079 plp = (struct plist *)qp;
1082 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1089 if (plp->pcp->pl_flags & P_A) {
1090 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1092 "\t%s detects sub movement in %s\n",
1093 prplane(pp), xyas(x, y, pp->pln_own));
1096 if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) {
1098 "\t%s tracks %s %s at %s\n",
1099 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1103 "\t%s depth-charging %s %s in %s\n",
1104 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1107 "\t%s pinbombing %s %s in %s\n",
1108 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1110 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1111 if (nuk_on_plane(&plp->plane) >= 0)
1113 else if (hardtarget != SECT_HARDTARGET)
1114 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1115 if (roll(100) <= hitchance) {
1116 newdam = pln_damage(&plp->plane, 'p', 1);
1118 "\t\thit %s %s for %d damage\n",
1119 cname(victim), s, newdam);
1122 newdam = pln_damage(&plp->plane, 'p', 0);
1123 wu(0, pp->pln_own, "missed\n");
1124 if (mission == MI_SINTERDICT) {
1126 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1127 xyas(x, y, victim));
1128 } else if (*s == 's') {
1129 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1130 s, xyas(x, y, victim));
1132 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1133 s, xyas(x, y, victim));
1135 /* Now, even though we missed, the bombs
1137 collateral_damage(x, y, newdam);
1140 /* use up missiles */
1141 if (plp->pcp->pl_flags & P_M)