Thread: [Solved] [L4D2] cs_ragdoll usage?
View Single Post
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 06-01-2019 , 06:57   Re: [L4D2] cs_ragdoll usage?
Reply With Quote #7

Quote:
Originally Posted by CliptonHeist View Post
If velfloat already has assigned values you can just pass it into SetEntPropVector directly.
Uh... thanks for pointing that out. I feel dumb.

I've gotten the velocity on player movement working. I'd like to get force from damage, but I don't know how.
Here's my code that applied the velocity:
PHP Code:
// This is the value initialized + hook
float g_saveVelocity[MAXPLAYERS+1][3];
HookEvent("player_hurt"Player_Hurt_PreEventHookMode_Pre);

// Below code is in the ragdoll spawning function.
if (!IsPlayerAlive(client))
    {
        
float multiply[3];
        
multiply[0] = g_saveVelocity[client][0]*25;
        
multiply[1] = g_saveVelocity[client][1]*25;
        
multiply[2] = g_saveVelocity[client][2]*25;
        
SetEntPropVector(RagdollProp_Send"m_vecForce"multiply);
        
//PrintToChatAll("Applied force!");
        
g_saveVelocity[client][0] = 0.0
        g_saveVelocity
[client][1] = 0.0
        g_saveVelocity
[client][2] = 0.0
    
}
    else
    {
        
float velfloat[3];
        
velfloat[0] = GetEntPropFloat(clientProp_Send"m_vecVelocity[0]")*25
        velfloat
[1] = GetEntPropFloat(clientProp_Send"m_vecVelocity[1]")*25
        velfloat
[2] = GetEntPropFloat(clientProp_Send"m_vecVelocity[2]")*25
        SetEntPropVector
(RagdollProp_Send"m_vecForce"velfloat);
    }

// Below code is the hooked damage event, which prepares the g_saveVelocity for the above code.
public void Player_Hurt_Pre(Handle event, const char[] namebool dontbroadcast)
{
    
int userID GetEventInt(event"userid");
    
int user GetClientOfUserId(userID);
    if (
user <= 0)
    return;
    
    
int health GetEventInt(event"health");
    if (
health 0)
    {
        return;
    }
    
    if(!
g_IsSequel || !g_RagdollModeEnabled)
        return;
    
    if (
GetClientTeam(user) != && GetClientTeam(user) != 4)
    return;
    
    
float velfloat[3];
    
velfloat[0] = GetEntPropFloat(userProp_Send"m_vecVelocity[0]")
    
velfloat[1] = GetEntPropFloat(userProp_Send"m_vecVelocity[1]")
    
velfloat[2] = GetEntPropFloat(userProp_Send"m_vecVelocity[2]")
    
g_saveVelocity[user] = velfloat;


Last edited by Shadowysn; 06-01-2019 at 06:57.
Shadowysn is offline