2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2010, 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 *,
87 tally_dam(int dam, int newdam)
89 return dam < 0 ? newdam : dam + newdam;
93 * Interdict commodities & transported planes
96 ground_interdict(coord x, coord y, natid victim, char *s)
99 int dam = 0, newdam, rel;
100 struct genlist mi[MAXNOC];
102 memset(mi, 0, sizeof(mi));
103 for (cn = 1; cn < MAXNOC; cn++)
104 emp_initque((struct emp_qelem *)&mi[cn]);
106 build_mission_list(mi, x, y, MI_INTERDICT, victim);
108 for (cn = 1; cn < MAXNOC; cn++) {
109 rel = getrel(getnatp(cn), victim);
113 if (QEMPTY(&mi[cn].queue))
116 newdam = perform_mission(x, y, victim, &mi[cn].queue,
117 MI_INTERDICT, s, SECT_HARDTARGET);
120 mpr(victim, "%s interdiction mission does %d damage!\n",
125 collateral_damage(x, y, dam);
131 collateral_damage(coord x, coord y, int dam)
139 getsect(x, y, §);
141 coll = ldround((double)dam * collateral_dam, 1);
144 mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
145 xyas(x, y, sect.sct_own), coll);
146 sectdamage(§, coll);
154 only_subs(struct emp_qelem *list)
156 struct emp_qelem *qp;
159 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
160 glp = (struct genlist *)qp;
162 if (glp->thing->ef_type != EF_SHIP)
164 if (!(mchr[glp->thing->type].m_flags & M_SUB))
168 /* They were all subs! */
174 * Interdict ships & land units
177 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
180 int cn, newdam, osubs;
182 struct genlist mi[MAXNOC];
184 memset(mi, 0, sizeof(mi));
185 for (cn = 1; cn < MAXNOC; cn++)
186 emp_initque((struct emp_qelem *)&mi[cn]);
188 build_mission_list(mi, x, y, mission, victim);
190 for (cn = 1; cn < MAXNOC; cn++) {
193 if (mission == MI_SINTERDICT) {
194 if (getrel(getnatp(cn), victim) >= FRIENDLY)
196 } else if (getrel(getnatp(cn), victim) > HOSTILE)
199 if (QEMPTY(&mi[cn].queue))
202 osubs = only_subs(&mi[cn].queue);
203 newdam = perform_mission(x, y, victim, &mi[cn].queue,
204 mission, s, hardtarget);
205 dam = tally_dam(dam, newdam);
207 mpr(victim, "%s interdiction mission does %d damage!\n",
208 osubs ? "Enemy" : cname(cn), newdam);
211 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 (cn = 1; cn < MAXNOC; cn++)
227 emp_initque((struct emp_qelem *)&mi[cn]);
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 (cn = 1; cn < MAXNOC; cn++)
248 emp_initque((struct emp_qelem *)&mi[cn]);
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 newdam = perform_mission(x, y, victim, &mi[cn].queue, MI_SUPPORT,
276 "", SECT_HARDTARGET);
284 build_mission_list(struct genlist *mi, coord x, coord y, int mission,
287 build_mission_list_type(mi, x, y, mission, EF_LAND, victim);
288 build_mission_list_type(mi, x, y, mission, EF_SHIP, victim);
289 build_mission_list_type(mi, x, y, mission, EF_PLANE, victim);
293 build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
294 int type, natid victim)
299 union empobj_storage item;
303 snxtitem_all(&ni, type);
304 while (nxtitem(&ni, &item)) {
305 gp = (struct empobj *)&item;
313 if ((gp->mission != mission) && (mission != MI_SINTERDICT))
316 if ((gp->mission != mission) && (mission == MI_SINTERDICT) &&
317 (gp->mission != MI_INTERDICT))
320 relat = getrel(getnatp(gp->own), victim);
321 if (mission == MI_SINTERDICT) {
322 if (relat >= FRIENDLY)
324 else if (type != EF_PLANE && relat > HOSTILE)
326 } else if (relat > HOSTILE)
329 if (!in_oparea(gp, x, y))
333 if (mission != MI_AIR_DEFENSE) {
334 getsect(x, y, §);
335 if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) {
338 * If the owner of the unit isn't at war
339 * with the victim, and doesn't own the
340 * sect being acted upon, and isn't the
341 * old owner of that sect, bounce them.
343 if (sect.sct_type != SCT_WATER &&
344 sect.sct_own != gp->own &&
345 sect.sct_oldown != gp->own)
351 glp = malloc(sizeof(struct genlist));
352 memset(glp, 0, sizeof(struct genlist));
353 glp->thing = malloc(sizeof(item));
354 memcpy(glp->thing, &item, sizeof(item));
355 emp_insque(&glp->queue, &mi[gp->own].queue);
360 find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
366 snxtitem_all(&ni, EF_PLANE);
367 while (nxtitem(&ni, &plane)) {
368 if (plane.pln_own != cn)
370 if (plane.pln_mission != MI_ESCORT)
372 if (!in_oparea((struct empobj *)&plane, x, y))
374 plp = malloc(sizeof(struct plist));
375 memset(plp, 0, sizeof(struct plist));
376 plp->pcp = &plchr[(int)plane.pln_type];
378 emp_insque(&plp->queue, escorts);
383 perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
384 int mission, char *s, int hardtarget)
386 struct emp_qelem *qp, missiles, bombers;
389 struct plchrstr *pcp;
391 int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
393 emp_initque(&missiles);
394 emp_initque(&bombers);
396 for (qp = list->q_forw; qp != list; ) {
397 glp = (struct genlist *)qp;
400 if (glp->thing->ef_type == EF_LAND) {
401 dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
402 x, y, victim, mission, s,
404 } else if (glp->thing->ef_type == EF_SHIP) {
405 dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
406 x, y, victim, mission, s,
408 } else if (glp->thing->ef_type == EF_PLANE) {
409 pcp = &plchr[glp->thing->type];
410 if (pcp->pl_flags & P_M)
411 /* units have their own missile interdiction */
412 if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
415 /* save planes for later */
416 plp = malloc(sizeof(struct plist));
418 memset(plp, 0, sizeof(struct plist));
420 memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
421 if (plp->pcp->pl_flags & P_M)
422 emp_insque(&plp->queue, &missiles);
424 emp_insque(&plp->queue, &bombers);
433 dam = perform_mission_msl(dam, &missiles, x, y, victim, hardtarget);
434 dam = perform_mission_bomb(dam, &bombers, x, y, victim, mission, s,
435 hardtarget, targeting_ships);
440 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
441 natid victim, int mission, char *s,
446 if (mission == MI_SINTERDICT)
449 md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
451 if (mission == MI_INTERDICT && md > land_max_interdiction_range)
454 range = roundrange(lnd_fire_range(lp));
459 putland(lp->lnd_uid, lp);
463 if (targeting_ships) {
464 if (chance(lnd_acc(lp) / 100.0))
465 dam2 = ldround(dam2 / 2.0, 1);
468 nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
470 nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
472 "%s fires at %s %s at %s\n",
473 prland(lp), cname(victim), s, xyas(x, y, lp->lnd_own));
475 mpr(victim, "%s %s fires at you at %s\n",
476 cname(lp->lnd_own), prland(lp), xyas(x, y, victim));
478 return tally_dam(dam, dam2);
482 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
483 natid victim, int mission, char *s,
486 struct mchrstr *mcp = &mchr[sp->shp_type];
487 double vrange, hitchance;
490 md = mapdist(x, y, sp->shp_x, sp->shp_y);
492 if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
493 && md > ship_max_interdiction_range)
496 if (mission == MI_SINTERDICT) {
497 if (!(mcp->m_flags & M_SONAR))
499 if (!(mcp->m_flags & M_DCH) && !(mcp->m_flags & M_SUBT))
501 vrange = techfact(sp->shp_tech, mcp->m_vrnge);
502 vrange *= sp->shp_effic / 200.0;
505 /* can't look all the time */
509 if (mcp->m_flags & M_SUB) {
510 if (!targeting_ships)
511 return dam; /* subs interdict only ships */
512 range = roundrange(torprange(sp));
515 if (!line_of_sight(NULL, x, y, sp->shp_x, sp->shp_y))
517 dam2 = shp_torp(sp, 1);
518 putship(sp->shp_uid, sp);
521 hitchance = shp_torp_hitchance(sp, md);
524 "%s locking on %s %s in %s\n",
525 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
527 "\tEffective torpedo range is %d.0\n", range);
529 "\tWhooosh... Hitchance = %d%%\n",
530 (int)(hitchance * 100));
532 if (!chance(hitchance)) {
533 wu(0, sp->shp_own, "\tMissed\n");
535 "Incoming torpedo sighted @ %s missed (whew)!\n",
537 return tally_dam(dam, 0);
539 wu(0, sp->shp_own, "\tBOOM!...\n");
540 nreport(victim, N_TORP_SHIP, 0, 1);
542 "\tTorpedo hit %s %s for %d damage\n",
543 cname(victim), s, dam2);
546 "Incoming torpedo sighted @ %s hits and does %d damage!\n",
547 xyas(x, y, victim), dam2);
549 range = roundrange(shp_fire_range(sp));
552 if (mission == MI_SINTERDICT)
553 dam2 = shp_dchrg(sp);
556 putship(sp->shp_uid, sp);
560 nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
562 nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
564 "%s fires at %s %s at %s\n",
565 prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
567 mpr(victim, "%s %s fires at you at %s\n",
568 cname(sp->shp_own), prship(sp), xyas(x, y, victim));
571 return tally_dam(dam, dam2);
575 perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
576 natid victim, int hardtarget)
578 int performed, air_dam, sublaunch, dam2;
579 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().
587 performed = air_dam = 0;
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,
600 if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
601 N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
603 dam2 = pln_damage(&plp->plane, 'p', 1);
606 plp->plane.pln_effic = 0;
607 putplane(plp->plane.pln_uid, &plp->plane);
613 return performed ? tally_dam(dam, air_dam) : dam;
617 perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
618 natid victim, int mission, char *s, int hardtarget,
621 struct emp_qelem *qp, *newqp, escorts, airp, b, e;
623 int plane_owner, performed, air_dam, md;
625 emp_initque(&escorts);
631 plp = (struct plist *)bombers->q_forw;
632 plane_owner = plp->plane.pln_own;
635 * If there are planes performing an
636 * interdict or support mission, find
637 * some escorts for them, if possible.
638 * Up to 2 per bomber, if possible.
640 find_escorts(x, y, plane_owner, &escorts);
642 if (mission == MI_SINTERDICT)
643 mission_pln_sel(bombers, P_T | P_A, 0, hardtarget);
645 mission_pln_sel(bombers, P_T, P_A, SECT_HARDTARGET);
647 mission_pln_sel(&escorts, P_ESC | P_F, 0, SECT_HARDTARGET);
649 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
650 plp = (struct plist *)qp;
651 if (!find_airport(&airp, plp->plane.pln_x, plp->plane.pln_y))
652 add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
655 performed = air_dam = 0;
656 for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
661 air = (struct airport *)qp;
662 md = mapdist(x, y, air->x, air->y);
667 /* Split off the bombers at this base into b */
668 divide(bombers, &b, air->x, air->y);
670 /* Split off the escorts at this base into e */
671 divide(&escorts, &e, air->x, air->y);
673 mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
678 mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
680 pp = BestAirPath(buf, air->x, air->y, x, y);
681 if (CANT_HAPPEN(!pp))
684 wu(0, plane_owner, "Flying %s mission from %s to %s\n",
685 mission_name(mission),
686 xyas(air->x, air->y, plane_owner),
687 xyas(x, y, plane_owner));
688 if (air->own && (air->own != plane_owner)) {
689 wu(0, air->own, "%s is flying %s mission from %s to %s\n",
690 cname(plane_owner), mission_name(mission),
691 xyas(air->x, air->y, air->own),
692 xyas(x, y, air->own));
695 ac_encounter(&b, &e, air->x, air->y, pp, 0);
699 air_damage(&b, x, y, mission, victim, s, hardtarget);
707 nreport(plane_owner, N_SHP_BOMB, victim, 1);
709 nreport(plane_owner, N_SCT_BOMB, victim, 1);
713 while (qp != (&escorts)) {
720 qp = bombers->q_forw;
721 while (qp != bombers) {
728 return performed ? tally_dam(dam, air_dam) : dam;
732 cando(int mission, int type)
736 if (type == EF_PLANE)
740 if (type == EF_PLANE)
744 if ((type == EF_PLANE) || (type == EF_SHIP))
752 if (type == EF_PLANE)
765 mission_name(int mission)
769 return "an interdiction";
773 return "an offensive support";
775 return "a defensive support";
781 return "a sub interdiction";
783 return "an air defense";
786 return "a mysterious";
790 * Maximum distance GP can perform its mission.
791 * Note: this has nothing to do with the radius of the op-area.
792 * oprange() governs where the unit *can* strike, the op-area governs
793 * where the player wants it to strike.
796 oprange(struct empobj *gp)
798 switch (gp->ef_type) {
800 return ldround(shp_fire_range((struct shpstr *)gp), 1);
802 if (gp->mission == MI_RESERVE)
803 return lnd_reaction_range((struct lndstr *)gp);
804 return ldround(lnd_fire_range((struct lndstr *)gp), 1);
806 /* missiles go one way, so we can use all the range */
807 if (plchr[(int)gp->type].pl_flags & P_M)
808 return ((struct plnstr *)gp)->pln_range;
809 return ((struct plnstr *)gp)->pln_range / 2;
816 * Does GP's mission op area cover X,Y?
819 in_oparea(struct empobj *gp, coord x, coord y)
821 return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
822 && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
826 * Remove all planes who cannot go on
827 * the mission from the plane list.
830 mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
833 struct emp_qelem *qp, *next;
835 struct plchrstr *pcp;
838 for (qp = list->q_forw; qp != list; qp = next) {
840 plp = (struct plist *)qp;
844 if (pp->pln_effic < 40) {
850 if (pp->pln_mobil < 1) {
857 if (ontradingblock(EF_PLANE, pp)) {
864 if (!pln_capable(pp, wantflags, nowantflags)) {
870 if (!pln_airbase_ok(pp, 0, 0)) {
876 if (pcp->pl_flags & P_A) {
877 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
884 putplane(pp->pln_uid, pp);
889 * Arm only the planes at x,y
892 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
893 int mission, struct ichrstr *ip)
895 struct emp_qelem *qp;
896 struct emp_qelem *next;
900 for (qp = list->q_forw; qp != list; qp = next) {
902 plp = (struct plist *)qp;
910 if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
911 || mission_pln_equip(plp, ip, mission) < 0) {
917 pp->pln_flags |= PLN_LAUNCHED;
918 pp->pln_mobil -= pln_mobcost(dist, pp, mission);
919 putplane(pp->pln_uid, pp);
924 mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
926 struct plchrstr *pcp;
937 if (pp->pln_ship >= 0) {
938 getship(pp->pln_ship, &ship);
939 item = ship.shp_item;
940 } else if (pp->pln_land >= 0) {
941 getland(pp->pln_land, &land);
942 item = land.lnd_item;
944 getsect(pp->pln_x, pp->pln_y, §);
945 item = sect.sct_item;
947 if (pcp->pl_fuel > item[I_PETROL]) {
950 item[I_PETROL] -= pcp->pl_fuel;
954 case 'p': /* pinpoint bomb */
957 case 'i': /* missile interception */
961 case 'e': /* escort */
962 case 0: /* plane interception */
970 if (itype != I_NONE) {
971 needed = load / ichr[itype].i_lbs;
974 if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
976 if (itype == I_SHELL && item[itype] < needed) {
977 if (pp->pln_ship >= 0)
978 shp_supply(&ship, I_SHELL, needed);
979 else if (pp->pln_land >= 0)
980 lnd_supply(&land, I_SHELL, needed);
982 sct_supply(§, I_SHELL, needed);
984 if (item[itype] < needed)
986 item[itype] -= needed;
990 if (pp->pln_ship >= 0)
991 putship(ship.shp_uid, &ship);
992 else if (pp->pln_land >= 0)
993 putland(land.lnd_uid, &land);
1000 * Return 1 if this x,y pair is in the list
1003 find_airport(struct emp_qelem *airp, coord x, coord y)
1005 struct emp_qelem *qp;
1008 for (qp = airp->q_forw; qp != airp; qp = qp->q_forw) {
1009 a = (struct airport *)qp;
1010 if ((a->x == x) && (a->y == y))
1017 /* #*# This needs to be changed to include acc's -KHS */
1019 add_airport(struct emp_qelem *airp, coord x, coord y)
1024 a = malloc(sizeof(struct airport));
1028 getsect(x, y, §);
1029 a->own = sect.sct_own;
1031 emp_insque((struct emp_qelem *)a, airp);
1035 * Take all the planes in list 1 that
1036 * are at x,y, and put them into list 2.
1039 divide(struct emp_qelem *l1, struct emp_qelem *l2, coord x, coord y)
1041 struct emp_qelem *qp, *next;
1044 for (qp = l1->q_forw; qp != l1; qp = next) {
1046 plp = (struct plist *)qp;
1048 if (plp->plane.pln_x != x)
1050 if (plp->plane.pln_y != y)
1059 air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
1060 natid victim, char *s, int hardtarget)
1062 struct emp_qelem *qp;
1065 int newdam, dam = 0;
1068 for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
1069 plp = (struct plist *)qp;
1072 if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
1079 if (plp->pcp->pl_flags & P_A) {
1080 if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) {
1082 "\t%s detects sub movement in %s\n",
1083 prplane(pp), xyas(x, y, pp->pln_own));
1086 if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) {
1088 "\t%s tracks %s %s at %s\n",
1089 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1093 "\t%s depth-charging %s %s in %s\n",
1094 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1097 "\t%s pinbombing %s %s in %s\n",
1098 prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
1100 hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
1101 if (nuk_on_plane(&plp->plane) >= 0)
1103 else if (hardtarget != SECT_HARDTARGET)
1104 wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
1105 if (roll(100) <= hitchance) {
1106 newdam = pln_damage(&plp->plane, 'p', 1);
1108 "\t\thit %s %s for %d damage\n",
1109 cname(victim), s, newdam);
1112 newdam = pln_damage(&plp->plane, 'p', 0);
1113 wu(0, pp->pln_own, "missed\n");
1114 if (mission == MI_SINTERDICT) {
1116 "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",
1117 xyas(x, y, victim));
1118 } else if (*s == 's') {
1119 mpr(victim, "SPLASH! Bombs miss your %s in %s\n",
1120 s, xyas(x, y, victim));
1122 mpr(victim, "SPLAT! Bombs miss your %s in %s\n",
1123 s, xyas(x, y, victim));
1125 /* Now, even though we missed, the bombs
1127 collateral_damage(x, y, newdam);
1130 /* use up missiles */
1131 if (plp->pcp->pl_flags & P_M)