AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D2] Inject Adrenaline to your Teammates (https://forums.alliedmods.net/showthread.php?t=334981)

xerox8521 10-31-2021 12:34

[L4D2] Inject Adrenaline to your Teammates
 
2 Attachment(s)
Based on the idea by MilanesaTM found here

This Plugin allows you to inject adrenaline to nearby survivor teammates.

Works on any gamemode.

How to Inject:
  1. Have Adrenaline actively equipped
  2. Go close to a survivor teammate you whish to inject it to
  3. Hold the USE key (E by default) for 2 seconds (default)

ConVars:
  • inject_adrenaline_version - Version of the Plugin
  • inject_adrenaline_range - Maximum Distance between injector and receiver. If any player is beyond this range it will not inject. Default: 128.0
  • inject_adrenaline_duration - Time it takes until the adrenaline is injected. Default: 2.0

The duration of the adrenaline effect can be adjusted using the build in ConVar: adrenaline_duration


REQUIREMENTS:
This plugin requires Left 4 DHooks Direct to use and for compiling.

Installation:
Put the inject_adre.smx into addons/sourcemod/plugins
Load a different map or restart the server or use "sm plugins load inject_adre" in the server console.

Using Get Plugin will fail due to the dependency of Left 4 DHooks Direct

Silvers 10-31-2021 13:47

Re: [L4D2] Inject Adrenaline to your Teammates
 
Nice plugin!

Some suggestions:

It might be better to use SDKHook_WeaponSwitchPost to detect when holding adrenaline - (instead of using SDKHook_WeaponSwitchPost's "weapon" variable use this instead: weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); to detect the weapon correctly, sometimes the "weapon" variable SDKHooks returns is not actually current one and causes issues, e.g. I think on Ladders).

That optimizes it instead of constantly checking "IsCurrentWeaponAdrenaline". Also the current method is constantly creating "char szClassName[32];" which would be better to set as "static char szClassName[32];", but if you switch to SDKHooks method that would be even better.

Because "OnPlayerRunCmd" is called for every client connected practically every frame, it is required to optimize this as best as possible. For example check if they're pressing the key before validating the client, the else statement looks good because you're checking if IN_USE was pressed already.

You have this:
PHP Code:

        if(!IsNearby(clienttarget)) return Plugin_Continue;
            
        
// Client let go of button. Abort. 

I think that should be "if(IsNearby())" continue, otherwise it will reset if they are still nearby and not reset when they have moved far away. Not really gone over the logic in detail to know the full intention.

Your "Inject_Adrenaline" function could be optimized, and probably elsewhere, I haven't checked the whole plugin. For example in this function you return when "if(g_bInUse[client] == false)" - this should be at the top before you start using more expensive native calls etc such as in the function "IsValidInjector".

These optimizations become important on servers with many plugins/players/slow hardware. These types of optimizations become noticeable especially when more plugins are optimized like that.

xerox8521 10-31-2021 17:10

Re: [L4D2] Inject Adrenaline to your Teammates
 
Update Version 1.0.1
- Updated the code with some more optimiziation. Thanks to Silvers

MilanesaTM 11-01-2021 18:40

Re: [L4D2] Inject Adrenaline to your Teammates
 
Good job Xerox, thanks a lot! :D

Kid_Bandes 11-03-2021 13:50

Re: [L4D2] Inject Adrenaline to your Teammates
 
Hi xerox, will it compatible with adrenaline powerup plugin?

xerox8521 11-04-2021 12:10

Re: [L4D2] Inject Adrenaline to your Teammates
 
After checking the source of the mentioned Plugin and Left 4 DHooks Direct it should work in theory. I haven't tested it.

NoroHime 01-04-2022 01:34

Re: [L4D2] Inject Adrenaline to your Teammates
 
i love this idea,players always save that pills even floor has more,can you add support pills?
and i think injecting should stop teammate and self


All times are GMT -4. The time now is 04:48.

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