I am relatively new to coding so please bear with me, I understand a bit of what im doing, but i havent learned how to *write the code* yet.
I've been making a swep for around a week now, and have not gotten what i wanted so i thought i'd make a thread.
Bear with me when i try to explain this to you.
What i want is a death effect, i kill someone on the opposing team, and their death animation is the same as the death animation for the secondary attack of the pulse rifle in the sandbox gamemode.
the effect in video form : [url]https://youtu.be/o3ka9a69EDQ[/url]
i found a code while searching titled AFC_Tracer, i thought it would be it so i tried adding it to the code of the gun, and it didnt work. i assume its because of one of two things,
either a : the code isnt meant to be directly imported into a swep like i tried to do with it; Or b : its the right effect and the right code, and im just not calling/ making it target the right person/team
the code that i imported :
[CODE]function EFFECT:Init( data )
self.Origin = data:GetOrigin()
self.DirVec = data:GetNormal()
self.Radius = data:GetRadius()
self.Emitter = ParticleEmitter( self.Origin )
end
function EFFECT:Think( )
for i=0, 2*self.Radius do
local Light = self.Emitter:Add( "sprites/light_glow02_add.vmt", self.Origin )
if (Light) then
Light:SetVelocity( Normal * math.random( 40,60*self.Radius) + VectorRand() * math.random( 25,50*self.Radius) )
Light:SetLifeTime( 0 )
Light:SetDieTime( math.Rand( 1 , 2 )*self.Radius/3 )
Light:SetStartAlpha( math.Rand( 50, 150 ) )
Light:SetEndAlpha( 0 )
Light:SetStartSize( 2.5*self.Scale )
Light:SetEndSize( 25*self.Radius )
Light:SetRoll( math.Rand(150, 360) )
Light:SetRollDelta( math.Rand(-2, 2) )
Light:SetAirResistance( 100 )
Light:SetGravity( Vector( math.random(-10,10)*self.Radius, math.random(-10,10)*self.Radius, 250 ) )
Light:SetColor( 170,140,90 )
end
end
end
function EFFECT:Render()
end[/CODE]
I think you can try [url]https://developer.valvesoftware.com/wiki/Env_entity_dissolver[/url]
I remember it working with E2(p)
thank you for the help, i will attempt to write this code, i dont know if ill be able to do it though..
will post what i have when i think i am finished writing it.
edit : im not really good at writing code, so i searched for more of this env_entity_dissolver to try to see if i could find someone who already solved it, *it would make my life easier.*
i found a large code from another post on this forum, and i assume it wasnt solved
this is the code
[CODE]function corpse_fizzle(corpse)
CORPSE.SetFound(corpse, false)
if string.find(corpse:GetModel(), "zm_", 6, true) then
-- corpse:Remove()
corpse:SetName("fizzled")
local dissolver = ents.Create( "env_entity_dissolver" )
dissolver:SetPos( ent:GetPos() )
dissolver:Spawn()
dissolver:Activate()
dissolver:SetKeyValue( "target", "fizzled")
dissolver:SetKeyValue( "magnitude", 100 )
dissolver:SetKeyValue( "dissolvetype", 0 )
dissolver:Fire( "Dissolve" )
dissolver:Remove()
elseif corpse.player_ragdoll then
-- corpse:Remove()
corpse:SetName("fizzled")
local dissolver = ents.Create( "env_entity_dissolver" )
dissolver:SetPos( ent:GetPos() )
dissolver:Spawn()
dissolver:Activate()
dissolver:SetKeyValue( "target", "fizzled")
dissolver:SetKeyValue( "magnitude", 100 )
dissolver:SetKeyValue( "dissolvetype", 0 )
dissolver:Fire( "Dissolve" )
dissolver:Remove()
end
end[/CODE]
i attempted to make it target players by adding [CODE]Entity:IsPlayer()[/CODE]
like this
[CODE] elseif corpse.player_ragdoll then
-- corpse:Remove()
corpse:SetName("fizzled")
local dissolver = ents.Create( "env_entity_dissolver" )
Entity:IsPlayer()
dissolver:SetPos( ent:GetPos() )
dissolver:Spawn()
dissolver:Activate()
dissolver:SetKeyValue( "target", "fizzled")
dissolver:SetKeyValue( "magnitude", 100 )
dissolver:SetKeyValue( "dissolvetype", 0 )
dissolver:Fire( "Dissolve" )
dissolver:Remove()
end
end[/CODE]
i saved it, tabbed into gmod where i was in singleplayer, and killed the opposing team, if i did enough damage, they exploded into gibs, like they would normally; Or, they would just die and fall to the ground, so its clear im not doing something right.
i know its possible to do this effect in this gamemode, there are custom weapons/sweps that already have this effect for when they kill enemies.
the gamemode is zs/ZombieSurvival
i dont know if that will help/change anything, but its there if it does.
ok, i figured it out, it was actually only one line of code to add to mine, however, if i deal too much damage to the enemy team, their body explodes into gibs, do you have an idea of how i would go about preventing that?
Sorry, you need to Log In to post a reply to this thread.