-
Автор темы
- #1
Я не знаю, на эту штуку был гайд, но говорят, что работает криво. А этот гайд вроде нормально работает.
Если что-то пойдёт не так - пишите, помогу.
Код:
Settings.cpp
bool DamageIndicator = false;
float DamagerColor[3] = { 0.f,0.0f,0.f };
-------------------------
Settings.h
float DamagerColor[3];
extern bool DamageIndicator;
-------------------------
Esp.cpp после инклудов
std::vector<DamageIndicator_t> DamageIndicator;
После СESP
void CEsp::DrawDamageIndicator()
{
CBaseEntity* pLocal = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
float CurrentTime = pLocal->GetTickBase() * Interfaces::GlobalVars()->interval_per_tick;
for (int i = 0; i < DamageIndicator.size(); i++)
{
if (DamageIndicator[i].flEraseTime < CurrentTime)
{
DamageIndicator.erase(DamageIndicator.begin() + i);
continue;
}
if (!DamageIndicator[i].bInitialized)
{
DamageIndicator[i].Position = DamageIndicator[i].Player->GetBonePosition(HITBOX_HEAD);
DamageIndicator[i].bInitialized = true;
}
if (CurrentTime - DamageIndicator[i].flLastUpdate > 0.0001f)
{
DamageIndicator[i].Position.z -= (0.6f * (CurrentTime - DamageIndicator[i].flEraseTime));
DamageIndicator[i].flLastUpdate = CurrentTime;
}
Vector ScreenPosition;
if (WorldToScreen(DamageIndicator[i].Position, ScreenPosition))
{
g_pRender->Text(ScreenPosition.x, ScreenPosition.y, false, true, Color(int(Settings::Esp::DamagerColor[0] * 255.f),
int(Settings::Esp::DamagerColor[1] * 255.f),
int(Settings::Esp::DamagerColor[2] * 255.f)), std::to_string(DamageIndicator[i].iDamage).c_str());
}
}
}
В OnRender
if (Settings::Esp::DamageIndicator)
DrawDamageIndicator();
В OnEvents
if (Settings::Esp::DamageIndicator)
{
if (strcmp(pEvent->GetName(), "player_hurt") == 0)
{
CBaseEntity* hurt = (CBaseEntity*)(Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetPlayerForUserID(pEvent->GetInt("userid"))));
CBaseEntity* attacker = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetPlayerForUserID(pEvent->GetInt("attacker")));
CBaseEntity* pLocal = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
if (hurt != pLocal && attacker == pLocal)
{
DamageIndicator_t DmgIndicator;
DmgIndicator.iDamage = pEvent->GetInt("dmg_health");
DmgIndicator.Player = hurt;
DmgIndicator.flEraseTime = pLocal->GetTickBase() * Interfaces::GlobalVars()->interval_per_tick + 3.f;
DmgIndicator.bInitialized = false;
DamageIndicator.push_back(DmgIndicator);
}
}
}
--------------------------
В Esp.h в CESP
void DrawDamageIndicator();
В конце
struct DamageIndicator_t
{
int iDamage;
bool bInitialized;
float flEraseTime;
float flLastUpdate;
CBaseEntity * Player;
Vector Position;
};
---------------------
В Client.cpp
ImGui::Checkbox("Damage Indicator", &Settings::Esp::DamageIndicator);
{
if (!Interfaces::Engine()->IsInGame())
Settings::Esp::DamageIndicator = false;
}
ImGui::ColorEdit3("Damager Color", Settings::Esp::DamagerColor);