* landgun.c: Fire weapons
*
* Known contributors to this file:
- * Markus Armbruster, 2006-2008
+ * Markus Armbruster, 2006-2009
*/
#include <config.h>
#include "sect.h"
#include "ship.h"
-double
+static double
fortgun(int effic, int guns)
{
double d;
return d;
}
-double
+static double
seagun(int effic, int guns)
{
double d;
return d;
}
-double
+static double
landunitgun(int effic, int guns)
{
double d;
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.
*/
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;
}