Raised This Month: $32 Target: $400
 8% 

[L4D2] Inject Adrenaline to your Teammates


Post New Thread Reply   
 
Thread Tools Display Modes
Author
xerox8521
Senior Member
Join Date: Sep 2011
Plugin ID:
7840
Plugin Version:
1.0.1
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
Servers with this Plugin:
18 
Plugin Description:
Allows the injection of Adrenaline on Teammates nearby
Old 10-31-2021 , 12:34   [L4D2] Inject Adrenaline to your Teammates
Reply With Quote #1

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
Attached Files
File Type: sp Get Plugin or Get Source (inject_adre.sp - 467 views - 10.2 KB)
File Type: smx inject_adre.smx (7.3 KB, 560 views)

Last edited by xerox8521; 10-31-2021 at 17:11. Reason: Update to Version 1.0.1
xerox8521 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 10-31-2021 , 13:47   Re: [L4D2] Inject Adrenaline to your Teammates
Reply With Quote #2

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.
__________________
Silvers is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 10-31-2021 , 17:10   Re: [L4D2] Inject Adrenaline to your Teammates
Reply With Quote #3

Update Version 1.0.1
- Updated the code with some more optimiziation. Thanks to Silvers
xerox8521 is offline
MilanesaTM
Junior Member
Join Date: Aug 2021
Old 11-01-2021 , 18:40   Re: [L4D2] Inject Adrenaline to your Teammates
Reply With Quote #4

Good job Xerox, thanks a lot!
MilanesaTM is offline
Kid_Bandes
Member
Join Date: May 2010
Old 11-03-2021 , 13:50   Re: [L4D2] Inject Adrenaline to your Teammates
Reply With Quote #5

Hi xerox, will it compatible with adrenaline powerup plugin?
Kid_Bandes is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 11-04-2021 , 12:10   Re: [L4D2] Inject Adrenaline to your Teammates
Reply With Quote #6

After checking the source of the mentioned Plugin and Left 4 DHooks Direct it should work in theory. I haven't tested it.
xerox8521 is offline
NoroHime
Veteran Member
Join Date: Aug 2016
Location: bed
Old 01-04-2022 , 01:34   Re: [L4D2] Inject Adrenaline to your Teammates
Reply With Quote #7

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
__________________
NoroHime is offline
Reply



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 08:36.


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