void Projectile::CheckLock(const Ship &target)
{
	double base = hasLock ? 1. : .5;
	hasLock = false;
	
	// For each tracking type, calculate the probability that a lock will be
	// lost in a given five-second period. Then, since this check is done every
	// second, test against the fifth root of that probability.
	if(weapon->Tracking())
		hasLock |= Check(weapon->Tracking(), base);
	
	// Optical tracking is about 15% for interceptors and 75% for medium warships.
	if(weapon->OpticalTracking())
	{
		double weight = target.Mass() * target.Mass();
		double probability = weapon->OpticalTracking() * weight / (200000. + weight);
		hasLock |= Check(probability, base);
	}
	
	// Infrared tracking is 10% when heat is zero and 100% when heat is full.
	if(weapon->InfraredTracking())
	{
		double probability = weapon->InfraredTracking() * min(1., target.Heat() + .1);
		hasLock |= Check(probability, base);
	}
	
	// Radar tracking depends on whether the target ship has jamming capabilities.
	// Jamming of 1 is enough to increase your chance of dodging to 50%.
	if(weapon->RadarTracking())
	{
		double probability = weapon->RadarTracking() / (1. + target.Attributes().Get("radar jamming"));
		hasLock |= Check(probability, base);
	}
}
Exemplo n.º 2
0
EscortDisplay::Icon::Icon(const Ship &ship, bool isHere)
	: sprite(ship.GetSprite().GetSprite()),
	isHere(isHere && !ship.IsDisabled()),
	stackSize(1),
	cost(ship.Cost()),
	system((!isHere && ship.GetSystem()) ? ship.GetSystem()->Name() : ""),
	low{ship.Shields(), ship.Hull(), ship.Energy(), ship.Heat(), ship.Fuel()},
	high(low)
{
}