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!
/*
* A typical example of stacking modifiers from different plugins is -> speedmodifier = speedmodifier * yourmodifier
* Example to overwrite modifiers placed before -> speedmodifier = yourmodifier
*/
/*
* 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 client, int weapon, float &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 client, int weapon, L4D2WeaponType weapontype, float &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 client, int weapon, L4D2WeaponType weapontype, float &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 client, int weapon, L4D2WeaponType weapontype, float &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 client, int weapon, L4D2WeaponType weapontype, float &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 client, int weapon, L4D2WeaponType weapontype, float &speedmodifier);
1. I'v included some useful stocks for performance friendly string checking of weapon classnames in l4d1 & 2 to output enum value.
2. L4D1 Pills use speed is now functional calls forward WH_OnGetRateOfFire().
3. These forwards are likely not safe to do much to clients in e.g. change weapon, stagger them, kill them, ect,
this is due to where parts are hooked and the game expects that kind of stuff later in post think ect.
4. Weapon SG552 firerate while zooming is "0.13500001",
to detect if someone is zoomed with the weapon check the FOV entprops which is what this function does CTerrorGun::IsOwnerZoomed.
5. Weapon Chainsaw deploy seems to have it's own internal timer somewhere, i'v not able to locate this , Rate of fire(hit interval) for chainsaw is a convar "chainsaw_hit_interval"
6. I tried to support l4d1 best I can, hope you like them
DemoPluign I'v attached a demo plugin that you can use to see how it works in speeding up actions.
Spoiler
This plugin speeds up weapon handling whenever you use Pain Pills and Adrenaline this concept already exists I think but it is just a demo
WeaponHandling.inc is required for compile.
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.
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.
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.