Raised This Month: $ Target: $400
 0% 

[Tutorial] Exaggerated Ragdolls


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 05-25-2010 , 19:25   [Tutorial] Exaggerated Ragdolls
Reply With Quote #1

i've only tested this with css but it should work with most valve games if not all. you need sdkhooks.

PHP Code:
#include <sourcemod>
#include <sdkhooks>

#pragma semicolon 1

public OnPluginStart()
{
    for (new 
client 1client <= MaxClientsclient++) 
    { 
        if (
IsClientInGame(client)) 
        {
            
SDKHook(clientSDKHook_PreThinkOnPreThink);
        }
    }
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_PreThinkOnPreThink);
}

public 
OnPreThink(client)
{
    static 
bool:RagdollSpawned[MAXPLAYERS 1];
    
    new 
Ragdoll GetEntPropEnt(clientProp_Send"m_hRagdoll");
    
    if (
Ragdoll != -1)
    {
        if (!
RagdollSpawned[client])
        {
            new 
Float:XMultiplier 10.0;
            new 
Float:YMultiplier 10.0;
            new 
Float:ZMultiplier 10.0;
            
            new 
Float:Force[3];
            
GetEntPropVector(RagdollProp_Send"m_vecForce"Force);
            
            
Force[0] *= XMultiplier;
            
Force[1] *= YMultiplier;
            
Force[2] *= ZMultiplier;
            
SetEntPropVector(RagdollProp_Send"m_vecForce"Force);
            
            new 
Float:Velocity[3];
            
GetEntPropVector(RagdollProp_Send"m_vecRagdollVelocity"Velocity);
            
            
Velocity[0] *= XMultiplier;
            
Velocity[1] *= YMultiplier;
            
Velocity[2] *= ZMultiplier;
            
SetEntPropVector(RagdollProp_Send"m_vecRagdollVelocity"Velocity); 
        }
        
RagdollSpawned[client] = true;
    }
    else
    {
        
RagdollSpawned[client] = false;
    }

when a player is killed by damage to a certain part of the body the force is applied to the relative bone of the ragdoll via m_vecForce e.g headshot applies the force to the head bone so the head flies back followed by the rest of the ragdoll. if the damage isn't done to a specific bone then m_vecRagdollVelocity is used to make the whole ragdoll move e.g explosive damage. the angles the damage was done from affects the direction the ragdoll travels.

setting a multiplier to 10 for example will make the ragdoll move ten times as far, setting it to 0 will stop the ragdoll moving along that axis and negative values will make the ragdoll move in the opposite direction.

i split the multipliers in 3 because sometimes the ragdolls move in different ways than expected e.g when you kill a player with a knife in css the ragdoll is forced towards the floor so it hardly moves, since you can change the force along each axis you can set z force to 0 or a negative value and the x and y values to a high value to make the ragdolls fly away from the attacker. you can change the height or xy distance independently.

ragdolls in css are awful, nearly every weapon kill results in ragdolls slumping on the floor, only grenades move the ragdolls some distance. if you want better ragdolls for css i recommend x, y and z multipliers of around 10. if you want insane ragdolls x, y and z values of 50 or over will make the ragdolls fly. if you want to scare the crap out of people use x, y and z values under -50(high negative values) which will make ragdolls fly towards the attacker.if you want more height then increase the z values more than the others (or leave the others at 1.0).

Last edited by blodia; 12-26-2010 at 14:49.
blodia is offline
 



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:12.


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