AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D2] Meteor Hunter (https://forums.alliedmods.net/showthread.php?t=326432)

rekcah 07-31-2020 00:04

[L4D2] Meteor Hunter
 
1 Attachment(s)
i was trying to think of ways to give infected players new abilities that can also encourage them to play with a higher level of skill.

this plugin rewards hunters who can pull off long distance pounces.

when a hunter lands a pounce with a distance over 500 it creates an impact crater, plays an explosion sound, flings all survivors in the area away and they take 20 damage.

i left in my testing command !testhit that admins can use to see what it actually does when a hunter lands.

KRUTIK 07-31-2020 09:11

Re: [L4D2] Meteor Hunter
 
when compiled on 1.9 E:\sourcemod\addons\sourcemod\scripting\meteo r hunter.sp(24) : warning 203: symbol is never used: "hunter"

HarryPotter 08-04-2020 15:27

Re: [L4D2] Meteor Hunter
 
wait, you have signature?
so this plugin only works in linux?
PHP Code:

stock L4D2_Fling(targetFloat:vector[3], attackerFloat:incaptime 3.0)
{
    new 
Handle:MySDKCall INVALID_HANDLE;    
    
StartPrepSDKCall(SDKCall_Player);
    
PrepSDKCall_SetSignature(SDKLibrary_Server"@_ZN13CTerrorPlayer5FlingERK6Vector17PlayerAnimEvent_tP20CBaseCombatCharacterf"0);

    
PrepSDKCall_AddParameter(SDKType_VectorSDKPass_ByRef);
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
    
PrepSDKCall_AddParameter(SDKType_CBasePlayerSDKPass_Pointer);
    
PrepSDKCall_AddParameter(SDKType_FloatSDKPass_Plain);

    
MySDKCall EndPrepSDKCall();
    if(
MySDKCall == INVALID_HANDLE)
    {
        
LogError("Could not prep the Fling function");
    }
    
    
SDKCall(MySDKCalltargetvector76attackerincaptime); //76 is the 'got bounced' animation in L4D2



Silvers 08-04-2020 17:17

Re: [L4D2] Meteor Hunter
 
This code is really really bad sorry to say.

1. Old syntax.
2. Hard coding signatures is bad, use a gamedata file.
3. Your "MySDKCall" is leaking handles, you should only prep the SDKCalls in plugin start storing handle in global variable. Right now you're constantly prepping on use which is bad.
4. See left4dhooks for windows and linux signature, why are you only including linux signature? These have been known for ages.
5. You're leaking the TR_TraceRayFilterEx handle - creating memory leak.
6. Redundant "IsValidEntity" check in player loop.
7. Using old "PrecacheParticle" method, see any of my plugins with effects for better method.
8. Using old "HurtEntity" method, see various plugins of mine for "SDKHooks_TakeDamage" method.
9. Not using entity references in timers to delete entities (so you'll inadvertently delete something else).
10. Using "return Plugin_Stop" in timer callback when it's not a repeating timer, unnecessary.
11. You have multiple warnings: "warning 234: symbol "FloatMul" is marked as deprecated: This native is internal implementation. For multiplication use the '*' operator."
12. Your "Plugin myinfo" section is weirdly placed half way through the script, standard practice is at the top of script.

rekcah 08-05-2020 02:56

Re: [L4D2] Meteor Hunter
 
added the window signatures and fixed a few of the other issues silvers listed.
my code is still probably pretty bad tho

HarryPotter 08-05-2020 07:17

Re: [L4D2] Meteor Hunter
 
I love the idea of this plugin, and want to put it in my server, so I remake code.
Hope you don't mind.

Updated:
Remake code, thanks to Silvers and Lux

-Convar-
Spoiler


-Edit-
Latest version always here

Silvers 08-05-2020 15:02

Re: [L4D2] Meteor Hunter
 
@fbef0102: your version is leaking handles in "CreateRing" - missing "delete hPack".

HarryPotter 08-05-2020 15:48

Re: [L4D2] Meteor Hunter
 
Quote:

Originally Posted by Silvers (Post 2713129)
@fbef0102: your version is leaking handles in "CreateRing" - missing "delete hPack".

Mabye I got wrong, I thought CreateTimer would automatically delete hPack,
do not need to call CloseHandle() only when using "CreateDataTimer"?

Lux 08-05-2020 15:56

Re: [L4D2] Meteor Hunter
 
Quote:

Originally Posted by fbef0102 (Post 2713136)
Mabye I got wrong, I thought CreateTimer would automatically delete hPack,
do not need to call CloseHandle() only when using "CreateDataTimer"?

PHP Code:

CreateTimer(0.3,CreateRing,hbPack,TIMER_FLAG_NO_MAPCHANGE|TIMER_DATA_HNDL_CLOSE); 

PHP Code:

#define TIMER_REPEAT            (1<<0)      /**< Timer will repeat until it returns Plugin_Stop */
#define TIMER_FLAG_NO_MAPCHANGE (1<<1)      /**< Timer will not carry over mapchanges */
#define TIMER_HNDL_CLOSE        (1<<9)      /**< Deprecated define, replaced by below */
#define TIMER_DATA_HNDL_CLOSE   (1<<9)      /**< Timer will automatically call CloseHandle() on its data when finished */ 


HarryPotter 08-05-2020 16:01

Re: [L4D2] Meteor Hunter
 
Quote:

Originally Posted by Lux (Post 2713137)
PHP Code:

CreateTimer(0.3,CreateRing,hbPack,TIMER_FLAG_NO_MAPCHANGE|TIMER_DATA_HNDL_CLOSE); 

PHP Code:

#define TIMER_REPEAT            (1<<0)      /**< Timer will repeat until it returns Plugin_Stop */
#define TIMER_FLAG_NO_MAPCHANGE (1<<1)      /**< Timer will not carry over mapchanges */
#define TIMER_HNDL_CLOSE        (1<<9)      /**< Deprecated define, replaced by below */
#define TIMER_DATA_HNDL_CLOSE   (1<<9)      /**< Timer will automatically call CloseHandle() on its data when finished */ 


Thanks, Lux, one more question, what if I use CreateDataTimer?
should I also write TIMER_DATA_HNDL_CLOSE?
PHP Code:

CreateDataTimer(0.3,CreateRing,hbPack,TIMER_FLAG_NO_MAPCHANGE|TIMER_DATA_HNDL_CLOSE); 



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

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