#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emprcs/lib/subs/landgun.c,v 2.2 1995/10/24 04:33:34 empire Exp $";
#endif

/*
 * landgun.c
 *
 * return values for land and ship gun firing damages
 *
 * from PSL Empire, 1985
 */

#include "misc.h"
#include "ship.h"
#include "land.h"
#include "sect.h"

double
landgun(effic, guns)
	int	effic, guns;
{
      double d;
  	int	g = (double)min(guns,7);

	d = ((random() % 30) + 20.0)*(g/7.0);
	d *= ((double)effic);
	d /= 100.0;
	return d;
}

double
seagun(effic, n)
	int	effic;
	int	n;
{
	double	dam=0.0;

	while(n--)
		dam += 10 + random() % 6;
	dam *= ((double)effic)*0.01;
	return dam;
}

double
landunitgun(type, effic)
	int	type;
	int	effic;
{
	register int x=lchr[type].l_dam, dam=0;

	while(x--)
		dam += (random() % 6);
	return ((double)dam * 0.01 * (double)effic);
}

int
roundrange(r)
	double r;
{
	double f;

	f=r-((int)r);
	if (chance(f))
		return(((int)r)+1);
	else
		return((int)r);
}
