top | item 45383043

(no title)

TapamN | 5 months ago

The headshot collision code in DX is broken as well. This is from memory from looking at the DX SDK years ago (+15 at least), but...

The collision shape used for a character in DX is a single cylinder. The game looks at where on the cylinder the collision point of the shot is, and tries to figure out if it's a head, body, or leg shot. It does this by checking how high the collision point is, with the lower X% being legs, top Y% being the head, and the middle being the body.

If a shot hits the head section, it runs some additional checks, and can sometimes still count as a body hit. There was some weird code that, after you stared at it long enough, looks like it ended up splitting the head area into compass aligned 1/8ths (so north, north-east, east, etc) and hits to the N-E-S-W octants would count as a head shot, and a hit to the NE-NW-SE-SW octants would count as body shots. (I couldn't tell if the angles rotate with the character, or are absolute relative to the world.) I think there was also a check for hits on the top cap of the cylinder, so that the hit would have to be close to the center of the cylinder to count as head hit, and near the outer rim would count as a body hit.

Hm, I should just make a diagram. Here: https://imgur.com/a/KG6MF1k

I guess what they were trying to do was make the actual head hitbox a smaller section of the head level, so that a shot that should go over the shoulder and miss would just count as a body shot and not a true headshot. And if you made a test map, with the player and a static test enemy placed in a line, this could work reliably from a fixed position. But when you actually play DX, and approach enemies from various angles, headshots inexplicably fail.

discuss

order

TapamN|5 months ago

Weird coincidence, but I had to look through some old files backed up from the computer I was using 15+ years ago, and noticed it had C:\DeusEx sitting right there, with the SDK files in it. I found the function that handles damage in it.

https://pastebin.com/bwjaiDj7

It looks like I misremembered/misinterpreted some stuff. It looks like the top of the head behaves like the sides of the head, extending upward, forming a + shape.

Judging by how the arm/leg damage works, it the collision hit zones rotate with the enemy. Offset appears to be were the collision point is releative to the character's rotation, since it's also used to determine front/back and left/right collision. So for a hit to count as a headshot, it has to hit a cardinal octant of the collision cylinder.

Edit:

Updated diagram: https://imgur.com/a/Mec7HGm

reactordev|5 months ago

I could be wrong, I didn’t work on it, but I believe these jankyness you describe was because DX was originally going to be like a Fallout style game but pivoted to an FPS. Old code left over from Troubleshooter and flawed game design choices that didn’t translate to a full 3D world. But I could just be remembering it wrong.

philistine|5 months ago

The good comes with the bad. Deus Ex's roots as an RPG are what made it so fun back when it was released.

I still remember how happy I was when I finally had gotten rid of any sort of sway on my reticle. Yeah, I can play this game like Half-Life now!.

LarsDu88|5 months ago

This explains the totally janky behavior of the stun prod and baton in the 5 playthroughs of this game I've done over the past 25 years

Anvoker|5 months ago

Are you sure that the jankiness you describe is not related to you not being close enough to the enemy for it to count as a point blank hit? The engine does a simple distance check which is rather unforgiving, and if you utilize the range your melee weapon affords you, you will fail this point black attack check. This is just a guess on my part, but it's the #1 reason I've seen people be perplexed at seemingly inconsistent melee stealth takedown behavior.

If you first push yourself as close as you can get to the enemy model and attack the general area of their torso, it works every single time. But again, this is just me taking a guess as to what the problem you're referring to is!

westmeal|5 months ago

You need to crawl up right next to their ass and zap their lower back

user____name|5 months ago

Also if you have to stun them in a pinch, they just stand there being spastic, you can knock them out by prodding a second time, but if you do it right away the hit won't register, you have to wait half a second and move around a bit or something. This is very annoying since it wastes precious prod charges.

xen0|5 months ago

This may be because the 'headshot' multiplier is lower than the regular multiplier (1x vs 2x) for the prod and baton. For most weapons the headshot multiplier is 8x (or something).

So torso hits from behind are the way to go.

NL807|5 months ago

I'm surprised they did not use a bunch of cheap sphere-ray intersection tests. It would be more accurate.

user____name|5 months ago

The game also features bullet drop, but this is completely broken. Iirc it does a hitscan against the cylinder and then depending on the length of the ray the hit point is moved further down the length of the cylinder, but this means you cannot for instance aim above the character to compensate for bullet drop.

anthk|5 months ago

GMDX should had that fixed that since long ago.