Ragdoll Bleeding Function

I just wanted to know if anyone could whip something up where if I shoot a ragdoll, it emits a blood effect. Pretty simple, I hope. Then again I’m not a coder myself so I wouldn’t know.

I suggest you to try it yourself. I’m not a pro lua coder but here are some hints as I can’t do any coding at the moment.

Try to make a function that checks whether the shot entity is a ragdoll and then just emit a blood particle on the position which was shot. You might want to change the blood colour for aliens and zombies, and you can also add some lua or orangebox driven particles for spicing things up.

Thank you for the suggestion, but I’m absolutely blank as to how to even accomplish this. I don’t know the code for the functions you’ve listed nor how I can go about formatting them. Is there some kind of template I can refer to?

Well too bad the old wiki’s down, you could’ve use it for this. Tell you what, add me on steam and I’ll try to help you with this.

May not be the most elegant bit of code, but it works for me. Put it inside autorun and you’re good to go. Works both on spawned ragdolls as well as on npc’s(make sure the ragdolls thingy in npc menu is ticked on)

function hiteffect( ent, inflictor, attacker, amount, dmginfo)

   if (ent:GetClass() == "prop_ragdoll" ) then

           local effect = EffectData()  
           local origin = dmginfo:GetDamagePosition()
           effect:SetOrigin( origin )
           effect:SetScale( 1 )
           util.Effect( "bloodimpact", effect )


hook.Add("EntityTakeDamage", "holyshit", hiteffect)

here ya go my fine fellows. the wiki was moved.

Works like a charm, thanks! I’d also be interested in learning how you’d change the blood particle type according to the npc.

Using Failure’s script as a base, you can do…

local NPCsHitEffects = {
	["npc_citizen"] = "bloodimpact",
	["npc_combine"] = "bloodimpact",
	["npc_antlion"] = "AntlionGib",
	["npc_crow"] = "Sparks",
	Default = "bloodimpact",

function RagdollEffect( Entity, Inflictor, Attacker, Amount, DamageInfo)
	if (!string.find(Entity:GetClass(), "npc_") && !Entity:IsNPC() ) then return false; end
	local Effect = EffectData()  
	local Origin = DamageInfo:GetDamagePosition()
	Effect:SetOrigin( Origin )
	Effect:SetScale( 1 )
	if (NPCsHitEffects[Entity:GetClass()]) then
		util.Effect( NPCsHitEffects[Entity:GetClass()], Effect )
		util.Effect( NPCsHitEffects.Default, Effect )

hook.Add("EntityTakeDamage", "Ragdoll Effect", RagdollEffect)

Using the ‘NPCsHitEffects’ as an example, you can add an NPC to have a custom hit effect. Just place the NPC’s name, surround it in brackets and quotation marks or apostrophes, and have it equal to an effect (A list can be found at **[Util.Effect list

http://wiki.garrysmod.com/favicon.ico](http://gmodwiki.com/wiki.garrysmod.com/indexe14a.html?title=Util.Effect_list)**). If the NPC that is hit has an effect data pre-defined, then it’ll use that effect, or it’ll use “NPCsHitEffects.Default”'s value.


Nicely done, I totally forgot about checking the ragdoll type and had a bleeding Dog and Gunship :stuck_out_tongue:

That’s certainly helpful, I’m having the wiki on my harddrive though :stuck_out_tongue:

Awesome, thank you very much for your time. :slight_smile: