-
Автор темы
- #1
Нашёл у себя в txt файле.
C++:
float DamageMult(int hitgroup)
{
switch (hitgroup)
{
case HITGROUP_GENERIC:
return 0.5f;
case HITGROUP_HEAD:
return 2.0f;
case HITGROUP_CHEST:
return 0.5f;
case HITGROUP_STOMACH:
return 0.75f;
case HITGROUP_LEFTARM:
return 0.5f;
case HITGROUP_RIGHTARM:
return 0.5f;
case HITGROUP_LEFTLEG:
return 0.375f;
case HITGROUP_RIGHTLEG:
return 0.375f;
case HITGROUP_GEAR:
return 0.5f;
default:
return 1.0f;
}
return 1.0f;
}
void autowall::scaleDamage(player_t* e, CGameTrace& enterTrace, weapon_info_t* weaponData, float& currentDamage)
{
if (!e->is_player())
return;
auto is_armored = [&]()->bool
{
auto has_helmet = e->m_bHasHelmet();
auto armor_value = e->m_ArmorValue();
if (armor_value > 0)
{
switch (enterTrace.hitgroup)
{
case HITGROUP_GENERIC:
case HITGROUP_CHEST:
case HITGROUP_STOMACH:
case HITGROUP_LEFTARM:
case HITGROUP_RIGHTARM:
case HITGROUP_LEFTLEG:
case HITGROUP_RIGHTLEG:
case HITGROUP_GEAR:
case HITGROUP_HEAD:
return has_helmet || e->m_bHasHeavyArmor();
default:
return e->m_bHasHeavyArmor();
}
}
return false;
};
static auto mp_damage_scale_ct_head = m_cvar()->FindVar(crypt_str("mp_damage_scale_ct_head"));
static auto mp_damage_scale_t_head = m_cvar()->FindVar(crypt_str("mp_damage_scale_t_head"));
static auto mp_damage_scale_ct_body = m_cvar()->FindVar(crypt_str("mp_damage_scale_ct_body"));
static auto mp_damage_scale_t_body = m_cvar()->FindVar(crypt_str("mp_damage_scale_t_body"));
auto head_scale = e->m_iTeamNum() == 3 ? mp_damage_scale_ct_head->GetFloat() : mp_damage_scale_t_head->GetFloat();
auto body_scale = e->m_iTeamNum() == 3 ? mp_damage_scale_ct_body->GetFloat() : mp_damage_scale_t_body->GetFloat();
auto armor_heavy = e->m_bHasHeavyArmor();
auto armor_value = (float)e->m_ArmorValue();
if (armor_heavy)
head_scale *= 0.5f;
currentDamage *= DamageMult(enterTrace.hitgroup) * body_scale;
if (is_armored())
{
auto armor_scale = 1.0f;
auto armor_ratio = weaponData->flArmorRatio * 0.5f;
auto armor_bonus_ratio = 0.5f;
if (armor_heavy)
{
armor_bonus_ratio = 0.5f;
armor_ratio = 0.33f;
armor_scale = 0.33f;
}
auto new_damage = currentDamage * armor_ratio;
auto estiminated_damage = (currentDamage - currentDamage * armor_ratio) * armor_scale * armor_bonus_ratio;
if (armor_heavy)
new_damage = new_damage * 0.85f;
if (estiminated_damage > armor_value)
new_damage = currentDamage - armor_value / armor_bonus_ratio;
currentDamage = floorf(new_damage);
}
}