Page 1 of 1

accuracy key for ships

Posted: Thu Jun 16, 2011 8:55 am
by Commander McLane
Just a small question: the Wiki says that the accuracy key, used for a ship, can enlarge the chance of the ship to shoot from greater distance, and then gives a range of values from -5 to 10. It doesn't say, however, which value corresponds to shooting from greater distance. So, does 10 give the greatest chance for long-distance shots and -5 lets it only shoot from close by, or is it vice versa?

Re: accuracy key for ships

Posted: Thu Jun 16, 2011 4:11 pm
by Cdr. Jettison
AFAICS, bigger values give greater accuracy. From the source:

Code: Select all

// accuracy. Must come after scanClass, because we are using scanClass to determine if this is a missile.
	accuracy = [shipDict oo_floatForKey:@"accuracy" defaultValue:-100.0f];	// Out-of-range default
	if (accuracy >= -5.0f && accuracy <= 10.0f)
	{
		pitch_tolerance = 0.01 * (85.0f + accuracy);
	}
	else
	{
		pitch_tolerance = 0.01 * (80 + (randf() * 15.0f));
	}

	// If this entity is a missile, clamp its accuracy within range from 0.0 to 10.0.
	// Otherwise, just make sure that the accuracy value does not fall below 1.0.
	// Using a switch statement, in case accuracy for other scan classes need be considered in the future.
	switch (scanClass)
	{
		case CLASS_MISSILE :
			accuracy = OOClamp_0_max_f(accuracy, 10.0f);
			break;
		default :
			if (accuracy < 1.0f) accuracy = 1.0f;
			break;
	}
Then, when firing laser

Code: Select all

	if (range > randf() * weaponRange * accuracy)  return NO;
	if (range > weaponRange)  return NO;