AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [Tutorial] Exaggerated Ragdolls (https://forums.alliedmods.net/showthread.php?t=127865)

blodia 05-25-2010 19:25

[Tutorial] Exaggerated Ragdolls
 
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).

FoxMulder 05-25-2010 20:07

Re: [SNIPPET] Exaggerated Ragdolls
 
Sounds hilarious and useful too :)

FoxMulder 06-19-2010 02:38

Re: [Tutorial] Exaggerated Ragdolls
 
Hmm I keep on getting Invalid Entity -1. I tried Post and Pre. Game is TF2. :/

blodia 06-19-2010 08:17

Re: [Tutorial] Exaggerated Ragdolls
 
it might be too early in tf2, try 1 gameframe after death.

Rincewind 06-30-2010 09:16

Re: [Tutorial] Exaggerated Ragdolls
 
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.

blodia 06-30-2010 11:11

Re: [Tutorial] Exaggerated Ragdolls
 
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.

Greyscale 06-30-2010 17:06

Re: [Tutorial] Exaggerated Ragdolls
 
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.

blodia 06-30-2010 17:55

Re: [Tutorial] Exaggerated Ragdolls
 
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.

Greyscale 06-30-2010 18:30

Re: [Tutorial] Exaggerated Ragdolls
 
Do both ;)

Mecha the Slag 10-05-2010 18:28

Re: [Tutorial] Exaggerated Ragdolls
 
fyi this doesn't work at all in TF2

Kevin_b_er 10-05-2010 19:08

Re: [Tutorial] Exaggerated Ragdolls
 
Yeah I tried this in TF2 shortly after the first post. The ragdolls appear quite differently on each client, even if done with all parties standing still. The ragdoll doesn't change at all with this method.

blodia 10-06-2010 11:20

Re: [Tutorial] Exaggerated Ragdolls
 
this method was for css where ragdolls are created immediately on death, in tf2 you have death animations and gibs, i was planning on trying an alternate method that should work much better in other games but never had time since i started work. at the moment i need sort issues with one of my plugins then i'll try it out.

blodia 12-26-2010 14:53

Re: [Tutorial] Exaggerated Ragdolls
 
i've updated the code in the first post if anyone wants to give this a try in tf2 or any other game. only problem now is that you don't know which weapon killed the ragdoll owner so you can't easily setup per weapon ragdoll adjustments. you could have an array that stores the weapon name that killed the client when they die and check it in client prethink.

Matheus28 12-29-2010 11:13

Re: [Tutorial] Exaggerated Ragdolls
 
I think OnClientPutInServer is fired for all clients in case of late load.

psychonic 12-29-2010 11:57

Re: [Tutorial] Exaggerated Ragdolls
 
Quote:

Originally Posted by Matheus28 (Post 1381741)
I think OnClientPutInServer is fired for all clients in case of late load.

It isn't.

Matheus28 01-02-2011 12:17

Re: [Tutorial] Exaggerated Ragdolls
 
Quote:

Originally Posted by psychonic (Post 1381767)
It isn't.

Damn, I'm gonna need to fix some of my plugins...

Böhser Onkel Leo 04-07-2011 13:31

Re: [Tutorial] Exaggerated Ragdolls
 
Why i didn't get the plugin to work?

I compiled the plugin, put it on the server, restart the server and nothing happens... no error log.. nothing..

Leo

Groger 04-07-2011 16:52

Re: [Tutorial] Exaggerated Ragdolls
 
Quote:

Originally Posted by Böhser Onkel Leo (Post 1445859)
Why i didn't get the plugin to work?

I compiled the plugin, put it on the server, restart the server and nothing happens... no error log.. nothing..

Leo

Same with me

blodia 05-02-2011 13:38

Re: [Tutorial] Exaggerated Ragdolls
 
which games are you trying it in?

Groger 05-03-2011 02:55

Re: [Tutorial] Exaggerated Ragdolls
 
Counter strike source

thetwistedpanda 05-03-2011 07:50

Re: [Tutorial] Exaggerated Ragdolls
 
I use virtually the same method, although I do it in player_death, and it has an effect in CS:S. Although it's possible Groger, that you're not using values large enough.

blodia 05-03-2011 16:43

Re: [Tutorial] Exaggerated Ragdolls
 
for css just use this. this snippet still works fine in css when i checked it.


All times are GMT -4. The time now is 18:12.

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