bool AntiSmokeBlocker::RT_SetTransmitCallback ( PlayerHandler::const_iterator sender, PlayerHandler::const_iterator receiver )
{
	//if(!receiver) return false;

	if( GetPlayerDataStructByIndex ( receiver.GetIndex () )->is_in_smoke )
		return true;

	if( GetPlayerDataStructByIndex ( receiver.GetIndex () )->can_not_see_this_player[ sender.GetIndex () ] == true )
		return true;

	return false;
}
void RadarHackBlocker::RT_ThinkPostCallback ( SourceSdk::edict_t const * const pent )
{
	ProcessFilter::HumanAtLeastConnectedOrBot const filter_class;

	for( PlayerHandler::const_iterator ph ( &filter_class ); ph != PlayerHandler::end (); ph += &filter_class )
	{
		int const index ( ph.GetIndex () );
		ClientRadarData * pData ( GetPlayerDataStructByIndex ( index ) );
		if( pData->m_last_spotted_status != m_players_spotted[ index ] )
		{
			pData->m_last_spotted_status = m_players_spotted[ index ];

			if( pData->m_last_spotted_status )
			{
				RT_UpdatePlayerData ( *ph );
				RT_ProcessEntity ( ph->GetEdict () );
			}
			else
			{
				//pData->m_next_update = curtime + 1.0f;
				//UpdatePlayerData(ph->playerClass);
				//ProcessEntity(Helpers::PEntityOfEntIndex(x));
			}
		}
	}
}
void RadarHackBlocker::RT_ProcessOnTick ( float const curtime )
{
	ProcessFilter::HumanAtLeastConnectedOrBot const filter_class;

	for( PlayerHandler::const_iterator ph ( &filter_class ); ph != PlayerHandler::end (); ph += &filter_class )
	{
		int const index ( ph.GetIndex () );

		ClientRadarData * pData ( GetPlayerDataStructByIndex ( index ) );

		if( pData->m_last_spotted_status )
		{
			RT_UpdatePlayerData ( *ph );
			RT_ProcessEntity ( ph->GetEdict () );
		}
		else
		{
			if( curtime > m_next_process )
			{
				RT_UpdatePlayerData ( *ph );
				RT_ProcessEntity ( ph->GetEdict () );
			}
		}
	}

	if( curtime > m_next_process )
	{
		m_next_process = curtime + 2.0f;
	}
}
void EyeAnglesTester::FireGameEvent ( SourceSdk::IGameEvent *ev ) // round_end
{
	ProcessFilter::HumanAtLeastConnected filter_class;
	for( PlayerHandler::const_iterator ph ( &filter_class ); ph != PlayerHandler::end (); ph+=&filter_class )
	{
		++( GetPlayerDataStructByIndex ( ph.GetIndex () )->ignore_last );
	}
}
void AutoAttackTester::Load ()
{
	for( PlayerHandler::const_iterator it ( PlayerHandler::begin () ); it != PlayerHandler::end (); ++it )
	{
		ResetPlayerDataStructByIndex ( it.GetIndex () );
	}

	PlayerRunCommandHookListener::RegisterPlayerRunCommandHookListener ( this, SystemPriority::UserCmdHookListener::AutoAttackTester );
}
void AutoAttackTester::OnAttack2Up ( PlayerHandler::const_iterator ph, int game_tick )
{
	AttackTriggerStats * const pdata ( GetPlayerDataStructByIndex ( ph.GetIndex () ) );

	pdata->attack2_up_tick = game_tick;
	pdata->attack2_sustain_stats.Store ( game_tick - pdata->attack2_down_tick , pdata->attack2_down_tick );

	FindDetection ( ph, &( pdata->attack2_sustain_stats ) );
}
void EyeAnglesTester::Load ()
{
	for( PlayerHandler::const_iterator it ( PlayerHandler::begin () ); it != PlayerHandler::end (); ++it )
	{
		ResetPlayerDataStructByIndex ( it.GetIndex () );
	}

	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "round_end", true );
	PlayerRunCommandHookListener::RegisterPlayerRunCommandHookListener ( this, SystemPriority::UserCmdHookListener::EyeAnglesTester );
}
void AntiSmokeBlocker::Load ()
{
	for( PlayerHandler::const_iterator it ( PlayerHandler::begin () ); it != PlayerHandler::end (); ++it )
	{
		ResetPlayerDataStructByIndex ( it.GetIndex () );
	}

	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "smokegrenade_detonate", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "round_start", true );
	OnTickListener::RegisterOnTickListener ( this );
	SetTransmitHookListener::RegisterSetTransmitHookListener ( this, 1 );
}
void AutoAttackTester::OnAttack2Down ( PlayerHandler::const_iterator ph, int game_tick )
{
	AttackTriggerStats * const pdata ( GetPlayerDataStructByIndex ( ph.GetIndex () ) );

	pdata->attack2_down_tick = game_tick;
}
void AntiSmokeBlocker::RT_ProcessOnTick ( float const curtime )
{
	METRICS_ENTER_SECTION ( "AntiSmokeBlocker::OnFrame" );

	SmokeListT::elem_t* it ( m_smokes.GetFirst () );

	// remove old smokes
	while( it != nullptr )
	{
		if( curtime - ( it->m_value.bang_time + ConfigManager::GetInstance ()->m_smoke_time ) > 0.0f )
			it = m_smokes.Remove ( it );
		else it = it->m_next;
	}

	ST_R_STATIC SmokeInfoT empty;
	ResetAll ( &empty );

	it = m_smokes.GetFirst ();
	if( it == nullptr ) return;

	// Test if players are immersed in smoke
	ProcessFilter::InTestsNoBot l1_filter;
	ProcessFilter::InTestsOrBot l2_filter;
	for( PlayerHandler::const_iterator ph ( &l1_filter ); ph != PlayerHandler::end (); ph+=&l1_filter )
	{
		SourceSdk::Vector delta, other_delta;

		MathInfo const & x_math ( MathCache::GetInstance ()->RT_GetCachedMaths ( ph.GetIndex () ) );

		do // At this stage, m_smokes ! empty
		{
			if( curtime - it->m_value.bang_time > ConfigManager::GetInstance ()->m_smoke_timetobang )
			{
				SourceSdk::vec_t dst;
				SourceSdk::VectorDistanceSqr ( x_math.m_eyepos, it->m_value.pos, delta, dst );
				if( dst < ConfigManager::GetInstance ()->m_innersmoke_radius_sqr )
				{
					GetPlayerDataStructByIndex ( ph.GetIndex () )->is_in_smoke = true;
				}

				/* Players can't see eachother if they are behind a smoke */

				const SourceSdk::vec_t ang_smoke ( tanf ( ConfigManager::GetInstance ()->m_smoke_radius / sqrtf ( dst ) ) );
				SourceSdk::VectorNorm ( delta );

				for( PlayerHandler::const_iterator other_ph ( &l2_filter ); other_ph != PlayerHandler::end (); other_ph+=&l2_filter )
				{
					if( ph == other_ph ) continue;

					MathInfo const & y_math ( MathCache::GetInstance ()->RT_GetCachedMaths ( other_ph.GetIndex () ) );

					// Is he behind the smoke against us ?

					SourceSdk::vec_t other_dst;
					SourceSdk::VectorDistanceSqr ( x_math.m_eyepos, y_math.m_abs_origin, other_delta, other_dst );
					if( dst + ConfigManager::GetInstance ()->m_smoke_radius < other_dst )
					{
						// Hidden by the hull of the smoke ?

						SourceSdk::VectorNorm ( other_delta );

						SourceSdk::vec_t dp;
						SourceSdk::VectorDotProduct ( other_delta, delta, dp );
						const SourceSdk::vec_t angle_player ( fabs ( acos ( dp ) ) );

						if( angle_player < ang_smoke )
						{
							GetPlayerDataStructByIndex ( ph.GetIndex () )->can_not_see_this_player[ other_ph.GetIndex () ] = true;
						}
					}
				}
			}
			it = it->m_next;
		}
		while( it != nullptr );
		it = m_smokes.GetFirst ();
	}

	METRICS_LEAVE_SECTION ( "AntiSmokeBlocker::OnFrame" );
}
Exemple #11
0
PlayerRunCommandRet EyeAnglesTester::RT_PlayerRunCommandCallback ( PlayerHandler::const_iterator ph, void * const pCmd, void * const old_cmd )
{
	int const * const flags ( EntityProps::GetInstance ()->GetPropValue<int, PROP_FLAGS> ( ph->GetEdict () ) );

	/*
		FL_FROZEN			(1 << 5)
		FL_ATCONTROLS		(1 << 6)
	*/
	if( *flags & ( 3 << 5 ) ) return PlayerRunCommandRet::CONTINUE;

	PlayerRunCommandRet drop_cmd ( PlayerRunCommandRet::CONTINUE );

	EyeAngleInfoT* playerData ( GetPlayerDataStructByIndex ( ph.GetIndex () ) );
	playerData->x.abs_value = fabs ( playerData->x.value = static_cast< SourceSdk::CUserCmd_csgo* >( pCmd )->viewangles.x );
	playerData->y.abs_value = fabs ( playerData->y.value = static_cast< SourceSdk::CUserCmd_csgo* >( pCmd )->viewangles.y );
	playerData->z.abs_value = fabs ( playerData->z.value = static_cast< SourceSdk::CUserCmd_csgo* >( pCmd )->viewangles.z );

	if( playerData->x.abs_value > 89.0f || playerData->z.abs_value > 1.0f || playerData->y.abs_value > 180.0f )
	{
		if( playerData->ignore_last ) --( playerData->ignore_last );
		else drop_cmd = PlayerRunCommandRet::INERT;
	}

	if( drop_cmd > PlayerRunCommandRet::CONTINUE )
	{
		if( playerData->x.abs_value > 89.0f )
		{
			++playerData->x.detectionsCount;
			if( playerData->x.lastDetectionPrintTime + ANTIFLOOD_LOGGING_TIME < Plat_FloatTime () )
			{
				playerData->x.lastDetectionPrintTime = Plat_FloatTime ();

				Detection_EyeAngleX pDetection;
				pDetection.PrepareDetectionData ( playerData );
				pDetection.PrepareDetectionLog ( *ph, this );
				pDetection.Log ();
			}
		}
		if( playerData->y.abs_value > 180.0f )
		{
			++playerData->y.detectionsCount;
			if( playerData->y.lastDetectionPrintTime + ANTIFLOOD_LOGGING_TIME < Plat_FloatTime () )
			{
				playerData->y.lastDetectionPrintTime = Plat_FloatTime ();

				Detection_EyeAngleY pDetection;
				pDetection.PrepareDetectionData ( playerData );
				pDetection.PrepareDetectionLog ( *ph, this );
				pDetection.Log ();
			}
		}
		if( playerData->z.abs_value > 1.0f )
		{
			++playerData->z.detectionsCount;
			if( playerData->z.lastDetectionPrintTime + ANTIFLOOD_LOGGING_TIME < Plat_FloatTime () )
			{
				playerData->z.lastDetectionPrintTime = Plat_FloatTime ();

				Detection_EyeAngleZ pDetection;
				pDetection.PrepareDetectionData ( playerData );
				pDetection.PrepareDetectionLog ( *ph, this );
				pDetection.Log ();
			}
		}

		BanRequest::GetInstance ()->AddAsyncBan ( *ph, 0, "Banned by NoCheatZ 4" );
	}
	return drop_cmd;
}
void NczPlayerManager::LoadPlayerManager ()
{
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "player_death", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "player_team", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "player_spawn", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "player_connect", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "player_disconnect", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "round_end", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "round_freeze_end", true );
	SourceSdk::InterfacesProxy::GetGameEventManager ()->AddListener ( this, "bot_takeover", true );

	//Helpers::FastScan_EntList();
	Helpers::m_EdictList = Helpers::PEntityOfEntIndex ( 0 );

	//if(Helpers::m_EdictList)
	//{
	//int maxcl = Helpers::GetMaxClients();

	for( PlayerHandler::const_iterator ph ( PlayerHandler::begin () ); ph != PlayerHandler::end (); ++ph )
	{
		SourceSdk::edict_t* const pEntity ( Helpers::PEntityOfEntIndex ( ph.GetIndex () ) );
		if( Helpers::isValidEdict ( pEntity ) )
		{
			void * playerinfo ( SourceSdk::InterfacesProxy::Call_GetPlayerInfo ( pEntity ) );
			if( playerinfo )
			{
				bool isfakeclient;
				if( SourceSdk::InterfacesProxy::m_game == SourceSdk::CounterStrikeGlobalOffensive )
				{
					isfakeclient = static_cast< SourceSdk::IPlayerInfo_csgo* >( playerinfo )->IsFakeClient ();
				}
				else
				{
					isfakeclient = static_cast< SourceSdk::IPlayerInfo* >( playerinfo )->IsFakeClient ();
				}
				if( isfakeclient )
				{
					ph.GetHandler ()->status = SlotStatus::BOT;
					ph.GetHandler ()->playerClass = new NczPlayer ( ph.GetIndex () );
					m_max_index = ph.GetIndex ();
				}
				else if( static_cast< SourceSdk::IPlayerInfo* >( playerinfo )->IsConnected () )
				{
					ph.GetHandler ()->status = SlotStatus::PLAYER_CONNECTED;
					ph.GetHandler ()->playerClass = new NczPlayer ( ph.GetIndex () );
					ph.GetHandler ()->playerClass->OnConnect ();
					m_max_index = ph.GetIndex ();
				}
			}
		}
	}

	//}

	if( m_max_index )
	{
		PlayerHandler::first = ( &FullHandlersList[ 1 ] );
		PlayerHandler::last = ( &FullHandlersList[ m_max_index ] );
	}
	else
	{
		PlayerHandler::first = PlayerHandler::invalid;
		PlayerHandler::last = PlayerHandler::invalid;
	}

	BaseSystem::ManageSystems ();
}
Exemple #13
0
PlayerRunCommandRet ShotTester::RT_PlayerRunCommandCallback ( PlayerHandler::const_iterator ph, void* pCmd, void* lastcmd )
{
	PlayerRunCommandRet drop_cmd = PlayerRunCommandRet::CONTINUE;

	ShotStatsT * const playerData ( GetPlayerDataStructByIndex ( ph.GetIndex () ) );

	float const curtime ( Plat_FloatTime () );

	bool cur_in_attack;
	bool past_in_attack;

	if( SourceSdk::InterfacesProxy::m_game == SourceSdk::CounterStrikeGlobalOffensive )
	{
		cur_in_attack = ( static_cast< SourceSdk::CUserCmd_csgo* >( pCmd )->buttons & IN_ATTACK ) != 0;
		past_in_attack = ( static_cast< SourceSdk::CUserCmd_csgo* >( lastcmd )->buttons & IN_ATTACK ) != 0;
	}
	else
	{
		cur_in_attack = ( static_cast< SourceSdk::CUserCmd* >( pCmd )->buttons & IN_ATTACK ) != 0;
		past_in_attack = ( static_cast< SourceSdk::CUserCmd* >( lastcmd )->buttons & IN_ATTACK ) != 0;
	}

	if( cur_in_attack && !past_in_attack )
	{
		//SystemVerbose1(Helpers::format("Player %s : IN_ATTACK button down.", ph->GetName()));
		playerData->down_time = curtime;
	}
	else if( past_in_attack && !cur_in_attack )
	{
		playerData->up_time = curtime;
		TriggerStat ( &( playerData->clicks ), playerData->up_time, playerData->down_time, playerData->clicks.n );
		//SystemVerbose1(Helpers::format("Player %s : IN_ATTACK button up.", ph->GetName()));

		if( playerData->up_time - playerData->down_time <= SHORT_TIME )
		{
			if( curtime - playerData->last_detection > 1.0 )
			{
				if( playerData->row == 1 )
				{
					if( playerData->on_target.ratio > 25.0 && playerData->clicks.n > 50 )
					{
						Detection_TriggerBot pDetection;
						pDetection.PrepareDetectionData ( playerData );
						pDetection.PrepareDetectionLog ( *ph, this );
						pDetection.Log ();

						ph->Ban ();
					}
				}
				playerData->row = 0;
			}
			if( playerData->row > 10 )
			{
				if( playerData->short_clicks.ratio > 40.0 && playerData->clicks.n > 50 )
				{
					Detection_AutoPistol pDetection;
					pDetection.PrepareDetectionData ( playerData );
					pDetection.PrepareDetectionLog ( *ph, this );
					pDetection.Log ();

					ph->Ban ();
				}
			}
			playerData->last_detection = curtime;
			++( playerData->row );

			TriggerStat ( &( playerData->short_clicks ), playerData->up_time, playerData->down_time, playerData->clicks.n );
			if( ph->GetWpnShotType () == HAND ) TriggerStat ( &( playerData->with_hand ), playerData->up_time, playerData->down_time, playerData->clicks.n );
			else if( ph->GetWpnShotType () == PISTOL ) TriggerStat ( &( playerData->with_pistol ), playerData->up_time, playerData->down_time, playerData->clicks.n );
			else TriggerStat ( &( playerData->with_auto ), playerData->up_time, playerData->down_time, playerData->clicks.n );
			if( ph->aimingAt () > 0 ) TriggerStat ( &( playerData->on_target ), playerData->up_time, playerData->down_time, playerData->clicks.n );
			drop_cmd = PlayerRunCommandRet::INERT;

			if( this->m_verbose )
			{
				printf ( "%f - clicks ", curtime );
				OutputStat ( &( playerData->clicks ) );
				printf ( ", short_clicks " );
				OutputStat ( &( playerData->short_clicks ) );
				printf ( ", with_hand " );
				OutputStat ( &( playerData->with_hand ) );
				printf ( ", with_pistol " );
				OutputStat ( &( playerData->with_pistol ) );
				printf ( ", with_auto " );
				OutputStat ( &( playerData->with_auto ) );
				printf ( ", on_target " );
				OutputStat ( &( playerData->on_target ) );
				printf ( ", row %u\n", playerData->row );
			}
		}
	}
	return drop_cmd;
}