Enemies "slide" when hit

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
lemming
Posts: 19
Joined: Sat Nov 10, 2018 11:29 pm

Enemies "slide" when hit

Post by lemming »

it seems like something introduced within the last day or two has changed monster physics in (at least) Doom, Doom 2, and Heretic. When you shoot an enemy, they are very likely to "slide" to the left or right. This effect is most noticeable in Heretic--just load up E1M1 and use the wand to shoot at the flying gargoyles near the docks--it's often hard to hit them with multiple successive shots. It just feels "off".

I think this is probably a recent development, because I didn't see it when I built yesterday.

Currently on commit SHA e22e249287ee7542c11ae40c657d5d5f431979c0, self-built for Windows x64 with VS CE 2017, no local changes.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Enemies "slide" when hit

Post by Graf Zahl »

I have no idea what you are talking about, it appears to be fine for me. Can you make a short video? Also, since you self-compile, can you check which commit this started with?
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Enemies "slide" when hit

Post by phantombeta »

The kickback and explosions are reversed. dpJudas noticed the same issue, too.
This can be easily noticed in a mod such as Guncaster, where the starting weapon has massive kickback - it thrusts sideways instead of backwards.
User avatar
Rachael
Posts: 13532
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Enemies "slide" when hit

Post by Rachael »

I actually just noticed this, too. I set "sv_damagefactormobj 0" on an archvile and shot it with a high damage weapon and it slid toward me. Are angles being exported correctly between C++ and ZScript? Are there any degree or radian conversions that should be happening and aren't?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Enemies "slide" when hit

Post by Graf Zahl »

Angles are exported properly. This is more likely some of the bad coding in the old kickback code now showing its ugly face. I thought I had it fixed before committing, but apparently not.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Enemies "slide" when hit

Post by _mental_ »

Tried Rachael's steps to reproduce with Debug Win64 and got bunch of beloved Invalid sound position (-111.044632, 1014.617737, -inf) for actor of class ArchvileFire at the beginning of Doom II MAP01.
Z coordinate is always bad while X and Y are correct.
User avatar
Rachael
Posts: 13532
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Enemies "slide" when hit

Post by Rachael »

I tried this to reproduce it: set "sv_damagefactormobj 100" to make it much more obvious what's happening with kickbacks. Then set godmode and infinite ammo and go slaughtering monsters - pay close attention to what happens to them on the map. They all go flying northeast.

This video is NOT meant to be debugged directly - it just shows the effect in action. For what it's worth, it reveals another bug: Somehow, WolfySS was able to see me on spawn.

When "vm_jit" is set to 0, the angles are always correct.

User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Enemies "slide" when hit

Post by Graf Zahl »

Rachael wrote: When "vm_jit" is set to 0, the angles are always correct.
Ok, that's why I did not notice during most later tests. That should narrow it down considerably. My guess is that there's another direct native function where the signature does not match the definition.
lemming
Posts: 19
Joined: Sat Nov 10, 2018 11:29 pm

Re: Enemies "slide" when hit

Post by lemming »

Rachael's video clip seems consistent with the behavior I noticed. I'll also see if I can bisect it down to the commit responsible, since it has to have been exposed by something within the ~24-48 hours before the commit SHA1 I listed.

edit:

It seems to have been introduced somewhere between 101ebe17311ff517af1a62c0092462f6b4ce95e2, where the bug does not occur, and de5ab0b4b69032316f24a4e47d58310ea994a551, where it does. I cannot, unfortunately, narrow it down any better than that right now, because every commit in between those two either fails to build, or fails to run with the error "gzdoom.pk3:zscript/actor.txt, line 670: The function 'Actor.LineAttack' has not been exported from the executable".

Hope that helps. I don't know your codebase well enough to mess around with the intervening commits and get them to work.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Enemies "slide" when hit

Post by _mental_ »

Apparently, it's an issue with code generation. "Sliding" bug is caused by this Actor.Thrust() call. Here is a corresponding JIT dump:

Code: Select all

; line 73: 50070300 CALL_K
movsd oword [rsp+120], xmm1             ; [Save] regF1
movsd oword [rsp+112], xmm2             ; [Save] regF2
mov rcx, rbx                            ; [Duplicate] regA0
movapd xmm1, xmm2                       ; [Duplicate] regF2                       // ???
movapd xmm2, xmm1                       ; [Duplicate] regF1                       // ???
call 140698867386448                    ; Actor.Thrust [Native]
No surprise that angle and speed arguments for this native function are the same.
dpJudas
 
 
Posts: 3037
Joined: Sat May 28, 2016 1:01 pm

Re: Enemies "slide" when hit

Post by dpJudas »

Eek, looks like it could be another register allocation bug in asmjit.

Essentially xmm1 holds regF2 and xmm2 holds regF1. The code wants to swap them - first two saves is the register allocator saving them to stack. Then it copies regF1 to xmm1 - so far so good. The bug is that it thinks it can copy the other way as well, but that of course doesn't work.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Enemies "slide" when hit

Post by Graf Zahl »

When bugs like this one surface, all I can say is :puke:. They are the worst of all - problems with third party code...
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Enemies "slide" when hit

Post by phantombeta »

I remember I stumbled upon this same bug when fixing MODF_RK. I can't remember what we did to fix it, though... :\
It should be doing a XOR swap in this case if it really needs to swap the registers, but for some reason it isn't.

Ninja edit: What if we manually did swaps like this instead of letting asmjit do it? That could work...
dpJudas
 
 
Posts: 3037
Joined: Sat May 28, 2016 1:01 pm

Re: Enemies "slide" when hit

Post by dpJudas »

Graf Zahl wrote:When bugs like this one surface, all I can say is :puke:. They are the worst of all - problems with third party code...
Indeed. This is why I personally try to keep 3rd party dependencies at a minimum. Too bad in this case it wasn't an option.
phantombeta wrote:Ninja edit: What if we manually did swaps like this instead of letting asmjit do it? That could work...
Unfortunately we use virtual registers and the asmjit register allocator is what assigns them to real registers. We simply don't know that some code prior to the call decided to place those in xmm0 and xmm1.

The code dealing with the registers in asmjit uses some somewhat nasty templating to share code between different register types (general purpose, SSE, etc.). I've tried to understand its logic before and it didn't go too well. However the good news is that maybe I can implement the XOR swap for XMM registers. The asmjit code already has support for swapping GP registers like that, which means I just need to convince those template functions to follow that code path instead.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Enemies "slide" when hit

Post by Graf Zahl »

dpJudas wrote: The code dealing with the registers in asmjit uses some somewhat nasty templating to share code between different register types
And this is why I normally steer clear of those 'cool' templated libraries. The only other one in GZDoom is RapidJSON, and not surprisingly, it also contains a bug I had to work around - and to my knowledge they still haven't fixed it, even two years after I reported it. (The library completely loses it if the user tries to write invalid data. Not only the incorrect values written get trashed, but the entire output becomes malformed.)

Template code tends to become totally unreadable rather quickly. The STL is also a good example for that.
Post Reply

Return to “Closed Bugs [GZDoom]”