General SDK Snippets & Fixes: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
Line 59: Line 59:
=Working CS:S Muzzle Flashes without Model Editing=
=Working CS:S Muzzle Flashes without Model Editing=


In c_baseanimating.cpp, at line 3024 (after the big ass switch statement), comment out the code so it looks like this
In c_baseanimating.cpp, at line 3024 (after the big switch statement), comment out the 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 );
*/
}


<pre>
and insert the following code after the comment.
//if ( iAttachment != -1 && m_Attachments.Count() > iAttachment )
 
{
 
//GetAttachment( iAttachment+1, attachOrigin, attachAngles );
 
//int entId = render->GetViewEntity();
 
//tempents->MuzzleFlash( attachOrigin, attachAngles, atoi( options ), entId, bFirstPerson );
 
</pre>
 
and place the following below it. (be sure not to comment out the ending brakets and final breaks)
 
 
<pre>
if ( iAttachment != -1 && m_Attachments.Count() > iAttachment )
{
if ( input->CAM_IsThirdPerson() )
{
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
pWeapon->GetAttachment( iAttachment+1, attachOrigin, attachAngles );
}
else
{
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
CBaseViewModel *vm = pPlayer->GetViewModel();
vm->GetAttachment( iAttachment+1, attachOrigin, attachAngles );
engine->GetViewAngles( attachAngles );
}
g_pEffects->MuzzleFlash( attachOrigin, attachAngles, 1.0, MUZZLEFLASH_TYPE_DEFAULT );
}
 
</pre>
 
Go to fx.cpp, line 227 (under the statement "pParticle->m_vecVelocity.Init();"), place the following code.
 


<pre>
<pre>
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
if ( input->CAM_IsThirdPerson() )
Vector velocity = pPlayer->GetLocalVelocity();
{
pParticle->m_vecVelocity += velocity;
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
pWeapon->GetAttachment( iAttachment+1, attachOrigin, attachAngles );
}
else
{
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
CBaseViewModel *vm = pPlayer->GetViewModel();
vm->GetAttachment( iAttachment+1, attachOrigin, attachAngles );
engine->GetViewAngles( attachAngles );
}
g_pEffects->MuzzleFlash( attachOrigin, attachAngles, 1.0, MUZZLEFLASH_TYPE_DEFAULT );
</pre>
</pre>


There you go, working muzzle flashes for CS:S weapons in HL2
Go to fx.cpp, under the statement pParticle->m_vecVelocity.Init();</code> in FX_MuzzleFlash, place the following code.


[[User:Trleighton|Trleighton]] 15:00, 25 May 2007 (PDT)
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
Vector velocity = pPlayer->GetLocalVelocity();
pParticle->m_vecVelocity += velocity;


[[Category:Snippets]]
[[Category:Snippets]]

Revision as of 17:02, 25 May 2007


Remove Head Crab

How to Remove HeadCrab from zombie

in hl2_dll\npc_zombie.cpp look for void CZombie::Spawn( void ) then find this line.

m_fIsHeadless = false;

ans simply change it to read this

m_fIsHeadless = true;

Now open hl2_dll\npc_BaseZombie.cpp and change this section to look like this.

//-----------------------------------------------------------------------------
// Purpose: A zombie has taken damage. Determine whether he release his headcrab.
// Output : YES, IMMEDIATE, or SCHEDULED (see HeadcrabRelease_t)
//-----------------------------------------------------------------------------
HeadcrabRelease_t CNPC_BaseZombie::ShouldReleaseHeadcrab( const CTakeDamageInfo &info, float flDamageThreshold )
{
if ( m_iHealth <= 0 )
{
// If I was killed by a bullet...
if ( info.GetDamageType() & DMG_BULLET )
{
if( m_bHeadShot )
{
if( flDamageThreshold > 0.25 )
{
// Enough force to kill the crab.
//return RELEASE_RAGDOLL;
}
}
else
{
// Killed by a shot to body or something. Crab is ok!
//return RELEASE_IMMEDIATE;
}
}

// If I was killed by an explosion, release the crab.
if ( info.GetDamageType() & DMG_BLAST )
{
//return RELEASE_RAGDOLL;
}

if ( m_fIsTorso && IsChopped( info ) )
{
return RELEASE_RAGDOLL_SLICED_OFF;
}
}

return RELEASE_NO;
} 


Working CS:S Muzzle Flashes without Model Editing

In c_baseanimating.cpp, at line 3024 (after the big switch statement), comment out the 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 insert the following code after the comment.

 				if ( input->CAM_IsThirdPerson() )
 				{
 					C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
 					pWeapon->GetAttachment( iAttachment+1, attachOrigin, attachAngles );
 				}
 				else
 				{
 					C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
 					CBaseViewModel *vm = pPlayer->GetViewModel();
 					vm->GetAttachment( iAttachment+1, attachOrigin, attachAngles );
 					engine->GetViewAngles( attachAngles );
 				}
 				g_pEffects->MuzzleFlash( attachOrigin, attachAngles, 1.0, MUZZLEFLASH_TYPE_DEFAULT );

Go to fx.cpp, under the statement pParticle->m_vecVelocity.Init(); in FX_MuzzleFlash, place the following code.

		C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
		Vector velocity = pPlayer->GetLocalVelocity();
		pParticle->m_vecVelocity += velocity;