extern int lnd_nland(struct lndstr *);
extern int lnd_fire(struct lndstr *);
+extern int lnd_sabo(struct lndstr *, short *);
extern double lnd_fire_range(struct lndstr *);
/* src/lib/subs/lndsub.c */
extern void lnd_postread(int, void *);
extern void lnd_prewrite(int, void *, void *);
/* landgun.c */
-extern double seagun(int, int);
-extern double fortgun(int, int);
-extern double landunitgun(int, int);
extern double torprange(struct shpstr *);
extern double fortrange(struct sctstr *);
extern int roundrange(double);
pr("%s has no shells.\n", prland(&land));
continue;
}
- --land.lnd_item[I_SHELL];
odds = LND_SPY_DETECT_CHANCE(land.lnd_effic);
if (chance(odds)) {
continue;
}
- dam = fortgun(3 * land.lnd_effic, 7);
- if (sect.sct_item[I_SHELL] > 20)
- dam += seagun(land.lnd_effic,
- random() % (sect.sct_item[I_SHELL] / 10));
- if (sect.sct_item[I_PETROL] > 100)
- dam += seagun(land.lnd_effic,
- random() % (sect.sct_item[I_PETROL] / 50));
+ dam = lnd_sabo(&land, sect.sct_item);
+ if (dam < 0)
+ continue;
pr("Explosion in %s causes %d damage.\n",
xyas(land.lnd_x, land.lnd_y, land.lnd_own), dam);
#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.
*/