[L4D & L4D2] Survivor Utilities (API) (v 1.5.1) [19-Mar-23]
1 Attachment(s)
About:
I’m making some plugins that changes survivor speeds and adds effects (better freeze, intoxication, bleeding, ect), to prevent multiple calls and bugs between plugins making the same effect, and to prevent redundancy, I have done this plugin that acts as an API, to allow plugins to work well together.
If you want to make plugins using this, you are free to do, also you can install this plugin in your server and change global player speeds with convars (to acces to other features you need to use other plugins, that I will upload too when I complete them).
Description:
Survivor movement speed modify:
This plugin modifies survivor moving speeds, jump and fall speed don't change, so the speed effect feels more realistic. Current speeds that can be modified by ConVar:
Running speed.
Walking speed.
Crouch speed.
Moving speed on water.
Limping speed (when survivor health is lower than 40 by default).
Critical speed (probably will have other name, but this refers to the survivor speed when he has been incapacitated once and HP falls to 1).
Movement speed while using an sniper scope.
Exhaust speed (this is an API feature that will only be activated by other plugins).
Rules of how speeds are being assigned:
Run, walk or crouch speeds are independent, and won't restrict the others (you can set walk speed faster than run speed if you want).
If the survivor is having one or more conditions that decreases the main speed, it will set the most restrictive.
If a restrictive speed has a higher value than the main speed, it won't be applied, restrictive speeds don't boost main speeds.
Adrenaline will prevent survivors to lose speed due to restrictions, just like in the original game.
Other plugins can use the Natives provided in this plugin to change specific survivor speeds, for perks, RPG, or anything you can imagine.
IMPORTANT Changes in the speed system. The plugin now has 2 systems or kernels to modify survivor speeds:
1 - Legacy kernel:
It uses Left 4 DHooks forwards to change survivor speeds. It has a much lower chance to conflict with other plugins that change player speeds, since the method used is not very often used. But in the other hand speeds are restricted between 65 and 650 units. Any speed under 65 will make survivors stop moving, and values over 650 will have no effect. Moreover, when boosted players jump they will notice an strange push in the direction of their movement.
2 - New kernel:
This one doesn't require Left 4 DHooks, if you don't have that plugin installed, only this kernel will work. It uses the "m_flLaggedMovementValue" netprop to scale survivor speeds. This kernel will conflict with other plugins that uses the same system to scale speeds, but the limitations are removed, you can set speed value with this kernel without restrictions. This kernel works getting the mechanics from here.
What kernel should be used?
It depends of the situation, by default the new kernel is enabled and is the most recomended option, but in case you start experiencing incompatibilities with other plugins, you should use the legacy kernel.
Survivor conditions accesible from natives and forwards:
Bleeding: Survivors will lose health over time, bleeding can be stopped if the survivor uses a medkit.
Intoxication: Survivors will lose health over time due to an intoxication, it can be stopped if the survivor uses pain pills or adrenaline.
Improved freeze: Survivor is unable to move, shoot, reload or shove, also a screen effect is displayed while the survivor is frozen.
Exhaustion, while exhausted the survivor will lose movement speed, maxed shove penalty and increased recoil, a screen effect is displayed (thanks to Silvers for the fog_volume and postprocess code). Exhaust can be cancelled with adrenaline, also if the survivor doesn’t move will recover faster.
Health, defib and revive hooks.
Detoured survivor healing, reviving and defibrillating game functions.
Survivor revive heal or defib duration can be override with GlobalForwards.
Functions can also be blocked to prevent survivors to revive or perform healing.
// Removes freeze effect on survivor
native void SU_RemoveFreeze(int client);
// Bleeds a survivor
native void SU_AddBleed(int client, int amount);
// Removes bleeding on survivor
native void SU_RemoveBleed(int client);
// intoxicates a survivor
native void SU_AddToxic(int client, int amount);
// Removes intoxication on survivor
native void SU_RemoveToxic(int client);
// Changes de survivor movement speeds
native void SU_SetSpeed(int client, int speedType, const float amount);
// Exhausts a survivor
native void SU_AddExhaust(int client, int amount);
// Removes the exhaustion on survivor
native void SU_RemoveExhaust(int client);
// Return true if the survivor is frozen
native bool SU_IsFrozen(int client);
// Return true if the survivor is bleeding
native bool SU_IsBleeding(int client);
// Return true if the survivor in intoxicated
native bool SU_IsToxic(int client);
// Return true if the survivor is exhausted
native bool SU_IsExhausted(int client);
// Returns the survivor speed
native float SU_GetSpeed(int client, int speedType);
GlobalForwards
You can hook, change or even block plugin natives via GlobalForwards.
Spoiler
PHP Code:
// Called whenever SU_AddExhaust is invoked
forward Action SU_OnExhaust(int client);
// Post forwards, they are fired right after their normal forwards have been generated and hoooked.
// In the case the forward was blocked via Plugin_Handled, post forwards won't be fired.
// If the values have been changed via Plugin_Changed these forwards will show the changed values
// In case of Plugin_Continue, they will show the same results
forward void SU_OnExhaust_Post(int client, int amount, const bool overload);
forward void SU_OnFreeze_Post(int client, float time, const bool overload);
forward void SU_OnBleed_Post(int client, int amount, const bool overload);
forward void SU_OnToxic_Post(int client, int amount, const bool overload);
// Called whenever SU_AddFreeze is invoked.
forward Action SU_OnFreeze(int client, float& time);
// Called whenever SU_AddBleed is invoked.
forward Action SU_OnBleed(int client, int& amount);
// Called whenever SU_AddToxic is invoked.
forward Action SU_OnToxic(int client, int& amount);
// Called whenever SU_RemoveFreeze is invoked.
forward void SU_OnFreezeEnd(int client);
// Called whenever SU_RemoveBleed is invoked.
forward void SU_OnBleedEnd(int client);
// Called whenever SU_RemoveToxic is invoked.
forward void SU_OnToxicEnd(int client);
// Called whenever SU_RemoveExhaust is invoked.
forward void SU_OnExhaustEnd(int client);
// Called when a survivor is using a defibrillator
forward Action SU_OnDefib(int client, int targetModel, float& duration);
// Called when a survivor revives another one
forward Action SU_OnRevive(int client, int target, float& duration);
// Called when a survivor heals with a first aid kit
forward Action SU_OnHeal(int client, int target, float& duration);
ConVars:
Spoiler
PHP Code:
// Amount of bleeding damage dealed to survivors.
// -
// Default: "1.0"
// Minimum: "1.000000"
sm_su_bleed_damage "1.0"
// Delay in seconds between bleed damages.
// -
// Default: "5.0"
// Minimum: "0.100000"
sm_su_bleed_delay "5.0"
// What should plugin do with bleed amount if a player is bleeding again?
// 0 = Don't override amount.
// 1 = Override if new amount is higher.
// 2 = Add new amount to the original one.
// 3 = Allways override amount.
// -
// Default: "2"
// Minimum: "0.000000"
// Maximum: "3.000000"
sm_su_bleed_override "2"
// Survivor speed when 1 HP afer one incapacitation.
// -
// Default: "85.0"
// Minimum: "65.000000"
sm_su_critical_speed "85.0"
// Survivor speed when exhausted by plugin.
// -
// Default: "115.0"
// Minimum: "110.000000"
sm_su_exhaust_speed "115.0"
// What should plugin do with freeze time if a player is frozen again?
// 0 = Don't change original freeze time.
// 1 = Change original freeze time if new time is higher.
// 2 = Add the new freeze time to the original time.
// 3 = Override original time.
// -
// Default: "2"
// Minimum: "0.000000"
// Maximum: "3.000000"
sm_su_freeze_override "2"
// Amount of toxic damage dealed to survivors.
// -
// Default: "1.0"
// Minimum: "1.000000"
sm_su_toxic_damage "1.0"
// Delay in seconds between toxic damages.
// -
// Default: "5.0"
// Minimum: "0.100000"
sm_su_toxic_delay "5.0"
// What should plugin do with toxic amount if a player is intoxicated again?
// 0 = Don't override amount.
// 1 = Override if new amount are higher.
// 2 = Add new amount to the remaining amount.
// 3 = Allways override amount.
// -
// Default: "2"
// Minimum: "0.000000"
// Maximum: "3.000000"
sm_su_toxic_override "2"
// Survivor speed while in water.
// -
// Default: "115.0"
// Minimum: "80.000000"
sm_su_water_speed "115.0"
// 0 = Use new speed kernel, unlimited speeds, less bugs.
// 1 = Use legacy (old) speed kernel: Less conflict with other plugins that may modify speeds by their own.
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sm_su_legacy_kernel "0"
- Left 4 DHooks dependency is now optional.
- Added a new system/kernel to change survivor speeds.
- Improved overall speed calculation performance.
- Removed unused dependences.
- Removed speed ConVar limits, now speed settings are completely free with the new speed kernel.
1.4 (23-Sep-2022)
- Added Post forwards for plugin events.
- Fixed missing natives in L4D.
1.3.5 (09-Sep-2022)
- Fixed error when attempting to check adrenaline in L4D games (thanks to Dominatez for reporting).
1.3.4 (28-Jun-2022)
- Fixed errors when zombie control transferred between bots and players in infected team.
1.3.3 (22-Jun-2022)
- Fixed a bug where adrenaline speed overrided crouch, walk and scope speeds.
1.3.2 (19-Jun-2022)
- Fixed water speed not getting settings from the right ConVar.
- Minor optimizations.
1.3.1 (16-Jun-2022)
- Fixed some possible bugs with timers.
- Removed public function declarations where the weren't needed.
- In L4D2, medkit ConVar is reset with a post DHook instead of using a RequestFrame.
1.3 (01-Feb-2022)
- Fixed adrenaline and scoping movement speed being overrided by run or limping speed.
- Both adrenaline and scoping movement speed are controlled by CVar and accessed by Natives.
- SU_AddExhaust now throws an error if client is under adrenaline effect. This prevents API consistency errors.
- If speed ConVars are changed ingame, survivor custom speeds will scale proportionally instead of being overrided.
1.2.2 (23-Jan-2022)
- Exhaustion extra recoil added to survivors now can be scaled or disabled by ConVar(thanks to Shao for the request).
1.2.1 (20-Jan-2022)
- Fixed errors when shoving a common infected with first aid kit in L4D2 (thanks to Sev for reporting).
- Fixed fakely triggering of SU_OnHeal when a survivor shoves an special infected with first aid kit in L4D2.
1.2 (18-Jan-2022)
- Added detouring for game functions:
* Healing.
* Reviving survivors.
* Defib survivors (L4D2).
- Detours allow to modify backpack usage, healing and revive duration, and block events.
- Minor optimizations.
1.1.2 (09-Jan-2022)
- Blocked plugin error messages when a survivor joins infected team (thanks to Sev for reporting).
1.1.1 (01-Jan-2022)
- Fixed timer Handle errors.
1.1 (30-Dec-2021)
- Fixed a bug where survivor limp speed was not being applied.
- Survivor speeds are correctly reset on round restart.
- Improved native error trhow messages.
- Survivor status now is paused if the survivor goes idle, it will be resumed after survivor joins back.
- SU_AddExhaust now requires a second parameter, token amount (read survivorutilities.inc for more info).
- SU_AddExhaust now allows to stack exhaust tokens or override, like the other effects.
1.0.3 (25-Dec-2021)
- Removed debugging messages.
1.0.2 (25-Dec-2021)
- Changed default override values from 1 to 2.
- Fixed ConVar descriptions.
1.0.1 (25-Dec-2021)
- Fixed missing config file.
1.0 (25-Dec-2021)
- Initial release.
Earendil
12-24-2021 23:23
Re: [L4D & L4D2] Surivor Utilities (API)
I'm making some plugins to show how to take the benefit of this utility:
Survivor Sprint, Stamina and Exhaustion Use this one as a guide of how to manipulate player speeds. Since Natives change player absolute speed, this plugins doesn't override permanently the survivor speed of other plugins.
a2121858
12-26-2021 21:55
Re: [L4D & L4D2] Surivor Utilities (API) (v 1.0.3) [25-Dec-21]
Thank you for your gift.:3
thewintersoldier97
12-27-2021 05:38
Re: [L4D & L4D2] Surivor Utilities (API) (v 1.0.3) [25-Dec-21]
Wow, very nice plugin :D Great work Earendil!
Earendil
12-30-2021 07:48
Re: [L4D & L4D2] Survivor Utilities (API) (v 1.1) [30-Dec-21]
New update to 1.1
Now you can add an exhaustion amount to survivors. Any plugin compiled with an older version will still work, exhaustion can be stacked just like the other effects. Also I fixed some bugs.
Earendil
01-01-2022 20:12
Re: [L4D & L4D2] Survivor Utilities (API) (v 1.1.1) [01-Jan-21]
Ok I was messing everything with timers. Now they are fixed and no Handle errors related to timers should appear.
Sev
01-04-2022 05:56
Re: [L4D & L4D2] Survivor Utilities (API) (v 1.1.1) [01-Jan-21]
L 01/03/2022 - 17:33:34: [SM] Exception reported: SU_GetSpeed Error: Client 9 is not survivor.
L 01/03/2022 - 17:33:34: [SM] Blaming: l4d_survivor_utilities.smx
L 01/03/2022 - 17:33:34: [SM] Call stack trace:
L 01/03/2022 - 17:33:34: [SM] [0] ThrowNativeError
L 01/03/2022 - 17:33:34: [SM] [1] Line 1160, l4d_survivor_utilities.sp::Native_GetFreeze
L 01/03/2022 - 17:33:34: [SM] [3] SU_IsFrozen
L 01/03/2022 - 17:33:34: [SM] [4] Line 361, l4d_survivor_utilities.sp::Event_Player_Repla ced
Earendil
01-06-2022 18:24
Re: [L4D & L4D2] Survivor Utilities (API) (v 1.1.1) [01-Jan-21]
Quote:
Originally Posted by Sev
(Post 2767603)
L 01/03/2022 - 17:33:34: [SM] Exception reported: SU_GetSpeed Error: Client 9 is not survivor.
L 01/03/2022 - 17:33:34: [SM] Blaming: l4d_survivor_utilities.smx
L 01/03/2022 - 17:33:34: [SM] Call stack trace:
L 01/03/2022 - 17:33:34: [SM] [0] ThrowNativeError
L 01/03/2022 - 17:33:34: [SM] [1] Line 1160, l4d_survivor_utilities.sp::Native_GetFreeze
L 01/03/2022 - 17:33:34: [SM] [3] SU_IsFrozen
L 01/03/2022 - 17:33:34: [SM] [4] Line 361, l4d_survivor_utilities.sp::Event_Player_Repla ced
Did it happen in VS mode? I think it happened due to team change, I will take a look.
Sev
01-07-2022 05:03
Re: [L4D & L4D2] Survivor Utilities (API) (v 1.1.1) [01-Jan-21]
Quote:
Originally Posted by Earendil
(Post 2767819)
Did it happen in VS mode? I think it happened due to team change, I will take a look.
Probably. I admittedly only retrieved the error from my logs but I have noticed some VS games lately on my server, so it was probably in that mode.
Earendil
01-09-2022 18:09
Re: [L4D & L4D2] Survivor Utilities (API) (v 1.1.1) [01-Jan-21]
Quote:
Originally Posted by Sev
(Post 2767853)
Probably. I admittedly only retrieved the error from my logs but I have noticed some VS games lately on my server, so it was probably in that mode.
I added a check when a player is replaced by a bot when survivors change teams. This error message was harmless, like some of them, but they are there to point when a plugin is trying to get incorrect data from players, like it happened with that message error.
EDIT: I'm adding a bigger update that will allow plugins to modify revive/heal/defib duration per player and also scale healing animations (the animation part is almost done).