Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Optimus

No auto-aim after a distance. Why?

Recommended Posts

I am curious about this known fact. Say you play Doom with keyboard only and no up-down look. There is auto-aim where an imp might be in a much higher or lower height than you but while you shoot straight the bullets go up or down directly to the target if it is on the line of your shooting. That's a known fact. It's also known that in far away distances this doesn't work and while a far away cacodemon for example that flies above is on your line, your bullets or rockets or whatever hit the wall below. Today, with a testing map in doombuilder I realized that the auto-aim stops working from 1024 units of distance or more.

My first question is why? Why did the designers of doom choose to disable auto-aim after such distance? Was there a technical or gameplay reason? There are maps where an annoying monster is harming me with serious firepower from a long distance and a bit above or below but I can't harm it if it's not at the same height except if I was playing with mouselook. I don't see a reason why it shouldn't be allowed in any distance. Or was there a technical reason for this?

My second question is: Any doom port with options to fix/allow this? Is it possible with a dehacked patch or do I have to change the source code?

p.s. I am curious now if this rule applies to the monsters too. Might test it with another map. Probably not though. I remember those huge areas where I can't shoot the friggin monsters unless I find a height, but they can shoot or throw fireballs from any height directly at you.

Share this post


Link to post

To make it harder, and more realistic.

Like in modern day games, you can aim at an enemy, shoot him, but the bullet won't reach him. Thats pretty much what doom is doing.

Share this post


Link to post

I think hitscan monsters are affected by distance, but the distance is much greater than the player's. I could be wrong though, but I swear I've seen it happen.

Share this post


Link to post
Optimus said:

There is auto-aim where an imp might be in a much higher or lower height than you but while you shoot straight the bullets go up or down directly to the target if it is on the line of your shooting. That's a known fact.


Not exactly. Your aim is clipped against the maximum view angles, so if you can't see something, you also can't shoot it.

This limitation affects all hitscan attacks (including those of monsters), through calls to P_AimLineAttack which does the aforementioned check. The limitation also applies to the player's melee and missile attacks. Ports with freelook or extended view windows also modify the allowed shooting angles to allow "aiming" when you are not looking straight ahead.

All other monsters (using melee or missile) DON'T have this limitation, and in fact their attack functions DON'T call P_AimLineAttack at all. They know exactly where to aim (to the player or their targets) and they are not subject to the same "if I can't see you I can't hit you" thing. Call it a case of The Computer Is a Cheating Bastard ;-)

You can only override this behavior in ports that allow you to disable/modify autoaim from within the engine. With DEHACKED alone, you can't change those behaviors for the player. Other than the aforementioned, there's also a distance check which however is more subtle to follow, and seems to only have an indirect effect (it's only used in slope calculations).

There doesn't seem to be a hard and fast rule such as "beyond this distance, autoaim doesn't work", but there's the potential for numeric overflows and accuracy errors which would screw up calculations over long distances, and send shots too high/too low without you noticing.

Share this post


Link to post
yellowmadness54 said:

To make it harder, and more realistic.



It has nothing to do with realism. It's just a means to avoid calculation overflows. Doom's code for tracing a hitscan could run into problems if the distance was harder.

And like in any commercial production environment it was decided not to improve the code but to tweak it with the least amount of work to make it robust enough for release.

Share this post


Link to post
Graf Zahl said:

It has nothing to do with realism. It's just a means to avoid calculation overflows. Doom's code for tracing a hitscan could run into problems if the distance was harder.

And like in any commercial production environment it was decided not to improve the code but to tweak it with the least amount of work to make it robust enough for release.


I really didn't mean realistic, this was one of those things that were hard to word out.

Of course, you have more credibility than I would in this case, as I just thought it to be like "Oh hay, if that guy is over there, he should be out of doomguy's line of fire" sort of thing.

Share this post


Link to post

This is pretty much the leading reason why I play OGL. Even in software you have limitations,as you can't look totally up or down. Needless to say, I hate those limitations.

Share this post


Link to post

I doubt it's for game balance given that none of the IWAD maps really feature a situation where it'd be really relevant.


Plus the game balance in Doom was pretty much a lucky accident rather than a careful formula elaborated after the designers wrote a master thesis on the theoretical aspects of game balance.

Share this post


Link to post

Thanks for the explanations. I just compiled chocolate doom to check this one.

Also, I made some test map with chaingunners in a higher ledge and a long room. It seems that their aiming ability stops after 2048 units, double the players ability. Another difference is that their bullet puffs seem to stop after 2048. There was a line over 2048 where they were shooting but no bullet puffs behind me yet bullet puffs in left right walls inside the allowed distance and not on the same height as me, so no auto aim for them. As I moved inside the area they hit me and bullet poofs where on my height in nearby walls. The only difference with the player, players bullet poofs will hit an obstacle from any distance, just will not auto-aim anymore.

It could make sense performance wise, having 100 chain gunners shoot many bullets at the same time and for each shot calculating intersections with possible many numbers of sectors through the big area would be a problem, but not for a single fire shot from a player. I also changed #define MISSILERANGE (32*64*FRACUNIT) to 2*32*64 and they could shoot me now. But it doesn't seem to affect my auto-aim, so I guess the next step is to play with the P_AimLineAttack function.

Share this post


Link to post
Optimus said:

It could make sense performance wise, having 100 chain gunners shoot many bullets at the same time and for each shot calculating intersections with possible many numbers of sectors through the big area would be a problem, but not for a single fire shot from a player.


That's the point: the game tries to make an honest guess about where the player is probably aiming (a kind of What You Get Is Almost What You Mean), that's why all those relatively expensive checks are necessary only for the player, unless of course you forego autoaim almost completely and go for full manual control.

In addition to the slope limitations, the game also allows for some horizontal leniency as well: if firing straight ahead doesn't work, it also tries to aim at an angle of +/- 1<<26 BAM units with respect to the player's direction (quite coarse, about +/- 5.625 degrees), so each attack results in actually 3 checks along 3 slightly different paths.

Monsters don't need all those checks because they already know the exact x,y,z coordinates of their target and they are not limited by sloped (so they can even launch attacks that hit the floor they are standing on), even though they may miss it or choose not to attack for other reasons related to the bullet spread/blockmap/distance code.

Share this post


Link to post
Maes said:

There doesn't seem to be a hard and fast rule such as "beyond this distance, autoaim doesn't work"

I believe there is: see P_BulletSlope and P_SpawnPlayerMissile, both of which call P_AimLineAttack with a maximum range of 16*64*FRACUNIT (1024 map units, as Optimus observed in his initial post)

Share this post


Link to post
RjY said:

I believe there is: see P_BulletSlope and P_SpawnPlayerMissile, both of which call P_AimLineAttack with a maximum range of 16*64*FRACUNIT (1024 map units, as Optimus observed in his initial post)


Dammit, you're right ><

Still...it only applies to bullet-using hitscanners and the player, who however has an additional limitation: the autoaim distance of 1024 units is half that of the MISSILERANGE constant (2048 map units), so attacks won't be aimed reliably for their full range. Even the name of the constant is deceiving, as it doesn't really apply to missile attacks at all, but only to the maximum range of hitscan attacks (autoaim range would be MISSILERANGE/2).

All other monsters (except the archvile) have no limits for their aiming (and there's no technical reason for limiting it, either: they don't need to transverse anything. Hell, they don't even need to see Doomguy or do some fancy inter-monster communication stuff to find him. Compare All seeing AI.

It would be interesting to see what would happen if hitscan monsters had an unlimited range attack, despite their gross aiming inaccuracy: people complaining about "cheap hitscanners" in maps would suffer a fatal stroke, and it would be like walking on a permanent damaging floor ;-)

Share this post


Link to post

Ugh, I hate this limitation. It bothers me when I can't shoot faraway monsters, yet they can happily lob their mess at me.

Graf Zahl said:

It's just a means to avoid calculation overflows.

like cancellation error?

Share this post


Link to post
Optimus said:

The only difference with the player, players bullet poofs will hit an obstacle from any distance, just will not auto-aim anymore.


Did you mis-type this...I thought the players bullets do not travel past a certain distance. I specifically remember not being able to hit anything super far away (regardless of autoaim) although monsters could shoot me

Share this post


Link to post

Hitscans are limited to 2048 map units. Player and monster hitscans will go no further than that. Projectiles are unlimited, but monsters will normally not try to aim at targets beyond that range.

ZDoom increases the player hitscan distance to 8192 map units; though monsters are still limited to 2048.

Share this post


Link to post
Gez said:

Hitscans are limited to 2048 map units. Player and monster hitscans will go no further than that. Projectiles are unlimited, but monsters will normally not try to aim at targets beyond that range.

ZDoom increases the player hitscan distance to 8192 map units; though monsters are still limited to 2048.


I see. I was mistaken because I tried the last one in Zdoom. Well, I first tried in chocolate doom and because the resolution was low I thought I just couldn't see the puffs. Nice to know now.

Share this post


Link to post
Gez said:

ZDoom increases the player hitscan distance to 8192 map units; though monsters are still limited to 2048.


This seems like a 'half change'. Why didn't ZDoom either stay faithful in this area (change neither) or go all the way (change both)?

Yes, I am aware that a Chaingunner snipping you from 8192 map unit's could be annoying.

Share this post


Link to post

Simply put, increased resolution means that you can see a monster from further away, and then it feels like a bug if you can't hit it with your chaingun. (Especially since you can have features like scopes that zoom the view.)

If a monster that is 3000 map units away fails to hit you, it doesn't feel like a bug: it seems natural that at this distance, with spread, you'd be luckier than if it was 300 map units away. Also you may not even notice you're being fired upon at all.

In fact, there are maps where it may affect the gameplay if hitscan monsters had an increased range.


It's a half change in the same way that jumping and crouching are half changes. The player can do that if so he choses. The monsters, however, still behave like they always did. They don't fire with a 8000 units range, they don't crouch, they don't jump.

But hey, monsters are still more likely to hit you anyway in ZDoom than in vanilla.

Share this post


Link to post
Gez said:

Hitscans are limited to 2048 map units. Player and monster hitscans will go no further than that. Projectiles are unlimited, but monsters will normally not try to aim at targets beyond that range



Projectile monsters have absolutely no distance or slope limit when targeting: they know their position, the target's position and they simply do the math. They have no option to abort an attack due to range, and the MISSILERANGE constant is not even used for missile attacks at all.

Share this post


Link to post

Yet, there's a point past which monsters won't fire missiles at the player. Keep studying the code until you find the reason why.

Share this post


Link to post
Creaphis said:

Yet, there's a point past which monsters won't fire missiles at the player. Keep studying the code until you find the reason why.


There's a half-reason, but it's way more complex than simply checking against a maximum range. Before you read any of the following, I challenge you NOT to take my word for it and study the code yourself, to see if we come to the same conclusions.

First of all, there's nothing causing most monsters to abort an attack if a target is already set AND they have already entered their firing state. They won't "yield" nor "chicken out" of it if e.g. their target gets out of range. Exceptions explained below.

The sequence is more or less: monsters execute A_Chase, they look for targets, and if they have one they run P_CheckMissileRange(). The player is a bit special in that he must be "detected" through the LOS functions, which may fail for other reasons which have more to do with a map's geometry or reject/bsp issues, rather than range. OK, in THAT ONE P_CheckMissileRange() function there are some range checks done but they are far from straightforward, and far from the only ones:

  • The only monsters which have some FIXED range limit that will prevent them from starting a ranged attack AT ALL are Archviles (at a ranges > 14*64 map units), and Revenants (won't use missile if closer than 196 map units, but there's an exception: read on).
  • If a monster is actually ATTACKED by its target, it will fire back no matter the distance. THIS TRUMPS ALL FOLLOWING CHECKS, and in theory it trumps even the archvile attack, at least within P_CheckMissileRange()
  • For all other monsters, the distance in map units is progressively divided by 2 after each check. After it's reduced to at most 200 or to 160 map units for cyberdemons, a call to P_Random() (!) is made, and if the result is smaller than the remaining dist value, then the attack is cancelled. That's right, PURE FUCKING LUCK.
  • Apart from the above mentioned cases, there are no further range limiting checks that may cancel an attack.
The corollary of the above? Barring some very special cases like Archviles, Revenants or immediate retaliation, the main limiting factor on STARTING ranged attacks is pure luck: ranged attacks have at most a 200/256 or 160/256 chance for cyberdemons of not being started at all.

WARNING: GORIER DETAILS FOLLOW
            if (P_Random() < dist)
                return false;
Of course, the larger the initial distance, the higher the chance that an attack will be aborted, which is however capped at 200/256 and 160/256 (about 75% and 60% accordingly). With sufficiently small distances, ranged attacks are never aborted, but even with the highest possible, the chance of starting them is always non-zero.

Assuming an Imp vs a Player:
  • P_CheckMissileRange() computes an initial value of dist which gets shifted >> 16 (from 16.16 fixed_t to 16-bit signed short).
  • dist doesn't get halved in any of the following checks.
  • Dist is capped at 200 map units.
  • P_Random() is called. If its value is <dist, the attack is aborted.
In the case of revenants, cyberdemons, spider masterminds and lost souls, dist gets halved. This effectively DOUBLES the chances of starting an attack.

So no matter the range, any monster has at most a 200/256 chance of aborting a very long range attack (assuming it can SEE the player when it attempts to do so).

So range does indeed make attacks increasingly rarer, but never with a zero chance. In order to do that you would need a value of dist >255 which would give a 256/256 cancellation chance, but would normally be impossible to achieve unless the distance calculations in P_ApproxDistance can cause some sort of overflow that would get past the capping. Setting it artificially to 256 makes indeed all monsters non-firing at ANY range, unless provoked (and then, they only fire once per provokation). Setting dist to 0 or negative removes all restraints on monsters, and they fire much more frequently.

AFTER an attack has been initiated, it might fail for other reasons (e.g. hitscan attacks actually ARE limited a-posteriori, archviles will abort if they lose LOS with their target), but the a priori causes are much more complex and unpredictable than people think, and luck/target behavior has far more influence than range.

Share this post


Link to post

In case anyone wants to see the auto-aim limitation in action, there is at least one level, Cathedral of Doom B1.0, where 100% Kills is impossible without freelook because some unreachable monsters are placed too far away for auto-aim to work. A few imps to the north of the start of the level stand in alcoves at a great height and at a long distance behind a fence — far enough that without freelook, all you will ever hit is the wall beneath them. Try it and see.

Share this post


Link to post
The Green Herring said:

An example of a map where autoaim doesn't work.


Well yeah. That one and maybe 10000 others with monsters on too far and high a ledge/too deep a pit.

Share this post


Link to post
The Green Herring said:

A few imps to the north of the start of the level stand in alcoves at a great height and at a long distance behind a fence — far enough that without freelook, all you will ever hit is the wall beneath them. Try it and see.


Well if the map has a rocket launcher, hitting the wall beneath is all you actually need, as actors can be set to infinitely tall.

Share this post


Link to post
The Green Herring said:

In case anyone wants to see the auto-aim limitation in action, there is at least one level, Cathedral of Doom B1.0, where 100% Kills is impossible without freelook because some unreachable monsters are placed too far away for auto-aim to work. A few imps to the north of the start of the level stand in alcoves at a great height and at a long distance behind a fence — far enough that without freelook, all you will ever hit is the wall beneath them. Try it and see.



Even Plutonia abused it to such a degree that I got annoyed by it.

Share this post


Link to post

Gez said in "wads that irritate you" thread:
If other ports have features allowing to create maps with huge outdoor areas where you fight with scoped rifles and railguns, I'd expect them to increase the player range as well.

Yes, but the chaingun is not exactly a sniper rifle, even if it's accurate. I don't need it to be upgraded like that by the engine. I'm perfectly OK with its limited range. If the mod used new hitscan weapons meant for long distances, then yes, the range upgrade would have been welcome. But otherwise, what it does is modify game behavior without user's input.

Share this post


Link to post

I really can't believe people are seriously whining about that. As if it is an important part of Doom's gameplay to fire shots at very distant monsters and happily notice that the bullets, indeed, do very well vanish entirely as is good and proper.

I mean, most Doom maps don't feature areas large enough for it to be noticed at all. With the advent of limit-removing ports, however, such maps started to appear. One day, someone noticed that the bullets didn't connect on some map and thought it was a bug, the range was increased as a result. Ten years later, people are considering it a bug that the bullets do not vanish.

Well, if a longer range does detract from your enjoyment of the game, it's a good thing there are other ports that didn't change this value. You can try using them.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×