There are some instances where a Survivor should not suffer the consequences of friendly fire. This plugin attempts to account for these situations.
1) Too Close
- When two players are very close to each other, the end of the first player's gun model's barrel could be in front of the second player's body, and yet the game will still register friendly fire. This type of friendly fire should be undone, since the bullet never really traveled through the survivor.
In the screenshot above, you can see that Rochelle is "inside" of Nick, and she has just pulled the trigger on a military sniper on expert. Without this plugin, that shot would have done 45 damage to Nick. It's unreasonable for Nick to take 45 damage in this situation.
2) Charger Carry
- When a Survivor is pinned by a smoker, hunter, or jockey, the game will prevent friendly fire. When a charger is pummeling a survivor, it also prevents friendly fire. But if a charger is carrying a survivor, you can still hit them with friendly fire. This type of friendly fire should be undone, because a carry should be like a pin.
3) Stupid Bot
- Sometimes when you friendly fire, the game will determine who is guilty and if it was the fault of the survivor who got hurt, it will display a message like "don't walk into the line of fire". If the game determines a bot is guilty of a friendly fire event, it should be undone, because bots shouldn't be able to friendly fire.
This plugin allows all of these situations to be accounted for. Each of the three scenarios can be individually enabled using enable bit flags.
Additionally, type 1 FF ("Too Close") distances have been calibrated on a per-gun basis using trial-and-error with one client watching another friendly firing a third client, to see at what distance the tip of the gun is not colliding with the third client's model. (CS weapons are "assumed" based on similar weapon classes, although they haven't been specifically tested) These values are hard-coded and cannot be changed unless you recompile.
melee, pistol, chainsaw = 25.0
smg, smg_silenced, smg_mp5, pistol_magnum, grenade_launcher = 30.0
pumpshotgun, autoshotgun, rifle, hunting_rifle, sniper_scout, sniper_awp, shotgun_spas, shotgun_chrome, rifle_sg552, rifle_desert, rifle_ak47 = 37.0
sniper_military = 42.0
rifle_m60 = 47.0
Friendly fire events that are undone are completely blocked with SDKHooks. This prevents it from counting in the final stat crawl, and it also prevents them from vocalizing friendly fire lines.
BLOCKING 0-DAMAGE EFFECTS
Additionally, you may be surprised to see how often the engine itself reduces friendly fire to 0 damage. These 0-damage friendly fires are also blocked. UPDATE (v1.2): By default this only happens on non-Easy difficulties, because all friendly fire damage is 0 on Easy so you would have no way to know how bad your friendly fire actually is. However, there is a cvar that can disable blocking 0 damage altogether, or it can disable it for all difficulties including easy.
UPDATE (v1.3): When a survivor bot shoots you a human, the human's vision recoils. By default this is now blocked. This is a bit flag that is added to the existing cvar
When friendly fire happens, it can optionally be announced in either the chat or the console (configurable via cvar), so that you know who hit who, from what distance, if it was undone and why. Announcing in the console has been provided as an option for those who dislike chatty plugins, but unfortunately console announcements don't have the pretty colors like chat announcements do. Announcements can also be entirely disabled as well.
This plugin also creates a new admin command, sm_undodamage. It keeps track of the last 16 hits against a survivor, and allows an admin to undo them. It can undo any type of damage, not just friendly fire, so when e.g. a zombie hits you through the side of a truck, you can sm_undodamage on yourself. It can undo incaps. UPDATE (v1.3): It can also undo a health kit being used, restoring the pre-health kit perm and temp health, and spawning the a weapon_first_aid_kit to compensate for the undone health kit.
FRACTIONAL DAMAGE TRANSFER
Finally, this plugin can also transfer a percentage of damage from permanent health to temporary health. Normally I would put such a different feature into another plugin, but in order to work properly with sm_undodamage, it must reside in the same plugin.
Allow me to use an example. Let's say you have 50 perm and 50 temp health, and you get shot by a sniper on expert (45 damage). Typically, and by default with this plugin, it would deal 45 damage to perm health and 0 damage transferred to temp health, leaving you with 5/50. If you set the permdmgfrac to 0.5, then half (round down) of the damage would be transferred to temp health, meaning 23 perm damage and 22 temp damage, leaving you with 27/28 instead of 5/50. If you set permdmgfrac to 0.0, then all 45 damage would be transferred to temp health before being done to permanent health, leaving you with 50/5.
// Bit flag: Enables plugin features (add together): 1=too close, 2=Charger carry, 4=guilty bots, 7=all, 0=off
// Bit flag: Block 0 damage friendly fire effects like recoil and vocalizations/stats (add together): 4=bot hits human block recoil, 2=block vocals/stats on ALL difficulties, 1=block vocals/stats on everything EXCEPT Easy (flag 2 has precedence), 0=off
// Bit flag: Enable damage announcements: 2=chat, 1=console, 0=off
// Minimum fraction of damage applied to permanent health
// Print debug output (1023=all)
- ADMFLAG_SLAY - undoes the last attack's damage to client (optional parameter, default is @me)
If upgrading from a previous version
, I recommend using SilverShot's Cvar Configs Updater
plugin to update because it's the easiest solution. Or you can add any new cvars to this file yourself. Or backup this file, delete it and it will be automatically recreated and then you can restore your backed up settings.
Another upgrade warning
, for v1.3 the default value for l4d2_undoff_blockzerodmg has changed from 1 to 5. This change is not automatically updated so you may need to go into the file config file and change it manually if you want enable blocking bot-on-human friendly fire recoil.
v1.1 - fixed sm_undodamage bug
v1.2 - Cleaned up the code a little more
fixed announce bug (0 would still print to console)
announce 0-damage melee attacks
1x stacked attacks do not show 1x multiplier
stacked attacks that incap a survivor announce only one message instead of two
added cvar for blocking 0-damage attacks
calls give health before undoing an incap and resetting health (better way to get survivors up)
v1.3 - Cleaned up the code a little more
Block bot-on-human friendly fire recoil
Can undodamage a health kit being used on a survivor
This plugin requires SDKHooks, so please DO NOT CLICK "Get Plugin", you must download the smx.