void CGEStats::Event_PlayerKilledOther( CBasePlayer *pAttacker, CBaseEntity *pVictim, const CTakeDamageInfo &info )
{
	//Make sure there is a victim and an attacker
	if( !pVictim || !pAttacker )
		return;
	
	//Make sure the victim is a player
	if( !pVictim->IsPlayer() )
		return;

	CBasePlayer *pBaseVictim = static_cast<CBasePlayer*>(pVictim);

	//Return both Player ID's
	int iVictim = FindPlayer( pBaseVictim );
	int iAttacker = FindPlayer( pAttacker );
	
	if( iVictim == -1  || iAttacker == -1 )
		return;

	// Check for suicide
	if ( pVictim == pAttacker )
	{
		m_pPlayerStats[iVictim]->AddStat( GE_AWARD_PROFESSIONAL, -15 );
		m_pPlayerStats[iVictim]->AddStat( GE_AWARD_MOSTLYHARMLESS, 50 );
		m_pPlayerStats[iVictim]->AddStat( GE_AWARD_LEMMING, 3 );
	}
	else
	{
		m_pPlayerStats[iVictim]->AddStat( GE_AWARD_PROFESSIONAL , -5 );
		m_pPlayerStats[iVictim]->AddStat( GE_AWARD_MOSTLYHARMLESS, 30 );

		m_pPlayerStats[iAttacker]->AddStat( GE_AWARD_DEADLY , 50 );
		m_pPlayerStats[iAttacker]->AddStat( GE_AWARD_PROFESSIONAL , 5 );

		int weapid = WEAPON_NONE;
		if ( info.GetWeapon() )
			weapid = ToGEWeapon( (CBaseCombatWeapon*)info.GetWeapon() )->GetWeaponID();
		else if ( !info.GetInflictor()->IsNPC() && Q_stristr( info.GetInflictor()->GetClassname(), "npc_" ) )
			weapid = ToGEGrenade( info.GetInflictor() )->GetWeaponID();

		if ( weapid != WEAPON_NONE )
			// Increment our kills with this weapon
			m_pPlayerStats[iAttacker]->m_iWeaponsKills[weapid]++;
	}

	BaseClass::Event_PlayerKilledOther( pAttacker, pVictim, info );
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// Purpose: Add damage to the existing multidamage, and apply if it won't fit
//-----------------------------------------------------------------------------
void AddMultiDamage( const CTakeDamageInfo &info, CBaseEntity *pEntity )
{
	if ( !pEntity )
		return;

	if ( pEntity != g_MultiDamage.GetTarget() )
	{
		ApplyMultiDamage();
		g_MultiDamage.Init( pEntity, info.GetInflictor(), info.GetAttacker(), info.GetWeapon(), vec3_origin, vec3_origin, vec3_origin, 0.0, info.GetDamageType(), info.GetDamageCustom() );
	}

	g_MultiDamage.AddDamageType( info.GetDamageType() );
	g_MultiDamage.SetDamage( g_MultiDamage.GetDamage() + info.GetDamage() );
	g_MultiDamage.SetDamageForce( g_MultiDamage.GetDamageForce() + info.GetDamageForce() );
	g_MultiDamage.SetDamagePosition( info.GetDamagePosition() );
	g_MultiDamage.SetReportedPosition( info.GetReportedPosition() );
	g_MultiDamage.SetMaxDamage( MAX( g_MultiDamage.GetMaxDamage(), info.GetDamage() ) );
	g_MultiDamage.SetAmmoType( info.GetAmmoType() );

	if ( g_MultiDamage.GetPlayerPenetrationCount() == 0 )
	{
		g_MultiDamage.SetPlayerPenetrationCount( info.GetPlayerPenetrationCount() );
	}

	bool bHasPhysicsForceDamage = !g_pGameRules->Damage_NoPhysicsForce( info.GetDamageType() );
	if ( bHasPhysicsForceDamage && g_MultiDamage.GetDamageType() != DMG_GENERIC )
	{
		// If you hit this assert, you've called TakeDamage with a damage type that requires a physics damage
		// force & position without specifying one or both of them. Decide whether your damage that's causing 
		// this is something you believe should impart physics force on the receiver. If it is, you need to 
		// setup the damage force & position inside the CTakeDamageInfo (Utility functions for this are in
		// takedamageinfo.cpp. If you think the damage shouldn't cause force (unlikely!) then you can set the 
		// damage type to DMG_GENERIC, or | DMG_CRUSH if you need to preserve the damage type for purposes of HUD display.
		if ( g_MultiDamage.GetDamageForce() == vec3_origin || g_MultiDamage.GetDamagePosition() == vec3_origin )
		{
			static int warningCount = 0;
			if ( ++warningCount < 10 )
			{
				if ( g_MultiDamage.GetDamageForce() == vec3_origin )
				{
					Warning( "AddMultiDamage:  g_MultiDamage.GetDamageForce() == vec3_origin\n" );
				}

				if ( g_MultiDamage.GetDamagePosition() == vec3_origin)
				{
					Warning( "AddMultiDamage:  g_MultiDamage.GetDamagePosition() == vec3_origin\n" );
				}
			}
		}
	}
}
Ejemplo n.º 3
0
void CASW_Harvester::Event_Killed( const CTakeDamageInfo &info )
{
	BaseClass::Event_Killed(info);

	// spawn a bunch of harvesites
	int iNumParasites = 4 + RandomInt(0,2);
	QAngle angParasiteFacing[6];
	float fJumpDistance[6];
	// for some reason if we calculate these inside the loop, the random numbers all come out the same.  Worrying.
	angParasiteFacing[0] = GetAbsAngles(); angParasiteFacing[0].y = RandomFloat( -180.0f, 180.0f );
	angParasiteFacing[1] = GetAbsAngles(); angParasiteFacing[1].y = RandomFloat( -180.0f, 180.0f );
	angParasiteFacing[2] = GetAbsAngles(); angParasiteFacing[2].y = RandomFloat( -180.0f, 180.0f );
	angParasiteFacing[3] = GetAbsAngles(); angParasiteFacing[3].y = RandomFloat( -180.0f, 180.0f );
	angParasiteFacing[4] = GetAbsAngles(); angParasiteFacing[4].y = RandomFloat( -180.0f, 180.0f );
	angParasiteFacing[5] = GetAbsAngles(); angParasiteFacing[5].y = RandomFloat( -180.0f, 180.0f );
	fJumpDistance[0] = RandomFloat( 30.0f, 70.0f );
	fJumpDistance[1] = RandomFloat( 30.0f, 70.0f );
	fJumpDistance[2] = RandomFloat( 30.0f, 70.0f );
	fJumpDistance[3] = RandomFloat( 30.0f, 70.0f );
	fJumpDistance[4] = RandomFloat( 30.0f, 70.0f );
	fJumpDistance[5] = RandomFloat( 30.0f, 70.0f );

	for ( int i = 0; i < iNumParasites; i++ )
	{
		bool bBlocked = true;			
		int k = 0;

		Vector vecSpawnPos = GetAbsOrigin();
		float fCircleDegree = ( static_cast< float >( i ) / iNumParasites ) * 2.0f * M_PI;
		vecSpawnPos.x += sinf( fCircleDegree ) * RandomFloat( 3.0f, 20.0f );
		vecSpawnPos.y += cosf( fCircleDegree ) * RandomFloat( 3.0f, 20.0f );
		vecSpawnPos.z += RandomFloat( 20.0f, 40.0f );

		while ( bBlocked && k < 6 )
		{
			if ( k > 0 )
			{
				// Scooch it up
				vecSpawnPos.z += NAI_Hull::Maxs( HULL_TINY ).z - NAI_Hull::Mins( HULL_TINY ).z;
			}

			// check if there's room at this position
			trace_t tr;
			UTIL_TraceHull( vecSpawnPos, vecSpawnPos + Vector( 0.0f, 0.0f, 1.0f ), 
				NAI_Hull::Mins(HULL_TINY) + Vector( -4.0f, -4.0f, -4.0f ),NAI_Hull::Maxs(HULL_TINY) + Vector( 4.0f, 4.0f, 4.0f ),
				MASK_NPCSOLID, this, ASW_COLLISION_GROUP_PARASITE, &tr );	
			
			//NDebugOverlay::Box(vecSpawnPos[i], NAI_Hull::Mins(HULL_TINY),NAI_Hull::Maxs(HULL_TINY), 255,255,0,255,15.0f);
			if ( tr.fraction == 1.0 )
			{
				bBlocked = false;
			}

			k++;				
		}

		if ( bBlocked )
			continue;	// couldn't find room for parasites

		CASW_Parasite *pParasite = dynamic_cast< CASW_Parasite* >( CreateNoSpawn("asw_parasite_defanged",
			vecSpawnPos, angParasiteFacing[i], this));

		if ( pParasite )
		{
			DispatchSpawn( pParasite );
			pParasite->SetSleepState(AISS_WAITING_FOR_INPUT);
			pParasite->SetJumpFromEgg(true, fJumpDistance[i]);
			pParasite->Wake();

			if ( IsOnFire() )
			{
				pParasite->ASW_Ignite( 30.0f, 0, info.GetAttacker(), info.GetWeapon() );
			}
		}
	}

	m_fGibTime = gpGlobals->curtime + random->RandomFloat(20.0f, 30.0f);
}