Hello. I was trying to get a autorun script to work. Basically it checks if a ragdoll has been damaged, and if so, create an emitter blood effect. The problem is that it gives me an error related to the DamageInfo, and i cant figure out what is wrong.
[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]
Thanks!
If you could show me the error, I can see what I can do for it...
[ERROR] lua/autorun/rag_blood.lua:12: attempt to index local 'DamageInfo' (a nil value)
1. v - lua/autorun/rag_blood.lua:12
2. unknown - lua/includes/modules/hook.lua:82
There it is.
EntityTakeDamage only has 2 arguments now so
[lua]RagdollEffect( Entity, DamageInfo )[/lua]
[QUOTE=Annoyed Tree;39734718]EntityTakeDamage only has 2 arguments now so
[lua]RagdollEffect( Entity, DamageInfo )[/lua][/QUOTE]
It probably got confused to which name meant the actual damage info...
[QUOTE=angrypepper;39735690]It probably got confused to which name meant the actual damage info...[/QUOTE]
Well in a way, technically "Inflictor" was "DamageInfo" and everything after Inflictor doesn't even get passed to the function
-snip-
Whoops i posted the wrong script! /facepalm
[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]
Thats the one i meant to post.
The error i get is:
[ERROR] lua/autorun/rag_blood.lua:6: attempt to index local 'dmginfo' (a nil value)
1. v - lua/autorun/rag_blood.lua:6
2. unknown - lua/includes/modules/hook.lua:82
Sorry about that.
[editline]27th February 2013[/editline]
-bump-
Like I said before.... change
[lua]function hiteffect( ent, inflictor, attacker, amount, dmginfo)[/lua]
[b]to[/b]
[lua]function hiteffect( ent, dmginfo)[/lua]
Yeah i figured that out, i later noticed that i forgot to change that, but then i didn't post. Thanks anyway.
But for some reason the blood particle isn't emitting when i hit the ragdoll/corpse. What is wrong???
[QUOTE=buu342;39746440]Yeah i figured that out, i later noticed that i forgot to change that, but then i didn't post. Thanks anyway.
But for some reason the blood particle isn't emitting when i hit the ragdoll/corpse. What is wrong???[/QUOTE]
Try setting the Effect scale to something major, the antlion thumper effect requires a size of 70.
[QUOTE=angrypepper;39748681]Try setting the Effect scale to something major, the antlion thumper effect requires a size of 70.[/QUOTE]
thanks! Fixed it, i couldn't find the correct scale so i just deleted the line and it worked!
Btw what is the script that places decals? I wanted to make it so that it would leave blood splats on the floor/walls when the ragdoll gets shot or hits something.
You'll need util.decal for it.
[QUOTE=Failure;39759424]You'll need util.decal for it.[/QUOTE]
Alright thanks!
I cant seem to get the tracing to work. Could someone give me a hand? I want it so that when i hit a ragdoll that is close enough to the floor or a wall, it paints the blood decal on the floor, but i am having trouble achieving the effect. Could someone help me quickly get this effect?
I've got this inside an EntityTakeDamage hook. Then you need to add a check if the entity is a ragdoll.
It's an old piece of code, so don't mind the effectdata. Basically you need to provide two positions, one with normal added and one with subtracted.
[CODE]
if(dmginfo:IsDamageType(DMG_CRUSH) or dmginfo:IsDamageType(DMG_FALL)) and (dmginfo:GetDamage() >= SlapDamage) then
local effectdata = EffectData()
local Pos1 = pos - pos:GetNormalized()
local Pos2 = pos + pos:GetNormalized()
effectdata:SetOrigin( pos )
effectdata:SetScale( 1 )
util.Decal("Blood", Pos1, Pos2)
sound.Play( table.Random(bloodysounds), entpos, 100, 100 )
ParticleEffect("blood_impact_red_01",pos,Angle(0,0,0),nil)
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.