Исходник Enrage handle_bullet_penetration for lw

Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2021
Сообщения
33
Реакции[?]
22
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
bool autowall::handle_bullet_penetration(weapon_info_t* weaponData, CGameTrace& enterTrace, Vector& eyePosition, const Vector& direction, int& possibleHitsRemaining, float& currentDamage, float penetrationPower, float ff_damage_reduction_bullets, float ff_damage_bullet_penetration, bool draw_impact)
{
    if (weaponData->flPenetration <= 0.0f)
        return false;

    if (possibleHitsRemaining <= 0)
        return false;

    auto contents_grate = enterTrace.contents & CONTENTS_GRATE;
    auto surf_nodraw = enterTrace.surface.flags & SURF_NODRAW;

    auto enterSurfaceData = m_physsurface()->GetSurfaceData(enterTrace.surface.surfaceProps);
    auto enter_material = enterSurfaceData->game.material;

    auto is_solid_surf = enterTrace.contents >> 3 & CONTENTS_SOLID;
    auto is_light_surf = enterTrace.surface.flags >> 7 & SURF_LIGHT;

    trace_t exit_trace;
    player_t* player;

    if (!trace_to_exit(enterTrace, exit_trace, enterTrace.endpos, direction) && !(m_trace()->GetPointContents(enterTrace.endpos, MASK_SHOT_HULL) & MASK_SHOT_HULL))
        return false;

    auto enter_penetration_modifier = enterSurfaceData->game.flPenetrationModifier;
    auto exit_surface_data = m_physsurface()->GetSurfaceData(exit_trace.surface.surfaceProps);

    if (!exit_surface_data)
        return false;

    auto exit_material = exit_surface_data->game.material;
    auto exit_penetration_modifier = exit_surface_data->game.flPenetrationModifier;

    float combined_damage_modifier = 0.16f;
    float combined_penetration_modifier;

    if (enter_material == CHAR_TEX_GLASS || enter_material == CHAR_TEX_GRATE)
    {
        combined_damage_modifier = 0.05f;
        combined_penetration_modifier = 3;
    }
    else if (is_solid_surf || is_light_surf)
    {
        combined_damage_modifier = 0.16f;
        combined_penetration_modifier = 1;
    }
    else if (enter_material == CHAR_TEX_FLESH && ff_damage_reduction_bullets && player->m_iTeamNum() == g_ctx.local()->m_iTeamNum())
    {
        if (ff_damage_bullet_penetration == 0)
        {
            combined_penetration_modifier = 0;
            return false;
        }
        combined_penetration_modifier = ff_damage_bullet_penetration;
    }
    else {
        combined_penetration_modifier = (enter_penetration_modifier + exit_penetration_modifier) / 2;
    }

    if (enter_material == exit_material)
    {
        if (exit_material == CHAR_TEX_WOOD || exit_material == CHAR_TEX_CARDBOARD)
            combined_penetration_modifier = 3;
        else if (exit_material == CHAR_TEX_PLASTIC)
            combined_penetration_modifier = 2;
    }

    float thickness = (exit_trace.endpos - enterTrace.endpos).LengthSqr();
    float modifier = fmax(0.f, 1.f / combined_penetration_modifier);

    float lost_damage = fmax(((modifier * thickness) / 24.f) + ((currentDamage * combined_damage_modifier) + (fmax(3.75f / penetrationPower, 0.f) * 3.f * modifier)), 0.f);

    if (lost_damage > currentDamage)
        return false;

    if (lost_damage > 0.f)
        currentDamage -= lost_damage;

    if (currentDamage < 1.f)
        return false;

    eyePosition = exit_trace.endpos;
    --possibleHitsRemaining;

    return true;
}
 
Сверху Снизу