Using specific TF2 particles

Hi. I’m making a weapon and I want to use the Righteous Bison particles from TF2. However, they do not seem be rendering.

If I use the following code:

lua_run ParticleEffect( "critgun_weaponmodel_red", Entity(1):GetEyeTrace().HitPos + Vector(0,0,100), Angle(0,0,0), nil )

in singleplayer, I see the TF2 crit effect as expected. However if I use the particle drg_bison_projectile, which is the Bison’s projectile particle…

lua_run ParticleEffect( "drg_bison_projectile", Entity(1):GetEyeTrace().HitPos + Vector(0,0,100), Angle(0,0,0), nil )

I see nothing.

Anyone know how this can be fixed?

edit: For the record, the particles are in the drg_bison particle file

Use it on the client (lua_run_cl).

That just results in an error particle (lots of x’es)

You need to precache the effect using PrecacheParticleSystem(“effect_name_here”) both serverside AND clientside. Even if you’re going to use it clientside only, not precaching an effect serverside still makes it show up as red X’es clientside.

I added the following to my weapon’s precache function:


Then ran

lua_run_cl ParticleEffect( "critgun_weaponmodel_red", Entity(1):GetEyeTrace().HitPos + Vector(0,0,100), Angle(0,0,0), nil )
lua_run_cl ParticleEffect( "drg_bison_projectile", Entity(1):GetEyeTrace().HitPos + Vector(0,0,100), Angle(0,0,0), nil )

The crit particle displayed fine, the bison particle did not display at all (not even x’es)

You’re right; I tried “drg_bison_projectile” as well, it didn’t show up. Will have a look at it in the Particle Editor.

Thanks, I’ll be awaiting your response :smiley:

Ah well, might as well spare you unneeded research.
All the effects related to the Cow Mangler and the Righteous Bison use some kind of “hack” to allow giving them team colours without creating a particle system for the red effect and another one for the blue effect.
Basically they remapped control point 9 and 10 to the color of different elements in the effect. I think 9 is the color of the main glowing part and 10 is the color of the rings, not sure though, you’ll have to experiment with that.

So you’ll have to use Entity:CreateParticleEffect() since ParticleEffect doesn’t allow you to set control points. That also means that you will need a projectile entity to which this effect will attach.

[lua] self:CreateParticleEffect(“drg_bison_projectile”, {

CreateParticleEffect takes an effect name and a list of control points. A control point can be either attached to an effect, or assigned to a fixed position. The first element of the list is control point 0, it’s what positions the main body of the effect, I’m telling it to attach to “self”, and to follow its origin. The 8 next elements are unused control points (1 to 8), so I just put nothing in there. Then you have control points 9 and 10, whose position control the color of the beam. Vector(0, 0, 0) is pure black (or invisible if the particles are additive, which explains why your effect didn’t show up), and Vector(1, 1, 1) is pure white.
In my example, you’ll get a purely red beam, as you guessed it, the red component is mapped to the X value of the vector, the green component is mapped to the Y value, and blue is mapped to Z.

I sure hope that was helpful because it took me quite a while to figure that out. :v:

Also, the code I gave you should work, unless you’re really doing something wrong. That’s the code I’m using, only slightly modified.

Weird, I’m getting a strange error

[tf_projectile\init.lua:38] attempt to call method 'CreateParticleEffect' (a nil value)

The entity’s base is base_gmodentity; should it be something else?

function ENT:Initialize()

	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_CUSTOM )
    if (self.ParticleEffect) then
        //local iTeam = self.owner.Owner:Team()
        local effect = self.ParticleEffect
        self:CreateParticleEffect("drg_bison_projectile", {

**[Entity.CreateParticleEffect](** is only available on the client; you’re trying to use it in init.lua.


sorry, my bad. Thanks :smiley: