A_WolfAttack

Moderator: GZDoom Developers

Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

A_WolfAttack

Post by Gez »

As suggested in the Wolf3D TC thread, here's an attack codepointer that works like the enemy guns in Wolf 3D rather than like standard hitscan attacks.
Differences with Doom hitscans:
  • The attack will never hit anything else than the intended target. It doesn't matter if the enemy using that codepointer is on the other side of a spiderdemon from you, the bullet will hit you and nothing else. A Nuts-like level with only enemies using that attack, and you're completely toast.
  • No puff.
  • No damage thrust.
  • Distance computation is orthogonal, like explosions. (So a target at [128, 127] relatively to the shooter will not be further away than a target at [128, 0], no matter what trigonometry says.)
  • The attack is less likely to be successful at longer range.
  • The attack is less likely to be successful if the attacker is in front of the target.
  • The attack is less likely to be successful if the target is running.
  • Damage is decreased with range, too: halved at medium range, and halved again (so, quartered) at long range. This can result in 0 damage.
Differences with Wolf 3D:
  • I've added a FaceTarget call that, obviously, Wolf3D never needed.
  • I also decreased the probability the attack hits successfully if you're currently invisible/blurred/etc. with an invisibility powerup. I thought it made sense, even if Wolf3D did not have blur spheres.
  • And likewise, I decreased damage inflicted if you're currently ghostly thanks to some powerup. Same reason.
  • Player speed check is done differently because player movement is handled very differently by ZDoom from the old Wolf 3D, the result should be about the same however.
  • To make maximum damage parameterizable, the initial damage computation is done with a modulo (%) rather than by bitshifting twice. This may result in a slightly greater average damage since you won't have as many damage rolls giving you 0 damage from the start. But it's not like the rest of the RNG is even remotely similar to Wolf3D's one, so...
Here is how the function works:

A_WolfAttack(sound whattoplay = "weapons/pistol", float snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, float runspeed = 160.0);
  • sound whattoplay is the attack sound. Seems straightforward enough.
  • float snipe corresponds to the factor by which the effective distance is multiplied. The lower it is, the more precise the enemy is. Hans Grosse and the blue SS in Wolf 3D have a snipe factor of 2/3.
  • int maxdamage corresponds to the theoretical maximum damage inflicted at point blank range, and is used as a modulo for the random number generator. The default value of 64 corresponds to Wolf's double-bitshift (255>>2 == 63; 255%64 == 63).
  • int blocksize corresponds to the size of a "block" emulating the Wolf 3D squares. I put a default of 128 since in the Doom II secret levels they've used 128 map units for one Wolf 3D square.
  • int pointblank corresponds to the number of squares below which the damage isn't divided.
  • int longrange corresponds to the number of squares beyond which the damage is further divided.
  • float runspeed is the combined velocity at which the target must move if it wants to be harder to aim. The default value of 160.0 was just me eyeballing it roughly based on the Doom player walk and run speeds, since a few tests showed it to be above a "strafewalk" but below a straight-line run. This is compared to the target's velx²+vely²+velz², if you're curious.
Any question, remark, or additional suggestion?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_WolfAttack

Post by Graf Zahl »

Ok, there's one thing I don't like here, and that's the damage calculation. This should be like A_MeleeAttack which uses its parameter unchanged without any randomization, leaving this to the modder to pass as an expression.

Also, isn't the MF3_GHOST check wrong? ;)
User avatar
Enjay
 
 
Posts: 27164
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: A_WolfAttack

Post by Enjay »

Although it may be more Wolf-like to not have a puff, I would like at least the option of setting a puff. Being able to add a puff would obviously allow a host of visual effects but puffs on attacks are also used for a bunch of other features too (eg damage type).

What about decals? Can these attacks generate bullet-chip-like decals?
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: A_WolfAttack

Post by Gez »

Would a flag parameter in which you could use values such as WAF_NORANDOM or WAF_USEPUFF be acceptable?
User avatar
Xtyfe
Posts: 1490
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: A_WolfAttack

Post by Xtyfe »

Why produce a new function, could these not be added to A_FireBullets and A_CustomBulletAttack?
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: A_WolfAttack

Post by Zippy »

Xtyfe wrote:Why produce a new function, could these not be added to A_FireBullets and A_CustomBulletAttack?
Try reading the first post again. The workings behind this are incredibly different from Doom's standard hitscan bullet attack.
User avatar
Enjay
 
 
Posts: 27164
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: A_WolfAttack

Post by Enjay »

Gez wrote:Would a flag parameter in which you could use values such as WAF_NORANDOM or WAF_USEPUFF be acceptable?
Certainly acceptable to me. However, I'm just an end user who is happy for things to work but I have little true feel for the correct way to do things inside the engine.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_WolfAttack

Post by Graf Zahl »

Gez wrote:Would a flag parameter in which you could use values such as WAF_NORANDOM or WAF_USEPUFF be acceptable?

Absolutely. While you are at it, how about WAF_NOGHOST?
User avatar
Enjay
 
 
Posts: 27164
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: A_WolfAttack

Post by Enjay »

I note that this attack means that the target will be hit even if other actors are standing in the way. If a check to see if actors are in the way is being made (I'm not sure that it is) is there any way to expose such a check to a modder so that they can put a jump into an attack state so that an enemy would not fire if there was another actor in the way? (I think that I may be right in saying that current checks only take account of map geometry and not the position of other actors?)
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: A_WolfAttack

Post by Xaser »

It seems that this feature suggestion would take care of that if implemented, though I certainly wouldn't complain if a flag here was added, either.
User avatar
Enjay
 
 
Posts: 27164
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: A_WolfAttack

Post by Enjay »

I knew I'd seen something like that somewhere recently. I reckon that Neural's suggestion would have more universal appeal than tying it to the A_WolfAttack function.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: A_WolfAttack

Post by Gez »

Graf Zahl wrote:Absolutely. While you are at it, how about WAF_NOGHOST?
Sure, what would it do? Remove the ghost check or remove damage for ghosts?
Enjay wrote:I note that this attack means that the target will be hit even if other actors are standing in the way. If a check to see if actors are in the way is being made (I'm not sure that it is)
The reason the target is hit even if other actors are in the way is because there are no such checks at all.

The normal hitscan functions work like this:
1. Verify that there is line of sight. (This only checks level geometry, actors never block line of sight.)
2. Compute horizontal angle between shooter and target.
3. Optionally add some random deviation to angle.
4. Trace line along that path.
5. Hit the first shootable actor that is met along the line.

The Wolf hitscan function works like this:
1. Verify that there is line of sight. (This only checks level geometry, actors never block line of sight.)
2. Compute distance between shooter and target.
3. Compute probability of hit depending on distance and other factors.
4. Compute damage depending on distance.
5. Damage target.

Doom is therefore a lot more "realistic" (as far as realism can be applied to faster-than-light attacks...) since the bullets are actually projected; whereas Wolf merely rolls to hit. There are a couple of niceties in the Wolf function, though, like the "dodge" effect (enemies are less likely to hit you if you see them, to simulate you seeing they aim and trying to move out of their crosshair) and the enemies having a harder time aiming you when you're moving fast. And a downside of Doom's approach is that, since it's exclusively 2D, a flying cacodemon can "intercept" a bullet from a zombie that had a clear shot at you.
User avatar
Enjay
 
 
Posts: 27164
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: A_WolfAttack

Post by Enjay »

OK, thanks for the explanation of how both types work. It makes a lot more sense to me now.
Gez wrote:There are a couple of niceties in the Wolf function, though, like the "dodge" effect (enemies are less likely to hit you if you see them, to simulate you seeing they aim and trying to move out of their crosshair) and the enemies having a harder time aiming you when you're moving fast.
Would there be any way (or any need?) to expose those features so that they could be used in other attacks. ie, you get the realism of the Doom system hitting the first shootable target in the path, but also the nice effect of the "dodge" and the speed related inaccuracy (and the distance degradation) - or are they intrinsically linked to an attack that "rolls to hit" (which I suspect may be the case)?
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: A_WolfAttack

Post by NeuralStunner »

Gez wrote:
Graf Zahl wrote:Absolutely. While you are at it, how about WAF_NOGHOST?
Sure, what would it do? Remove the ghost check or remove damage for ghosts?
I would hope it would be equivalent to having +THRUGHOST on the weapon, which is very limiting in many cases. (Setting it by A_ChangeFlag is useless, as that affects the Player.)
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: A_WolfAttack

Post by Blue Shadow »

I hope I don't see/play a mod where chaingunner's attack has been replaced with this :) .
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”