AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [L4D2] Shotgun and bolt rifle fire rate and reload modification? (https://forums.alliedmods.net/showthread.php?t=331064)

a vehicle 03-04-2021 11:42

[L4D2] Shotgun and bolt rifle fire rate and reload modification?
 
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?

sorallll 03-04-2021 14:20

Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
 
https://forums.alliedmods.net/showthread.php?p=2674761

a vehicle 03-04-2021 14:41

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

Originally Posted by sorallll (Post 2739267)

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?

Psyk0tik 03-04-2021 14:57

Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
 
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.

sbeve 03-16-2021 23:40

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

Originally Posted by Crasher_3637 (Post 2739269)
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.

SEGA EMPRESS ERIS 04-09-2021 23:50

Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
 
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.

Psyk0tik 04-10-2021 00:06

Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
 
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 ...


SEGA EMPRESS ERIS 04-10-2021 02:34

Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
 
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.

AzureStars 10-18-2021 13:06

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

Originally Posted by Psyk0tik (Post 2739269)
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 :bee:

AzureStars 10-18-2021 21:25

Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
 
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 :?:


All times are GMT -4. The time now is 12:57.

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