-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
// put this in your FireEvent hook
if (Settings->Visuals.DamageIndicator)
{
if (strcmp(event->GetName(), "player_hurt") == 0)
{
CBaseEntity* hurt = (CBaseEntity*)EntityList->GetClientEntity(EngineClient->GetPlayerForUserID(event->GetInt("userid")));
CBaseEntity* attacker = (CBaseEntity*)EntityList->GetClientEntity(EngineClient->GetPlayerForUserID(event->GetInt("attacker")));
if (hurt != pLocalPlayer && attacker == pLocalPlayer)
{
DamageIndicator_t DmgIndicator;
DmgIndicator.iDamage = event->GetInt("dmg_health");
DmgIndicator.Player = hurt;
DmgIndicator.flEraseTime = pLocalPlayer->TickBase() * Globals->interval_per_tick + 3.f;
DmgIndicator.bInitialized = false;
visuals->DamageIndicator.push_back(DmgIndicator);
}
}
}
// put this in your header
struct DamageIndicator_t
{
int iDamage;
bool bInitialized;
float flEraseTime;
float flLastUpdate;
CBaseEntity * Player;
Vector Position;
};
std::vector<DamageIndicator_t> DamageIndicator;
//then call this func once each frame
void Visuals::DrawDamageIndicator()
{
float CurrentTime = pLocalPlayer->TickBase() * Globals->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->GetBonePositionByHitbox(HITBOX_HEAD);
DamageIndicator[i].bInitialized = true;
}
if (CurrentTime - DamageIndicator[i].flLastUpdate > 0.0001f)
{
DamageIndicator[i].Position.z -= (0.1f * (CurrentTime - DamageIndicator[i].flEraseTime));
DamageIndicator[i].flLastUpdate = CurrentTime;
}
Vector ScreenPosition;
if (GameUtils::World2Screen(DamageIndicator[i].Position, ScreenPosition))
{
drawManager->drawString(Menu->indicator_font, true, ScreenPosition.x, ScreenPosition.y, Color(255, 0, 0, 255), std::to_string(DamageIndicator[i].iDamage).c_str());
}
}
}