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.
- 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...
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.