#ifndef lint
static char *RCSid = "$Header: /users/empire/EMP/empmain/SUBS/RCS/landgun.c,v 1.1 89/05/17 20:51:58 mr-frog Exp $";
#endif

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

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

double
landgun(effic)
	int	effic;
{
	return ((random() % 10) * 0.01 * effic) + 20.0;
}

double
seagun(type, effic, n)
	int	type;
	int	effic;
	int	n;
{
	double	rng;
	double	atten;

	rng = 0.9 - (mchr[type].m_frnge * effic * 0.0002);
	atten = rng;
	while (--n > 0)
		atten *= rng;
	return 100 - (atten * 100.0);
}

int
landdef(type)
	int	type;
{
	if (type == SCT_BANK)
		return 320;
	return 160;
}

int
seadef(type)
	int	type;
{
	return mchr[type].m_armor;
}

int
shelldam(dam, ac)
	double	dam;
	int	ac;
{
	return (int) ((dam * 100.0) / (ac + dam + 1.0));
}

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

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