• Ragdoll Bleeding Function
    8 replies, posted
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.
[QUOTE=Failure;36719490]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.[/QUOTE] 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) [CODE] 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 ) end end hook.Add("EntityTakeDamage", "holyshit", hiteffect) [/CODE]
[QUOTE=Failure;36725823]Well too bad the old wiki's down, you could've use it for this. [/QUOTE] here ya go my fine fellows. the wiki was moved. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html?title=Main_Page[/url]
Works like a charm, thanks! I'd also be interested in learning how you'd change the blood particle type according to the npc.
[QUOTE=Fidchell;36732487]Works like a charm, thanks! I'd also be interested in learning how you'd change the blood particle type according to the npc.[/QUOTE] Using Failure's script as a base, you can do... [CODE] 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 ) else util.Effect( NPCsHitEffects.Default, Effect ) end end hook.Add("EntityTakeDamage", "Ragdoll Effect", RagdollEffect) [/CODE] 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 [b][url=http://gmodwiki.com/wiki.garrysmod.com/indexe14a.html?title=Util.Effect_list]Util.Effect list [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]). 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. Enjoy!
[QUOTE=Mr. Quiggles;36733211]Using Failure's script as a base, you can do... [CODE] 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 ) else util.Effect( NPCsHitEffects.Default, Effect ) end end hook.Add("EntityTakeDamage", "Ragdoll Effect", RagdollEffect) [/CODE] 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 [b][url=http://gmodwiki.com/wiki.garrysmod.com/indexe14a.html?title=Util.Effect_list]Util.Effect list [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]). 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. Enjoy![/QUOTE] Nicely done, I totally forgot about checking the ragdoll type and had a bleeding Dog and Gunship :P [QUOTE=FrankPetrov;36727390]here ya go my fine fellows. the wiki was moved. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html?title=Main_Page[/url][/QUOTE] That's certainly helpful, I'm having the wiki on my harddrive though :P
[QUOTE=Mr. Quiggles;36733211]Using Failure's script as a base, you can do... [CODE] 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 ) else util.Effect( NPCsHitEffects.Default, Effect ) end end hook.Add("EntityTakeDamage", "Ragdoll Effect", RagdollEffect) [/CODE] 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 [b][url=http://gmodwiki.com/wiki.garrysmod.com/indexe14a.html?title=Util.Effect_list]Util.Effect list [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]). 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. Enjoy![/QUOTE] Awesome, thank you very much for your time. :)
Sorry, you need to Log In to post a reply to this thread.