Fear would be implemented as an inventory item with +INVENTORY.KEEPDEPLETED, for maximum monster compat. While the item count is above 1, the FearEffect item forces the target's bFRIGHTENED flag to true and takes 1 FearEffect every tic; when it hits 0, bFRIGHTENED is set to false. The KEEPDEPLETED flag is used to avoid dealing with shenanigans around trying to affect the monster while removing the last bit of FearEffect. The maximum amount of FearEffect a monster can have should be somewhere between 105 (3 seconds in tics) and 175 (5 seconds in tics).
Fear effects are handled by an event handler, in WorldThingDamaged. This event handler will have to grab the player's active weapon to get these stats. Technically speaking, for projectile weapons, the player
could switch weapons while the projectile is in the air, but A) most of the weapons in the arsenal are hitscan, so this bug would only affect the rocket launchers, grenade launchers, and flamethrower, and B) all of those guns should have more favorable fear characteristics than everything but the Fortunate Son anyway. The Fortunate Son's best fear effects come specifically from firing it, too (see below).
Each weapon has a different chance to apply fear, with bigger and more horrifyingly powerful guns getting more reliable fear effects (i.e., the M16 has a very low chance of inflicting fear per shot, the shotgun has a much higher chance of inflicting fear per shot, the flamethrower is practically guaranteed to terrify everything it hits, and the Fortunate Son has a 100% chance to apply fear).
Each weapon applies that fear in a radius around the point of impact--again, the more terrifying the gun, the better the effect. The exception to this is the Fortunate Son, which applies its fear in a large radius around
you, making it an excellent weapon for diving into a trench and going berserk.
The
duration of fear is semi-random for most weapons. Every time a projectile successfully rolls its fear chance, it does A_RadiusGive to give 15-35 FearEffect to every enemy in the radius defined by the weapon. The Fortunate Son's player-centered fear effect is separate from this, but should give 20 FearEffect on each shot--this means that emptying the Fortunate Son into an Unfortunate One will apply just over a second of fear to everything nearby, which should be enough time to reload in safety. Since FearEffect is an inventory item with a maximum amount, you can't stack fear
forever, but if you hose something down with napalm and it's still standing, it'll spend the next several seconds trying to get the hell away from you.
In general, weapons that fire slower, weapons that have more damage, and weapons that hit in a wider area should be more frightening.
Roughly speaking, here's a list of the weapons in order from least to most frightening:
- M3A1 Grease Gun
- M16
- Stoner 63
- 1911
- Machete
- M60
- M14
- Stevens 77E
- M79
- Flamethrower
- Fortunate Son
- RPG-7
- M202 FLASH