[L4D2] Undo Friendly Fire (1.1) [2012-Jul-07]


There are some instances where a Survivor should not suffer the consequences of friendly fire. This plugin attempts to account for these situations.

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

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

weapon_melee, weapon_pistol, weapon_chainsaw = 25.0

weapon_smg, weapon_smg_silenced, weapon_smg_mp5, weapon_pistol_magnum, weapon_grenade_launcher = 30.0

weapon_pumpshotgun, weapon_autoshotgun, weapon_rifle, weapon_hunting_rifle, weapon_sniper_scout, weapon_sniper_awp, weapon_shotgun_spas, weapon_shotgun_chrome, weapon_rifle_sg552, weapon_rifle_desert, weapon_rifle_ak47 = 37.0

weapon_sniper_military = 42.0

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

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.

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.

Finally, this plugin can also change the percentage of damage that is applied to permanent health vs. temporary health. Normally I would 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 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 dealt 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 done to temp health before being done to permanent health, leaving you with 50/5.


l4d2_undoff_enable - Bit flag enables plugin: 1=too close, 2=Charger carry, 4=guilty bots, 7=all, 0=off (default 7)

l4d2_undoff_announce - enable announcements, 2=chat, 1=console, 0=off (default 2)

l4d2_undoff_permdmgfrac - Minimum fraction of damage applied to permanent health (default 1.0)

l4d2_undoff_debug - Debug output flags (127=all) (default 0)



sm_undodamage [client/#userid] - ADMFLAG_SLAY - undoes the last attack's damage to client (optional parameter, default is @me)




v1.1 - fixed sm_undodamage bug


This plugin requires SDKHooks, so please DO NOT CLICK "Get Plugin", you must download the smx.

Attached Files

File Type: sp

Get Plugin or
Get Source (l4d2_undoff.sp - 29.0 KB)

File Type: smx

l4d2_undoff.smx (16.7 KB)

Orignal From: [L4D2] Undo Friendly Fire (1.1) [2012-Jul-07]

1 comment:

  1. Hi, thanks for your interest in my plugin! :)

    I would like for you to provide a link at the top of the page pointing to the URL for the plugin, because then your site visitors could easily ensure they're using the latest version. It also has a picture demonstrating the plugin in action.

    I tried the link at the bottom which is labeled "Original From:" but it takes me to a 403 Forbidden error. Here is a link to the actual original plugin



Not a single link is allowed to submit in comment :o