[Fixed] Enemies "slide" when hit

Bugs that have been investigated and resolved somehow.

Moderator: Developers

Enemies "slide" when hit

Postby lemming » Wed Dec 05, 2018 9:31 pm

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.
lemming
 
Joined: 10 Nov 2018

Re: Enemies "slide" when hit

Postby Graf Zahl » Thu Dec 06, 2018 2:33 am

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
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Enemies "slide" when hit

Postby phantombeta » Thu Dec 06, 2018 9:31 am

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
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

Re: Enemies "slide" when hit

Postby Rachael » Thu Dec 06, 2018 10:02 am

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
Rachael
QZDoom + Webmaster
 
Joined: 13 Jan 2004

Re: Enemies "slide" when hit

Postby Graf Zahl » Thu Dec 06, 2018 10:04 am

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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Enemies "slide" when hit

Postby _mental_ » Thu Dec 06, 2018 10:18 am

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.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Enemies "slide" when hit

Postby Rachael » Thu Dec 06, 2018 10:40 am

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
Rachael
QZDoom + Webmaster
 
Joined: 13 Jan 2004

Re: Enemies "slide" when hit

Postby Graf Zahl » Thu Dec 06, 2018 11:32 am

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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Enemies "slide" when hit

Postby lemming » Thu Dec 06, 2018 8:44 pm

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.
lemming
 
Joined: 10 Nov 2018

Re: Enemies "slide" when hit

Postby _mental_ » Fri Dec 07, 2018 4:33 am

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 allExpand view
; 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.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Enemies "slide" when hit

Postby dpJudas » Fri Dec 07, 2018 4:41 am

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.
dpJudas
 
 
 
Joined: 28 May 2016

Re: Enemies "slide" when hit

Postby Graf Zahl » Fri Dec 07, 2018 5:48 am

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
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Enemies "slide" when hit

Postby phantombeta » Fri Dec 07, 2018 10:12 am

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...
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

Re: Enemies "slide" when hit

Postby dpJudas » Fri Dec 07, 2018 12:03 pm

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.
dpJudas
 
 
 
Joined: 28 May 2016

Re: Enemies "slide" when hit

Postby Graf Zahl » Fri Dec 07, 2018 1:21 pm

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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Next

Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 2 guests