RSSy MYGO.pl Opublikowano Listopad 28, 2019 o 08:44 RSSy Udostępnij Opublikowano Listopad 28, 2019 o 08:44 Hello, WeaponHanding API is a group of hooks to scale handing speeds of weapons with a multiplier with forwards. Little project i'v been working on for a while, hope you like.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 SM Dev team!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 speed animation to the "DeployDuration" keyvalue in weapon_*.txt) 0 = (ignore "DeployDuration" keyvalue in weapon_*.txt and matches deploy speed to animation speed) before being modified // - // Default: "1" // Minimum: "0.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" // 1 = (use "survivor_incapacitated_reload_multiplier" for incap reloading cycle rate) 0 = (ignores the cvar and uses default reload cycle rates) before being modified // - // Default: "1" // Minimum: "0.000000" // Maximum: "1.000000" wh_use_incap_reload_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 } /* * 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); /* * L4D2 only Affects pills/adrenaline use speed. * * @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); 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); return hWeaponClassnameHashMap; } stock L4D2WeaponType GetWeaponTypeFromClassname(const char[] sClassname) { static StringMap hWeaponClassnameHashMap; if(hWeaponClassnameHashMap == INVALID_HANDLE) hWeaponClassnameHashMap = CreateWeaponClassnameHashMap(hWeaponClassnameHashMap); static L4D2WeaponType WeaponType; if(!hWeaponClassnameHashMap.GetValue(sClassname, WeaponType)) return L4D2WeaponType_Unknown; return WeaponType; } Include notes Spoiler 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 not functional, is different to L4D2, L4D1 pills use speed looks to be in CPainPills::PrimaryAttack but I could not figure out how to read the countdown timer to change it, maybe someone else knows yes I used l4d2d_timers.inc and tried some stuff my self don't wanna read :(. 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. I tried to support l4d1 best I can, hope you like them :D Attached Files WeaponHandling.zip (21.0 KB) Wyświetl pełny artykuł Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi
Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto
Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.
Zarejestruj nowe konto
Załóż nowe konto. To bardzo proste!
Zarejestruj sięZaloguj się
Posiadasz już konto? Zaloguj się poniżej.
Zaloguj się