]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/mslsub.c
Nuclear-tipped missile exploding on launch could not damage base
[empserver] / src / lib / subs / mslsub.c
index 30ed82cb206bd4e64bb9bd10a291ae0f45c931ea..1e78e443c368d7423916a19fbf1521df1bd86c44 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
@@ -59,9 +59,9 @@ msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y,
           natid victim, int *sublaunchp)
 {
     struct shpstr ship;
+    struct nukstr nuke;
     struct sctstr sect;
     int sublaunch = 0;
-    struct plchrstr *pcp = plchr + pp->pln_type;
     char *from;
     int dam;
 
@@ -69,7 +69,7 @@ msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y,
        prplane(pp),
        cname(victim),
        what,
-       (type == EF_SHIP || type == EF_PLANE) ? "in " : "",
+       type != EF_SECTOR ? "in " : "",
        xyas(x, y, pp->pln_own));
     mpr(pp->pln_own, "\tLaunching from ");
     if (pp->pln_ship >= 0) {
@@ -94,13 +94,18 @@ msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y,
     if (chance((0.05 + (100 - pp->pln_effic) / 100.0)
               * (1 - techfact(pp->pln_tech, 1.0)))) {
        mpr(pp->pln_own, "KABOOOOM!  Missile explodes %s!\n", from);
+       if (getnuke(nuk_on_plane(pp), &nuke)) {
+           pr("%s lost!\n", prnuke(&nuke));
+           nuke.nuk_effic = 0;
+           putnuke(nuke.nuk_uid, &nuke);
+       }
        if (chance(0.33)) {
            dam = pln_damage(pp, 'p', 1) / 2;
            if (pp->pln_ship >= 0) {
                shipdamage(&ship, dam);
                putship(ship.shp_uid, &ship);
            } else {
-               pr("Explosion damages %s %d%%",
+               pr("Explosion damages %s %d%%\n",
                   xyas(pp->pln_x, pp->pln_y, pp->pln_own), dam);
                getsect(pp->pln_x, pp->pln_y, &sect);
                sectdamage(&sect, dam);
@@ -115,16 +120,16 @@ msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y,
     putplane(pp->pln_uid, pp);
     mpr(pp->pln_own, "\tSHWOOOOOSH!  Missile launched!\n");
 
-    if (pcp->pl_flags & P_T)
+    if (type != EF_PLANE)
        mpr(victim, "Incoming %s missile sighted at %s...\n",
            sublaunch ? "sub-launched" : cname(pp->pln_own),
            xyas(x, y, victim));
 
-    if ((pcp->pl_flags & P_T && !(pcp->pl_flags & P_MAR))) {
+    if (type == EF_SECTOR || type == EF_LAND) {
        if (msl_abm_intercept(pp, x, y, sublaunch))
            return -1;
     }
-    if (pcp->pl_flags & P_MAR) {
+    if (type == EF_SHIP) {
        if (shp_missile_defense(x, y, pp->pln_own, pln_def(pp))) {
            return -1;
        }
@@ -139,7 +144,6 @@ int
 msl_hit(struct plnstr *pp, int hardtarget, int type,
        int news_item, int snews_item, int sublaunch, natid victim)
 {
-    struct plchrstr *pcp = plchr + pp->pln_type;
     int hitchance, hit;
 
     if (nuk_on_plane(pp) >= 0) {
@@ -152,7 +156,7 @@ msl_hit(struct plnstr *pp, int hardtarget, int type,
            hit ? "HIT!" : "miss");
     }
 
-    if (pcp->pl_flags & P_T)
+    if (type != EF_PLANE)
        mpr(victim, "...Incoming %s missile %s\n",
            sublaunch ? "" : cname(pp->pln_own),
            hit ? "HIT!\n" : "missed\n");
@@ -218,7 +222,6 @@ msl_intercept(struct plnstr *msl, struct sctstr *sp, int sublaunch,
              int news_item)
 {
     struct plnstr *pp;
-    struct plchrstr *pcp;
     struct emp_qelem *intlist;
     struct emp_qelem intfoo;
     struct emp_qelem *qp;
@@ -238,7 +241,6 @@ msl_intercept(struct plnstr *msl, struct sctstr *sp, int sublaunch,
        pp = &ip->plane;
        if (pp->pln_own != sp->sct_own)
            continue;
-       pcp = ip->pcp;
        if (mission_pln_equip(ip, NULL, 'i') < 0) {
            emp_remque(qp);
            free(qp);
@@ -257,7 +259,6 @@ msl_intercept(struct plnstr *msl, struct sctstr *sp, int sublaunch,
        next = qp->q_forw;
        ip = (struct plist *)qp;
        pp = &ip->plane;
-       pcp = ip->pcp;
        if (mission_pln_equip(ip, NULL, 'i') < 0) {
            emp_remque(qp);
            free(qp);
@@ -289,7 +290,6 @@ msl_intercept(struct plnstr *msl, struct sctstr *sp, int sublaunch,
        qp = intlist->q_forw;
        ip = (struct plist *)qp;
        pp = &ip->plane;
-       pcp = ip->pcp;
 
        mpr(msl->pln_own, "%s %s launched in defense!\n",
            cname(pp->pln_own), def_name);