void __fastcall hooks::hooked_postscreeneffects(void * thisptr, void * edx, CViewSetup * setup) {
	static auto run_glow = []() -> void {
		if (!g_ctx.available() || !g_ctx.m_local) {
			return;
		}

		for (int i = 0; i < g_csgo.m_glow()->m_GlowObjectDefinitions.Count(); i++) {
			if (g_csgo.m_glow()->m_GlowObjectDefinitions[i].IsUnused() || !g_csgo.m_glow()->m_GlowObjectDefinitions[i].GetEnt()) {
				continue;
			}

			auto * object = &g_csgo.m_glow()->m_GlowObjectDefinitions[i];
			auto entity = reinterpret_cast<entity_t*>(object->GetEnt());

			if (!entity || entity->IsDormant()) {
				continue;
			}

			if (entity == g_ctx.m_local) {
				continue;
			}

			float color[3];

			if (entity->m_iTeamNum() != g_ctx.m_local->m_iTeamNum()) {
				if (!g_cfg.player.glow[GLOW_ENEMY].enabled)
					continue;

				color[0] = g_cfg.player.glow_color_enemy[0] / 255.0f;
				color[1] = g_cfg.player.glow_color_enemy[1] / 255.0f;
				color[2] = g_cfg.player.glow_color_enemy[2] / 255.0f;
			}

			if (entity->m_iTeamNum() == g_ctx.m_local->m_iTeamNum()) {
				if (!g_cfg.player.glow[GLOW_TEAMMATE].enabled)
					continue;

				color[0] = g_cfg.player.glow_color_teammate[0] / 255.0f;
				color[1] = g_cfg.player.glow_color_teammate[1] / 255.0f;
				color[2] = g_cfg.player.glow_color_teammate[2] / 255.0f;
			}

			if (entity->GetClientClass()->m_ClassID == 35) {
				object->Set(color[0], color[1], color[2],
					g_cfg.player.glowopacity / 100.0f,
					g_cfg.player.glowbloom / 100.0f,
					g_cfg.player.glow_type);
			}
		}
	};

	static auto original_fn = clientmode_hook->get_func_address<DoPostScreenEffects_t>(44);

	if (g_cfg.player.glow[GLOW_TEAMMATE].enabled || g_cfg.player.glow[GLOW_ENEMY].enabled)
		run_glow();

	return original_fn(thisptr, setup);
}
Example #2
0
void eventlogs::events(IGameEvent * event) {
	static auto get_hitgroup_name = [](int hitgroup) -> std::string {
		switch (hitgroup) {
		case HITGROUP_HEAD:
			return "head";
		case HITGROUP_LEFTLEG:
			return "left leg";
		case HITGROUP_RIGHTLEG:
			return "right leg";
		case HITGROUP_STOMACH:
			return "stomach";
		case HITGROUP_LEFTARM:
			return "left arm";
		case HITGROUP_RIGHTARM:
			return "right arm";
		default:
			return "body";
		}
	};

	constexpr char * hasdefusekit[2] = { "without defuse kit.","with defuse kit." };
	constexpr char * hasbomb[2] = { "without the bomb.","with the bomb." };
	constexpr char * hitgroups[7] = { "head" };

	if (g_cfg.misc.events_to_log[EVENTLOG_HIT].enabled && strstr(event->GetName(), "player_hurt")) {
		auto
			userid = event->GetInt("userid"),
			attacker = event->GetInt("attacker");

		if (!userid || !attacker) {
			return;
		}

		auto
			userid_id = g_csgo.m_engine()->GetPlayerForUserID(userid),
			attacker_id = g_csgo.m_engine()->GetPlayerForUserID(attacker);

		player_info_t userid_info, attacker_info;
		if (!g_csgo.m_engine()->GetPlayerInfo(userid_id, &userid_info)) {
			return;
		}

		if (!g_csgo.m_engine()->GetPlayerInfo(attacker_id, &attacker_info)) {
			return;
		}

		auto m_victim = static_cast<player_t *>(g_csgo.m_entitylist()->GetClientEntity(userid_id));

		std::stringstream ss;
		if (attacker_id == g_csgo.m_engine()->GetLocalPlayer()) {
			ss << "hit " << get_hitgroup_name(event->GetInt("hitgroup")) << " for " << event->GetInt("dmg_health");

			add(ss.str(), Color::White);
		}
		else if (userid_id == g_csgo.m_engine()->GetLocalPlayer()) {
		}
	}

	if (g_cfg.misc.events_to_log[EVENTLOG_ITEM_PURCHASES].enabled && strstr(event->GetName(), "item_purchase")) {
		auto userid = event->GetInt("userid");

		if (!userid) {
			return;
		}

		auto userid_id = g_csgo.m_engine()->GetPlayerForUserID(userid);

		player_info_t userid_info;
		if (!g_csgo.m_engine()->GetPlayerInfo(userid_id, &userid_info)) {
			return;
		}

		auto m_player = static_cast<player_t *>(g_csgo.m_entitylist()->GetClientEntity(userid_id));

		if (!g_ctx.m_local || !m_player) {
			return;
		}

		if (m_player->m_iTeamNum() == g_ctx.m_local->m_iTeamNum()) {
			return;
		}

		std::stringstream ss;
		ss << userid_info.szName << " bought a " << event->GetString("weapon");

		add(ss.str(), Color::White);
	}

	if (g_cfg.misc.events_to_log[EVENTLOG_PLANTING].enabled && strstr(event->GetName(), "bomb_beginplant")) {
		auto userid = event->GetInt("userid");

		if (!userid) {
			return;
		}

		auto userid_id = g_csgo.m_engine()->GetPlayerForUserID(userid);

		player_info_t userid_info;
		if (!g_csgo.m_engine()->GetPlayerInfo(userid_id, &userid_info)) {
			return;
		}

		auto m_player = static_cast<player_t *>(g_csgo.m_entitylist()->GetClientEntity(userid_id));

		if (!m_player) {
			return;
		}

		std::stringstream ss;

		add(ss.str(), Color::White);
	}

	if (g_cfg.misc.events_to_log[EVENTLOG_DEFUSING].enabled && strstr(event->GetName(), "bomb_begindefuse")) {
		auto userid = event->GetInt("userid");

		if (!userid) {
			return;
		}

		auto userid_id = g_csgo.m_engine()->GetPlayerForUserID(userid);

		player_info_t userid_info;
		if (!g_csgo.m_engine()->GetPlayerInfo(userid_id, &userid_info)) {
			return;
		}

		auto m_player = static_cast<player_t *>(g_csgo.m_entitylist()->GetClientEntity(userid_id));

		if (!m_player) {
			return;
		}

		std::stringstream ss;

		add(ss.str(), Color::White);
	}
}
void AimLegit::Triggerbot()
{
	Vector rem, forward,
		src = g_LocalPlayer->GetEyePos();

	trace_t tr;
	Ray_t ray;
	CTraceFilter filter;
	filter.pSkip = g_LocalPlayer;

	QAngle viewangles = usercmd->viewangles;

	viewangles += g_LocalPlayer->m_aimPunchAngle() * 2.f;

	Math::AngleVectors(viewangles, forward);

	forward *= g_LocalPlayer->m_hActiveWeapon().Get()->GetWeapInfo()->m_fRange;

	rem = src + forward;

	ray.Init(src, rem);
	g_EngineTrace->TraceRay(ray, 0x46004003, &filter, &tr);

	if (!tr.hit_entity)
		return;

	bool dh = false;

	if (tr.hitgroup == HITGROUP_HEAD || tr.hitgroup == HITGROUP_CHEST || tr.hitgroup == HITGROUP_STOMACH || (tr.hitgroup == HITGROUP_LEFTARM || tr.hitgroup == HITGROUP_RIGHTARM) || (tr.hitgroup == HITGROUP_LEFTLEG || tr.hitgroup == HITGROUP_RIGHTLEG))
		dh = true;

	auto player = reinterpret_cast<C_BasePlayer*>(tr.hit_entity);
	if (player && !player->IsDormant() && player->m_iHealth() > 0 && player->IsPlayer())
	{
		if (player->m_iTeamNum() != g_LocalPlayer->m_iTeamNum())
		{
			if (g_Options.legit_trigger_with_aimkey)
			{
				if(dh && (!(usercmd->buttons & IN_ATTACK) && (!g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey1)) || !g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey2))))) // if you don't attack currently
					usercmd->buttons |= IN_ATTACK;

				static bool already_shot = false;
				if (g_LocalPlayer->m_hActiveWeapon().Get()->IsPistol())
				{
					if (usercmd->buttons & IN_ATTACK)
						if (already_shot)
							usercmd->buttons &= ~IN_ATTACK;

					already_shot = usercmd->buttons & IN_ATTACK ? true : false;
				}
			}
			else
			{
				if (dh && (!(usercmd->buttons & IN_ATTACK) && !g_InputSystem->IsButtonDown(ButtonCode_t::MOUSE_LEFT))) // if you don't attack currently
					usercmd->buttons |= IN_ATTACK;

				static bool already_shot = false;
				if (g_LocalPlayer->m_hActiveWeapon().Get()->IsPistol())
				{
					if (usercmd->buttons & IN_ATTACK)
						if (already_shot)
							usercmd->buttons &= ~IN_ATTACK;

					already_shot = usercmd->buttons & IN_ATTACK ? true : false;
				}
			}
		}
	}
}
Example #4
0
void Glow::Run()
{
	for (auto i = 0; i < g_GlowObjManager->m_GlowObjectDefinitions.Count(); i++) {
		auto& glowObject = g_GlowObjManager->m_GlowObjectDefinitions[i];
		auto entity = reinterpret_cast<C_BasePlayer*>(glowObject.m_pEntity);
		glowObject.m_flAlpha = 50.0f;
		if (glowObject.IsUnused())
			continue;

		if (!entity || entity->IsDormant())
			continue;

		auto class_id = entity->GetClientClass()->m_ClassID;
		auto color = Color{};
		switch (class_id) {
		case CCSPlayer:
		{
			auto is_enemy = entity->m_iTeamNum() != g_LocalPlayer->m_iTeamNum();

			if (entity->HasC4() && is_enemy && g_Options.glow_c4_carrier) {
				color = g_Options.color_glow_c4_carrier;
				break;
			}

			if (!g_Options.glow_players || !entity->IsAlive())
				continue;

			if (!is_enemy && g_Options.glow_enemies_only)
				continue;

			color = is_enemy ? g_Options.color_glow_enemy : g_Options.color_glow_ally;

			break;
		}
		case CChicken:
			if (!g_Options.glow_chickens)
				continue;
			entity->m_bShouldGlow() = true;
			color = g_Options.color_glow_chickens;
			break;
		case CBaseAnimating:
			if (!g_Options.glow_defuse_kits)
				continue;
			color = g_Options.color_glow_defuse;
			break;
		case CPlantedC4:
			if (!g_Options.glow_planted_c4)
				continue;
			color = g_Options.color_glow_planted_c4;
			break;
		case CHostage:
			if (!g_Options.glow_planted_c4)
				continue;
			color = g_Options.color_glow_planted_c4;
		default:
		{
			if (entity->IsWeapon()) {
				if (!g_Options.glow_weapons)
					continue;
				color = g_Options.color_glow_weapons;
			}
		}
		}
		switch (g_Options.GlowType)
		{
		case 0:
			glowObject.m_nGlowStyle = 0;
			break;
		case 1:
			glowObject.m_nGlowStyle = 2;
			break;
		case 2:
			glowObject.m_nGlowStyle = 1;
			break;
		}
			glowObject.m_flRed = color.r() / 255.0f;
			glowObject.m_flGreen = color.g() / 255.0f;
			glowObject.m_flBlue = color.b() / 255.0f;
			glowObject.m_flAlpha = color.a() / 255.0f;
			glowObject.m_bRenderWhenOccluded = true;
			glowObject.m_bRenderWhenUnoccluded = false;
		
	}
}