Muzzle Flash (CSS Style)
For DODS muzzle flashed I will be happy to provide the code for DODS muzzle flashes, just PM me and I will explain what to do, but for now enjoy the tutorial.
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;<pre> 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 <pre>//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
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