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, int);
78 static int perform_mission_ship(int, struct shpstr *, coord, coord,
79 natid, int, char *, int, 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;
393 struct plchrstr *pcp;
396 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
398 getsect(x, y, §);
400 emp_initque(&missiles);
401 emp_initque(&bombers);
403 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
404 glp = (struct genlist *)qp;
407 md = mapdist(x, y, gp->x, gp->y);
409 if (glp->thing->ef_type == EF_LAND) {
410 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
411 x, y, victim, mission, s,
412 md, targeting_ships);
413 } else if (glp->thing->ef_type == EF_SHIP) {
414 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
415 x, y, victim, mission, s,
416 md, targeting_ships);
417 } else if (glp->thing->ef_type == EF_PLANE) {
419 if (pcp->pl_flags & P_M)
420 /* units have their own missile interdiction */
421 if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
424 /* save planes for later */
425 plp = malloc(sizeof(struct plist));
427 memset(plp, 0, sizeof(struct plist));
429 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
430 if (plp->pcp->pl_flags & P_M)
431 emp_insque(&plp->queue, &missiles);
433 emp_insque(&plp->queue, &bombers);
440 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
441 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
442 hardtarget, targeting_ships);
446 glp = (struct genlist *)qp;
457 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
458 natid victim, int mission, char *s, int md,
463 if (mission == MI_SINTERDICT)
466 if ((mission == MI_INTERDICT) &&
467 (md > land_max_interdiction_range))
470 range = roundrange(lnd_fire_range(lp));
475 putland(lp->lnd_uid, lp);
479 if (targeting_ships) {
480 if (chance(lnd_acc(lp) / 100.0))
481 dam2 = ldround(dam2 / 2.0, 1);
484 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
486 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
488 "%s fires at %s %s at %s\n",
489 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
491 mpr(victim, "%s %s fires at you at %s\n",
492 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
498 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
499 natid victim, int mission, char *s, int md,
502 struct mchrstr *mcp = &mchr[sp->shp_type];
503 double vrange, hitchance;
506 if (((mission == MI_INTERDICT) ||
507 (mission == MI_SINTERDICT)) &&
508 (md > ship_max_interdiction_range))
510 if (mission == MI_SINTERDICT) {
511 if (!(mcp->m_flags & M_SONAR))
513 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
515 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
516 vrange *= sp->shp_effic / 200.0;
519 /* can't look all the time */
523 if (mcp->m_flags & M_SUB) {
524 if (!targeting_ships)
525 return dam; /* subs interdict only ships */
526 range = roundrange(torprange(sp));
529 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
531 dam2 = shp_torp(sp, 1);
532 putship(sp->shp_uid, sp);
535 hitchance = shp_torp_hitchance(sp, md);
538 "%s locking on %s %s in %s\n",
539 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
541 "\tEffective torpedo range is %d.0\n", range);
543 "\tWhooosh... Hitchance = %d%%\n",
544 (int)(hitchance * 100));
546 if (!chance(hitchance)) {
547 wu(0, sp->shp_own, "\tMissed\n");
549 "Incoming torpedo sighted @ %s missed (whew)!\n",
553 wu(0, sp->shp_own, "\tBOOM!...\n");
554 nreport(victim, N_TORP_SHIP, 0, 1);
556 "\tTorpedo hit %s %s for %d damage\n",
557 cname(victim), s, dam2);
560 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
561 xyas(x, y, victim), dam2);
563 range = roundrange(shp_fire_range(sp));
566 if (mission == MI_SINTERDICT)
567 dam2 = shp_dchrg(sp);
570 putship(sp->shp_uid, sp);
574 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
576 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
578 "%s fires at %s %s at %s\n",
579 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
581 mpr(victim, "%s %s fires at you at %s\n",
582 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
589 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
590 natid victim, int hardtarget)
593 struct emp_qelem *qp, *newqp;
598 * Missiles, except for interdiction of ships or land units,
599 * because that happens elsewhere, in shp_missile_interdiction()
600 * and lnd_missile_interdiction().
603 for (qp = missiles->q_back; qp != missiles; qp = newqp) {
605 plp = (struct plist *)qp;
608 && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
609 || (plp->pcp->pl_flags & P_MAR))
610 && mission_pln_equip(plp, NULL, 'p') >= 0) {
611 if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
614 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
615 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
617 dam2 = pln_damage(&plp->plane, 'p', 1);
620 plp->plane.pln_effic = 0;
621 putplane(plp->plane.pln_uid, &plp->plane);
626 return dam + air_dam;
630 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
631 natid victim, int mission, char *s, int hardtarget,
634 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
636 int plane_owner, air_dam, md;
638 emp_initque(&escorts);
644 plp = (struct plist *)bombers->q_forw;
645 plane_owner = plp->plane.pln_own;
648 * If there are planes performing an
649 * interdict or support mission, find
650 * some escorts for them, if possible.
651 * Up to 2 per bomber, if possible.
653 find_escorts(x, y, plane_owner, &escorts);
655 if (mission == MI_SINTERDICT)
656 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
658 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
660 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
662 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
663 plp = (struct plist *)qp;
664 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
665 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
669 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
674 air = (struct airport *)qp;
675 md = mapdist(x, y, air->x, air->y);
680 /* Split off the bombers at this base into b */
681 divide(bombers, &b, air->x, air->y);
683 /* Split off the escorts at this base into e */
684 divide(&escorts, &e, air->x, air->y);
686 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
691 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
693 pp = BestAirPath(buf, air->x, air->y, x, y);
694 if (CANT_HAPPEN(!pp))
696 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
697 mission_name(mission),
698 xyas(air->x, air->y, plane_owner),
699 xyas(x, y, plane_owner));
700 if (air->own && (air->own != plane_owner)) {
701 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
702 cname(plane_owner), mission_name(mission),
703 xyas(air->x, air->y, air->own),
704 xyas(x, y, air->own));
707 ac_encounter(&b, &e, air->x, air->y, pp, 0);
711 air_damage(&b, x, y, mission, victim, s, hardtarget);
719 nreport(plane_owner, N_SHP_BOMB, victim, 1);
721 nreport(plane_owner, N_SCT_BOMB, victim, 1);
725 while (qp != (&escorts)) {
732 qp = bombers->q_forw;
733 while (qp != bombers) {
740 return dam + air_dam;
744 cando(int mission, int type)
748 if (type == EF_PLANE)
752 if (type == EF_PLANE)
756 if ((type == EF_PLANE) || (type == EF_SHIP))
764 if (type == EF_PLANE)
777 mission_name(int mission)
781 return "an interdiction";
785 return "an offensive support";
787 return "a defensive support";
793 return "a sub interdiction";
795 return "an air defense";
798 return "a mysterious";
802 * Maximum distance GP can perform its mission.
803 * Note: this has nothing to do with the radius of the op-area.
804 * oprange() governs where the unit *can* strike, the op-area governs
805 * where the player wants it to strike.
808 oprange(struct empobj *gp)
810 switch (gp->ef_type) {
812 return ldround(shp_fire_range((struct shpstr *)gp), 1);
814 if (gp->mission == MI_RESERVE)
815 return lnd_reaction_range((struct lndstr *)gp);
816 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
818 /* missiles go one way, so we can use all the range */
819 if (plchr[(int)gp->type].pl_flags & P_M)
820 return ((struct plnstr *)gp)->pln_range;
821 return ((struct plnstr *)gp)->pln_range / 2;
828 * Does GP's mission op area cover X,Y?
831 in_oparea(struct empobj *gp, coord x, coord y)
833 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
834 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
838 * Remove all planes who cannot go on
839 * the mission from the plane list.
842 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
845 struct emp_qelem *qp, *next;
847 struct plchrstr *pcp;
850 for (qp = list->q_forw; qp != list; qp = next) {
852 plp = (struct plist *)qp;
856 if (pp->pln_effic < 40) {
862 if (pp->pln_mobil < 1) {
869 if (ontradingblock(EF_PLANE, pp)) {
876 if (!pln_capable(pp, wantflags, nowantflags)) {
882 if (!pln_airbase_ok(pp, 0, 0)) {
888 if (pcp->pl_flags & P_A) {
889 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
896 putplane(pp->pln_uid, pp);
901 * Arm only the planes at x,y
904 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
905 int mission, struct ichrstr *ip)
907 struct emp_qelem *qp;
908 struct emp_qelem *next;
912 for (qp = list->q_forw; qp != list; qp = next) {
914 plp = (struct plist *)qp;
922 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
923 || mission_pln_equip(plp, ip, mission) < 0) {
929 pp->pln_flags |= PLN_LAUNCHED;
930 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
931 putplane(pp->pln_uid, pp);
936 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
938 struct plchrstr *pcp;
949 if (pp->pln_ship >= 0) {
950 getship(pp->pln_ship, &ship);
951 item = ship.shp_item;
952 } else if (pp->pln_land >= 0) {
953 getland(pp->pln_land, &land);
954 item = land.lnd_item;
956 getsect(pp->pln_x, pp->pln_y, §);
957 item = sect.sct_item;
959 if (pcp->pl_fuel > item[I_PETROL]) {
962 item[I_PETROL] -= pcp->pl_fuel;
966 case 'p': /* pinpoint bomb */
969 case 'i': /* missile interception */
973 case 'e': /* escort */
974 case 0: /* plane interception */
982 if (itype != I_NONE) {
983 needed = load / ichr[itype].i_lbs;
986 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
988 if (itype == I_SHELL && item[itype] < needed) {
989 if (pp->pln_ship >= 0)
990 shp_supply(&ship, I_SHELL, needed);
991 else if (pp->pln_land >= 0)
992 lnd_supply(&land, I_SHELL, needed);
994 sct_supply(§, I_SHELL, needed);
996 if (item[itype] < needed)
998 item[itype] -= needed;
1002 if (pp->pln_ship >= 0)
1003 putship(ship.shp_uid, &ship);
1004 else if (pp->pln_land >= 0)
1005 putland(land.lnd_uid, &land);
1012 * Return 1 if this x,y pair is in the list
1015 find_airport(struct emp_qelem *airp, coord x, coord y)
1017 struct emp_qelem *qp;
1020 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
1021 a = (struct airport *)qp;
1022 if ((a->x == x) && (a->y == y))
1029 /* #*# This needs to be changed to include acc's -KHS */
1031 add_airport(struct emp_qelem *airp, coord x, coord y)
1036 a = malloc(sizeof(struct airport));
1040 getsect(x, y, §);
1041 a->own = sect.sct_own;
1043 emp_insque((struct emp_qelem *)a, airp);
1047 * Take all the planes in list 1 that
1048 * are at x,y, and put them into list 2.
1051 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1053 struct emp_qelem *qp, *next;
1056 for (qp = l1->q_forw; qp != l1; qp = next) {
1058 plp = (struct plist *)qp;
1060 if (plp->plane.pln_x != x)
1062 if (plp->plane.pln_y != y)
1071 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1072 natid victim, char *s, int hardtarget)
1074 struct emp_qelem *qp;
1077 int newdam, dam = 0;
1080 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1081 plp = (struct plist *)qp;
1084 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1091 if (plp->pcp->pl_flags & P_A) {
1092 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1094 "\t%s detects sub movement in %s\n",
1095 prplane(pp), xyas(x, y, pp->pln_own));
1098 if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) {
1100 "\t%s tracks %s %s at %s\n",
1101 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1105 "\t%s depth-charging %s %s in %s\n",
1106 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1109 "\t%s pinbombing %s %s in %s\n",
1110 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1112 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1113 if (nuk_on_plane(&plp->plane) >= 0)
1115 else if (hardtarget != SECT_HARDTARGET)
1116 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1117 if (roll(100) <= hitchance) {
1118 newdam = pln_damage(&plp->plane, 'p', 1);
1120 "\t\thit %s %s for %d damage\n",
1121 cname(victim), s, newdam);
1124 newdam = pln_damage(&plp->plane, 'p', 0);
1125 wu(0, pp->pln_own, "missed\n");
1126 if (mission == MI_SINTERDICT) {
1128 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1129 xyas(x, y, victim));
1130 } else if (*s == 's') {
1131 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1132 s, xyas(x, y, victim));
1134 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1135 s, xyas(x, y, victim));
1137 /* Now, even though we missed, the bombs
1139 collateral_damage(x, y, newdam);
1142 /* use up missiles */
1143 if (plp->pcp->pl_flags & P_M)