Raised This Month: $12 Target: $400
 3% 

[L4D2] Shotgun and bolt rifle fire rate and reload modification?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
a vehicle
New Member
Join Date: Mar 2021
Old 03-04-2021 , 11:42   [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #1

As you may know, the fire rate and reload speed for the pump shotguns and auto shotguns in L4D2 are hardcoded and can't be modified through weapon scripts, unlike all the other guns. The CS bolt action rifles also cannot have their fire rate modified (the reload can be, since they use detachable magazines).

Is it possible to make a SourceMod plugin that can change those properties of the weapons?
a vehicle is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 03-04-2021 , 14:20   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?p=2674761
sorallll is offline
a vehicle
New Member
Join Date: Mar 2021
Old 03-04-2021 , 14:41   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #3

Quote:
Originally Posted by sorallll View Post
If I'm reading it right, it would take a roundabout method to implement what I want using that weapon handling API.

In order to speed up the reload of the pump shotgun, I would need to:

1. Apply a speed modifier when the pump shotgun is reloading.

2. De-apply the speed modifier whenever anything else happens? And if I forget to check everything then it results in a bug/unintended behavior.

Isn't there a way to more directly modify the code of the pump shotgun specifically?

Last edited by a vehicle; 03-04-2021 at 17:05.
a vehicle is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 03-04-2021 , 14:57   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #4

The WeaponHandling API is already pretty direct with what you want. It hooks all the functions of the player's weapon and allows users to change the speed of those functions.

You can do something like this:
PHP Code:
#include <sourcemod>
#include <WeaponHandling>

public void WH_OnReloadModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_PumpshotgunL4D2WeaponType_PumpshotgunChromespeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_AutoshotgunL4D2WeaponType_AutoshotgunSpasspeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.5// 50% faster reload
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.5// 50% faster reload
    
}
}

public 
void WH_OnGetRateOfFire(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.25// 25% faster fire rate
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.25// 25% faster fire rate
    
}

The speed modifier is automatically applied for those two specific situations (reloading and rate of fire) so you don't have to remove the modifier "whenever anything else happens" because the WeaponHandling API takes care of all that.
__________________
Psyk0tik is offline
sbeve
Junior Member
Join Date: Feb 2021
Old 03-16-2021 , 23:40   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #5

Quote:
Originally Posted by Crasher_3637 View Post
The WeaponHandling API is already pretty direct with what you want. It hooks all the functions of the player's weapon and allows users to change the speed of those functions.

You can do something like this:
PHP Code:
#include <sourcemod>
#include <WeaponHandling>

public void WH_OnReloadModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_PumpshotgunL4D2WeaponType_PumpshotgunChromespeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_AutoshotgunL4D2WeaponType_AutoshotgunSpasspeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.5// 50% faster reload
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.5// 50% faster reload
    
}
}

public 
void WH_OnGetRateOfFire(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.25// 25% faster fire rate
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.25// 25% faster fire rate
    
}

The speed modifier is automatically applied for those two specific situations (reloading and rate of fire) so you don't have to remove the modifier "whenever anything else happens" because the WeaponHandling API takes care of all that.

You have no idea how thankful I am. I've been looking for a plugin that does exactly this (on and off, half-assedly) since 2017. I was literally writing up a request about this until I decided to take yet another look at previous post mentioning shotguns reload before submitting. The fact this this was never made before baffles me.
sbeve is offline
SEGA EMPRESS ERIS
Senior Member
Join Date: Sep 2010
Location: THE-MILKY-WAY-GALAXY
Old 04-09-2021 , 23:50   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #6

PHP Code:
#include <sourcemod>
#include <WeaponHandling>

public void WH_OnReloadModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_PumpshotgunL4D2WeaponType_PumpshotgunChromespeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_AutoshotgunL4D2WeaponType_AutoshotgunSpasspeedmodifier speedmodifier 1.25// 25% faster reload
    
}

OK I tried this but it doesnt compile, how to get it to compile to play around with reload values in the game? i also had the weaponhandling plugin installed.
__________________
SEGA EMPRESS ERIS is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 04-10-2021 , 00:06   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #7

I compiled that exact code and it worked just fine. Make sure you have WeaponHandling.inc inside your include folder.
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// test.sp
//
// Code size:             3676 bytes
// Data size:             2328 bytes
// Stack/heap size:      16384 bytes
// Total requirements:   22388 bytes
//
// Compilation Time: 0.14 sec
// ----------------------------------------

Press enter to exit ...
__________________
Psyk0tik is offline
SEGA EMPRESS ERIS
Senior Member
Join Date: Sep 2010
Location: THE-MILKY-WAY-GALAXY
Old 04-10-2021 , 02:34   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #8

PHP Code:
include <sourcemod>
#include <WeaponHandling>

public void WH_OnReloadModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_Pumpshotgunspeedmodifier speedmodifier 1.25// 25% faster reload

        
case L4D2WeaponType_Autoshotgunspeedmodifier speedmodifier 1.25// 25% faster reload
    
}

Sweet! got it to work with your suggestion. 1 last thing. Do u know if its possible to make the SPAS-12 Shotgun and Chrome Shotgun fire 1 bullet/pellet as opposed to 9 or so pellets and have sniper/smg/assault rifle accuracy in other words, making it a Slug Ammunition Shotgun?

Thanks.
__________________
SEGA EMPRESS ERIS is offline
AzureStars
Member
Join Date: May 2016
Location: Milky Way
Old 10-18-2021 , 13:06   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #9

Quote:
Originally Posted by Psyk0tik View Post
The WeaponHandling API is already pretty direct with what you want. It hooks all the functions of the player's weapon and allows users to change the speed of those functions.

You can do something like this:
PHP Code:
#include <sourcemod>
#include <WeaponHandling>

public void WH_OnReloadModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_PumpshotgunL4D2WeaponType_PumpshotgunChromespeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_AutoshotgunL4D2WeaponType_AutoshotgunSpasspeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.5// 50% faster reload
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.5// 50% faster reload
    
}
}

public 
void WH_OnGetRateOfFire(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.25// 25% faster fire rate
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.25// 25% faster fire rate
    
}

The speed modifier is automatically applied for those two specific situations (reloading and rate of fire) so you don't have to remove the modifier "whenever anything else happens" because the WeaponHandling API takes care of all that.
This works fantastic the only issue i have with it is it only applies to first person gameplay.
In 3rd person the reload speed is normal even when i got them set much much faster.

Can you add 3rd person code to this at all please i'd really appreciate it

Last edited by AzureStars; 10-18-2021 at 21:05.
AzureStars is offline
AzureStars
Member
Join Date: May 2016
Location: Milky Way
Old 10-18-2021 , 21:25   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #10

I've just tested this again more, the shotguns animations seem to work fine and are just as fast in 3rd person as in 1st person.
I added most the other guns from the game to this script with 75% increase in speed for test and whilst they had fast reload in 1st person they were slow in 3rd person view.

Not really sure why only the shotgun animations reload faster in 3rd person and the others do not.

Can this script be adjusted to work fast for all guns in 3rd person view

Last edited by AzureStars; 10-18-2021 at 21:32.
AzureStars is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:29.


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