AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D1 & L4D2] Weapon Auto Fire [v1.0.9 | 07-March-2021] (https://forums.alliedmods.net/showthread.php?t=327919)

Marttt 10-16-2020 19:20

[L4D1 & L4D2] Weapon Auto Fire [v1.0.9 | 07-March-2021]
 
20 Attachment(s)
Description

This plugin allows you to continue shooting while holding the attack button (M1), like if the client was repeatedly pressing it.

The weapons below don't have this feature by default, so if you keep holding the attack button, it does nothing:
  • All Pistols
  • All Snipers
  • Pump and Chrome Shotguns
  • Grenade Launcher

I made it based on these plugins:

Features
  • Allow configuring which weapons should have the auto fire turned on.
  • Allow configuring the delay in frames to auto fire.
  • Enable auto fire on weapon switch.
  • Enable auto fire after releasing a minigun/50 cal.
  • Enable auto-reload for shotguns.

Cvars

A configuration file named "l4d_weapon_auto_fire.cfg" will automatically be created for you upon the first run in the "\cfg\sourcemod\" folder.

PHP Code:

// Auto fire for Auto Shotgun.
// Already has auto fire on vanilla.
// Enabling makes it fire faster.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_auto_shotgun "1"

// How many frames must wait to enable auto fire for Auto Shotgun.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_auto_shotgun_frame "0"

// Auto fire for Dual Pistol.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_dual_pistol "1"

// Force dual pistol fire sound to the shooter while on auto-fire.
// Other clients aren't affected. The first shot is ignored.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_dual_pistol_force_sound "1"

// How many frames must wait to enable auto fire for Dual Pistol.
// 0 = Instantly on "weapon_fire".
// -
// Default: "3"
// Minimum: "0.000000"
l4d_weapon_auto_fire_dual_pistol_frame "3"

// Enable/Disable the plugin.
// 0 = Disable, 1 = Enable.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_enable "1"

// Auto fire for Grenade Launcher.
// L4D2 only.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_grenade_launcher "1"

// How many frames must wait to enable auto fire for Grenade Launcher.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_grenade_launcher_frame "0"

// Auto fire for Hunting Rifle.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_hunting_rifle "1"

// How many frames must wait to enable auto fire for Hunting Rifle.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_hunting_rifle_frame "0"

// Auto fire on Machine Guns (Minigun/50cal) release.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_machine_gun_release "1"

// Auto fire for Pistol.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_pistol "1"

// Force pistol fire sound to the shooter while on auto-fire.
// Other clients aren't affected. The first shot is ignored.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_pistol_force_sound "1"

// How many frames must wait to enable auto fire for Pistol.
// 0 = Instantly on "weapon_fire".
// -
// Default: "3"
// Minimum: "0.000000"
l4d_weapon_auto_fire_pistol_frame "3"

// Auto fire for Pistol Magnum.
// L4D2 only.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_pistol_magnum "1"

// How many frames must wait to enable auto fire for Pistol Magnum.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_pistol_magnum_frame "0"

// Auto fire for Pump Shotgun.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_pump_shotgun "1"

// How many frames must wait to enable auto fire for Pump Shotgun.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_pump_shotgun_frame "0"

// Auto fire for Chrome Shotgun.
// L4D2 only.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_shotgun_chrome "1"

// How many frames must wait to enable auto fire for Chrome Shotgun.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_shotgun_chrome_frame "0"

// Auto shotgun reload when the ammo clip is empty.
// 0 = OFF, 1 = ON, 2 = Enable but forces full reload.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "2.000000"
l4d_weapon_auto_fire_shotgun_reload_empty "1"

// Auto fire for Spas Shotgun.
// L4D2 only.
// Already has auto fire on vanilla.
// Enabling makes it fire faster.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_shotgun_spas "1"

// How many frames must wait to enable auto fire for Spas Shotgun.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_shotgun_spas_frame "0"

// Auto fire for AWP Sniper.
// L4D2 only.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_sniper_awp "1"

// How many frames must wait to enable auto fire for AWP Sniper.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_sniper_awp_frame "0"

// Auto fire for Military Sniper.
// L4D2 only.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_sniper_military "1"

// How many frames must wait to enable auto fire for Military Sniper.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_sniper_military_frame "0"

// Auto fire for Scout Sniper.
// L4D2 only.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_sniper_scout "1"

// How many frames must wait to enable auto fire for Scout Sniper.
// 0 = Instantly on "weapon_fire".
// -
// Default: "0"
// Minimum: "0.000000"
l4d_weapon_auto_fire_sniper_scout_frame "0"

// Auto fire on weapon switch.
// 0 = OFF, 1 = ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_weapon_auto_fire_weapon_switch "1" 

Admin Commands
  • sm_print_cvars_l4d_weapon_auto_fire => Print the plugin related cvars and their respective values to the console. (z flag required)

Change Log

Spoiler


Known issues
  • Depending on the ping, the client may experience sound and animations bugs. Pistols (Normal/Dual/Magnum) are more noticeable to this issue.

Notes
  • You can achieve a similar behavior (without plugin) by clicking fast the attack button while shooting with these weapons.
  • Frames runs approximately every 0.1 seconds on a 30 tick rate server (thanks "Lux"). If you run in a different tick rate you may have to change the "*_frame" cvar values.
  • The config is based on frames and not by gametime cause it's really hard to calculate how many milisseconds are necessary to see some changes and during my tests with gametime it reproduced inconsistent and random behaviors even with the "right" values.
  • Is possible to simulate some "lag" behaviors by using "net_fakelag <value>" in the console. I usually use a value of 100 to test.
  • Shotgun full reload may cause animation glitches cause of the client-side prediction. If you turn of the prediction (cl_predict 0) it will work more smoothy but I don't recomend cause it has some bad side-effects.
  • Auto and Spas Shotguns already do auto fire by default, but with the cvar enabled, their fire rate is increased. (increasing their respective *_frame cvars, can cancel this behavior)
  • SMGs (SMG Uzi, SMG Silenced, SMG MP5) and Rifles (M16, Desert, AK47, SG552, M60) already does auto fire in vanilla, so this plugin just ignore them.

Understanding the frame cvars calculation (thanks "Lux")

Code:

Example:

l4d_weapon_auto_fire_pistol_frame "3"

At tickrate @30 (default):
Next auto fire = GetGameTime + (0.033 * 3)

At tickrate @60:
Next auto fire = GetGameTime + (0.0165 * 3)

Formula:
GetGameTime + (GetTickInterval * 3)

To Do
  • Enable auto fire for SI.
  • Enable auto fire while on shoving penalty.
  • Make dual pistols shoot at the same time.

Thank you!

Related Plugins

Post Reply
  • Any feedback, bug reports, fixes, improvements, translations or suggestions for the plugin are welcome.

Installation
  • Put the "l4d_weapon_auto_fire.smx" file (click Get Plugin) in your "\addons\sourcemod\plugins\" folder.

Psyk0tik 10-16-2020 20:07

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.0 | 16-October-2020]
 
Oooh sounds like an interesting plugin! Combine this with Silvers' Reload Interrupt plugin and you can have fully automated weapons with just the use of ONE button.

ReCreator 10-17-2020 06:16

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.0 | 16-October-2020]
 
Pistols starts shooting faster then m16) if it possible to make some delay it would be great)

Marttt 10-19-2020 02:43

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.1 | 19-October-2020]
 
1.0.1 (19-October-2020)
- Added new cvars to control frame delays of each weapon.
- Nerfed the pistols shooting speed.

KRUTIK 10-27-2020 01:03

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
 
The plugin is super, thanks.

Lux 10-27-2020 13:42

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
 
Why do you count frames?

You should be using gametime instead of frames(tick) for auto fire, this will make it not dependent on a being a fixed tickrate.

Marttt 10-27-2020 14:10

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
 
I had some bugs when I started using GameTime, that way it worked smoother. Thanks

Lux 10-27-2020 15:22

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
 
Here is the issue when i tested it the pistol autofire was faster on 60ticks, current method makes the convars inconsistent because of framecounting when game's tickrate is altered.

PHP Code:

l4d_weapon_auto_fire_pistol_frame "3"
Translates to at default tickrate @30

Next auto fire 
GetGameTime + (0.033 3)

At tickrate @60
Next auto fire 
GetGameTime + (0.0165 3)

Formula
GetGameTime 
+ (GetTickInterval 3

If you had bugs using gametime you are using it wrong, gametime is how weapon firerates are calculated internally and nearly everything else bound to a tick.

Edit:
In any case you know how a tick works, I simply wanted to help you by informing you how a tick works and it's not always same tickrate you will deal with most people how no idea that it can affect plugins like this.

MasterMe 10-27-2020 18:08

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
 
Quote:

Originally Posted by Marttt (Post 2721566)
Depending on the ping, the client may experience sound and animations bugs. Pistols (Normal/Dual/Magnum) are more noticeable to this issue.

I tested with a dedicated server on my LAN and indeed ran into this issue. But even if I change the cvar so pistols shoot pretty slow (I can click faster) there is only a sound the first time the weapon fires.

Guessing this a client bug, thoughts?

Edit: If this happens so consistently, maybe the server can force the client to play the pistol fire sound on from the second shot onwards?

MasterMe 11-02-2020 22:09

Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
 
I think this plugin is causing issues with the mounted minigun and 50cal, the behaviour when shooting those is as if you are tap firing instead of constantly firing. Guessing it needs some special handling for this, could you check?


All times are GMT -4. The time now is 14:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.