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

[L4D2] Constant survivor speed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alcybery
Member
Join Date: Apr 2016
Old 06-26-2018 , 17:36   [L4D2] Constant survivor speed
Reply With Quote #1

Is there a way to remove slowdown when a survivor has low health?
I know that it can be done witch cvars survivor_limp_health and survivor_limp_walk_speed, but then yellow health would disappear, higher than 25 hp it would be green, lower than 25 hp it would be red.
alcybery is offline
blacklagoon
Senior Member
Join Date: Jun 2012
Old 06-27-2018 , 13:59   Re: [L4D2] Constant survivor speed
Reply With Quote #2

That should set you on the right path
Code:
laggedMovementOffset = FindSendPropInfo(PLAYER_CLASSNAME, MOVE_SPEED_ENTPROP);
SetEntDataFloat(client, lagMoveOffset, FULL_SPEED, true);
blacklagoon is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-27-2018 , 15:44   Re: [L4D2] Constant survivor speed
Reply With Quote #3

Quote:
Originally Posted by blacklagoon View Post
That should set you on the right path
Code:
laggedMovementOffset = FindSendPropInfo(PLAYER_CLASSNAME, MOVE_SPEED_ENTPROP);
SetEntDataFloat(client, lagMoveOffset, FULL_SPEED, true);
Why does everyone use FindSendPropInfo when they're not modifying the offset. This can simply be done with: SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", "1.0");
__________________
Silvers is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 06-27-2018 , 18:04   Re: [L4D2] Constant survivor speed
Reply With Quote #4

If I remember correctly, you'd want to run a repetitive timer to keep that speed constant. No matter what value you set m_flLaggedMovementValue to, it'll be overridden when the entity is affected by something. In this case, if the prop is set to 1.0 once and a survivor goes below 40 HP, they'll be slow again.

By having a repetitive timer to keep setting that prop to 1.0 (normal speed) you can make sure that the survivor doesn't get slowed down.

Of course, you could just check for the survivor's HP and then set their speed to 1.0 once their health is below 40.

PHP Code:
int iHealth GetClientHealth(client);
If (
iHealth 40)
{
     
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"1.0);

Check for the health in the player_hurt event, OnTakeDamage, TraceAttack, etc.
__________________

Last edited by Psyk0tik; 06-27-2018 at 23:07.
Psyk0tik is offline
alcybery
Member
Join Date: Apr 2016
Old 06-27-2018 , 18:40   Re: [L4D2] Constant survivor speed
Reply With Quote #5

Something like this?
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("player_hurt"Event_PlayerHurt);
}

public 
Action Event_PlayerHurt(Handle eventchar[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event,"userid")); 

    
int iHealth GetClientHealth(client);
    if (
iHealth 40)
    {
        
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"1.0); 
    }

Doesn't seem to work.
alcybery is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-27-2018 , 19:15   Re: [L4D2] Constant survivor speed
Reply With Quote #6

I thought "m_flLaggedMovementValue" needed a Pre/PostThink because sometimes it's modified each frame in some situations or something. I've not messed with it enough to know. Check other projects for example usage.
__________________
Silvers is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 06-27-2018 , 23:06   Re: [L4D2] Constant survivor speed
Reply With Quote #7

Change Prop_Send to Prop_Data.
__________________
Psyk0tik is offline
alcybery
Member
Join Date: Apr 2016
Old 06-28-2018 , 09:36   Re: [L4D2] Constant survivor speed
Reply With Quote #8

Quote:
Originally Posted by Silvers View Post
I thought "m_flLaggedMovementValue" needed a Pre/PostThink because sometimes it's modified each frame in some situations or something. I've not messed with it enough to know. Check other projects for example usage.
Maybe you know some projects I could check? I couldn't find useful examples.

Quote:
Originally Posted by Crasher_3637 View Post
Change Prop_Send to Prop_Data.
Still not working.
alcybery is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-28-2018 , 10:01   Re: [L4D2] Constant survivor speed
Reply With Quote #9

PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

Handle g_TimerHandles[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
HookEvent("player_hurt"Event_PlayerHurt);
}

public 
Action Event_PlayerHurt(Handle eventchar[] namebool dontBroadcast)
{
    
int userid GetEventInt(event,"userid"); 
    
int client GetClientOfUserId(userid); 

    
int iHealth GetClientHealth(client);
    if (
iHealth 40)
    {
        if( 
g_TimerHandles[client] == null )
        {
            
CreateTimer(1.0tmrSpeeduserid);
        }
    }
}

public 
Action tmrSpeed(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if( 
client && IsClientInGame(client) && IsPlayerAlive(client) )
    {
        
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"1.0);
        return 
Plugin_Continue;
    }

    
g_TimerHandles[client] = null;
    return 
Plugin_Stop;

Something like that maybe a 0.1 timer.

I'm guessing because their health is low it's resetting the m_fLaggedMovementValue. I'd suggest watching the netprop with tEntDev to find out when it's changing.
__________________

Last edited by Silvers; 06-28-2018 at 10:23. Reason: Prop_Data*
Silvers is offline
alcybery
Member
Join Date: Apr 2016
Old 06-28-2018 , 15:30   Re: [L4D2] Constant survivor speed
Reply With Quote #10

Quote:
Originally Posted by Silvers View Post
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

Handle g_TimerHandles[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
HookEvent("player_hurt"Event_PlayerHurt);
}

public 
Action Event_PlayerHurt(Handle eventchar[] namebool dontBroadcast)
{
    
int userid GetEventInt(event,"userid"); 
    
int client GetClientOfUserId(userid); 

    
int iHealth GetClientHealth(client);
    if (
iHealth 40)
    {
        if( 
g_TimerHandles[client] == null )
        {
            
CreateTimer(1.0tmrSpeeduserid);
        }
    }
}

public 
Action tmrSpeed(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if( 
client && IsClientInGame(client) && IsPlayerAlive(client) )
    {
        
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"1.0);
        return 
Plugin_Continue;
    }

    
g_TimerHandles[client] = null;
    return 
Plugin_Stop;

Something like that maybe a 0.1 timer.

I'm guessing because their health is low it's resetting the m_fLaggedMovementValue. I'd suggest watching the netprop with tEntDev to find out when it's changing.
Also doesn't work.

I tried watching the netprops, that's what I got:
PHP Code:
baseclass->m_cellX (912changed from 555 to 554
baseclass
->m_cellY (916changed from 605 to 606
baseclass
->m_vecOrigin (924changed from 1380.2132 2991.5471 572.0312 to 1357.1743 3008.4899 572.0312
baseclass
->m_angRotation (936changed from 0.0000 161.0314 0.0000 to 0.0000 141.6715 0.0000
m_flPoseParameter
->000 (1176changed from 0.6989 to 0.7035
m_flPoseParameter
->001 (1180changed from 0.4490 to 0.4157
m_flPoseParameter
->003 (1188changed from 0.5009 to 0.4569
m_flPoseParameter
->004 (1192changed from 0.5000 to 0.8709
m_flPoseParameter
->005 (1196changed from 0.5000 to 0.7429
baseclass
->m_nSequence (1172changed from 7 to 313
baseclass
->m_nNewSequenceParity (1292changed from 5 to 0
baseclass
->m_nResetEventsParity (1296changed from 5 to 0
serveranimdata
->m_flCycle (1168changed from 0.1477 to 0.1776
baseclass
->m_iHealth (256changed from 50 to 38
baseclass
->m_flMaxspeed (8216changed from 220.0000 to 150.0000
localdata
->m_nTickBase (8308changed from 52214 to 52314
localdata
->m_vecVelocity[0] (748changed from 0.0000 to -71.4111
localdata
->m_vecVelocity[1] (752changed from 0.0000 to 112.2314
baseclass
->m_angEyeAngles[0] (10672changed from 35.8050 to 36.6300
baseclass
->m_angEyeAngles[1] (10676changed from 161.0314 to 141.6715
CTerrorPlayer
->m_fServerAnimStartTime (11072changed from 521.4699 to 522.8300
CTerrorPlayer
->m_checkpointDamageTaken (14680changed from 117 to 129 
So the game changes m_flMaxspeed from 220.0000 to 150.0000 as soon as m_iHealth goes below 40.
alcybery 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 09:03.


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