Autoaim stuff

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Gez
 
 
Posts: 17654
Joined: Fri Jul 06, 2007 3:22 pm

Autoaim stuff

Post by Gez »

When you set your autoaim value from the [wiki]player setup[/wiki] menu, you have these seven choices:

Code: Select all

OptionValue "Autoaim"
{
	0, "Never"
	1, "Very low"
	2, "Low"
	3, "Medium"
	4, "High"
	5, "Very high"
	6, "Always"
}
They correspond to these values for the autoaim CVAR:

Code: Select all

void DPlayerMenu::AutoaimChanged (FListMenuItem *li)
{
	static const float ranges[] = { 0, 0.25, 0.5, 1, 2, 3, 5000 };

	int	sel;

	if (li->GetValue(0, &sel))
	{
		autoaim = ranges[sel];
	}
}
So; "never" is 0, "very low" is 0.25, "low" is 0.5, and so on. What happens to the autoaim CVAR afterwards? It's turned into the player's aimdist variable. With this code:

Code: Select all

	if (autoaim > 35.f || autoaim < 0.f)
	{
		coninfo->aimdist = ANGLE_1*35;
	}
	else
	{
		coninfo->aimdist = abs ((int)(autoaim * (float)ANGLE_1));
	}
So here it gets capped between 0° and 35°. Now here's the interesting thing about aimdist. If autoaim is "never", then it is 0°. If autoaim is "very low", then it is 0.25°. And if autoaim is "low", then it is 0.5°. Everybody's following so far?

Now let's look at how aimdist is used. It does not affect railguns, so it is only used for hitscans and projectiles. First, when aiming, it always eventually boils down to this:

Code: Select all

fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, 
						 int flags, AActor *target, AActor *friender)
{
<snip some code not relevant here>

	// can't shoot outside view angles
	if (vrange == 0)
	{
		if (t1->player == NULL || !level.IsFreelookAllowed())
		{
			vrange = ANGLE_1*35;
		}
		else
		{
			// [BB] Disable autoaim on weapons with WIF_NOAUTOAIM.
			AWeapon *weapon = t1->player->ReadyWeapon;
			if ( weapon && (weapon->WeaponFlags & WIF_NOAUTOAIM) )
			{
				vrange = ANGLE_1/2;
			}
			else
			{
				// 35 degrees is approximately what Doom used. You cannot have a
				// vrange of 0 degrees, because then toppitch and bottompitch will
				// be equal, and PTR_AimTraverse will never find anything to shoot at
				// if it crosses a line.
				vrange = clamp (t1->player->userinfo.aimdist, ANGLE_1/2, ANGLE_1*35);
			}
		}
	}
Alright. See how vrange gets set to aimdist with a minimum of 0.5° and a maximum of 35°? (Provided it starts at 0, which is the case for every weapon except the chainsaw and the bloodscourge.) That means that "never", "very low", and "low" are essentially the same thing.

Also, here's a snippet the player projectile function eventually reached from pretty much all the weapon projectile functions (P_SpawnPlayerMissile()):

Code: Select all

			if (source->player != NULL &&
				!nofreeaim &&
				level.IsFreelookAllowed() &&
				source->player->userinfo.GetAimDist() <= ANGLE_1/2)
			{
				break;
			}
This is used to break out of an aiming function if freelook isn't disabled and autoaim is equal to or less than 0.5°). So, once again, "never", "very low" and "low" are the same thing.

And here's a snippet from the hitscan function (P_BulletSlope()):

Code: Select all

		if (mo->player != NULL &&
			level.IsFreelookAllowed() &&
			mo->player->userinfo.GetAimDist() <= ANGLE_1/2)
		{
			break;
		}
Oh wait it's the exact same thing, just with "mo" instead of "source". The logic and values are the same.



Am I missing something or is this borderline a bug? Given that 0.5 is the effective minimum value, I'd suggest changing "very low" to 1, "low" to 2, "medium" to 3, "high" to 5, and "very high" to 8.
User avatar
Mr. Tee
Posts: 1111
Joined: Sun Feb 08, 2004 7:49 pm

Re: Autoaim stuff

Post by Mr. Tee »

Gez, good show lad. From the code you have pointed out, I believe you are correct, however strange it seems.

Without actually looking at the code I never noticed this myself in the game. I usually play with autoaim "never", but trying "very low" and "low" doesn't yield a noticeable difference, well to me anyway. I'm guessing the effect is so small that it isn't readily noticeable, but is still technically incorrect.

Return to “Editing (Archive)”