Raised This Month: $28 Target: $400
 7% 

Solved [L4D2] Tank Water Slowdown


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Polyano
Member
Join Date: Jun 2024
Old 07-19-2024 , 00:18   [L4D2] Tank Water Slowdown
Reply With Quote #1

I couldn't find this anywhere. What I've found instead are Water slowdown disabler - addon and [L4D] Water Speed - plugin. Is there any plugin to enable water slowdown on zombie, specifically Tank, because it's not fair for survivors if suddenly there's multiple tank spawning at the same time in a sewer pipe. I don't want to instead disable water slowdown for the survivor because it is immersive enough to remove it.

An option to enable water slowdown on each CI/SI/Witch/Tank with percentage of slowdown would be great.

Edit (Solved):
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_tank_water_slowdown.sp - 48 views - 1.2 KB)
File Type: smx l4d2_tank_water_slowdown.smx (3.3 KB, 30 views)

Last edited by Polyano; 07-21-2024 at 11:30. Reason: Adding plugin attachment
Polyano is offline
101
Senior Member
Join Date: Nov 2023
Old 07-19-2024 , 12:25   Re: [L4D2] Tank Water Slowdown
Reply With Quote #2

PHP Code:
#define F1_xy(%1,%2)        Pow( GetConVarFloat( Factor[%2 % 2 ]) , float(GetEntProp(%1, Prop_Send, "m_nWaterLevel")) )

ConVar Factor[2];
Handle h_timer[32];

public 
OnPluginStart()
{
    
Factor[0] = CreateConVar("X_Water_Factor_Survivor" "0.68" ,"Water Resistance Factor For Survivor [1.0 : Disable effects]"FCVAR_NOTIFYtrue ,0.6 ,true ,1.0);
    
Factor[1] = CreateConVar("X_Water_Factor_Infected" "0.68" ,"Water Resistance Factor For Infected [1.0 : Disable effects]"FCVAR_NOTIFYtrue ,0.6 ,true ,1.0);
}

public 
OnClientPostAdminCheck(client)
{
    
h_timer[client] = CreateTimer(0.5 ,Timer_Refresh_Speed client ,TIMER_REPEAT);
}

public 
Action Timer_Refresh_Speed(Handle Timer ,any client)
{
    
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"F1_xy(client GetClientTeam(client)) );
    return 
Plugin_Continue;
}

public 
OnClientDisconnect(client)
{
    
delete h_timer[client];   

I Don't Think Witch Is A Player ,I Don't Know If It Has The Same NetProps or not , so its not included.

Last edited by 101; 07-19-2024 at 13:27.
101 is offline
Polyano
Member
Join Date: Jun 2024
Old 07-19-2024 , 15:01   Re: [L4D2] Tank Water Slowdown
Reply With Quote #3

Quote:
Originally Posted by 101 View Post
[...]
I've tested it, and it worked, Tank speed did decrease when he walked on a swamp.

But, his walking speed on the water was faster than Survivor. Which code to edit to make it so that Tank speed is slightly slower than survivor, just like how Tank speed is slightly slower than Survivor on normal ground, so that Survivor can outrun Tank in the water?
Polyano is offline
101
Senior Member
Join Date: Nov 2023
Old 07-19-2024 , 22:37   Re: [L4D2] Tank Water Slowdown
Reply With Quote #4

Did you change the cvar value to be lower than 0.68 ?
101 is offline
Polyano
Member
Join Date: Jun 2024
Old 07-19-2024 , 22:55   Re: [L4D2] Tank Water Slowdown
Reply With Quote #5

Quote:
Originally Posted by 101 View Post
Did you change the cvar value to be lower than 0.68 ?
I didn't change anything. I just copy pasted all the code. Hmm, maybe there's clash with other plugin?

Here's my current list of plugins for reference:
Spoiler


List of current addons: Admin System, Friendly Fire 50-50 Reflector
Polyano is offline
101
Senior Member
Join Date: Nov 2023
Old 07-20-2024 , 04:40   Re: [L4D2] Tank Water Slowdown
Reply With Quote #6

If Fake players don't pass through OnClientPostAdminCheck () , then It was my fault .
Quote:
Originally Posted by Polyano View Post
But, his walking speed on the water was faster than Survivor.
I think that because of difference in water level , or tanks maybe have twice ٍthe survivors' speed in water

However .Check This :
PHP Code:
#define F1_xy(%1,%2)        Pow( GetConVarFloat( Factor[%2 % 2]) , float(GetEntProp(%1, Prop_Send, "m_nWaterLevel")) * 0.1* %2 )

ConVar Factor[2];
Handle h_timer[32];

public 
OnPluginStart()
{
    
Factor[0] = CreateConVar("X_Water_Smooth_Factor_Survivor" "0.30" ,"Water Speed Factor For Survivor [1.0 : Disable effects]"FCVAR_NOTIFYtrue ,0.01 ,true ,1.0);
    
Factor[1] = CreateConVar("X_Water_Smooth_Factor_Infected" "0.20" ,"Water Speed Factor For Infected [1.0 : Disable effects]"FCVAR_NOTIFYtrue ,0.01 ,true ,1.0);
    
HookEvent("player_spawn",E_P_X);
    
HookEvent("player_death",E_P_X);
}

public 
E_P_X(Handle:event, const String:name[], bool:Broadcast
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (!
client)    return ;
    
    if (
name[7] == 's')
    {
        if (
h_timer[client] == null)
        {
            
h_timer[client] = CreateTimer(0.5 ,Timer_Refresh_Speed client ,TIMER_REPEAT);
        }
    }
    else    
OnClientDisconnect(client);
}

public 
Action Timer_Refresh_Speed(Handle Timer ,any client)
{
    
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"F1_xy(client GetClientTeam(client)) );
    return 
Plugin_Continue;
}

public 
OnClientDisconnect(client)
{
    if (
h_timer[client]!=null)    delete h_timer[client];  

Note : You Can Change The Convar Of Infected to 0.15 or lower than the default If you want tanks to be extra slow

Last edited by 101; 07-20-2024 at 04:55.
101 is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 07-20-2024 , 06:19   Re: [L4D2] Tank Water Slowdown
Reply With Quote #7

https://github.com/SirPlease/L4D2-Co...l.sp#L252-L333
__________________
HarryPotter is offline
Polyano
Member
Join Date: Jun 2024
Old 07-20-2024 , 10:32   Re: [L4D2] Tank Water Slowdown
Reply With Quote #8

Quote:
Originally Posted by 101 View Post
Note : You Can Change The Convar Of Infected to 0.15 or lower than the default If you want tanks to be extra slow
I've changed "X_Water_Smooth_Factor_Infected" , "0.20" to 0.05, 0.10, 0.15, 0.35, 0.40, 0.50, 0.90 but still no luck. Tank still can catch me, although now the speed is slower than the first code you posted. It seems Tank don't like me to gimp his walking speed on water lol. I did the test on Swamp Fever - Swamp map outside the saferoom.
Polyano is offline
Polyano
Member
Join Date: Jun 2024
Old 07-20-2024 , 10:36   Re: [L4D2] Tank Water Slowdown
Reply With Quote #9

Quote:
Originally Posted by HarryPotter View Post
I got this error message, using line L252-L333:
Spoiler
Polyano is offline
101
Senior Member
Join Date: Nov 2023
Old 07-21-2024 , 05:39   Re: [L4D2] Tank Water Slowdown
Reply With Quote #10

PHP Code:
float Multiplier[2][4]= {{1.0 0.70 0.50 0.36}    ,    {1.0 0.35 0.23 0.20}}; 

// First group is the survivors' multiplier of speed based on their level in water , And the 2nd one is for Infected .
// As you can see above , when a survivor went deep in water the multiplier of speed would be 0.36 .while it would be 0.20 for tanks.

Handle h_timer[32];

public 
OnPluginStart()
{
    
HookEvent("player_spawn",E_P_X);
    
HookEvent("player_death",E_P_X);
}

public 
E_P_X(Handle:event, const String:name[], bool:Broadcast
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (!
client)    return ;
    
    if (
name[7] == 's')
    {
        if (
h_timer[client] == null)
        {
            
h_timer[client] = CreateTimer(0.5 ,Timer_Refresh_Speed client ,TIMER_REPEAT);
        }
    }
    else    
OnClientDisconnect(client);
}

public 
Action Timer_Refresh_Speed(Handle Timer ,any client)
{
    
SetEntPropFloat(clientProp_Send"m_flVelocityModifier"MultiplierGetClientTeam(client) %][ GetEntProp(clientProp_Send"m_nWaterLevel") ] );
    return 
Plugin_Continue;
}

public 
OnClientDisconnect(client)
{
    if (
h_timer[client]!=null)    delete h_timer[client];  

Quote:
Originally Posted by Polyano View Post
Tank still can catch me, although now the speed is slower than the first code you posted. It seems Tank don't like me to gimp his walking speed on water lol.
I see , I couldn't understand the f logic of tank speed under water , This is what i found :

- Tank (sometimes) has different level of survivor , this means he will get a higher speed . and I've found nothing logical that can deals with that [Its God's problem not ours] , The only solution for that is [neglect Levels] Or by checking the distance between them , but this should be the last solution .

- Tank even at the same water level is still faster , this may due to the acceleration which is based on velocity , I had to change "m_flLaggedMovementValue" to "m_flVelocityModifier" [it maybe more logical as it was used in the code provided above] , I also changed the function of multiplier to be totally manual .

After so .... I Have Nothing To Do With That , I just shortened the main plugin and added a function to include the red team .

If the problem of tanks was not solved then check the harrypotter's one .And the errors that you see were due to *.inc file that you are missing in include folder .
HTH

Last edited by 101; 07-21-2024 at 07:43.
101 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 18:11.


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