]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/aircombat.c
Update copyright notice.
[empserver] / src / lib / subs / aircombat.c
index 81353bde572af7ffc94902cf3a06208efcea8aba..b513e5cad1c2721016f62516feaac22196674749 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
 
 #include <config.h>
 
-#include <string.h>
-
-#include "misc.h"
-#include "player.h"
-#include "news.h"
+#include "file.h"
 #include "land.h"
-#include "sect.h"
-#include "plane.h"
-#include "ship.h"
+#include "map.h"
+#include "misc.h"
 #include "nat.h"
-#include "file.h"
-#include "xy.h"
+#include "news.h"
 #include "nsc.h"
+#include "optlist.h"
 #include "path.h"
+#include "plane.h"
+#include "player.h"
 #include "prototypes.h"
-#include "optlist.h"
+#include "sect.h"
 #include "server.h"
+#include "ship.h"
+#include "xy.h"
 
 #define FLAK_GUN_MAX 14
 
@@ -947,10 +946,8 @@ ac_landflak(struct emp_qelem *list, coord x, coord y)
 static void
 ac_fireflak(struct emp_qelem *list, natid from, int guns)
 {
-    struct plnstr *pp;
     struct plist *plp;
     int n;
-    int diff;
     struct emp_qelem *qp;
     struct emp_qelem *next;
     char msg[255];
@@ -958,22 +955,9 @@ ac_fireflak(struct emp_qelem *list, natid from, int guns)
     plp = (struct plist *)list->q_forw;
 
     for (qp = list->q_forw; qp != list; qp = next) {
-       /*
-        * fighters don't get shot at by flak
-        * non-tactical bombers are harder to hit with flak.
-        * ('Cause they're not dive-bombing?)
-        */
        next = qp->q_forw;
        plp = (struct plist *)qp;
-       pp = &plp->plane;
-       diff = guns - pp->pln_def;
-       if ((plp->pcp->pl_flags & P_T) == 0)
-           diff--;
-       if (plp->pcp->pl_flags & P_X)
-           diff -= 2;
-       if (plp->pcp->pl_flags & P_H)
-           diff -= 1;
-       n = ac_flak_dam(diff);
+       n = ac_flak_dam(guns, plp->plane.pln_def, plp->pcp->pl_flags);
        ac_planedamage(plp, from, n, 0, 2, 1, msg);
     }
 }
@@ -982,9 +966,9 @@ ac_fireflak(struct emp_qelem *list, natid from, int guns)
  * Calculate flak damage
  */
 int
-ac_flak_dam(int flak)
+ac_flak_dam(int guns, int def, int pl_flags)
 {
-    int dam;
+    int flak, dam;
     float mult;
     /*                            <-7      -7     -6     -5     -4 */
     static float flaktable[18] = { 0.132f, 0.20f, 0.20f, 0.25f, 0.30f,
@@ -994,6 +978,14 @@ ac_flak_dam(int flak)
         0.70f,0.75f, 0.80f, 0.85f, 1.1305f };
     enum { FLAK_MAX = sizeof(flaktable)/sizeof(flaktable[0]) - 1 };
 
+    flak = guns - def;
+    if ((pl_flags & P_T) == 0)
+       flak--;
+    if (pl_flags & P_X)
+       flak -= 2;
+    if (pl_flags & P_H)
+       flak -= 1;
+
     if (flak > 8)
        mult = flaktable[FLAK_MAX];
     else if (flak < -7)