Muzzle Flash (CSS Style)

This tutorial is an expansion to the previous posted tutorial on CSS Muzzle Flashes although that original code was edited slightly this code, expands on the idea and of course fixing it to working more like the actual CSS muzzle flash.
Step 1. Open c_baseanimating.cpp and around line 3866, comment the following code so it looks like this.
		 if ( iAttachment != -1 && m_Attachments.Count() > iAttachment )
			{
			 /*
				GetAttachment( iAttachment+1, attachOrigin, attachAngles );
				int entId = render->GetViewEntity();
				ClientEntityHandle_t hEntity = ClientEntityList().EntIndexToHandle( entId );
				tempents->MuzzleFlash( attachOrigin, attachAngles, atoi( options ), hEntity, bFirstPerson );
				*/
 			}
and underneath it add the following code.
 if ( input->CAM_IsThirdPerson() )
 			{
 				C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
 				pWeapon->GetAttachment( 1, attachOrigin, attachAngles );
 			}
 			else
 			{
 				C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
 				CBaseViewModel *vm = pPlayer->GetViewModel();
 				vm->GetAttachment( 1, attachOrigin, attachAngles );
 				engine->GetViewAngles( attachAngles );
 			}
Step 2. Open up Fx.cpp and in void FX_MuzzleEffect and under pParticle->m_vecVelocity.Init(); add the following code
 C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
		Vector velocity = pPlayer->GetLocalVelocity();
		pParticle->m_vecVelocity += velocity;
Step 3. Setting up the muzzle flash.
Still in fx.cpp we need to first precache the muzzle flash so around line 34 add in
CLIENTEFFECT_MATERIAL( "effects/muzzleflashX" )
and now back to void FX_MuzzleEffect fined the line
==NOTE ==
This is just a personal preference and its as close as you can get to CSS right now at the moment (in till i figure out the last bit of codding but what i changed is instead of having the muzzle flash keep changing sizes it stays at one set size like in CSS, so this part of the code is optional
 float flScale = random->RandomFloat( scale-0.25f, scale+0.25f );
	if ( flScale < 0.5f )
	{
		flScale = 0.5f;
	}
	else if ( flScale > 8.0f )
	{
		flScale = 8.0f;
	}
and change it to just
	float flScale = 0.8f;
now for the material itself, scroll down in till you see this bit of code here
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), pSimple->GetPMaterial( VarArgs( "effects/muzzleflash%d", random->RandomInt(1,4) ) ), offset );	
and change it to
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), pSimple->GetPMaterial( VarArgs( "effects/muzzleflashX" ) ), offset );
now for the final 3 steps, dietime, rotations and color.
- first will set the dietime so find
pParticle->m_flDieTime		= /*bOneFrame ? 0.0001f : */0.1f;
and change it to
pParticle->m_flDieTime		= 0.025f;
The rotation is also an optional effect like in css there is no rotation but removing the rotation for this tutorial, i find personaly looks a lot better, so what your going to do is comment out this line like so
//pParticle->m_flRoll		= random->RandomInt( 0, 360 );
and lastly the color, this part of the code is pretty much straight forward. right now its set as white and you can play around with this as much as you like intill you gain your wanted effect.
 //I found best effect using 252, 238, 128
		pParticle->m_uchColor[0]	= 255;
		pParticle->m_uchColor[1]	= 255;
		pParticle->m_uchColor[2]	= 200+random->RandomInt(0,55); //dont remove +random->RandomInt(0,55);
Thats it compile the code and run your mod. Post here if you have problems. **Works on both OB and EP1 SDK's. Please post your comments
What I did was i used the css muzzle flash from CSS but if you want to remname the muzzle flash juts replace "effects/muzzleflashX" with what ever you want.
Above all I would like to thank the original person who first posted the tutorial on adding css muzzle flashes to the VDC website which helped me start off with a base code that went threw minor edits in my tutorial.
for added effect check out my tutorial for muzzle flashes lighting
== NOTES ==
There is still a few touch ups that can be done to have this running like CSS.
1. Different scales for each weapon (which i am currently working on)
2. The muzzle flash tends to clip into the wall and even disappear into the wall.
Category:Counter-Strike: Source