inline float CSGO_Armores(float flDamage, int ArmorValue) {
float flArmorRatio = 0.5f;
float flArmorBonus = 0.5f;
if (ArmorValue > 0) {
float flNew = flDamage * flArmorRatio;
float flArmor = (flDamage - flNew) * flArmorBonus;
if (flArmor > static_cast<float>(ArmorValue)) {
flArmor = static_cast<float>(ArmorValue) * (1.f / flArmorBonus);
flNew = flDamage - flArmor;
}
flDamage = flNew;
}
return flDamage;
}
position = nade_drop_position;
CTraceFilter filter;
int end_damage = 0; int fire_dist = 0;
std::pair <float, player_t*> target{ 0.f, nullptr };
for (int i{ 0 }; i < m_globals()->m_maxclients; ++i) {
player_t* player = (player_t*)m_entitylist()->GetClientEntity(i);
if (!player) //-V704
continue;
if (!player->is_player())
continue;
if (!player->is_alive())
continue;
if (player->IsDormant() )
continue;
// get center of mass for player.
auto origin = player->m_vecOrigin();
auto collideable = player->GetCollideable();
auto min = collideable->OBBMins() + origin;
auto max = collideable->OBBMaxs() + origin;
auto center = min + (max - min) * 0.5f;
// get delta between center of mass and final nade pos.
auto delta = center - position;
if (he_nade) {
// is within damage radius?
if (delta.Length() > 350.f)
continue;
Ray_t ray;
Vector NadeScreen;
math::world_to_screen(position, NadeScreen);
// main hitbox, that takes damage
Vector vPelvis = player->hitbox_position(HITBOX_PELVIS);
ray.Init(position, vPelvis);
trace_t ptr;
m_trace()->TraceRay(ray, MASK_SHOT, &filter, &ptr);
//trace to it
if (ptr.hit_entity == player) {
Vector PelvisScreen;
math::world_to_screen(vPelvis, PelvisScreen);
// some magic values by VaLvO
static float a = 105.0f;
static float b = 25.0f;
static float c = 140.0f;
float d = ((delta.Length() - b) / c);
float flDamage = a * exp(-d * d);
auto dmg = max(static_cast<int>(ceilf(CSGO_Armores(flDamage, player->m_ArmorValue()))), 0);
dmg = min(dmg, (player->m_ArmorValue() > 0) ? 57 : 100);
if (dmg > target.first) {
target.first = dmg;
target.second = player;
}
end_damage = dmg;
}
}
}
target.first = твой дамаг
target.second = тот кому ты дамаг нанесёшь