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

[L4D|L4D2] Odin's Rock


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Plugin ID:
8632
Plugin Version:
2024.01.25
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
Servers with this Plugin:
 
Plugin Description:
Make tank rock more funnier.
Old 01-31-2024 , 00:55   [L4D|L4D2] Odin's Rock
Reply With Quote #1

Description:

This plugin makes tank's rock have something powerful.
As the name says, The Rock, it becomes odin's weapon, just like the "Gungnir".
If tank throws a rock, the rock will ignore the distance and the time, impact the target at once. No miss, no survivor.

Usage:

Put it into 'plugins' folder.
And you also need [L4D & L4D2] Left 4 DHooks Direct

Cvars:

odins_rock: Turn on/off the plugin.
odins_tp: If this convar is true, tank will teleport to player after the rock hit.
odins_rock_human: Can player tank use the odin's rock or not.
odins_time: AI tank will throw rock after this convar time, 0 is off.
odins_trick: Damage to the player hit by rock.
odins_rock_punch: Rock will impact the player, this is the speed on the xOy plane.
odins_rock_punch_h: Rock will impact the player, this is the speed at the z axis.

Source:

You can ALWAYS find latest source at my GitHub:
Paimon-Kawaii - L4D2-Plugins/MyPlugins/Odin's Rock

Download:
Attached Files
File Type: smx odins_rock.smx (8.4 KB, 65 views)
__________________

Last edited by Paimon; 01-31-2024 at 22:45.
Paimon is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-31-2024 , 12:28   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #2

PHP Code:
if (!IsFakeClient(tank) && !g_hOdinsHuman.BoolValue
Flip these checks around, more optimized.


PHP Code:
    if (IsTank(tank))
        
target GetClientAimTarget(tank); 
You already have the "IsTank" check above which will return if not. Again you have several "IsTank" checks below, these are not needed.


PHP Code:
    if (!IsTankRock(inflictor)) return Plugin_Continue;

    
damage g_hOdinsTrick.FloatValue;

    if (!
IsTank(attacker)) return Plugin_Continue
Put the two checks together, assigning a value that maybe never used is not optimized.


PHP Code:
for (int i 1MaxClientsi++) 
All loops like this should be: i <= MaxClients


PHP Code:
char classname[MAX_NAME_LENGTH]; 
You assign a random length, this is player name length not the targetname length. Then you're only checking a string that is 9 chars long, so you should set as "char classname[10]" and I would even set as "static char classname[10]" so it doesn't create the string each time, since you're filling it with data before reading ever reading it.


PHP Code:
SDKHook(targetSDKHook_OnTakeDamageOnTakeDamage); 
You will be hooking the same target multiple times on multiple throws. You never remove the damage hook. I suggest removing the hook in the post forward "L4D_TankRock_OnRelease_Post".
__________________

Last edited by Silvers; 01-31-2024 at 12:31.
Silvers is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 01-31-2024 , 22:26   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #3

Thank you, Silvers. You taught me a lot.
I will optimize them later.
__________________

Last edited by Paimon; 01-31-2024 at 22:27.
Paimon is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 01-31-2024 , 22:44   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #4

Quote:
Originally Posted by Silvers View Post
PHP Code:
SDKHook(targetSDKHook_OnTakeDamageOnTakeDamage); 
You will be hooking the same target multiple times on multiple throws. You never remove the damage hook. I suggest removing the hook in the post forward "L4D_TankRock_OnRelease_Post".
For this part I have some questions:
1. Will the multiple hook call OnTakeDamage multiple times even if they are the same target?
2. I have seen that the sdkhook.inc says SDKHook could "Unhooked automatically upon destruction/removal of the entity", so is unhook necessary?
__________________
Paimon is offline
NekoYa4r
Junior Member
Join Date: Mar 2020
Old 02-01-2024 , 00:23   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #5

Why i can't compile your plugin ?
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// odins_rock.sp
//
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 001: expected token: "function", but found ">"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 001: expected token: "function", but found ">"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\paiutils.inc(340) : error 001: expected token: ";", but found "-identifier-"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\paiutils.inc(881) : error 001: expected token: ";", but found "return"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\paiutils.inc(881) : warning 217: inconsistent indentation (did you mix tabs and spaces?)
//
// 6 Errors.
//
// Compilation Time: 1.14 sec
// ----------------------------------------

Press enter to exit ...

Last edited by NekoYa4r; 02-01-2024 at 00:23.
NekoYa4r is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-01-2024 , 04:36   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #6

Quote:
Originally Posted by NekoYa4r View Post
Why i can't compile your plugin ?
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// odins_rock.sp
//
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 001: expected token: "function", but found ">"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 001: expected token: "function", but found ">"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\paiutils.inc(340) : error 001: expected token: ";", but found "-identifier-"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\paiutils.inc(881) : error 001: expected token: ";", but found "return"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\paiutils.inc(881) : warning 217: inconsistent indentation (did you mix tabs and spaces?)
//
// 6 Errors.
//
// Compilation Time: 1.14 sec
// ----------------------------------------

Press enter to exit ...
Sorry I forgot to update the include file
Now try it again.
__________________
Paimon is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 02-01-2024 , 04:42   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #7

Quote:
Originally Posted by Paimon View Post
For this part I have some questions:
1. Will the multiple hook call OnTakeDamage multiple times even if they are the same target?
2. I have seen that the sdkhook.inc says SDKHook could "Unhooked automatically upon destruction/removal of the entity", so is unhook necessary?
1. Yes.
2. The client "entity" is never destroyed unless they disconnect.
__________________
Silvers is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-01-2024 , 04:57   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #8

Quote:
Originally Posted by Silvers View Post
1. Yes.
2. The client "entity" is never destroyed unless they disconnect.
OK. Thanks for your kindly reply!
__________________
Paimon is offline
NekoYa4r
Junior Member
Join Date: Mar 2020
Old 02-01-2024 , 05:03   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #9

Quote:
Originally Posted by Paimon View Post
Sorry I forgot to update the include file
Now try it again.
Still the same....I'm using lastest Sourcemod Stable build
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// odins_rock.sp
//
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 001: expected token: "function", but found ">"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 001: expected token: "function", but found ">"
//
// 4 Errors.
//
// Compilation Time: 1.16 sec
// ----------------------------------------

Press enter to exit ...
NekoYa4r is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-03-2024 , 23:24   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #10

Quote:
Originally Posted by NekoYa4r View Post
Still the same....I'm using lastest Sourcemod Stable build
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// odins_rock.sp
//
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(324) : error 001: expected token: "function", but found ">"
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 122: expected type expression
// D:\Dedicated\L4D2\left4dead2\addons\sourcemod\scripting\include\sdkhooks.inc(339) : error 001: expected token: "function", but found ">"
//
// 4 Errors.
//
// Compilation Time: 1.16 sec
// ----------------------------------------

Press enter to exit ...
I know what happened now.
I have removed some defines from paiutils.inc.
Just try again.
__________________

Last edited by Paimon; 02-03-2024 at 23:24.
Paimon is offline
Reply


Thread Tools
Display Modes

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 00:52.


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