View Single Post
Author Message
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-22-2020 , 05:32   [L4D2] Throwable Melee Weapons (1.21) [05-Jul-2022]
Reply With Quote #1

Related Plugins:


About:
  • Allows players to throw melee weapons. Press the Scope / Zoom button to throw (MMB - middle mouse button).
  • Various ways to set damage, depending on weapon type and target.
  • Video demonstration - Thanks to "sonic155" for recording.



Thanks:
  • Sev - For the request.
  • Ethan Max - For also requesting and reminding me.
  • Lux - Because why not.



Admin Commands: (requires "z" flag)

PHP Code:
sm_throwable_reload // Reloads the weapons damage data config. 


Cvars:

Saved to l4d2_throwable_melee.cfg in your servers \cfg\sourcemod\ folder.

PHP Code:
// 0=Plugin off, 1=Plugin on.
l4d2_throwable_allow "1"

// Turn on the plugin in these game modes, separate by commas (no spaces). (Empty = all).
l4d2_throwable_modes ""

// Turn off the plugin in these game modes, separate by commas (no spaces). (Empty = none).
l4d2_throwable_modes_off ""

// Turn on the plugin in these game modes. 0=All, 1=Coop, 2=Survival, 4=Versus, 8=Scavenge. Add numbers together.
l4d2_throwable_modes_tog "0"

// 0=Off. 1=Notify of usage on first melee equip. 2=Notify on Survivor hit. 4=Notify on Special Infected Death. 8=Notify on Witch and Common Infected death. 16=Print to all, else print to client. Add numbers together.
l4d2_throwable_notify "7"

// 0=Off. 1=Changes the thrown melee weapon into a boomerang returning to the thrower when it hits something.
l4d2_throwable_return "1"

// Minimum speed. How fast to throw a melee weapon, affects range
l4d2_throwable_speed "500"

// Maximum speed. How fast to throw a melee weapon, affects range
l4d2_throwable_speed_max "1000"

// 0.0=Off, instant throw. Max time to get max speed. The longer players hold Zoom/Scope (MMB - middle mouse button) the faster they throw.
l4d2_throwable_speed_time "1.0"

// 0=Off. 1=Spin top over. 2=Spin sideways. 3=Both randomly selected. Requires gamedata.
l4d2_throwable_spin "3"

// Which melee weapons can be thrown: 1=Baseball Bat, 2=Cricket Bat, 4=Crowbar, 8=Frying Pan, 16=Guitar, 32=Fireaxe, 64=Golfclub, 128=Katana, 256=Knife, 512=Machete, 1024=Tonfa, 2048=Shield, 4096=Generic, 8192=Pitchfork, 16384=Shovel, 32767=All. Add numbers together.
l4d2_throwable_types "32767"

// 0=Off. 1=Play throw animation in first person view - causes screen tilt bug.
l4d2_throwable_view "1"

// Throwable Melee Weapons plugin version.
l4d2_throwable_version 


Changes:
Code:
1.21 (05-Jul-2022)
    - Fixed melee weapons glowing when equipped by players. Thanks to "BystanderZK" for reporting.
    - Fixed the "l4d2_throwable_types" cvar from following the wrong settings. Thanks to "moschinovac" for reporting.
    - Glow now enables 1 second after throwing to show the melee weapon can be picked up.
    - Thanks to "Marttt" for help testing and fixing.

    - Plugin is now compiled with SourceMod 1.11.

1.20 (16-Jun-2022)
    - Added notifications and translations when equipping melee weapons or hitting Survivors or killing Special Infected. Requested by "Voevoda".
    - Added cvar "l4d2_throwable_notify" to control notifications.
    - Added Russian translations, thanks to "Voevoda" for providing.

1.19 (06-Jan-2022)
    - Added each weapon types damage flags for slash and club. Requested by "Shao".

1.18 (01-Nov-2021)
    - Added cvar "l4d2_throwable_view" to enable/disable the throw animation in first person view that causes screen tilt bug.
    - Blocked throwing melee weapons if they that was their only held weapon/item. Thanks to "swiftswing1" for reporting.
    - Blocked throwing melee weapons if pinned or incapacitated.

1.17 (21-Sep-2021)
    - Fixed errors. Thanks to "Sev" for reporting.

1.16 (19-Sep-2021)
    - Fixed potentially blocking throwing on map changes.

1.15 (19-Sep-2021)
    - Now plays a throwing animation. Requested by "Sev".
    - Now removes the weapon glow when thrown (most of the time).
    - Now delays the throw slightly to hide the weapon being frozen when thrown.

1.14 (17-Sep-2021)
    - Fixed 1 line of code blocking unknown (generic) melee weapons from being used. Thanks to "swiftswing1" for reporting.

1.13 (20-Jun-2021)
    - Changed "SDKHook_WeaponSwitchPost" to read the "m_hActiveWeapon" netprop instead of using "weapon" from the callback.
    - When climbing ladders or being pinned "SDKHook_WeaponSwitchPost" returns the wrong weapon.
    - This should fix various issues such as not being able to throw after pinned or throwing after climbing while primary weapon is active.
    - Thanks to "SDArt" for reporting various issues.

1.12 (01-Oct-2020)
    - Fixed not verifying weapon reference and causing errors. Thanks to "SDArt" for reporting.

1.11 (30-Sep-2020)
    - Fixed compile errors on SM 1.11.
    - Fixed being able to throw while using something or climbing ladders.
    - To enable the new melee weapons, change cvar "l4d2_throwable_types" value adding the new ones.

1.10 (24-Sep-2020)
    - Compatibility update for L4D2's "The Last Stand" update.
    - Added support for the 2 new melee weapons.
    - Changed cvar "l4d2_throwable_types" to support the new types.
    - Updated data config "data/l4d2_throwable_melee.cfg" updated with the new Melee weapons.

1.9 (15-May-2020)
    - Replaced "point_hurt" entity with "SDKHooks_TakeDamage" function.

1.8 (10-May-2020)
    - Extra checks to prevent "IsAllowedGameMode" throwing errors.
    - Various changes to tidy up code.

1.7 (01-Apr-2020)
    - Fixed "IsAllowedGameMode" from throwing errors when the "_tog" cvar was changed before MapStart.

1.6 (29-Feb-2020)
    - Fixed throwing the melee weapon after switching weapon and back to melee. Thanks to "moschinovac" for reporting.

1.5 (26-Jan-2020)
    - To fix the Tonfa not working change "l4d2_throwable_types" value to "2047".

    - New feature: Throw distance - the longer you hold Zoom before releasing the further you throw. Requested by "MasterMind420".
    - Added cvar "l4d2_throwable_speed_max" to set a maximum throwing speed when holding MMB. Minimum speed set by "l4d2_throwable_speed".
    - Added cvar "l4d2_throwable_speed_time" to scale the throwing speed, how long the key must be held to reach maximum speed when letting go.
    - Changed cvar "l4d2_throwable_types" value to "2047" to include the missing Frying Pan option.
    - Boomerang type now verifies the players weapon slot is empty before equipping.
    - Optimized throwing event CPU cycles by validating weapon in WeaponSwitch.
    - Removed all commented out reference code.

1.4 (25-Jan-2020)
    - Fixed incorrect Linux gamedata signature causing crashing.
    - Fixed the "l4d2_throwable_types" cvar using the wrong index.
    - Fixed the Baseball Bat not working.
    - Fixed the Golfclub not playing any sounds.
    - Fixed the Tank not taking damage.
    - Fixed truncating damage values with 4 numbers to 3.
    - Fixed hitting when the melee is not moving or potentially not always hitting.
    - Fixed hitting yourself.
    - Removed TraceRay.

1.3 (24-Jan-2020)
    - Added cvar "l4d2_throwable_return" to enable a boomerang effect and return the weapon to thrower.
    - Added support for "Riot Shield" melee type and "Generic" - any 3rd party melee weapon.
    - Riot Shield requires extra scripts to enable, I do not support. You're on your own.
    - Data config changed to add the new types.
    - Changed from using max health cvars to reading the entities "m_iMaxHealth" value.
    - Fixed incorrect percentage calculation when using the "hits" damage type.
    - Replaced index numbers with enums for easier source readability.

1.2 (24-Jan-2020)
    - Added TraceRay to hit zombies directly in front of player. Thanks to "Lux" for suggesting.
    - Replaced optional VPhysics extension with gamedata method. Thanks to "BHaType" for suggesting.
    - Cvar "l4d2_throwable_spin" uses this method and requires the optional gamedata file.
    - Fixed damage not crediting the owner.

1.1 (22-Jan-2020)
    - Added correct data config.
    - Changed plugin to point to correct config.
    - Changed plugin to remove VPhysics extension for now, since optional is not working.

1.0 (22-Jan-2019)
    - Initial release.


Installation:
  1. Download the .zip and extract the files to their respective folders in your servers \addons\sourcemod\ folder.


Updating from 1.19 or older:
  • New cvars have been added: use the Cvar Configs Updater, or delete the old cvars config or manually add them.


Updating from 1.19 or older:
  • Optional translations have been added.

Current Translations: English (en), Russian (ru).
Attached Files
File Type: zip l4d2_throwable_melee.zip (35.5 KB, 723 views)
__________________

Last edited by Silvers; 07-04-2022 at 23:06.
Silvers is offline