]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/plnsub.c
Nuclear-tipped missile exploding on launch could not damage base
[empserver] / src / lib / subs / plnsub.c
index 293fefeed96d7729b84958fb0b868ee99fe9590a..5e11ec05e2f3f8c907297a100eac7036e835cc54 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -54,7 +54,6 @@
 #include "ship.h"
 #include "xy.h"
 
-static int pln_equip(struct plist *, struct ichrstr *, char);
 static int fit_plane_on_ship(struct plnstr *, struct shpstr *);
 
 /*
@@ -275,7 +274,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
     amt = 0;
     for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
        plp = (struct plist *)qp;
-       amt += plp->misc;
+       amt += plp->load;
     }
     if (cno < 0) {
        getsect(tx, ty, &sect);
@@ -340,7 +339,7 @@ pln_mine(struct emp_qelem *list, coord tx, coord ty)
     amt = 0;
     for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
        plp = (struct plist *)qp;
-       amt += plp->misc;
+       amt += plp->load;
 
     }
     if (amt > 0) {
@@ -580,8 +579,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
        plane.pln_mission = 0;
        putplane(plane.pln_uid, &plane);
        plp = malloc(sizeof(struct plist));
-       plp->misc = 0;
-       plp->bombs = 0;
+       plp->load = 0;
        plp->pcp = pcp;
        plp->plane = plane;
        emp_insque(&plp->queue, list);
@@ -614,7 +612,7 @@ pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip)
     }
 }
 
-static int
+int
 pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
 {
     struct plchrstr *pcp;
@@ -653,12 +651,9 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
     switch (mission) {
     case 's':          /* strategic bomb */
     case 'p':          /* pinpoint bomb */
-       if (nuk_on_plane(pp) >= 0)
-           break;
        itype = I_SHELL;
        break;
     case 't':          /* transport */
-    case 'd':          /* drop */
        if (!(pcp->pl_flags & P_C) || !ip)
            break;
        itype = ip->i_uid;
@@ -670,15 +665,31 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
        itype = I_SHELL;
        load *= 2;
        break;
+    case 'd':          /* drop */
+       if (!(pcp->pl_flags & P_C) || CANT_HAPPEN(!ip))
+           break;
+       itype = ip->i_uid;
+       if (pcp->pl_flags & P_V)
+           load *= 2;
+       break;
     case 'a':          /* paradrop */
        if (!(pcp->pl_flags & P_P))
            break;
        itype = I_MILIT;
+       if (pcp->pl_flags & P_V)
+           load *= 2;
        break;
     case 'r':          /* reconnaissance */
     case 'e':          /* escort */
        load = 0;
        break;
+    case 'i':          /* missile interception */
+       if (CANT_HAPPEN(!(pcp->pl_flags & P_M)
+                       || !(pcp->pl_flags & (P_N | P_O))))
+           break;
+       if (load)
+           itype = I_SHELL;
+       break;
     default:
        CANT_REACH();
        load = 0;
@@ -690,6 +701,16 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
            pr("%s can't contribute to mission\n", prplane(pp));
            return -1;
        }
+       if (nuk_on_plane(pp) >= 0) {
+           if (mission == 's' || mission == 't')
+               needed = 0;
+           else {
+               pr("%s can't fly this mission"
+                  " while it is carrying a nuclear weapon",
+                  prplane(pp));
+               return -1;
+           }
+       }
        if (itype == I_CIVIL && pp->pln_own != own) {
            pr("You don't control those civilians!\n");
            return -1;
@@ -708,10 +729,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
            return -1;
        }
        item[itype] -= needed;
-       if (itype == I_SHELL && (mission == 's' || mission == 'p'))
-           plp->bombs = needed;
-       else
-           plp->misc = needed;
+       plp->load = needed;
     }
 
     if (pp->pln_ship >= 0) {
@@ -959,13 +977,9 @@ pln_hitchance(struct plnstr *pp, int hardtarget, int type)
     return hitchance;
 }
 
-/* return 0 if there was a nuclear detonation */
-
 int
-pln_damage(struct plnstr *pp, coord x, coord y, char type, int *nukedamp,
-          int noisy)
+pln_damage(struct plnstr *pp, char type, int noisy)
 {
-    struct nukstr nuke;
     struct plchrstr *pcp = plchr + pp->pln_type;
     int load, i;
     int hitroll;
@@ -974,14 +988,8 @@ pln_damage(struct plnstr *pp, coord x, coord y, char type, int *nukedamp,
     int effective = 1;
     int pinbomber = 0;
 
-    if (getnuke(nuk_on_plane(pp), &nuke)) {
-       mpr(pp->pln_own, "Releasing RV's for %s detonation...\n",
-           pp->pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
-       *nukedamp = detonate(&nuke, x, y,
-                            pp->pln_flags & PLN_AIRBURST);
+    if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
        return 0;
-    }
-    *nukedamp = 0;
 
     load = pln_load(pp);
     if (!load)                /* e.g. ab, blowing up on launch pad */