]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/mission.c
launch interception: Drop support for ABM, a-sat consuming shells
[empserver] / src / lib / subs / mission.c
index 9d287d573145a179331e2a2104642dacac5836dd..40b82c069d64836b66cde79b43e3844272e24adf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Ken Stevens, 1995
  *     Steve McClure, 1996-2000
- *     Markus Armbruster, 2003-2012
+ *     Markus Armbruster, 2003-2021
  */
 
 #include <config.h>
@@ -37,7 +37,6 @@
 #include <stdlib.h>
 #include "chance.h"
 #include "empobj.h"
-#include "file.h"
 #include "item.h"
 #include "misc.h"
 #include "mission.h"
@@ -180,7 +179,8 @@ int
 unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
               int mission)
 {
-    int cn, rel, newdam, osubs;
+    int cn, newdam, osubs;
+    enum relations rel;
     int dam = -1;
     unsigned char plane_act[MAXNOC], other_act[MAXNOC];
     struct genlist mi[MAXNOC];
@@ -233,8 +233,8 @@ def_support(coord x, coord y, natid victim, natid actee)
 }
 
 /*
- * Perform support missions in X,Y against VICTIM for ACTEE.
- * MISSION is either MI_OSUPPORT or MI_DSUPPORT.
+ * Perform support missions in @x,@y against @victim for @actee.
+ * @mission is either MI_OSUPPORT or MI_DSUPPORT.
  * Return total damage.
  */
 static int
@@ -487,8 +487,7 @@ perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
        wu(0, sp->shp_own,
           "\tEffective torpedo range is %d.0\n", range);
        wu(0, sp->shp_own,
-          "\tWhooosh... Hitchance = %d%%\n",
-          (int)(hitchance * 100));
+          "\tWhooosh... Hit chance = %.0f%%\n", hitchance * 100);
 
        if (!chance(hitchance)) {
            wu(0, sp->shp_own, "\tMissed\n");
@@ -561,7 +560,7 @@ perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
            if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
                         N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
                CANT_REACH();
-           dam2 = pln_damage(&plp->plane, 'p', 1);
+           dam2 = pln_damage(&plp->plane, 'p', "");
            air_dam += dam2;
        use_up_msl:
            plp->plane.pln_effic = 0;
@@ -748,7 +747,7 @@ mission_name(int mission)
 }
 
 /*
- * Maximum distance GP can perform its mission.
+ * Maximum distance @gp can perform its mission.
  * Note: this has nothing to do with the radius of the op-area.
  * oprange() governs where the unit *can* strike, the op-area governs
  * where the player wants it to strike.
@@ -774,7 +773,7 @@ oprange(struct empobj *gp)
 }
 
 /*
- * Does GP's mission op area cover X,Y?
+ * Does @gp's mission op area cover @x,@y?
  */
 int
 in_oparea(struct empobj *gp, coord x, coord y)
@@ -918,12 +917,8 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
     case 'p':          /* pinpoint bomb */
        itype = I_SHELL;
        break;
-    case 'i':          /* missile interception */
-       if (load)
-           itype = I_SHELL;
-       break;
     case 'e':          /* escort */
-    case 0:            /* plane interception */
+    case 0:            /* interception */
        load = 0;
        break;
     default:
@@ -1027,6 +1022,7 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
     struct plist *plp;
     struct plnstr *pp;
     int newdam, dam = 0;
+    char buf[32];
     int hitchance;
 
     for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
@@ -1057,23 +1053,28 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
               prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
        } else {
            wu(0, pp->pln_own,
-              "\t%s pinbombing %s %s in %s\n",
+              "\t%s pin-bombing %s %s in %s\n",
               prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
        }
-       hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
+
+       buf[0] = 0;
        if (nuk_on_plane(&plp->plane) >= 0)
            hitchance = 100;
-       else if (hardtarget != SECT_HARDTARGET)
-           wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
+       else {
+           hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
+           if (hardtarget != SECT_HARDTARGET)
+               snprintf(buf, sizeof(buf), "\t\t%d%% hit chance...",
+                        hitchance);
+       }
        if (pct_chance(hitchance)) {
-           newdam = pln_damage(&plp->plane, 'p', 1);
+           newdam = pln_damage(&plp->plane, 'p', buf);
            wu(0, pp->pln_own,
               "\t\thit %s %s for %d damage\n",
               cname(victim), s, newdam);
            dam += newdam;
        } else {
-           newdam = pln_damage(&plp->plane, 'p', 0);
-           wu(0, pp->pln_own, "missed\n");
+           newdam = pln_damage(&plp->plane, 'p', NULL);
+           wu(0, pp->pln_own, "%smissed\n", buf);
            if (mission == MI_SINTERDICT) {
                mpr(victim,
                    "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",