示例#1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : const char
//-----------------------------------------------------------------------------
const char *GetSyringeTrailParticleName( int iTeamNumber, bool bCritical )
{
	if (TFGameRules() && TFGameRules()->IsDeathmatch())
		return (bCritical ? "nailtrails_medic_dm_crit" : "nailtrails_medic_dm");

	switch (iTeamNumber)
	{
	case TF_TEAM_RED:
		return ( bCritical ? "nailtrails_medic_red_crit" : "nailtrails_medic_red" );
		break;

	case TF_TEAM_BLUE:
		return ( bCritical ? "nailtrails_medic_blue_crit" : "nailtrails_medic_blue" );
		break;

	case TF_TEAM_GREEN:
		return ( bCritical ? "nailtrails_medic_green_crit" : "nailtrails_medic_green" );
		break;

	case TF_TEAM_YELLOW:
		return ( bCritical ? "nailtrails_medic_yellow_crit" : "nailtrails_medic_yellow" );
		break;
	default:
		return ( bCritical ? "nailtrails_medic_red_crit" : "nailtrails_medic_red" );
		break;
	}
}
void CTFBotDeliverFlag::OnEnd(CTFBot *actor, Action<CTFBot> *action)
{
	/* BUG: will make bots that are intended to have SuppressFire lose it */
	actor->m_nBotAttrs &= ~CTFBot::AttributeType::SUPPRESSFIRE;
	
	if (TFGameRules() && TFGameRules()->IsMannVsMachineMode()) {
		// BUG: doesn't revert TF_COND_CRITBOOSTED_USER_BUFF if gained via flagcarrier upgrade
		actor->m_Shared.ResetSoldierBuffs();
	}
}
示例#3
0
float GetCurrentGravity( void )
{
#if defined( TF_CLIENT_DLL ) || defined( TF_DLL )
	if ( TFGameRules() )
	{
		return ( sv_gravity.GetFloat() * TFGameRules()->GetGravityMultiplier() );
	}
#endif 
	return sv_gravity.GetFloat();
}
void CTFFlameThrower::DeflectEntity( CBaseEntity *pEntity, CTFPlayer *pAttacker, Vector &vecDir )
{
	if ( !TFGameRules() )
		return;

	if ( ( pEntity->GetTeamNumber() == pAttacker->GetTeamNumber() ) && !TFGameRules()->IsDeathmatch() )
		return;

	pEntity->Deflected( pAttacker, vecDir );
	pEntity->EmitSound( "Weapon_FlameThrower.AirBurstAttackDeflect" );
}
ActionResult<CTFBot> CTFBotMvMEngineerTeleportSpawn::Update(CTFBot *actor, float dt)
{
	if (!this->m_ctPushAway.HasStarted()) {
		this->m_ctPushAway.Start(0.1f);
		
		if (this->m_hintEntity != nullptr) {
			TFGameRules()->PushAllPlayersAway(this->m_hintEntity->GetAbsOrigin(),
				400.0f, 500.0f, TF_TEAM_RED, nullptr);
		}
		
		return ActionResult<CTFBot>::Continue();
	}
	
	if (!this->m_ctPushAway.IsElapsed()) {
		return ActionResult<CTFBot>::Continue();
	}
	
	if (this->m_hintEntity == nullptr) {
		return ActionResult<CTFBot>::Done("Cannot teleport to hint as m_hintEntity is NULL");
	}
	
	Vector tele_pos = this->m_hintEntity->GetAbsOrigin();
	QAngle tele_ang = this->m_hintEntity->GetAbsAngles();
	
	actor->Teleport(tele_pos, tele_ang, nullptr);
	
	CPVSFilter filter(tele_pos);
	
	TE_TFParticleEffect(filter, 0.0f, "teleported_blue", tele_pos, vec3_angle);
	TE_TFParticleEffect(filter, 0.0f, "player_sparkles_blue", tele_pos, vec3_angle);
	
	if (this->m_bNonSilent) {
		TE_TFParticleEffect(filter, 0.0f, "teleported_mvm_bot", tele_pos, vec3_angle);
		actor->EmitSound("Engineer.MvM_BattleCry07");
		this->m_hintEntity->EmitSound("MvM.Robot_Engineer_Spawn");
		
		if (g_pPopulationManager != nullptr) {
			CWave *wave = g_pPopulationManager->GetCurrentWave();
			if (wave != nullptr) {
				if (wave->m_iEngiesTeleportedIn == 0) {
					TFGameRules()->BroadcastSound(255,
						"Announcer.MvM_First_Engineer_Teleport_Spawned");
				} else {
					TFGameRules()->BroadcastSound(255,
						"Announcer.MvM_Another_Engineer_Teleport_Spawned");
				}
				++wave->m_iEngiesTeleportedIn;
			}
		}
	}
	
	return ActionResult<CTFBot>::Done("Teleported");
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_TFProjectile_Rocket::CreateRocketTrails( void )
{
	if ( IsDormant() )
		return;

	if ( enginetrace->GetPointContents( GetAbsOrigin() ) & MASK_WATER )
	{
		ParticleProp()->Create( "rockettrail_underwater", PATTACH_POINT_FOLLOW, "trail" );
	}
	else
	{
		ParticleProp()->Create( GetTrailParticleName(), PATTACH_POINT_FOLLOW, "trail" );
	}

	if ( m_bCritical )
	{
		if ( TFGameRules() && TFGameRules()->IsDeathmatch() )
		{
			C_TFPlayer *pPlayer = ToTFPlayer(GetOwnerEntity());
			if (pPlayer)
			{
				pPlayer->m_Shared.SetParticleToMercColor(
					ParticleProp()->Create("critical_rocket_dm", PATTACH_ABSORIGIN_FOLLOW)
					);
				return;
			}
			ParticleProp()->Create("critical_rocket_red", PATTACH_ABSORIGIN_FOLLOW);
		}

		switch( GetTeamNumber() )
		{
		case TF_TEAM_RED:
			ParticleProp()->Create("critical_rocket_red", PATTACH_ABSORIGIN_FOLLOW);
			break;
		case TF_TEAM_BLUE:
			ParticleProp()->Create("critical_rocket_blue", PATTACH_ABSORIGIN_FOLLOW );
			break;
		case TF_TEAM_GREEN:
			ParticleProp()->Create("critical_rocket_green", PATTACH_ABSORIGIN_FOLLOW);
			break;
		case TF_TEAM_YELLOW:
			ParticleProp()->Create("critical_rocket_yellow", PATTACH_ABSORIGIN_FOLLOW);
			break;
		default:
			break;
		}
	}
}
示例#7
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void DispatchParticleEffect( int iEffectIndex, Vector vecOrigin, Vector vecStart, QAngle vecAngles, CBaseEntity *pEntity )
{
	CEffectData	data;

	data.m_nHitBox = iEffectIndex;
	data.m_vOrigin = vecOrigin;
	data.m_vStart = vecStart;
	data.m_vAngles = vecAngles;

	if ( pEntity )
	{
#ifdef CLIENT_DLL
		data.m_hEntity = pEntity;
#else
		data.m_nEntIndex = pEntity->entindex();
#endif
		data.m_fFlags |= PARTICLE_DISPATCH_FROM_ENTITY;
		data.m_nDamageType = PATTACH_CUSTOMORIGIN;

#if defined(TF_CLASSIC_CLIENT)
		if (TFGameRules() && TFGameRules()->IsDeathmatch())
		{
			C_TFPlayer *pPlayer = ToTFPlayer(pEntity);
			if (pPlayer && pPlayer->m_Shared.InCond(TF_COND_POWERUP_CRITDAMAGE))
			{
				data.m_bCustomColors = true;
				C_TF_PlayerResource *pResource = dynamic_cast<C_TF_PlayerResource *>(g_PR);
				data.m_CustomColors.m_vecColor1 = Vector(
					pResource->GetPlayerColor(pPlayer->entindex()).r() / 255.0f,
					pResource->GetPlayerColor(pPlayer->entindex()).g() / 255.0f,
					pResource->GetPlayerColor(pPlayer->entindex()).b() / 255.0f
					);
			}
		}
#endif

	}
	else
	{
#ifdef CLIENT_DLL
		data.m_hEntity = NULL;
#else
		data.m_nEntIndex = 0;
#endif
	}

	DispatchEffect( "ParticleEffect", data );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CSniperDot::OnDataChanged( DataUpdateType_t updateType )
{
	if ( updateType == DATA_UPDATE_CREATED )
	{
		// If we are in DM mode, we precache a clear, white
		// version of the sniper dot which we can color in later.
		if ( TFGameRules()->IsDeathmatch() )
		{
			m_hSpriteMaterial.Init(SNIPER_DOT_SPRITE_CLEAR, TEXTURE_GROUP_CLIENT_EFFECTS);
		}
		else
		{
			switch (GetTeamNumber())
			{
			case TF_TEAM_RED:
				m_hSpriteMaterial.Init(SNIPER_DOT_SPRITE_RED, TEXTURE_GROUP_CLIENT_EFFECTS);
				break;
			case TF_TEAM_BLUE:
				m_hSpriteMaterial.Init(SNIPER_DOT_SPRITE_BLUE, TEXTURE_GROUP_CLIENT_EFFECTS);
				break;
			case TF_TEAM_GREEN:
				m_hSpriteMaterial.Init(SNIPER_DOT_SPRITE_GREEN, TEXTURE_GROUP_CLIENT_EFFECTS);
				break;
			case TF_TEAM_YELLOW:
				m_hSpriteMaterial.Init(SNIPER_DOT_SPRITE_YELLOW, TEXTURE_GROUP_CLIENT_EFFECTS);
				break;
			}
		}
	}
}
void CTFBotVision::Update()
{
	if (TFGameRules()->IsMannVsMachineMode()) {
		if (!this->m_ctUpdate.IsElapsed()) {
			return;
		}
		
		this->m_ctUpdate.Start(RandomFloat(0.9f, 1.1f));
	}
	
	IVision::Update();
	
	CTFBot *actor = static_cast<CTFBot *>(this->GetBot()->GetEntity());
	if (actor == nullptr) {
		return;
	}
	
	CUtlVector<CTFPlayer *> enemies;
	CollectPlayers<CTFPlayer>(enemies, GetEnemyTeam(actor), true, false);
	
	FOR_EACH_VEC(enemies, i) {
		CTFPlayer *enemy = enemies[i];
		
		if (enemy->IsPlayerClass(TF_CLASS_SPY)) {
			const CKnownEntity *known = this->GetKnown(enemy);
			
			if (known != nullptr && (known->IsVisibleRecently() ||
				!player->m_Shared.InCond(TF_COND_DISGUISING))) {
				actor->ForgetSpy(enemy);
			}
		}
	}
//-----------------------------------------------------------------------------
// Purpose: Try and find an entity to lock onto
//-----------------------------------------------------------------------------
CBaseEntity *CWeaponCombat_ChargeablePlasma::GetLockTarget( void )
{
	CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
	if ( !pPlayer )
		return NULL;

	Vector vecSrc = pPlayer->Weapon_ShootPosition( );
	Vector vecAiming;
	pPlayer->EyeVectors( &vecAiming );
	Vector vecEnd = vecSrc + vecAiming * MAX_TRACE_LENGTH;

	trace_t tr;
	TFGameRules()->WeaponTraceLine( vecSrc, vecEnd, MASK_SHOT, pPlayer, GetDamageType(), &tr );

	if ( (tr.fraction < 1.0f) && tr.m_pEnt )
	{
		CBaseEntity *pTargetEntity = tr.m_pEnt;

		// Don't guide on same team or on anything other than players, objects, and NPCs
		if ( pTargetEntity->InSameTeam(pPlayer) || (!pTargetEntity->IsPlayer() 
			&& (pTargetEntity->MyNPCPointer() == NULL)) )
			return NULL;

		// Compute the target offset relative to the target
		Vector vecWorldOffset;
		VectorSubtract( tr.endpos, pTargetEntity->GetAbsOrigin(), vecWorldOffset );
		VectorIRotate( vecWorldOffset, pTargetEntity->EntityToWorldTransform(), m_vecTargetOffset ); 
		m_flLockedAt = gpGlobals->curtime + 0.2;
		return pTargetEntity;
	}

	return NULL;
}
示例#11
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFGameStats::Event_PlayerFiredWeapon( CTFPlayer *pPlayer, bool bCritical ) 
{
	// If normal gameplay state, track weapon stats. 
	if ( TFGameRules()->State_Get() == GR_STATE_RND_RUNNING )
	{
		CTFWeaponBase *pTFWeapon = pPlayer->GetActiveTFWeapon();
		if ( pTFWeapon )
		{
			// record shots fired in reported per-weapon stats
			int iWeaponID = pTFWeapon->GetWeaponID();

			if ( m_reportedStats.m_pCurrentGame != NULL )
			{
				TF_Gamestats_WeaponStats_t *pWeaponStats = &m_reportedStats.m_pCurrentGame->m_aWeaponStats[iWeaponID];
				pWeaponStats->iShotsFired++;
				if ( bCritical )
				{
					pWeaponStats->iCritShotsFired++;
				}
			}
		}
	}

	IncrementStat( pPlayer, TFSTAT_SHOTS_FIRED, 1 );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFWeaponBaseGrenadeProj::Deflected( CBaseEntity *pDeflectedBy, Vector &vecDir )
{
	IPhysicsObject *pPhysicsObject = VPhysicsGetObject();
	if ( pPhysicsObject )
	{
		Vector vecOldVelocity, vecVelocity;

		pPhysicsObject->GetVelocity( &vecOldVelocity, NULL );

		float flVel = vecOldVelocity.Length();

		vecVelocity = vecDir;
		vecVelocity *= flVel;
		AngularImpulse angVelocity( ( 600, random->RandomInt( -1200, 1200 ), 0 ) );

		// Now change grenade's direction.
		pPhysicsObject->SetVelocityInstantaneous( &vecVelocity, &angVelocity );
	}

	CBaseCombatCharacter *pBCC = pDeflectedBy->MyCombatCharacterPointer();

	IncremenentDeflected();
	m_hDeflectOwner = pDeflectedBy;
	SetThrower( pBCC );
	ChangeTeam( pDeflectedBy->GetTeamNumber() );
	if ( !TFGameRules()->IsDeathmatch() )
		m_nSkin = pDeflectedBy->GetTeamNumber() - 2;
	// TODO: Live TF2 adds white trail to reflected pipes and stickies. We need one as well.
}
ActionResult<CTFBot> CTFBotPayloadGuard::Update(CTFBot *actor, float dt)
{
	const CKnownEntity *threat = actor->GetVisionInterface()->GetPrimaryKnownThreat(false);
	if (threat != nullptr && threat->IsVisibleRecently()) {
		actor->EquipBestWeaponForThreat(threat);
	}
	
	CHandle<CTeamTrainWatcher> watcher = TFGameRules()->GetPayloadToBlock(actor->GetTeamNumber());
	if (watcher == nullptr) {
		return ActionResult<CTFBot>::Continue();
	}
	
	CBaseEntity *train = watcher->GetTrainEntity();
	if (train == nullptr) {
		return ActionResult<CTFBot>::Continue();
	}
	
	if (!watcher->IsDisabled() && watcher->GetCapturerCount() > 0) {
		// TODO
		// (there's some branchy stuff going on here)
	}
	
	// TODO
	
	return ActionResult<CTFBot>::Continue();
}
示例#14
0
void CTFHudNotify::Display( CBaseEntity *pActivator )
{
	CBroadcastRecipientFilter filter;

	switch( m_iRecipientTeam )
	{
	case TF_TEAM_RED:
		filter.RemoveRecipientsByTeam( GetGlobalTeam(TF_TEAM_BLUE) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_GREEN) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_YELLOW) );
		break;

	case TF_TEAM_BLUE:
		filter.RemoveRecipientsByTeam( GetGlobalTeam(TF_TEAM_RED) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_GREEN) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_YELLOW) );
		break;

	case TF_TEAM_GREEN:
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_RED) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_BLUE) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_YELLOW) );
		break;

	case TF_TEAM_YELLOW:
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_RED) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_BLUE) );
		filter.RemoveRecipientsByTeam(GetGlobalTeam(TF_TEAM_GREEN) );
		break;

	}

	TFGameRules()->SendHudNotification( filter, STRING(m_iszMessage), STRING(m_iszIcon), m_iBackgroundTeam );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponCombatLaserRifle::PrimaryAttack( void )
{
	CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
	if (!pPlayer)
		return;
	
	WeaponSound(SINGLE);

	// Fire the bullets
	Vector vecSrc = pPlayer->Weapon_ShootPosition( );
	Vector vecAiming;
	pPlayer->EyeVectors( &vecAiming );

	PlayAttackAnimation( GetPrimaryAttackActivity() );

	// Reduce the spread if the player's ducking
	Vector vecSpread = GetBulletSpread();
	vecSpread *= m_flInaccuracy;

	TFGameRules()->FireBullets( CTakeDamageInfo( this, pPlayer, weapon_combat_laserrifle_damage.GetFloat(), DMG_PLASMA), 1, 
		vecSrc, vecAiming, vecSpread, weapon_combat_laserrifle_range.GetFloat(), m_iPrimaryAmmoType, 0, entindex(), 0 );

	m_flInaccuracy += 0.3;
	m_flInaccuracy = clamp(m_flInaccuracy, 0, 1);

	m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
	m_iClip1 = m_iClip1 - 1;
}
示例#16
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFGameStats::Event_PlayerSpawned( CTFPlayer *pPlayer )
{	
	// if player is spawning as a member of valid team, increase the spawn count for his class
	int iTeam = pPlayer->GetTeamNumber();
	int iClass = pPlayer->GetPlayerClass()->GetClassIndex();
	if ( TEAM_UNASSIGNED != iTeam && TEAM_SPECTATOR != iTeam )
	{
		if ( m_reportedStats.m_pCurrentGame != NULL )
		{
			m_reportedStats.m_pCurrentGame->m_aClassStats[iClass].iSpawns++;
		}
	}

	TF_Gamestats_LevelStats_t *map = m_reportedStats.m_pCurrentGame;
	if ( !map )
		return;

	int iTeamCount = TFGameRules()->IsFourTeamGame() ? 5 : 3;

	// calculate peak player count on each team
	for ( iTeam = FIRST_GAME_TEAM; iTeam <= iTeamCount; iTeam++ )
	{
		int iPlayerCount = GetGlobalTeam( iTeam )->GetNumPlayers();
		if ( iPlayerCount > map->m_iPeakPlayerCount[iTeam] )
		{
			map->m_iPeakPlayerCount[iTeam] = iPlayerCount;
		}
	}

	if ( iClass >= TF_FIRST_NORMAL_CLASS && iClass <= TF_LAST_NORMAL_CLASS )
	{
		SendStatsToPlayer( pPlayer, STATMSG_PLAYERSPAWN );
	}
}
示例#17
0
//-----------------------------------------------------------------------------
// Purpose: Burn charge level to generate invulnerability
//-----------------------------------------------------------------------------
void CWeaponMedigun::SecondaryAttack( void )
{
	CTFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
	if ( !pOwner )
		return;

	if ( !CanAttack() )
		return;

	// Ensure they have a full charge and are not already in charge release mode
	if ( m_flChargeLevel < 1.0 || m_bChargeRelease )
	{
#ifdef CLIENT_DLL
		// Deny, flash
		if ( !m_bChargeRelease && m_flFlashCharge <= 0 )
		{
			m_flFlashCharge = 10;
			pOwner->EmitSound( "Player.DenyWeaponSelection" );
		}
#endif
		return;
	}

	if ( pOwner->HasTheFlag() )
	{
#ifdef GAME_DLL
		CSingleUserRecipientFilter filter( pOwner );
		TFGameRules()->SendHudNotification( filter, HUD_NOTIFY_NO_INVULN_WITH_FLAG );
#endif
		pOwner->EmitSound( "Player.DenyWeaponSelection" );
		return;
	}

	// Start super charge
	m_bChargeRelease = true;
	m_flReleaseStartedAt = 0;//gpGlobals->curtime;

#ifdef GAME_DLL
	CTF_GameStats.Event_PlayerInvulnerable( pOwner );
	pOwner->m_Shared.RecalculateChargeEffects();

	pOwner->SpeakConceptIfAllowed( MP_CONCEPT_MEDIC_CHARGEDEPLOYED );

	if ( m_hHealingTarget && m_hHealingTarget->IsPlayer() )
	{
		CTFPlayer *pTFPlayer = ToTFPlayer( m_hHealingTarget );
		pTFPlayer->m_Shared.RecalculateChargeEffects();
		pTFPlayer->SpeakConceptIfAllowed( MP_CONCEPT_HEALTARGET_CHARGEDEPLOYED );
	}

	IGameEvent * event = gameeventmanager->CreateEvent( "player_chargedeployed" );
	if ( event )
	{
		event->SetInt( "userid", pOwner->GetUserID() );

		gameeventmanager->FireEvent( event, true );	// don't send to clients
	}
#endif
}
	DETOUR_DECL_MEMBER(float, CTFBot_GetTimeLeftToCapture)
	{
		if (TFGameRules()->IsMannVsMachineMode()) {
			return FLT_MAX;
		}
		
		return DETOUR_MEMBER_CALL(CTFBot_GetTimeLeftToCapture)();
	}
	DETOUR_DECL_MEMBER(Action<CTFBot> *, CTFBotTacticalMonitor_InitialContainedAction, CTFBot *actor)
	{
		if (TFGameRules()->IsMannVsMachineMode() && actor->GetTeamNumber() == TF_TEAM_RED) {
			return new CTFBotMvMDefender();
		}
		
		return DETOUR_MEMBER_CALL(CTFBotTacticalMonitor_InitialContainedAction)(actor);
	}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &inputdata - 
//-----------------------------------------------------------------------------
void CTFIntermission::InputActivate( inputdata_t &inputdata )
{
	CTFGameRules *pCTFGameRules = TFGameRules();
	if ( pCTFGameRules )
	{
		pCTFGameRules->GoToIntermission();
	}
}
EventDesiredResult<CTFBot> CTFBotDeliverFlag::OnContact(CTFBot *actor, CBaseEntity *ent, CGameTrace *trace)
{
	if (TFGameRules()->IsMannVsMachineMode() && ent != nullptr && ent->ClassMatches("func_capturezone")) {
		return EventDesiredResult<CTFBot>::SuspendFor(new CTFBotMvMDeployBomb(), "Delivering the bomb!", ResultSeverity::CRITICAL);
	}
	
	return EventDesiredResult<CTFBot>::Continue();
}
	DETOUR_DECL_MEMBER(void, CTFGameRules_DropHalloweenSoulPack, int i1, const Vector& vec1, CBaseEntity *ent1, int i2)
	{
		if (TFGameRules()->IsMannVsMachineMode()) {
			/* don't spawn "halloween_souls_pack" entities in MvM mode */
			return;
		}
		
		DETOUR_MEMBER_CALL(CTFGameRules_DropHalloweenSoulPack)(i1, vec1, ent1, i2);
	}
示例#23
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CObjectTeleporter::TeleporterTouch( CBaseEntity *pOther )
{
	if ( IsDisabled() )
	{
		return;
	}

	// if it's not a player, ignore
	if ( !pOther->IsPlayer() )
		return;

	CTFPlayer *pPlayer = ToTFPlayer( pOther );

	CTFPlayer *pBuilder = GetBuilder();

	Assert( pBuilder );

	if ( !pBuilder )
	{
		return;
	}

	// if its not a teammate of the builder, notify the builder
	if ( pBuilder->GetTeamNumber() != pOther->GetTeamNumber() )
	{
		// Don't teleport enemies
		return;
	}

	// is this an entrance and do we have an exit?
	if ( GetType() == OBJ_TELEPORTER_ENTRANCE )
	{		
		if ( ( m_iState == TELEPORTER_STATE_READY ) )
		{
			// are we able to teleport?
			if ( pPlayer->HasTheFlag() )
			{
				// If they have the flag, print a warning that you can't tele with the flag
				CSingleUserRecipientFilter filter( pPlayer );
				TFGameRules()->SendHudNotification( filter, HUD_NOTIFY_NO_TELE_WITH_FLAG );
				return;
			}

			// get the velocity of the player touching the teleporter
			if ( pPlayer->GetAbsVelocity().Length() < 5.0 )
			{
				CObjectTeleporter *pDest = GetMatchingTeleporter();

				if ( pDest )
				{
					TeleporterSend( pPlayer );
				}
			}
		}
	}
}
QueryResponse CTFBotPayloadGuard::ShouldRetreat(const INextBot *nextbot) const
{
	CTFBot *actor = ToTFBot(nextbot->GetEntity());
	
	CHandle<CTeamTrainWatcher> watcher = TFGameRules()->GetPayloadToBlock(actor->GetTeamNumber());
	if (watcher != nullptr && watcher->IsTrainNearCheckpoint()) {
		return QueryResponse::NO;
	}
	
	return QueryResponse::DONTCARE;
}
//-----------------------------------------------------------------------------
// Purpose: Update the designator position
//-----------------------------------------------------------------------------
void CObjectBaseMannedGun::UpdateDesignator( void )
{
	// Make the beam, if we don't have one yet
	if ( !m_hBeam && GetDriverPlayer() )
	{
		m_hBeam = BEAM_CREATE_PREDICTABLE_PERSIST( "sprites/laserbeam.vmt", 5, GetDriverPlayer() );
		if ( m_hBeam.Get() )
		{
			m_hBeam->PointEntInit( vec3_origin, this );
			m_hBeam->SetEndAttachment( m_nBarrelAttachment );
			m_hBeam->SetColor( 255, 32, 32 );
			m_hBeam->SetBrightness( 255 );
			m_hBeam->SetNoise( 0 );
			m_hBeam->SetWidth( 0.5 );
			m_hBeam->SetEndWidth( 0.5 );
		}
	}

	// We have to flush the bone cache because it's possible that only the bone controllers
	// have changed since the bonecache was generated, and bone controllers aren't checked.
	InvalidateBoneCache();

	QAngle vecAng;
	Vector vecSrc, vecAim;
	GetAttachment( m_nBarrelAttachment, vecSrc, vecAng );
	AngleVectors( vecAng, &vecAim, 0, 0 );

	// "Fire" the designator beam
	Vector vecEnd = vecSrc + vecAim * obj_manned_gun_designator_range.GetFloat();
	trace_t tr;
	TFGameRules()->WeaponTraceLine(vecSrc, vecEnd, MASK_SHOT, this, DMG_PROBE, &tr);

	if ( m_hLaserDesignation.Get() )
	{
		// Only update our designated target point if we hit something
		if ( tr.fraction != 1.0 )
		{
			m_hLaserDesignation->SetActive( true );
			m_hLaserDesignation->SetAbsOrigin( tr.endpos );
		}
		else
		{
			m_hLaserDesignation->SetActive( false );
		}
	}

	// Update beam visual
	if ( m_hBeam.Get() )
	{
		m_hBeam->SetStartPos( tr.endpos );
		m_hBeam->RelinkBeam();
	}
}
//-----------------------------------------------------------------------------
// Purpose: Check that the points aren't all held by one team if they are 
//			this will reset the round and will reset all the points
//-----------------------------------------------------------------------------
int CTeamControlPointRound::CheckWinConditions( void )
{
	int iWinners = TeamOwnsAllPoints();
	if ( ( m_iInvalidCapWinner != 1 ) &&
		 ( iWinners >= FIRST_GAME_TEAM ) && 
		 ( iWinners != m_iInvalidCapWinner ) )
	{
		bool bWinner = true;

#if defined( TF_DLL)
		if ( TFGameRules() && TFGameRules()->IsInKothMode() )
		{
			CTeamRoundTimer *pTimer = NULL;
			if ( iWinners == TF_TEAM_RED )
			{
				pTimer = TFGameRules()->GetRedKothRoundTimer();
			}
			else if ( iWinners == TF_TEAM_BLUE )
			{
				pTimer = TFGameRules()->GetBlueKothRoundTimer();
			}

			if ( pTimer )
			{
				if ( pTimer->GetTimeRemaining() > 0 || TFGameRules()->TimerMayExpire() == false )
				{
					bWinner = false;
				}
			}
		}
#endif
		if ( bWinner )
		{
			FireTeamWinOutput( iWinners );
			return iWinners;
		}
	}

	return -1;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFWeaponBuilder::ItemPostFrame( void )
{
	CTFPlayer *pOwner = ToTFPlayer( GetOwner() );
	if ( !pOwner )
		return;

	// If we're building, and our team has lost, stop placing the object
	if ( m_hObjectBeingBuilt.Get() && 
		TFGameRules()->State_Get() == GR_STATE_TEAM_WIN && 
		pOwner->GetTeamNumber() != TFGameRules()->GetWinningTeam() )
	{
		StopPlacement();
		return;
	}

	// Check that I still have enough resources to build this item
	if ( pOwner->CanBuild( m_iObjectType ) != CB_CAN_BUILD )
	{
		SwitchOwnersWeaponToLast();
	}

	if (( pOwner->m_nButtons & IN_ATTACK ) && (m_flNextPrimaryAttack <= gpGlobals->curtime) )
	{
		PrimaryAttack();
	}

	if ( pOwner->m_nButtons & IN_ATTACK2 )
	{
		if ( m_flNextSecondaryAttack <= gpGlobals->curtime )
		{
			SecondaryAttack();
		}
	}
	else
	{
		m_bInAttack2 = false;
	}

	WeaponIdle();
}
示例#28
0
	DETOUR_DECL_MEMBER(CEconItemView *, CTFPlayer_GetLoadoutItem, int pclass, int slot, bool b1)
	{
		auto result = DETOUR_MEMBER_CALL(CTFPlayer_GetLoadoutItem)(pclass, slot, b1);
		
		if (TFGameRules()->IsMannVsMachineMode() && result->GetItemDefIndex() == DEFIDX_CANTEEN_DEFAULT) {
			auto player = reinterpret_cast<CTFPlayer *>(this);
			if (player->GetTeamNumber() == TF_TEAM_BLUE && player->IsBot()) {
				return nullptr;
			}
		}
		
		return result;
	}
	DETOUR_DECL_MEMBER(void, CTFPlayer_HandleCommand_JoinTeam, const char *team)
	{
		DETOUR_MEMBER_CALL(CTFPlayer_HandleCommand_JoinTeam)(team);
		
		auto player = reinterpret_cast<CTFPlayer *>(this);
		
		if (TFGameRules()->IsMannVsMachineMode() && player->GetTeamNumber() == TF_TEAM_RED) {
			CTFBot *bot = ToTFBot(player);
			if (bot != nullptr) {
				(void)bot->GetAutoTeam(5);
			}
		}
	}
示例#30
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CObjectSapper::Killed( const CTakeDamageInfo &info )
{
	// If the sapper is removed by someone other than builder, award bonus points.
	CTFPlayer *pScorer = ToTFPlayer( TFGameRules()->GetDeathScorer( info.GetAttacker(), info.GetInflictor(), this ) );
	if ( pScorer )
	{
		CBaseObject *pObject = GetParentObject();
		if ( pObject && pScorer != pObject->GetBuilder() )
		{
			CTF_GameStats.Event_PlayerAwardBonusPoints( pScorer, this, 1 );
		}
	}

	BaseClass::Killed( info );
}