Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Исходник Damage indicator

Забаненный
Забаненный
Статус
Оффлайн
Регистрация
16 Мар 2017
Сообщения
788
Реакции
242
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Damage Indicator
Код:
Expand Collapse Copy
[LIST=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());
[*]}
[*]}
[*]}
[/LIST]
Результат:
-e-_aSy7S9iztGvWsaa0lg.png


 
Последнее редактирование:
Смысл сливать половину кода с uc?
Код:
Expand Collapse Copy
// 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());
        }
    }
}
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Это ведь просто отрисовка, запостил бы пример использования (геймивент on_hurt в помощь)
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Назад
Сверху Снизу