Skip to content

Commit

Permalink
Added Dropped weapon esp, Fixed Spectator list showing wrong info
Browse files Browse the repository at this point in the history
  • Loading branch information
Viceroyy committed Jul 3, 2024
1 parent a4a176f commit 776e3e2
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 81 deletions.
2 changes: 1 addition & 1 deletion Arsenal/Features/CFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace CFG

CFGVAR(ESP_World_Enabled, true);
CFGVAR(ESP_World_Ignore_PlantedC4, false);
//CFGVAR(ESP_World_Ignore_DroppedWeapons, false);
CFGVAR(ESP_World_Ignore_DroppedWeapons, false);
CFGVAR(ESP_World_Name, true);
CFGVAR(ESP_World_Box, false);

Expand Down
120 changes: 54 additions & 66 deletions Arsenal/Features/ESP/ESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ void CFeatures_ESP::DrawPlayers(C_CSPlayer* pLocal)
{
if (const auto& pWeapon = pPlayer->GetActiveCSWeapon())
{
H::Draw.String(fFont, x + (w / 2), y + h + bOffset, COLOR_WHITE, ALIGN_TOP, "%s", GetWeaponName(pWeapon->GetWeaponID()));
bOffset += H::Draw.GetFontHeight(fFont);
if (auto weapon_name = Util::ConvertToUppercase(GetWeaponName(pWeapon->GetWeaponID())))
{
H::Draw.String(fFont, x + (w / 2), y + h + bOffset, COLOR_WHITE, ALIGN_TOP, weapon_name.get());
bOffset += H::Draw.GetFontHeight(fFont);
}
}
}

Expand Down Expand Up @@ -162,91 +165,76 @@ void CFeatures_ESP::DrawWorld()
}
}

//if (!CFG::ESP_World_Ignore_DroppedWeapons)
//{
// for (auto pWeapons : H::EntityCache.GetGroup(EGroupType::WORLD_WEAPONS))
// {
// int x = 0, y = 0, w = 0, h = 0;
// if (!GetDynamicBounds(pWeapons, x, y, w, h))
// continue;
if (!CFG::ESP_World_Ignore_DroppedWeapons)
{
for (auto pWeapons : H::EntityCache.GetGroup(EGroupType::WORLD_WEAPONS))
{
int x = 0, y = 0, w = 0, h = 0;
if (!GetDynamicBounds(pWeapons, x, y, w, h))
continue;

// if (CFG::ESP_World_Box)
// {
// H::Draw.OutlinedRect(x, y, w, h, CFG::Colors_PlantedC4);
auto pWeps = pWeapons->As<C_WeaponCSBase>();

// //Outline
// H::Draw.OutlinedRect(x - 1, y - 1, w + 2, h + 2, COLOR_BLACK);
if (CFG::ESP_World_Box)
{
H::Draw.OutlinedRect(x, y, w, h, CFG::Colors_PlantedC4);

// //Inline
// H::Draw.OutlinedRect(x + 1, y + 1, w - 2, h - 2, COLOR_BLACK);
// }
//Outline
H::Draw.OutlinedRect(x - 1, y - 1, w + 2, h + 2, COLOR_BLACK);

// if (CFG::ESP_World_Name)
// H::Draw.String(fFont, x + w / 2, y - nTextTopOffset, COLOR_RED, ALIGN_TOP, "Weapon");
// }
//}
//Inline
H::Draw.OutlinedRect(x + 1, y + 1, w - 2, h - 2, COLOR_BLACK);
}

if (CFG::ESP_World_Name)
{
if (auto weapon_name = Util::ConvertToUppercase(GetWeaponName(pWeps->GetWeaponID())))
{
H::Draw.String(fFont, x + w / 2, y - nTextTopOffset, COLOR_WHITE, ALIGN_TOP, weapon_name.get());
}
}
}
}

I::MatSystemSurface->DrawSetAlphaMultiplier(1.f);
}

bool CFeatures_ESP::GetDynamicBounds(C_BaseEntity* pEntity, int& x, int& y, int& w, int& h)
{
Vector vMins = pEntity->m_vecMins(), vMaxs = pEntity->m_vecMaxs();
if (!pEntity)
return false;

Vector vMins, vMaxs;
pEntity->GetRenderBounds(vMins, vMaxs);

auto& transform = const_cast<matrix3x4_t&>(pEntity->RenderableToWorldTransform());
if (pEntity && pEntity->entindex() == I::EngineClient->GetLocalPlayer())
{
Vector vAngles = I::EngineClient->GetViewAngles();
vAngles.x = vAngles.z = 0.f;
U::Math.AngleMatrix(vAngles, transform);
U::Math.MatrixSetColumn(pEntity->GetAbsOrigin(), 3, transform);
}
U::Math.AngleMatrix(pEntity->GetRenderAngles(), transform);
U::Math.MatrixSetColumn(pEntity->GetRenderOrigin(), 3, transform);

float flLeft, flRight, flTop, flBottom;
if (!Util::IsOnScreen(pEntity, transform, &flLeft, &flRight, &flTop, &flBottom))
return false;

x = flLeft + (flRight - flLeft) / 8.f;
x = flLeft;
y = flBottom;
w = flRight - flLeft - (flRight - flLeft) / 8.f * 2.f;
w = flRight - flLeft;
h = flTop - flBottom;

return !(x > H::Draw.m_nScreenW || x + w < 0 || y > H::Draw.m_nScreenH || y + h < 0);
}

const char* CFeatures_ESP::GetWeaponName(int wpnid)
std::uintptr_t get_rel32(std::uintptr_t address, std::uintptr_t offset, std::uintptr_t instruction_size)
{
switch (wpnid)
{
case WEAPON_P228: return "P228"; break;
case WEAPON_GLOCK: return "GLOCK"; break;
case WEAPON_SCOUT: return "SCOUT"; break;
case WEAPON_HEGRENADE: return "HE GRENADE"; break;
case WEAPON_XM1014: return "XM1014"; break;
case WEAPON_C4: return "C4"; break;
case WEAPON_MAC10: return "MAC10"; break;
case WEAPON_AUG: return "AUG"; break;
case WEAPON_SMOKEGRENADE: return "SMOKE GRENADE"; break;
case WEAPON_ELITE: return "ELITE"; break;
case WEAPON_FIVESEVEN: return "FIVE-SEVEN"; break;
case WEAPON_UMP45: return "UMP45"; break;
case WEAPON_SG550: return "SG550"; break;
case WEAPON_GALIL: return "GALIL"; break;
case WEAPON_FAMAS: return "FAMAS"; break;
case WEAPON_USP: return "USP"; break;
case WEAPON_AWP: return "AWP"; break;
case WEAPON_MP5NAVY: return "MP5"; break;
case WEAPON_M249: return "M249"; break;
case WEAPON_M3: return "M3"; break;
case WEAPON_M4A1: return "M4A1"; break;
case WEAPON_TMP: return "TMP"; break;
case WEAPON_G3SG1: return "G3SG1"; break;
case WEAPON_FLASHBANG: return "FLASHBANG"; break;
case WEAPON_DEAGLE: return "DEAGLE"; break;
case WEAPON_SG552: return "SG552"; break;
case WEAPON_AK47: return "AK47"; break;
case WEAPON_KNIFE: return "KNIFE"; break;
case WEAPON_P90: return "P90"; break;
}
return "UNKNOWN";
}
return address + *reinterpret_cast<std::uintptr_t*>(address + offset) + instruction_size;
}

std::wstring CFeatures_ESP::GetWeaponName(int wpnid)
{
static auto function = reinterpret_cast<const char* (*)(int)>(
get_rel32(U::Pattern.Find("client.dll", "E8 ? ? ? ? 50 FF 75 94"), 1, 5));

if (!function(wpnid))
return L"UNKNOWN";

return Util::ConvertUtf8ToWide(function(wpnid));
}
2 changes: 1 addition & 1 deletion Arsenal/Features/ESP/ESP.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CFeatures_ESP

private:
bool GetDynamicBounds(C_BaseEntity* pEntity, int& x, int& y, int& w, int& h);
const char* GetWeaponName(int wpnid);
std::wstring GetWeaponName(int wpnid);

void DrawPlayers(C_CSPlayer* pLocal);
void DrawWorld();
Expand Down
3 changes: 2 additions & 1 deletion Arsenal/Features/Menu/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ void CFeatures_Menu::MainWindow()

multiselect("Ignore", WorldIgnore, {
{ "Planted C4", CFG::ESP_World_Ignore_PlantedC4 },
//{ "Dropped Weapons", CFG::ESP_World_Ignore_DroppedWeapons }
{ "Dropped Weapons", CFG::ESP_World_Ignore_DroppedWeapons }
});

multiselect("Draw", WorldDraw, {
Expand All @@ -1228,6 +1228,7 @@ void CFeatures_Menu::MainWindow()
}
GroupBoxEnd();
}

if (VisualsTab == EVisualsTabs::OTHER)
{
anchor_x = m_nCursorX;
Expand Down
10 changes: 5 additions & 5 deletions Arsenal/Features/SpectatorList/SpectatorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ bool CFeatures_SpectatorList::GetSpectators(C_CSPlayer* pLocal)
std::wstring szMode;
switch (pPlayer->m_iObserverMode())
{
case OBS_MODE_DEATHCAM: szMode = L"Death"; break;
case OBS_MODE_FREEZECAM: szMode = L"Freeze"; break;
case OBS_MODE_DEATHCAM: szMode = L"Deathcam"; break;
case OBS_MODE_FREEZECAM: szMode = L"Freezecam"; break;
case OBS_MODE_FIXED: szMode = L"Fixed"; break;
case OBS_MODE_FIRSTPERSON: szMode = L"3rd"; break;
case OBS_MODE_THIRDPERSON: szMode = L"1st"; break;
case OBS_MODE_FIRSTPERSON: szMode = L"1st"; break;
case OBS_MODE_THIRDPERSON: szMode = L"3rd"; break;
case OBS_MODE_ROAMING: szMode = L"Roaming"; break;
default: continue;
}

player_info_t pi{};
if (I::EngineClient->GetPlayerInfo(pPlayer->entindex(), &pi))
{
Spectators.push_back({ Util::ConvertUtf8ToWide(pi.name), szMode, pPlayer->m_iTeamNum(), pPlayer->entindex() });
Spectators.push_back({ Util::ConvertUtf8ToWide(pi.name), szMode });
}
}

Expand Down
3 changes: 0 additions & 3 deletions Arsenal/Features/SpectatorList/SpectatorList.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ class CFeatures_SpectatorList
{
std::wstring Name;
std::wstring Mode;
int Team;
int Index;
};

std::vector<Spectator_t> Spectators;

public:
int SpecListX = 30, SpecListY = 100;
bool GetSpectators(C_CSPlayer* pLocal);
void Run();
};
Expand Down
6 changes: 3 additions & 3 deletions Arsenal/SDK/EntityCacher/EntityCacher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void CHelpers_EntityCache::Fill()
m_mGroups[EGroupType::WORLD_C4PLANTED].push_back(pEntity);
break;
}
/*case ECSClientClass::CAK47:
case ECSClientClass::CAK47:
case ECSClientClass::CWeaponP228:
case ECSClientClass::CWeaponGlock:
case ECSClientClass::CWeaponScout:
Expand Down Expand Up @@ -72,10 +72,10 @@ void CHelpers_EntityCache::Fill()
case ECSClientClass::CWeaponSG552:
case ECSClientClass::CWeaponP90:
{
if (pEntity->As<C_BaseCombatWeapon>()->m_hOwner().ToInt() == 255)
if (pEntity->As<C_BaseCombatWeapon>()->m_hOwner().Get() == nullptr)
m_mGroups[EGroupType::WORLD_WEAPONS].push_back(pEntity);
break;
}*/
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Arsenal/SDK/EntityCacher/EntityCacher.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
enum struct EGroupType
{
PLAYERS_ALL, PLAYERS_ENEMIES, PLAYERS_TEAMMATES,
WORLD_C4PLANTED//, WORLD_WEAPONS
WORLD_C4PLANTED, WORLD_WEAPONS
};

class CHelpers_EntityCache
Expand Down
25 changes: 25 additions & 0 deletions Arsenal/SDK/SDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,31 @@ namespace Util
return result;
}

inline std::string ConvertWideToUtf8(const std::wstring& unicode)
{
const int size = WideCharToMultiByte(CP_UTF8, 0, unicode.c_str(), -1, nullptr, 0, nullptr, nullptr);
std::string result(size, '\0');
WideCharToMultiByte(CP_UTF8, 0, unicode.c_str(), -1, result.data(), size, nullptr, nullptr);
return result;
}

inline std::unique_ptr<char[]> ConvertToUppercase(const std::wstring& wstr)
{
size_t length = wstr.length();
auto upper_wstr = std::make_unique<wchar_t[]>(length + 1);
wcscpy_s(upper_wstr.get(), length + 1, wstr.c_str());

for (size_t i = 0; i < length; ++i) {
upper_wstr[i] = std::toupper(upper_wstr[i]);
}

std::string utf8_str = ConvertWideToUtf8(upper_wstr.get());
auto result = std::make_unique<char[]>(utf8_str.size() + 1);
strcpy_s(result.get(), utf8_str.size() + 1, utf8_str.c_str());

return result;
}

inline void MakeSafeName(const char* oldName, char* newName, int newNameBufSize)
{
assert(newNameBufSize >= sizeof(newName[0]));
Expand Down

0 comments on commit 776e3e2

Please sign in to comment.