]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/landgun.c
Streamline fortgun()'s efficiency comparison
[empserver] / src / lib / subs / landgun.c
index cd4298cdb44a760e0e8f10f9953282a99105b482..bdb32f65f6f97f079c4748fd48b22dec8a813a1a 100644 (file)
@@ -42,7 +42,7 @@
 #include "sect.h"
 #include "ship.h"
 
-double
+static double
 fortgun(int effic, int guns)
 {
     double d;
@@ -53,7 +53,7 @@ fortgun(int effic, int guns)
     return d;
 }
 
-double
+static double
 seagun(int effic, int guns)
 {
     double d;
@@ -65,7 +65,7 @@ seagun(int effic, int guns)
     return d;
 }
 
-double
+static double
 landunitgun(int effic, int guns)
 {
     double d;
@@ -202,6 +202,31 @@ lnd_fire(struct lndstr *lp)
     return d;
 }
 
+/*
+ * Sabotage with land unit LP.
+ * Use ammo.
+ * Return damage if the land unit sabotages, else -1.
+ */
+int
+lnd_sabo(struct lndstr *lp, short item[])
+{
+    int dam;
+
+    if (lp->lnd_ship >= 0 || lp->lnd_land >= 0)
+       return -1;
+    if (!(lchr[lp->lnd_type].l_flags & L_SPY))
+       return -1;
+    if (!lp->lnd_item[I_SHELL])
+       return -1;
+    lp->lnd_item[I_SHELL]--;
+    dam = fortgun(3 * lp->lnd_effic, 7);
+    if (item[I_SHELL] > 20)
+       dam += seagun(lp->lnd_effic, random() % (item[I_SHELL] / 10));
+    if (item[I_PETROL] > 100)
+       dam += seagun(lp->lnd_effic, random() % (item[I_PETROL] / 50));
+    return dam;
+}
+
 /*
  * Return number of guns ship SP can fire.
  */
@@ -234,7 +259,7 @@ fortrange(struct sctstr *sp)
        return -1.0;
 
     rng = effrange(14.0 * fire_range_factor, np->nat_level[NAT_TLEV]);
-    if (sp->sct_effic > 59)
+    if (sp->sct_effic >= 60)
        rng++;
     return rng;
 }