f3mb0y
-
Автор темы
- #1
Опять же, код слишком простой, поэтому приступаем:
В ESP.cpp вставляем:
В Esp.h
Вызываем в рендере:
ДОПОЛНЮ!
В void OnFireEventClientSideThink(IGameEvent* pEvent)
В ESP.h
Вот и все, и как обычно говнокод)
В ESP.cpp вставляем:
Код:
AWHitmarker* AWpHitmarker = new AWHitmarker();
Код:
int64 GetEpochMS()
{
int64 now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
return now;
}
Код:
void AWHitmarker::Initialize()
{
Interfaces::GameEvent()->AddListener(this, "player_hurt", false);
Interfaces::GameEvent()->AddListener(this, "bullet_impact", false);
}
Код:
CBaseEntity* AWHitmarker::GetPlayer(int userid)
{
int index = Interfaces::Engine()->GetPlayerForUserID(userid);
return (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(index);
}
Код:
void AWHitmarker::Paint()
{
auto pLocal = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
if (!Settings::Esp::esp_HitMarker)
return;
if (!Interfaces::Engine()->IsConnected() || !Interfaces::Engine()->IsInGame() || !pLocal)
{
if (!pImpacts.empty())
pImpacts.clear();
if (!pHitmarkers.empty())
pHitmarkers.clear();
return;
}
long long pTime = GetEpochMS();
std::vector<pHitmarkerInfo>::iterator pIter;
for (pIter = pHitmarkers.begin(); pIter != pHitmarkers.end(); ) {
bool pExpired = pTime > pIter->pImpact.time + 3000; // 2000
static int pAlphaInterval = 255 / 50;
if (pExpired)
pIter->alpha -= pAlphaInterval;
if (pExpired && pIter->alpha <= 0) {
pIter = pHitmarkers.erase(pIter);
continue;
}
Vector pos3D = Vector(pIter->pImpact.x, pIter->pImpact.y, pIter->pImpact.z), pos2D;
if (!WorldToScreen(pos3D, pos2D))
{
++pIter;
continue;
}
Color AWHitmarkerColor = Color((Settings::Esp::esp_HitMarkerColor[0] * 255.f), int(Settings::Esp::esp_HitMarkerColor[1] * 255.f), int(Settings::Esp::esp_HitMarkerColor[2] * 255.f));
int pLineSize = 6;
g_pRender->DrawLine(pos2D.x - pLineSize / 4, pos2D.y - pLineSize / 4, pos2D.x - (pLineSize), pos2D.y - (pLineSize), AWHitmarkerColor);
g_pRender->DrawLine(pos2D.x - pLineSize / 4, pos2D.y + pLineSize / 4, pos2D.x - (pLineSize), pos2D.y + (pLineSize), AWHitmarkerColor);
g_pRender->DrawLine(pos2D.x + pLineSize / 4, pos2D.y + pLineSize / 4, pos2D.x + (pLineSize), pos2D.y + (pLineSize), AWHitmarkerColor);
g_pRender->DrawLine(pos2D.x + pLineSize / 4, pos2D.y - pLineSize / 4, pos2D.x + (pLineSize), pos2D.y - (pLineSize), AWHitmarkerColor);
++pIter;
}
}
Код:
void AWHitmarker::FireGameEvent(SDK::IGameEvent* pEvent)
{
auto pLocal = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
if (!Settings::Esp::esp_HitMarker)
return;
if (!pEvent || !pLocal)
return;
if (!strcmp(pEvent->GetName(), "player_hurt"))
PlayerHurt(pEvent);
if (!strcmp(pEvent->GetName(), "bullet_impact"))
BulletImpact(pEvent);
}
Код:
int AWHitmarker::GetEventDebugID(void) { return 0x2A; }
Код:
void AWHitmarker::PlayerHurt(SDK::IGameEvent* pEvent)
{
auto pLocal = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
CBaseEntity* pAttacker = GetPlayer(pEvent->GetInt("attacker"));
CBaseEntity* pVictim = GetPlayer(pEvent->GetInt("userid"));
if (!pAttacker || !pVictim || pAttacker != pLocal)
return;
Vector pEnemyPos = pVictim->GetEyeAngles();
pImpactInfo pBestImpact;
float pBestImpactDistance = -1;
long long pTime = GetEpochMS();
std::vector<pImpactInfo>::iterator pIter;
for (pIter = pImpacts.begin(); pIter != pImpacts.end(); )
{
if (pTime > pIter->time + 25) {
pIter = pImpacts.erase(pIter);
continue;
}
Vector Position = Vector(pIter->x, pIter->y, pIter->z);
float pDistance = Position.DistTo(pEnemyPos);
if (pDistance < pBestImpactDistance || pBestImpactDistance == -1)
{
pBestImpactDistance = pDistance;
pBestImpact = *pIter;
}
pIter++;
}
if (pBestImpactDistance == -1)
return;
pHitmarkerInfo pInfo;
pInfo.pImpact = pBestImpact;
pInfo.alpha = 255;
pHitmarkers.push_back(pInfo);
}
Код:
void AWHitmarker::BulletImpact(SDK::IGameEvent* pEvent) {
auto pLocal = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
CBaseEntity* pShooter = GetPlayer(pEvent->GetInt("userid"));
if (!pShooter || pShooter != pLocal)
return;
pImpactInfo pInfo;
pInfo.x = pEvent->GetFloat("x");
pInfo.y = pEvent->GetFloat("y");
pInfo.z = pEvent->GetFloat("z");
pInfo.time = GetEpochMS();
pImpacts.push_back(pInfo);
}
Код:
class AWHitmarker : public IGameEventListener2
{
public:
void Initialize();
void Paint();
private:
void FireGameEvent(SDK::IGameEvent* pEvent) override;
int GetEventDebugID(void) override;
void PlayerHurt(SDK::IGameEvent* pEvent);
void BulletImpact(SDK::IGameEvent* pEvent);
CBaseEntity* GetPlayer(int userid);
std::vector<pImpactInfo> pImpacts;
std::vector<pHitmarkerInfo> pHitmarkers;
};
Код:
if (Settings::Esp::esp_HitMarker)
{
pHitmarker->Paint();
}
В void OnFireEventClientSideThink(IGameEvent* pEvent)
Код:
pHitmarker->Initialize();
Код:
struct pImpactInfo
{
float x, y, z;
long long time;
};
struct pHitmarkerInfo
{
pImpactInfo pImpact;
int alpha;
};
Последнее редактирование: