rg_ShellEject Modification

You know that beutiful rg_shelleject effect when you download CS:S Realistic weapons? I was trying to change the shell model that was ejected, but I ran into a problem.

EDIT: Yeah it turns out the effect I though I was looking at, just was an effect to set values for a default effect made by VALVe.

As shown on this line



util.Effect("**ShellEject**", effectdata)


Intrestingly enough, No body pointed this out to me.

Here is the shell eject LUA
Name: rg_shelleject


 function EFFECT:Init(data)
	
	self.WeaponEnt = data:GetEntity()
	self.Attachment = data:GetAttachment()
	if not (self.WeaponEnt:IsValid() and self.WeaponEnt:IsWeapon()) then return end
	
	self.Normal = data:GetNormal()

	if self.WeaponEnt:IsCarriedByLocalPlayer() and GetViewEntity() == LocalPlayer() then 
	
		local ViewModel = LocalPlayer():GetViewModel()
		if not ViewModel:IsValid() then return end
				
		self.EjectionPort = ViewModel:GetAttachment(self.Attachment)
		if not self.EjectionPort then return end

		self.Angle = self.EjectionPort.Ang
		self.Forward = self.Angle:Forward()
		self.Position = self.EjectionPort.Pos

		
	else

		self.EjectionPort = self.WeaponEnt:GetAttachment(self.Attachment)
		if not self.EjectionPort then return end
		
		self.Forward = self.Normal:Angle():Right()
		self.Angle = self.Forward:Angle()
		self.Position = self.EjectionPort.Pos - (0.5*self.WeaponEnt:BoundingRadius())*self.EjectionPort.Ang:Forward()	
		
	end

	local AddVel = self.WeaponEnt:GetOwner():GetVelocity()

	local effectdata = EffectData()
	effectdata:SetOrigin(self.Position)
	effectdata:SetAngle(self.Angle)
	effectdata:SetEntity(self.WeaponEnt)
	util.Effect("ShellEject", effectdata)

	local emitter = ParticleEmitter(self.Position)
		
		for i=1,2 do
			local particle = emitter:Add("particle/particle_smokegrenade", self.Position)
			particle:SetVelocity(6*i*self.Forward + 1.02*AddVel)
			particle:SetDieTime(math.Rand(0.33,0.35))
			particle:SetStartAlpha(math.Rand(50,60))
			particle:SetStartSize(1)
			particle:SetEndSize(math.Rand(2,3)*i)
			particle:SetRoll(math.Rand(180,480))
			particle:SetRollDelta(math.Rand(-1,1))
			particle:SetColor(245,245,245)
			particle:SetLighting(true)
			particle:SetAirResistance(40)
		end

	emitter:Finish()

end


function EFFECT:Think()

	return false
	
end


function EFFECT:Render()


end 

It emits a pistol shell (models\weapons\shell.mdl) when you shoot.

I don’t see anything in that, where it calls a model :S, sorry can’t help.

I put the rg_shelleject_rifle & rg_shelleject through a doc comparason on MS Word (used for legal documentation) im a hope to find an obvuse diffrence, definatly that selects the model, but the only change i could find was with the angling #'s.

I probly did miss something, or the lua refers to something else, that is the same in both …

If the lua dose call on another source, then i’ll isolate it in a way that gives back an error code in console

Okay, I noticed where it hints* the shell model


 util.Effect("ShellEject", effectdata) 

Found near “local emitter = ParticleEmitter(self.Position)” near the end of the code.

I Know from experience that the V_SMG model (From HL2) emits shells WITHOUT any Eject scripts.
I’m sure its because of presets in the model or in the “Weapon_base” (HL2 base weapon. Not download).
Now i’m not 100% sure on my process of thought but, that may provide the information for the effect.
So thats what it calls for… Nothing too major.

I belive the script are calling on effects built into HL2.

Thus why the SMG1 model’s Primary Fire can eject a pistol shell and why the Shotgun model’s pump animation can eject a shotgun, without any scripts

The rifle shell eject was unused in HL2. Non of the models use it, but its there -,-

So most of the script is an angular equation and Im not going to be able to modify these unless I come up with some script to imitate the ones in HL2.


void ShellEjectCallback( const CEffectData &data )
{
	// Use the gun angles to orient the shell
	IClientRenderable *pRenderable = data.GetRenderable();
	if ( pRenderable )
	{
		tempents->EjectBrass( data.m_vOrigin, data.m_vAngles, pRenderable->GetRenderAngles(), 0 );
	}
}

DECLARE_CLIENT_EFFECT( "ShellEject", ShellEjectCallback );

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void RifleShellEjectCallback( const CEffectData &data )
{
	// Use the gun angles to orient the shell
	IClientRenderable *pRenderable = data.GetRenderable();
	if ( pRenderable )
	{
		tempents->EjectBrass( data.m_vOrigin, data.m_vAngles, pRenderable->GetRenderAngles(), 1 );
	}
}

DECLARE_CLIENT_EFFECT( "RifleShellEject", RifleShellEjectCallback );

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ShotgunShellEjectCallback( const CEffectData &data )
{
	// Use the gun angles to orient the shell
	IClientRenderable *pRenderable = data.GetRenderable();
	if ( pRenderable )
	{
		tempents->EjectBrass( data.m_vOrigin, data.m_vAngles, pRenderable->GetRenderAngles(), 2 );
	}
}

DECLARE_CLIENT_EFFECT( "ShotgunShellEject", ShotgunShellEjectCallback );