Raised This Month: $276 Target: $400
 69% 

[L4D/L4D2]WeaponHandling_API(25/09/2020 - 1.0.4)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Lux
Veteran Member
Join Date: Jan 2015
Location: Brexit
Plugin ID:
6827
Plugin Version:
1.0.4
Plugin Category:
Technical/Development
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    6 
    Plugin Description:
    Weapon Handling API for guns and melee weapons in left 4 dead
    Old 11-28-2019 , 03:44   [L4D/L4D2]WeaponHandling_API(25/09/2020 - 1.0.4)
    Reply With Quote #1

    Hello, WeaponHandling API is a group of hooks to scale handling speeds of weapons with a multiplier with forwards.

    Little project i'v been working on for a while, hope you like since it is nearly christmas here is a present.

    Thanks:

    Timocop: Using some code of your code.
    Silvers: Helping with stupid moments and advice.
    smlib: Thanks for smlib code and all contributors.
    DHooks: Thanks Peace-Maker & Dr!fter for their dhooks.
    SM Dev team: for sourcemod!
    ConfoglTeam: for timer learning.
    Convars These are for you,
    I made some fixes and changes to weapon handling, by default all of turned off, besides deploy modifier animation speed which valve forgot implement in their code e.g. in vanilla single pistol DeployDuration is a "0.5" modifier which is 2x faster than the animation shows.

    PHP Code:
    // 1 = (match deploy animation speed to the "DeployDuration" keyvalue in weapon_*.txt) 0 = (ignore "DeployDuration" keyvalue in weapon_*.txt and matches deploy speed to animation speed) before being modified -1(do nothing)
    // -
    // Default: "1"
    // Minimum: "-1.000000"
    // Maximum: "1.000000"
    wh_deploy_animation_speed "1"

    // 1 = (double pistol shoot at double speed of a single pistol 2~ shots persec slower than vanilla) 0 = (keeps vanilla cycle rate of 0.075) before being modified
    // -
    // Default: "0"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    wh_double_pistol_cycle_rate "0"

    // 1 = (use "survivor_incapacitated_cycle_time" for incap shooting cycle rate) 0 = (ignores the cvar and uses weapon_*.txt cycle rates) before being modified
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    wh_use_incap_cycle_cvar "1" 
    Code:
    WeaponHandling API has forwards for OnReloading, OnShooting, OnDeploy, OnMeleeSwing and OnThrowingThrowable, these are not proper forward names those are documented in the include file. 
    
    Little history:
    I needed something that was direct(is not reliant on events, events are usually after game actions) for modifying weapon handling stats that can eliminate cross plugin issues without too much work. One of the common issues with speeding up reloading is awful animation issues of double reload, this is because of internal timer for the reload finish timer, OnReloadModifier is called twice for reload modifier which we can change with entprops, second OnReloadFinish we cannot, not really looked into too much likely a countdown time. This will not beable to correct animation issues caused by prediction errors, since this is all server sided and latency is a thing!
    Include
    PHP Code:
    /*
    *    A typical example of stacking modifiers from different plugins is ->    speedmodifier = speedmodifier * yourmodifier
    *    Example to overwrite modifiers placed before ->                            speedmodifier = yourmodifier
    */

    enum L4D2WeaponType 
    {
        
    L4D2WeaponType_Unknown 0,
        
    L4D2WeaponType_Pistol,
        
    L4D2WeaponType_Magnum,
        
    L4D2WeaponType_Rifle,
        
    L4D2WeaponType_RifleAk47,
        
    L4D2WeaponType_RifleDesert,
        
    L4D2WeaponType_RifleM60,
        
    L4D2WeaponType_RifleSg552,
        
    L4D2WeaponType_HuntingRifle,
        
    L4D2WeaponType_SniperAwp,
        
    L4D2WeaponType_SniperMilitary,
        
    L4D2WeaponType_SniperScout,
        
    L4D2WeaponType_SMG,
        
    L4D2WeaponType_SMGSilenced,
        
    L4D2WeaponType_SMGMp5,
        
    L4D2WeaponType_Autoshotgun,
        
    L4D2WeaponType_AutoshotgunSpas,
        
    L4D2WeaponType_Pumpshotgun,
        
    L4D2WeaponType_PumpshotgunChrome,
        
    L4D2WeaponType_Molotov,
        
    L4D2WeaponType_Pipebomb,
        
    L4D2WeaponType_FirstAid,
        
    L4D2WeaponType_Pills,
        
    L4D2WeaponType_Gascan,
        
    L4D2WeaponType_Oxygentank,
        
    L4D2WeaponType_Propanetank,
        
    L4D2WeaponType_Vomitjar,
        
    L4D2WeaponType_Adrenaline,
        
    L4D2WeaponType_Chainsaw,
        
    L4D2WeaponType_Defibrilator,
        
    L4D2WeaponType_GrenadeLauncher,
        
    L4D2WeaponType_Melee,
        
    L4D2WeaponType_UpgradeFire,
        
    L4D2WeaponType_UpgradeExplosive,
        
    L4D2WeaponType_BoomerClaw,
        
    L4D2WeaponType_ChargerClaw,
        
    L4D2WeaponType_HunterClaw,
        
    L4D2WeaponType_JockeyClaw,
        
    L4D2WeaponType_SmokerClaw,
        
    L4D2WeaponType_SpitterClaw,
        
    L4D2WeaponType_TankClaw,
        
    L4D2WeaponType_Gnome
    }

    /*
    *    Fires for melee weapons
    *    
    *    @Param    client            Client Index
    *    @Param    weapon            Weapon Index
    *    @Param    speedmodifier    Current swing speed modifier, change this to manipulate swing speed e.g. 2.0 = 2x speed
    *    
    *    @noreturn
    */
    forward void WH_OnMeleeSwing(int clientint weaponfloat &speedmodifier);

    /*
    *    Fires for throwables
    *    e.g. when about to throw pipebomb 
    *    
    *    @Param    client            Client Index
    *    @Param    weapon            Weapon Index
    *    @Param    weapontype        Weapon Type
    *    @Param    speedmodifier    Current throw speed modifier, change this to manipulate throw speed e.g. 2.0 = 2x speed
    *    
    *    @noreturn
    */
    forward void WH_OnStartThrow(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier);

    /*
    *    Fires for throwables
    *    e.g. when winding up to throw pipebomb
    *    
    *    @Param    client            Client Index
    *    @Param    weapon            Weapon Index
    *    @Param    weapontype        Weapon Type
    *    @Param    speedmodifier    Current windup speed modifier, change this to manipulate windup speed e.g. 2.0 = 2x speed
    *    
    *    @noreturn
    */
    forward void WH_OnReadyingThrow(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier);

    /*
    *    @Param    client            Client Index
    *    @Param    weapon            Weapon Index
    *    @Param    weapontype        Weapon Type
    *    @Param    speedmodifier    Current reload speed modifier, change this to manipulate reload speed e.g. 2.0 = 2x speed
    *    
    *    @noreturn
    */
    forward void WH_OnReloadModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier);

    /*
    *    
    *    @Param    client            Client Index
    *    @Param    weapon            Weapon Index
    *    @Param    weapontype        Weapon Type
    *    @Param    speedmodifier    Current rate of fire speed modifier, change this to manipulate rate of fire e.g. 2.0 = 2x speed
    *    
    *    @noreturn
    */
    forward void WH_OnGetRateOfFire(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier);

    /*
    *    Does not trigger for chainsaw, gascan, propane, oxygentank, fireworks and gnome.
    *    
    *    @Param    client            Client Index
    *    @Param    weapon            Weapon Index
    *    @Param    weapontype        Weapon Type
    *    @Param    speedmodifier    Current deploy speed modifier, change this to manipulate deploy speed e.g. 2.0 = 2x speed
    *    
    *    @noreturn
    */
    forward void WH_OnDeployModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier);

    stock StringMap CreateWeaponClassnameHashMap(StringMap hWeaponClassnameHashMap)
    {
        
    hWeaponClassnameHashMap CreateTrie();
        
    hWeaponClassnameHashMap.SetValue("weapon_pistol"L4D2WeaponType_Pistol);
        
    hWeaponClassnameHashMap.SetValue("weapon_pistol_magnum"L4D2WeaponType_Magnum);
        
    hWeaponClassnameHashMap.SetValue("weapon_rifle"L4D2WeaponType_Rifle);
        
    hWeaponClassnameHashMap.SetValue("weapon_rifle_ak47"L4D2WeaponType_RifleAk47);
        
    hWeaponClassnameHashMap.SetValue("weapon_rifle_desert"L4D2WeaponType_RifleDesert);
        
    hWeaponClassnameHashMap.SetValue("weapon_rifle_m60"L4D2WeaponType_RifleM60);
        
    hWeaponClassnameHashMap.SetValue("weapon_rifle_sg552"L4D2WeaponType_RifleSg552);
        
    hWeaponClassnameHashMap.SetValue("weapon_hunting_rifle"L4D2WeaponType_HuntingRifle);
        
    hWeaponClassnameHashMap.SetValue("weapon_sniper_awp"L4D2WeaponType_SniperAwp);
        
    hWeaponClassnameHashMap.SetValue("weapon_sniper_military"L4D2WeaponType_SniperMilitary);
        
    hWeaponClassnameHashMap.SetValue("weapon_sniper_scout"L4D2WeaponType_SniperScout);
        
    hWeaponClassnameHashMap.SetValue("weapon_smg"L4D2WeaponType_SMG);
        
    hWeaponClassnameHashMap.SetValue("weapon_smg_silenced"L4D2WeaponType_SMGSilenced);
        
    hWeaponClassnameHashMap.SetValue("weapon_smg_mp5"L4D2WeaponType_SMGMp5);
        
    hWeaponClassnameHashMap.SetValue("weapon_autoshotgun"L4D2WeaponType_Autoshotgun);
        
    hWeaponClassnameHashMap.SetValue("weapon_shotgun_spas"L4D2WeaponType_AutoshotgunSpas);
        
    hWeaponClassnameHashMap.SetValue("weapon_pumpshotgun"L4D2WeaponType_Pumpshotgun);
        
    hWeaponClassnameHashMap.SetValue("weapon_shotgun_chrome"L4D2WeaponType_PumpshotgunChrome);
        
    hWeaponClassnameHashMap.SetValue("weapon_molotov"L4D2WeaponType_Molotov);
        
    hWeaponClassnameHashMap.SetValue("weapon_pipe_bomb"L4D2WeaponType_Pipebomb);
        
    hWeaponClassnameHashMap.SetValue("weapon_first_aid_kit"L4D2WeaponType_FirstAid);
        
    hWeaponClassnameHashMap.SetValue("weapon_pain_pills"L4D2WeaponType_Pills);
        
    hWeaponClassnameHashMap.SetValue("weapon_gascan"L4D2WeaponType_Gascan);
        
    hWeaponClassnameHashMap.SetValue("weapon_oxygentank"L4D2WeaponType_Oxygentank);
        
    hWeaponClassnameHashMap.SetValue("weapon_propanetank"L4D2WeaponType_Propanetank);
        
    hWeaponClassnameHashMap.SetValue("weapon_vomitjar"L4D2WeaponType_Vomitjar);
        
    hWeaponClassnameHashMap.SetValue("weapon_adrenaline"L4D2WeaponType_Adrenaline);
        
    hWeaponClassnameHashMap.SetValue("weapon_chainsaw"L4D2WeaponType_Chainsaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_defibrillator"L4D2WeaponType_Defibrilator);
        
    hWeaponClassnameHashMap.SetValue("weapon_grenade_launcher"L4D2WeaponType_GrenadeLauncher);
        
    hWeaponClassnameHashMap.SetValue("weapon_melee"L4D2WeaponType_Melee);
        
    hWeaponClassnameHashMap.SetValue("weapon_upgradepack_incendiary"L4D2WeaponType_UpgradeFire);
        
    hWeaponClassnameHashMap.SetValue("weapon_upgradepack_explosive"L4D2WeaponType_UpgradeExplosive);
        
    hWeaponClassnameHashMap.SetValue("weapon_boomer_claw"L4D2WeaponType_BoomerClaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_charger_claw"L4D2WeaponType_ChargerClaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_hunter_claw"L4D2WeaponType_HunterClaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_jockey_claw"L4D2WeaponType_JockeyClaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_smoker_claw"L4D2WeaponType_SmokerClaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_spitter_claw"L4D2WeaponType_SpitterClaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_tank_claw"L4D2WeaponType_TankClaw);
        
    hWeaponClassnameHashMap.SetValue("weapon_gnome"L4D2WeaponType_Gnome);
        return 
    hWeaponClassnameHashMap;
    }

    stock L4D2WeaponType GetWeaponTypeFromClassname(const char[] sClassname)
    {
        static 
    StringMap hWeaponClassnameHashMap;
        
        if(
    hWeaponClassnameHashMap == INVALID_HANDLE)
            
    hWeaponClassnameHashMap CreateWeaponClassnameHashMap(hWeaponClassnameHashMap);
        
        static 
    L4D2WeaponType WeaponType;
        if(!
    hWeaponClassnameHashMap.GetValue(sClassnameWeaponType))
            return 
    L4D2WeaponType_Unknown;
        
        return 
    WeaponType;


    Include notes
    Spoiler


    DemoPluign I'v attached a demo plugin that you can use to see how it works in speeding up actions.
    Spoiler


    RepoLink

    Requirements:
    DHooks (Experimental Dynamic Detour support)
    Installation: Of WeaponHandling

    1.Download the .zip file.
    2.Merge with \addons\ folder.
    3.Restart the server.
    Attached Files
    File Type: zip Demo plugin.zip (12.1 KB, 246 views)
    File Type: zip WeaponHandling.zip (22.4 KB, 49 views)
    __________________

    Last edited by Lux; 09-25-2020 at 11:19. Reason: Laststand update
    Lux is offline
    theproperson
    Member
    Join Date: Feb 2017
    Old 11-28-2019 , 08:37   Re: [L4D/L4D2]WeaponHandling_API
    Reply With Quote #2

    This is interesting. Didn't know valve had an issue in their weapon deployment speeds. I've been using custom weapon deploy speeds for years using a edit of the weapon script and adding

    "DeployDuration" "0.5" to guns and "DeployDuration" "0.01" to healing / grenades. Gives real smooth TF2 / COD item transition that compliments the hardcore mutations and custom behaving weapons I scripted up.
    theproperson is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 11-28-2019 , 08:46   Re: [L4D/L4D2]WeaponHandling_API
    Reply With Quote #3

    it was only the animation that was not scaled the real deploy speed is unchanged.
    Really bothed me that you shoot halfway through the deploy animation with pistols

    EDIT:
    Small update for l4d1.
    I forgot to not hook pills in l4d1 for use speed, this has corrected.
    __________________

    Last edited by Lux; 11-28-2019 at 08:57.
    Lux is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 12-03-2019 , 15:58   Re: [L4D/L4D2]WeaponHandling_API
    Reply With Quote #4

    So yea, Left4Downtown exists...

    If you use downtown you will need to redownload the zip file to get latest gamedata which allows them to work together at the date of this post.

    Thanks silvers.
    __________________

    Last edited by Lux; 12-03-2019 at 15:58.
    Lux is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 12-10-2019 , 20:28   Re: [L4D/L4D2]WeaponHandling_API(11/12/2019 - 1.0.3)
    Reply With Quote #5

    Update 1.0.3
    Added l4d1 pills use speed.

    This is to be called to forward "WH_OnGetRateOfFire()" like l4d2
    new gamedata required it's in the zip in OP.

    https://github.com/LuxLuma/Weapon_Ha...31e3d9204bdc72
    __________________
    Lux is offline
    xy9860
    Junior Member
    Join Date: Dec 2019
    Old 12-13-2019 , 04:19   Re: [L4D/L4D2]WeaponHandling_API(11/12/2019 - 1.0.3)
    Reply With Quote #6

    How can I hook throw weapon_propanetank event?
    xy9860 is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 12-13-2019 , 04:57   Re: [L4D/L4D2]WeaponHandling_API(11/12/2019 - 1.0.3)
    Reply With Quote #7

    Quote:
    Originally Posted by xy9860 View Post
    How can I hook throw weapon_propanetank event?
    Not really sure how to hook event for that.

    You can try using dhooks and hooking this function

    PHP Code:
    CCarriedProp::DropCarriedProp() 
    __________________

    Last edited by Lux; 12-13-2019 at 05:00.
    Lux is offline
    xZk
    Senior Member
    Join Date: Nov 2017
    Location: cl
    Old 01-04-2020 , 13:45   Re: [L4D/L4D2]WeaponHandling_API(11/12/2019 - 1.0.3)
    Reply With Quote #8

    great job!. Will it be possible to handling weapons of infected specials, claws or abilities?
    xZk is online now
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 01-04-2020 , 17:45   Re: [L4D/L4D2]WeaponHandling_API(11/12/2019 - 1.0.3)
    Reply With Quote #9

    Quote:
    Originally Posted by xZk View Post
    great job!. Will it be possible to handling weapons of infected specials, claws or abilities?
    Thanks, yes it's possible but not done yet the game likely reads the entprop values so should be easy enough whenever I get around to it ill update this thread.
    __________________
    Lux is offline
    gamer_kanelita
    Member
    Join Date: Jun 2019
    Location: Peru
    Old 01-09-2020 , 20:52   Re: [L4D/L4D2]WeaponHandling_API(11/12/2019 - 1.0.3)
    Reply With Quote #10

    you cannot extract any of the two zip files, since it does not recognize the files help
    gamer_kanelita 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 01:05.


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