Factor new lnd_sabo() out of sabo()
This permits giving seagun(), fortgun() and landunitgun() internal linkage.
This commit is contained in:
parent
162c79bb73
commit
ad296698f9
4 changed files with 32 additions and 14 deletions
|
@ -165,6 +165,7 @@ extern int lnd_nxlight(struct lndstr *);
|
||||||
extern int lnd_nland(struct lndstr *);
|
extern int lnd_nland(struct lndstr *);
|
||||||
|
|
||||||
extern int lnd_fire(struct lndstr *);
|
extern int lnd_fire(struct lndstr *);
|
||||||
|
extern int lnd_sabo(struct lndstr *, short *);
|
||||||
extern double lnd_fire_range(struct lndstr *);
|
extern double lnd_fire_range(struct lndstr *);
|
||||||
|
|
||||||
/* src/lib/subs/lndsub.c */
|
/* src/lib/subs/lndsub.c */
|
||||||
|
|
|
@ -454,9 +454,6 @@ extern void lnd_oninit(void *);
|
||||||
extern void lnd_postread(int, void *);
|
extern void lnd_postread(int, void *);
|
||||||
extern void lnd_prewrite(int, void *, void *);
|
extern void lnd_prewrite(int, void *, void *);
|
||||||
/* landgun.c */
|
/* landgun.c */
|
||||||
extern double seagun(int, int);
|
|
||||||
extern double fortgun(int, int);
|
|
||||||
extern double landunitgun(int, int);
|
|
||||||
extern double torprange(struct shpstr *);
|
extern double torprange(struct shpstr *);
|
||||||
extern double fortrange(struct sctstr *);
|
extern double fortrange(struct sctstr *);
|
||||||
extern int roundrange(double);
|
extern int roundrange(double);
|
||||||
|
|
|
@ -69,7 +69,6 @@ sabo(void)
|
||||||
pr("%s has no shells.\n", prland(&land));
|
pr("%s has no shells.\n", prland(&land));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
--land.lnd_item[I_SHELL];
|
|
||||||
|
|
||||||
odds = LND_SPY_DETECT_CHANCE(land.lnd_effic);
|
odds = LND_SPY_DETECT_CHANCE(land.lnd_effic);
|
||||||
if (chance(odds)) {
|
if (chance(odds)) {
|
||||||
|
@ -83,13 +82,9 @@ sabo(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dam = fortgun(3 * land.lnd_effic, 7);
|
dam = lnd_sabo(&land, sect.sct_item);
|
||||||
if (sect.sct_item[I_SHELL] > 20)
|
if (dam < 0)
|
||||||
dam += seagun(land.lnd_effic,
|
continue;
|
||||||
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));
|
|
||||||
|
|
||||||
pr("Explosion in %s causes %d damage.\n",
|
pr("Explosion in %s causes %d damage.\n",
|
||||||
xyas(land.lnd_x, land.lnd_y, land.lnd_own), dam);
|
xyas(land.lnd_x, land.lnd_y, land.lnd_own), dam);
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "sect.h"
|
#include "sect.h"
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
|
|
||||||
double
|
static double
|
||||||
fortgun(int effic, int guns)
|
fortgun(int effic, int guns)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
|
@ -53,7 +53,7 @@ fortgun(int effic, int guns)
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
static double
|
||||||
seagun(int effic, int guns)
|
seagun(int effic, int guns)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
|
@ -65,7 +65,7 @@ seagun(int effic, int guns)
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
static double
|
||||||
landunitgun(int effic, int guns)
|
landunitgun(int effic, int guns)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
|
@ -202,6 +202,31 @@ lnd_fire(struct lndstr *lp)
|
||||||
return 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 number of guns ship SP can fire.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue