Исходник Onetap v2 handle bullet penetration

Пользователь
Статус
Оффлайн
Регистрация
8 Янв 2020
Сообщения
187
Реакции[?]
138
Поинты[?]
20K
Onetap v2 handle bullet penetration.

C++:
bool AutoWall::HandleBulletPenetration(FireBulletData& data)
{
    if (data.penetrate_count <= 0)
        return false;

    if (data.weapon_info->m_fPenetration <= 0.0)
        return false;

    Vector dummy;
    trace_t traceExit;

    bool solid = (data.enter_trace.contents >> 3) & CONTENTS_SOLID;
    bool light = (data.enter_trace.surface.flags >> 7) & SURF_LIGHT;

    if (!AutoWall::Get().TraceToExit(data.src, data.dir, dummy, data.enter_trace, traceExit)
        && !(g_pEngineTrace->GetPointContents(dummy, MASK_SHOT_HULL) & MASK_SHOT_HULL))
        return false;

    SurfaceData_t* exitSurfaceData = g_pPhysSurface->GetSurfaceData(traceExit.surface.surfaceProps);
    SurfaceData_t* enterSurfaceData = g_pPhysSurface->GetSurfaceData(data.enter_trace.surface.surfaceProps);

    if (!exitSurfaceData || !enterSurfaceData)
        return false;

    unsigned short exitSurfaceMaterial = exitSurfaceData->game.material;
    unsigned short enterSurfaceMaterial = enterSurfaceData->game.material;

    float combinedPenetrationModifier = 1.0;
    float finalDamageModifier = 0.16;

    if (enterSurfaceMaterial == 71 || enterSurfaceMaterial == 89)
    {
        finalDamageModifier = 0.05;
        combinedPenetrationModifier = 3.0;
    }
    else
    {
        if (!solid && !light)
            combinedPenetrationModifier = (enterSurfaceData->game.penetrationModifier + exitSurfaceData->game.penetrationModifier) * 0.5;

        finalDamageModifier = 0.16;
    }

    if (enterSurfaceMaterial == exitSurfaceMaterial)
    {
        if (exitSurfaceMaterial != 87 && exitSurfaceMaterial != 85)
        {
            if (exitSurfaceMaterial == 76)
                combinedPenetrationModifier = 2.0;
        }
        else
            combinedPenetrationModifier = 3.0;
    }

    float thickness = (traceExit.endpos - data.enter_trace.endpos).LengthSqr();
    float modifier = fmaxf(1.0 / combinedPenetrationModifier, 0.0);
    float lost_damage = data.current_damage -
        fmaxf(((fmaxf((3.0 / data.weapon_info->m_fPenetration) * 1.25, 0.0) * (modifier * 3.0)) + (data.current_damage * finalDamageModifier))
            + ((thickness * modifier) / 24.0), 0.0);

    data.current_damage = lost_damage;

    if (data.current_damage > 0.0)
    {
        data.src = traceExit.endpos;
        data.penetrate_count--;

        return true;
    }

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