Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CAntlionGrub::Squash( CBaseEntity *pOther, bool bDealDamage, bool bSpawnBlood )
{
	// If we're already squashed, then don't bother doing it again!
	if ( GetEffects() & EF_NODRAW )
		return;

	SpawnSquashedGrub();

	AddEffects( EF_NODRAW );
	AddSolidFlags( FSOLID_NOT_SOLID );
	
	// Stop being attached to us
	if ( m_hGlowSprite )
	{
		FadeGlow();
		m_hGlowSprite->SetParent( NULL );
	}

	EmitSound( "NPC_Antlion_Grub.Die" );
	EmitSound( "NPC_Antlion_Grub.Squish" );

	// if vort stepped on me, maybe he wants to say something
	if ( pOther && FClassnameIs( pOther, "npc_vortigaunt" ) )
	{
		Assert(dynamic_cast<CNPC_Vortigaunt *>(pOther));
		static_cast<CNPC_Vortigaunt *>(pOther)->OnSquishedGrub(this);
	}

	SetTouch( NULL );

	//if ( bSpawnBlood )
	{
		// Temp squash effect
		Vector vecForward, vecUp;
		AngleVectors( GetAbsAngles(), &vecForward, NULL, &vecUp );

		// Start effects at either end of the grub
		Vector vecSplortPos = GetAbsOrigin() + vecForward * 14.0f;
		DispatchParticleEffect( "GrubSquashBlood", vecSplortPos, GetAbsAngles() );

		vecSplortPos = GetAbsOrigin() - vecForward * 16.0f;
		Vector vecDir = -vecForward;
		QAngle vecAngles;
		VectorAngles( vecDir, vecAngles );
		DispatchParticleEffect( "GrubSquashBlood", vecSplortPos, vecAngles );
		
		MakeSquashDecals( GetAbsOrigin() + vecForward * 32.0f );
		MakeSquashDecals( GetAbsOrigin() - vecForward * 32.0f );
	}

	// Deal deadly damage to ourself
	if ( bDealDamage )
	{
		CTakeDamageInfo info( pOther, pOther, Vector( 0, 0, -1 ), GetAbsOrigin(), GetHealth()+1, DMG_CRUSH );
		TakeDamage( info );
	}
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNPC_AntlionGrub::Squash( CBaseEntity *pOther )
{
	SpawnSquashedGrub();

	AddEffects( EF_NODRAW );
	AddSolidFlags( FSOLID_NOT_SOLID );
	
	EmitSound( "NPC_AntlionGrub.Squash" );
	
	BroadcastAlert();

	Vector vecUp;
	AngleVectors( GetAbsAngles(), NULL, NULL, &vecUp );

	trace_t	tr;
	
	for ( int i = 0; i < 4; i++ )
	{
		tr.endpos = WorldSpaceCenter();
		tr.endpos[0] += random->RandomFloat( -16.0f, 16.0f );
		tr.endpos[1] += random->RandomFloat( -16.0f, 16.0f );
		tr.endpos += vecUp * 8.0f;

		MakeDamageBloodDecal( 2, 0.8f, &tr, -vecUp );
	}

	SetTouch( NULL );

	m_bSquashed = true;

	// Temp squash effect
	CEffectData	data;
	data.m_fFlags = 0;
	data.m_vOrigin = WorldSpaceCenter();
	data.m_vNormal = vecUp;
	VectorAngles( vecUp, data.m_vAngles );
	data.m_flScale = random->RandomFloat( 5, 7 );
	data.m_fFlags |= FX_WATER_IN_SLIME;
	DispatchEffect( "watersplash", data );
}