. Reverse Friendly-Fire (l4d_reverse_ff) by Mystik Spiral
Reverses friendly-fire.
Attacker takes damage, victim does not.
Objectives:
Do not allow griefers to cause friendly-fire damage to other players.
Incentivize all players to improve their shooting tactics and aim.
Description and options:
Reverses friendly-fire weapon damage on survivor team and claw attacks on infected team.
Does not reverse burn/blast damage, except for grenade launcher and incendiary/explosive ammo.
Supports client language translation: English, French, Spanish, Russian, and Traditional Chinese.
Options for the true(1) / false(0) parameters below:
· 1 = friendly-fire is reversed for that option and the attacker takes damage.
· 0 = friendly-fire is disabled for that option and the attacker does not take damage.
ReverseFF when attacker is an admin. [reverseff_admin (default: 0)]
ReverseFF when victim is a bot. [reverseff_bot (default: 0)]
ReverseFF when victim is incapacitated. [reverseff_incapped (default: 0)]
ReverseFF when attacker is incapacitated. [reverseff_attackerincapped (default: 0)]
ReverseFF when damage from mounted gun. [reverseff_mountedgun (default: 1)]
ReverseFF when damage from melee weapon. [reverseff_melee (default: 1)]
ReverseFF when damage from chainsaw. [reverseff_chainsaw (default: 1)]
ReverseFF during Smoker pull or Charger carry. [reverseff_pullcarry (default: 0)]
_____________________________________________
Options for the damage modifier parameters below:
Range: 0.0 - 2.0
0.0 = disabled
0.1 = 10% of real damage
0.5 = 50% of real damage
1.0 = 100% of real damage
1.125 = 112.5% of real damage (12.5% extra damage)
Added two new parameters by popular demand to allow victim damage...
Survivor bot victim: reverseff_botdmgmodifier
Survivor human victim: reverseff_humandmgmodifier
These two parameters control how much damage friendly-fire victims take, and operate independently of the parameters that control how much friendly-fire damage is reversed to attackers. If you want survivor attackers to have 80% of damage reversed, survivor bot victims to take 100% of damage, and survivor human victims to take 50% of damage, then you would set:
Without this plugin, if you shoot another player while they are being pulled by the Smoker (before they are choked) or while being carried by the Charger (before they are pummeled), the game engine would trigger friendly-fire. Setting reverseff_pullcarry=0 allows you to turn this off, and is the default. The game engine does not generate friendly-fire if you shoot another player while they are pinned by the Hunter or Jockey and is not affected by the reverseff_pullcarry setting.
The proximity feature (reverseff_proximity) compares the distance between the attacker and victim, and if the distance is less than reverseff_proximity, ignores friendly-fire. The default value is 32, which is where players bodies are so close they begin to overlap. However, you could also set it to a lower value (more body overlap before friendly-fire is ignored) or a higher value to provide a buffer around you for griefers/idiots that run through or in front of you while you are firing. Also note this feature ignores melee weapons and chainsaw... those will always generate friendly-fire (unless you have one of the other ConVars set to negate that). You can disable this feature by setting reverseff_proximity=0. If you want the opposite effect... ignore friendly-fire when the distance is greater than reverseff_proximity (instead of less than) then set reverseff_proximity to a negative value.
L4D1/2 engine check fix requested by Crasher_3637/Psyk0tik
Reverse accusation vocalizations requested by kooper990
Kick or ban option requested by Maku and Crasher_3637/Psyk0tik
ReverseFF for infected requested by Kai0205
Short FF grace immediately after killing SI requested by Kai0205
L4D1/2 specific checks fix requested by kooper990 and Marttt
Attacker incapped option and mounted gun option requested by Shao
Melee and chainsaw option requested by Shao
Charger carry and Smoker pull option requested by Shao
Chainsaw damage fix by pan0s
Damage modifier by percentage requested by TrueDarkness
Promximity option requested by Shao
Announcement option requested by tamasa1969
Chat option requested by kevinracer
Cooldown timer requested by Shao
Game modes on/off/tog by Silvers
GetClientDist adapted from UndoFF by dcx2
Traditional Chinese translation by in2002
SM 11 compile warnings fix requested by S.A.S
Grenade stumble effect option requested by Automage
Option to reverse the logic of reverseff_proximity requested by Smeraldo
Add missing victim/attacker validation in datapack passed to chainsaw timer requested by S.A.S
Most recent update:
Spoiler
Code:
09-Oct-2024 v2.9
By popular demand...
Allow victim damage using a modifier with separate values for bot victim and human victim.
Modifier range: 0.0 - 2.0:
0.0 = disabled (no damage to victim)
0.1 = 10% of real damage
0.5 = 50% of real damage
1.0 = 100% of real damage
1.1 = 110% of real damage
1.5 = 150% of real damage
2.0 = 200% of real damage
Survivor bot victim damage: reverseff_botdmgmodifier (default=0.0)
Survivor human victim damage: reverseff_humandmgmodifier (default=0.0)
Either manually add these two parameters or delete the l4d_reverse_ff.cfg file and let the system recreate it.
Full changelog:
Spoiler
Code:
09-Oct-2024 v2.9
By popular demand...
Allow victim damage using a modifier with separate values for bot victim and human victim.
Modifier range: 0.0 - 2.0:
0.0 = disabled (no damage to victim)
0.1 = 10% of real damage
0.5 = 50% of real damage
1.0 = 100% of real damage
1.1 = 110% of real damage
1.5 = 150% of real damage
2.0 = 200% of real damage
Survivor bot victim damage: reverseff_botdmgmodifier (default=0.0)
Survivor human victim damage: reverseff_humandmgmodifier (default=0.0)
Either manually add these two parameters or delete the l4d_reverse_ff.cfg file and let the system recreate it.
24-Sep-2024 v2.8.6
- Add missing victim/attacker validation in datapack passed to chainsaw timer
- Remove spam when ChatMsg option is enabled.
07-Oct-2023 v2.8.5
- Modified the reverseff_proximity console variable to allow for negative values.
When reverseff_proximity is set to a negative value, ignore friendly-fire when the distance between the victim and attacker is greater than abs(reverseff_proximity), and reverseff if the distance between victim and attacker is less than abs(reverseff_proximity).
When reverseff_proximity is set to a positive value, ignore friendly-fire when the distance between the victim and attacker is less than reverseff_proximity and reverseff if the distance between victim and attacker is greater than reverseff_proximity.
24-Sep-2023 v2.8.4
- Option to enable/disable stumble effect from grenade launcher friendly-fire (0=disable). [reverseff_glstumble (default: 0)]
07-Sep-2023 v2.8.3
- Fixed warnings when compiling using SourceMod 11.
- Add cooldown option to suppress ReverseFF for specified time (reverseff_cooldowntime [default: 0])
-- 0=disable, xx=seconds to disable ReverseFF after initial ReverseFF
16-Sep-2021 v2.8.2
- Add option to display/suppress ReverseFF chat messages (reverseff_chatmsg [default=1])
-- 0=Suppress chat messages, 1=Display chat messages
29-Aug-2021 v2.8.1
- Add option to set announcement on/off (reverseff_announce [default=1])
25-Jun-2021 v2.8
- Add proximity feature.
-- If distance between victim and attacker is less than the proximity setting, do not reverseff.
-- Set reverseff_proximity to 0 to disable this feature
05-Jun-2021 v2.7.1
- Add damage modifier for infected (reverseff_dmgmodinfected) ConVar to decrease/increase reversed damage by a percentage.
-- Allows damage modifier to be set separately for infected and survivors.
- Ensure reverseff_dmgmod* ConVars have minimum value of 0 (no damage reverse) and maximum value of 2 (double damage reverse).
- When reverseff_dmgmod* is not 0 (no damage reverse) or 1 (unmodified damage reverse), ensure minimum inflicted damage is 1.
- Add Spanish (es) and Russian (ru) to existing English (en) and French (fr) translations.
27-May-2021 v2.7
- Add damage modifier (reverseff_dmgmodifier) ConVar to decrease/increase reversed damage by a percentage.
-- 1=damage unmodified (default), <1 damage reduced, >1 damage increased, 0=no damage
-- 0.01=1% of actual dmg, 0.1=10% of actual dmg, 0.5=50% of actual dmg
-- 1.01=1% more dmg, 1.1=10% more dmg, 1.5=50% more dmg
- Fix regression when bot is attacker to remove hit/hurt sound/visual, even though no damage was actually done.
- Fix when attacker continually causes friendly-fire using translated language and would occasionally display some of the messages in English (not translated).
- In conjunction with the translation fix above, reduce the frequency of reverse friendly-fire messages.
-- The translated message fixes require you download the new l4d_reverse_ff_phrases.txt file and copy it to the left4dead/addons/sourcemod/translations directory.
11-May-2021 v2.6
- Fix by pan0s for server crash when chainsaw reverse damage causes incap or death.
-- Fixed regression caused by chainsaw fix (GetEdictClassname used with weapon values < 1).
-- Added a few optimizations to the chainsaw fix.
- Fix friendly-fire triggered during hunter pounce/jockey ride if attacker shoots victim instead of hunter/jockey.
- Fix reverse friendly-fire vocalizations and messages even though the damage is reversed...
-- The victim will vocalize an accusation against the attacker.
-- The attack message displayed will show correct victim and attacker.
-- If the attacker is using explosive/incendiary ammo, the victim will not stumble/burn, but the attacker will.
-- Due to this fix, the "reverseff_self" ConVar is no longer used and needs to be removed from the cfg file.
-- Remove "reverseff_self" entry from l4d_reverse_ff.cfg or just delete the file and let the plugin recreate it.
- Allow kick/ban feature to be disabled by setting reverseff_*maxdmg to 0.
28-Mar-2021 v2.5
- Add new ConVar option to ReverseFF during Smoker pull or Charger carry.
- Fixed ReverseFF when victim freed from Smoker tongue after pull started but before being choked.
- Shorten grace period (God Frames) from 2.5 seconds to 2.0 seconds.
- Add support for late load.
25-Mar-2021 v2.4
- Add new ConVar options for melee and chainsaw.
- Fix minor bug if player quit while pinned by special infected (hunter/smoker/jockey/charger).
08-Mar-2021 v2.3
- Check for two ReverseBurn plugins, and if found, only do a single combined announcement for all of them.
- Added colors to Announcement message and to messages displayed to attacker when friendly-fire is reversed.
- Changes above require new phrases download.
05-Mar-2021 v2.2
- Option to ReverseFF if attacker incapped (generally not needed except with "Incapped Weapons Patch" or similar).
[reverseff_attackerincapped (default: false)]
- Option to ReverseFF if damage from mounted gun.
[reverseff_mountedgun (default: true)]
27-Feb-2021 v2.1
- New L4D2 check before hooking L4D2-only events.
- New method to verify/load required translation file.
- New ConVar (reverseff_tankmaxdmg) since tanks do much more "friendly-fire" damage than other special infected.
- Modified cfg file default max damage values: reverseff_survivormaxdmg=200, reverseff_infectedmaxdmg=50, reverseff_tankmaxdmg=300
- Changed phrases file name to match standard naming conventions.
25-Feb-2021 v2.0.1
- Fixed issue where it sometimes tried to kick/ban a bot (thanks to Shadowart for reporting).
12-Feb-2021 v2.0
- Support for language translations, using new file "l4d_reverse_ff_phrases.txt".
· The translation file must be copied to the <left4dead(2)>\addons\sourcemod\translations directory.
· Includes translations for English and French, but "Mon Français est vraiment mauvais, désolé".
· If you have a better French translation, or any other language, please create a GitHub pull request.
11-Feb-2021 v1.9
- Annouce ReverseFF when player joins.
- Display ReverseFF chat message to attacker on friendly-fire.
- Ensure brief immunity from ReverseFF after victim freed from SI (hunter pounce, jockey ride, charger pummel, smoker choke).
- Cleaned-up cfg file descriptions for more clarity.
- Changed "reverseff_immunity" ConVar to "reverseff_admin" and flipped its meaning (to match other similar options).
- Enable/disable plugin by game mode with new ConVars: reverseff_modes_on, reverseff_modes_off, reverseff_modes_tog
· By default, all game modes are enabled.
· Examples of just a few of the many possible entries for game modes (includes default and custom mutations):
· coop,realism,survival,versus,scavenge,mutation4,mutation12,nightmaredifficulty
· For custom mutations, ensure your server already has the mutation installed and working correctly.
· Thank you to Silvers (SilverShot) for the game mode change detection code.
21-Jan-2021 v1.8
- Now reverses "friendly-fire" for infected team too.
- New ConVar for infected maximum damage per chapter before kick/ban. [reverseff_infectedmaxdmg (default: 110)]
- Renamed ConVar "reverseff_maxdamage" to indicate it is for survivors. [reverseff_survivormaxdmg (default: 180)]
20-Jan-2021 v1.7.1
- Increase max possible value for "reverseff_maxdamage" from "999" to "999999".
- Add option to kick instead of ban using "reverseff_banduration".
· "0" = permanent ban
· "-1" = kick instead of ban
20-Jan-2021 v1.7
- Option to treat friendly-fire as self-damage (or vocalize accusations). [reverseff_self (default: false)]
· false (0) = the attacker will vocally accuse the victim
· true (1) = will only vocalize pain sounds without accusations
11-Jan-2021 v1.6
- Option to reverse friendly-fire when victim is incapacitated. [reverseff_incapped (default: false)]
· false (0) = do not reverse friendly-fire if victim is shot while incapped
· true (1) = reverse friendly-fire if victim is shot while incapped
04-Jan-2021 v1.5
- Now reverses friendly-fire for mounted guns (mini-guns) too.
21-Dec-2020 v1.4.1
- Minor change to "reverseff_version" ConVar flag. (added FCVAR_NOTIFY for server queries)
21-Dec-2020 v1.4
- Option to specify maximum damage allowed per chapter before ban. [reverseff_maxdamage (default: 180)]
· Reset if player is kicked/banned
· Reset when player spawns into map (OnClientPutInServer)
- Option to specify ban duration in minutes when "reverseff_maxdamage" is exceeded [reverseff_banduration (default: 10)]
· 0 = permanent ban
13-Dec-2020 v1.3
- Added dynamically changeable ConVar. [reverseff_bot (default: 0)]
· false (0) = attacker does not have friendly-fire reversed when victim is a bot
· true (1) = reverse friendly-fire against all victims, human and bot
· Note that the victim (bot) does not take damage with either setting.
- Added detection for grenade launcher special ammo.
09-Dec-2020 v1.2
- Added dynamically changeable ConVars:
[reverseff_enabled (default: 1)]
· true (1) = enable plugin
· false (0) = disable plugin
[reverseff_immunity (default: 1)]
- Determine whether admins are immune to reverse friendly-fire.
· true (1) = admins are immune to reverse friendly-fire damage
· false (0) = admins are not immune to reverse friendly-fire damage
· Note that the victim does not take damage with either setting.
[reverseff_multiplier (default: 1.125)]
- Increase damage by this multiplier if explosive/incendiary ammo was used.
· "1.0" = normal, no extra damage
· "1.5" = 50% extra damage
· "2.0" = 100% extra damage (double damage)
· The default value of 1.125 results in 12.5% extra damage.
- Also added a standard ConVar [reverseff_version] that displays the plugin version.
08-Dec-2020 v1.1
- If attacker used incendiary/explosive ammo, increase damage to attacker by 12.5%.
05-Dec-2020 v1.0
- Initial release.
The phrases file is REQUIRED, and must be downloaded/copied to the "addons\sourcemod\translations" directory.
.
I know there are many friendly-fire plugins out there already, but it has been my experience that most of them do not work at all or have too many bugs to be useful. I had been using one of those other plugins for a while, and fixed several bugs with it, but some things just could not be fixed (hooking player_hurt), so I created this new plugin using the new (SM 1.7+) syntax. This plugin hooks SDKHook_OnTakeDamage to intercept damage, and uses SDKHooks_TakeDamage to reverse the damage. Note that if you shoot a teammate with explosive ammo, you (the attacker) will be stumbled, not the victim. Similarly, if you shoot a teammate with incendiary ammo, you (the attacker) will be lit on fire for a few seconds, not the victim.
Last edited by Mystik Spiral; 12-21-2020 at 13:36.
If attacker weapon has incendiary/explosive ammo, increase damage to attacker by 12.5%.
I haven't yet figured out how to tell if the grenade launcher (projectile) has incendiary/explosive ammo, so there is no extra damage for that weapon yet. All other primary weapons should be working fine with higher damage when using special ammo. The special ammo extra damage is not a true reversal, but is a good compromise until/if I figure out how to directly reverse it.
this plugin is perfect for me
It would be possible to add a .cfg to activate or deactivate the immunity to the administrator or to control the weapon damage
this plugin is perfect for me
It would be possible to add a .cfg to activate or deactivate the immunity to the administrator or to control the weapon damage
It might be a while, but I would like to add some ConVars for that, and also to enable/disable the plugin. And as I mentioned in the last post, I also want to reverse damage for grenade launcher projectiles.
I was able to get to this sooner than expected and released version 1.2...
Code:
Added dynamically changeable ConVars:
reverseff_enabled: set to 1 to enable plugin, 0 to disable
reverseff_immunity: set to 1 to make admins immune to reverse FF damage, set to 0 to reverse FF damage for everyone
reverseff_multiplier: if attacker is using explosive or incendiary ammo, increase damage by this multiplier
default is 1.125 (12.5% extra damage), 1.0=no extra damage, 2.0=double damage
Also added a standard ConVar:
reverseff_version: shows the plugin version
If you are a server admin, and you have the admin system active on your client, you can change these ConVars during the middle of a game. For example, bring up a chat window and type...
!cvar reverseff_immunity 0
...to instantly make everyone, including admins, take reverse friendly-fire damage. Another example...
!cvar reverseff_multiplier 1.25
...to instantly make explosive/incendiary ammo do 25% more damage to the attacker than regular ammo.
Of course, the changes are not permanent. To make your changes permanent, edit the values in the cfg/sourcemod/l4d_reverse_ff.cfg file.
Last edited by Mystik Spiral; 12-09-2020 at 08:52.
Reason: add examples
New version 1.3 released, see original post for download.
Added new ConVar "reverseff_bot" to determine if friendly-fire against bots should have damage reversed. Default is no. I created this option because bots often move in unpredictable and stupid ways, including walking into your line of fire even when you are crouched and not moving. With the default value, only attacks against human victims will reverse damage.
The plugin now also detects when the grenade launcher has incendiary ammo and deals the appropriate (reverseff_multiplier) extra damage for it. Explosive ammo for the grenade launcher is not checked, because in my tests, there was no difference in the amount of damage between regular explosive ammo and explosive explosive ammo. I think that explosive explosive ammo for the grenade launcher may just expand the kill/stumble zone, but I'm not sure about that.
If you have an older version of the plugin installed, you will need to add an entry to the "l4d_reverse_ff.cfg file to use the new ConVar, but I recommend you just delete the cfg file and let the plugin create a new one for you.
Last edited by Mystik Spiral; 12-13-2020 at 18:14.