Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Mr. Kong

Weapon Kickback

Question

Hey folks.
I was trying to change some stuff on Geezy and found the "Doom weap base class", which has the default weapon kickback set to 100.
I read somewhere that one of the many differences between vanilla and GZDoom gameplay is that the latter's weapons push enemies much further.
So, I was just wondering if anyone knows what the vanilla kickback factor is and, if I changed GZDoom's default to it, if I could bring combat closer to it's original form.

Share this post


Link to post

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

Skimming the Doom source, I found this line in P_DamageMobj() in p_inter.c (comments mine):

 

// FRACUNITS is defined as 1<<16, which is just 2^16 or 65536
// A right-shift 3 is the same as dividing by 2^3, which ends up being 8192
thrust = damage*(FRACUNIT>>3)*100/target->info->mass;

Mass for most things is 100 with some notable exceptions for Cyberdemons and Masterminds who have a mass of 1000, as well as Keens and Romero's head who have a mass of 10,000,000 making them practically immobile. You can find all of them in info.c or in decino's video on monster stats.

 

So at least in vanilla Doom, knockback is dependent on how much damage you do and is not fixed. I've never looked at GZDooms internals, so I don't know how it differs, but since you mention that you found a fixed knockback attribute, then I don't know if you can totally reproduce vanilla Doom's knockback behavior in GZDoom.

 

Taking a shot in the dark, perhaps it still uses this thrust calculation to some degree, and that there may be some magic value you could set weapon knockback to achieve vanilla behavior? I think I'll have to take a look at GZDoom, or perhaps someone more experienced with it can chime in.

Share this post


Link to post
  • 0
18 minutes ago, ZeroKnight said:

Skimming the Doom source, I found this line in P_DamageMobj() in p_inter.c (comments mine):

 


// FRACUNITS is defined as 1<<16, which is just 2^16 or 65536
// A right-shift 3 is the same as dividing by 2^3, which ends up being 8192
thrust = damage*(FRACUNIT>>3)*100/target->info->mass;

Mass for most things is 100 with some notable exceptions for Cyberdemons and Masterminds who have a mass of 1000, as well as Keens and Romero's head who have a mass of 10,000,000 making them practically immobile. You can find all of them in info.c or in decino's video on monster stats.

 

So at least in vanilla Doom, knockback is dependent on how much damage you do and is not fixed. I've never looked at GZDooms internals, so I don't know how it differs, but since you mention that you found a fixed knockback attribute, then I don't know if you can totally reproduce vanilla Doom's knockback behavior in GZDoom.

 

Taking a shot in the dark, perhaps it still uses this thrust calculation to some degree, and that there may be some magic value you could set weapon knockback to achieve vanilla behavior? I think I'll have to take a look at GZDoom, or perhaps someone more experienced with it can chime in.

This is really informative.
I have to confess I don't really know either, so I'll have to dig deeper.
But, if there's no such ting in vanilla's weapons, only in it's monsters, perhaps setting it to 0 would do the trick?

Share this post


Link to post
  • 0

Decided to dig around and see how GZDoom does things in this regard, and it seems my hunch was on track; both damage and GZDoom's kickback attribute influence how much an enemy is knocked back.

 

As you mentioned, Doom weapons have a default kickback of 100; this seems to be defined in ZScript as part of the DoomWeapon class (wiki, source). Among its other modifications and restructuring of P_DamageMobj, GZDoom actually handles kickback in ZScript as well, in the Actor class's ApplyKickback method (wiki, source). The relevant lines seem to be:

thrust = mod == 'MDK' ? 10 : 32;
if (Mass > 0)
{
    thrust = clamp((damage * 0.125 * kickback) / Mass, 0., thrust);
}

Breaking this down, it sets thrust to an initial value of 10 if the attack has the "MDK" modifier, which I'm guessing is from the mdk debug command, or 32 otherwise. Next, if the enemy has mass, it calculates a thrust based on the attack damage, the weapon's kickback (which could be modified by mods, mind you), the victim's mass, and some coefficient of 0.125 that I'm guessing normalizes the result to something expected for thrust values. This result is clamped to always be between 0 and either 10 or 32 depending on that initial value.

 

Now, I haven't looked much farther than this, so I don't know how different GZDoom's thrust and speed values are, and if how they're calculated differs from vanilla Doom, but based on that calculation you could try setting the weapon kickback to 1 (not 0, as that won't move the target at all) and see if that feels closer to vanilla.

Share this post


Link to post
  • 0
39 minutes ago, ZeroKnight said:

Now, I haven't looked much farther than this, so I don't know how different GZDoom's thrust and speed values are, and if how they're calculated differs from vanilla Doom, but based on that calculation you could try setting the weapon kickback to 1 (not 0, as that won't move the target at all) and see if that feels closer to vanilla.

I'll go ahead and try that when I have the chance. I'm just aiming to get that value as close to vanilla as possible so that some features such as this one, or the air control one, are as close to vanilla as possible.

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
×