Page 1 of 2

Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Wed Oct 09, 2019 7:07 am
by Marisa Kirisame
Bouncing projectiles explode/die as expected, but don't deal damage to the actor they hit. Linked here is an example to show this behaviour. I'd check if the bug happens on 4.2.1 but I can no longer compile it due to glibc updates and versioned symbol nonsense.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Fri Mar 06, 2020 1:20 am
by Marisa Kirisame
Is anyone ever going to bother with this? A crapton of mods trigger this bug, you know.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Fri Mar 06, 2020 5:48 am
by SanyaWaffles
This explains the weird behavior I've been experiencing with DD2's gem bombs.

Let me see if I can reproduce it.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Mon Mar 09, 2020 4:33 pm
by Major Cooke
There's a couple ways this could be fixed.

I could either move the P_DamageMobj call into P_ExplodeMissile that's found in PIT_CheckThing (p_map.cpp line 1565), ensuring P_ExplodeMissile accurately handles all future impact damage appropriately:
Code: Select allExpand view
damage = tm.thing->GetMissileDamage((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1);
if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN) || (tm.thing->flags7 & MF7_CAUSEPAIN))
{
   int newdam = P_DamageMobj(thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType);
   //...


Or I could go the simple route and insert P_DamageMobj here:

Code: Select allExpand view
if (Vel.Z != 0 && (BounceFlags & BOUNCE_Actors))
{
   bool res = P_BounceActor(this, onmo, true);
   // If the bouncer is a missile and has hit the other actor it needs to be exploded here
   // to be in line with the case when an actor's side is hit.
   if (!res && (flags & MF_MISSILE))
   {
      P_ExplodeMissile(this, nullptr, onmo);
   }
}


Which one seems better? The former, I can include a boolean that disables damage as needed.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Tue Mar 10, 2020 3:40 am
by Marisa Kirisame
wouldn't calling explodemissile cause the projectile to, you know, explode, even in cases where they might still keep bouncing?

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Tue Mar 10, 2020 3:42 am
by Graf Zahl
Yes. It's also not the function inflicting the damage.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Tue Mar 10, 2020 7:30 am
by Major Cooke
If neither of those are fitting solutions, what is?

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Tue Mar 10, 2020 7:36 am
by Graf Zahl
That's the problem, I don't really know how to do it without causing unintended side effects.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Wed Mar 18, 2020 2:46 pm
by SanyaWaffles
This is becoming extremely noticeable at times in my project. You can hit an enemy square on the top and there's no damage or whatever when using bouncing bombs. It's an extremely aggravating bug and there's no way to fix.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Wed Mar 18, 2020 4:41 pm
by Major Cooke
It might be worth going back to Cacodemon345's commits and finding out what he fixed.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Fri Apr 03, 2020 2:46 am
by Cacodemon345
All I fixed is the missile not entering bouncing state when hit from top. I don't really believe it could cause any possible side-effects.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Fri Apr 03, 2020 11:55 am
by Cacodemon345
Now that I look into the source code, P_XYMovement function calls P_BounceActor with "ontop = false" in two places. The only function where I found that function called with "ontop = true" is the main Actor Tick function.

When I used a breakpoint in line 1483 of p_map, I found that the code in PIT_CheckThing only reaches there with the non-bouncing projectile, it does not even reach there with the bouncing project when I used Marisa's bug reproduction example. When that happens, P_BounceActor is called with "ontop = true".

This means that there HAS to be some place in the code which uses the Actor Bounce flag to change something that causes that portion of PIT_CheckThing to be unreachable.

Edit: further testing reveals a oddity: CanCollideWith() is called more than once for the non-bouncing projectile when it does not actually hit, but is only called once when the bouncing projectile actually hits the monster.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Tue Apr 07, 2020 6:17 pm
by Major Cooke
I'm going to merge in this PR into QZDoom if no one has any qualms about it, since I very much am finding myself in need of it.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Tue Apr 07, 2020 11:30 pm
by SanyaWaffles
If you do Cooke, when can you expect a build? This has been messing with one of my projects and I very much wish to test it out. I normally don't use qzdoom so I have no idea how frequently it gets updated. I also worry about it being out of date with recent GZDoom features.

Re: Bouncing projectiles don't hurt when hitting top/bottom

PostPosted: Wed Apr 08, 2020 9:09 am
by Major Cooke
I've merged it. It'll become available whenever the next build is scheduled, which is usually daily. The release times can be seen here.

Don't be, I usually keep it up to date whenever it's needed. I have contributor access to the repository so I can keep it up to date.