Raised This Month: $51 Target: $400
 12% 

[Tutorial] Exaggerated Ragdolls


Post New Thread Reply   
 
Thread Tools Display Modes
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
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 05-25-2010 , 20:07   Re: [SNIPPET] Exaggerated Ragdolls
Reply With Quote #2

Sounds hilarious and useful too
__________________
FoxMulder is offline
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 06-19-2010 , 02:38   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #3

Hmm I keep on getting Invalid Entity -1. I tried Post and Pre. Game is TF2. :/
__________________
FoxMulder is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-19-2010 , 08:17   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #4

it might be too early in tf2, try 1 gameframe after death.
blodia is offline
Rincewind
BANNED
Join Date: Jun 2010
Location: Switzerland
Old 06-30-2010 , 09:16   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #5

I guess to use this in TF2 could cause problems with death animations (headshots, backstabs, ...). Eg. a Scout who gets a headshot by a Sniper does not result instantly in a ragdoll, but after a few seconds, when the animation is over.
Rincewind is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-30-2010 , 11:11   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #6

i guess you could try sdkhooks OnEntityCreated to find when the ragdoll is created then try changing props, you may still need to wait a gameframe though as its a prehook.
blodia is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 06-30-2010 , 17:06   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #7

Great idea blodia! This looks like a must-have for almost any server. You should release this as a plugin if you haven't already.
__________________
Greyscale is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-30-2010 , 17:55   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #8

i was going to but i thought it would be better to let people do it themselves depending on what they wanted to do e.g if they wanted weapon specific effects and if they wanted to use it in other source games.
blodia is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 06-30-2010 , 18:30   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #9

Do both ;)
__________________
Greyscale is offline
Mecha the Slag
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 10-05-2010 , 18:28   Re: [Tutorial] Exaggerated Ragdolls
Reply With Quote #10

fyi this doesn't work at all in TF2
__________________
Mecha the Slag is offline
Reply



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 05:47.


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