C++ Handle bullet penetration from nothing for lw

Пользователь
Статус
Оффлайн
Регистрация
20 Мар 2020
Сообщения
166
Реакции[?]
41
Поинты[?]
0
Как я понял это с nothing взято и перекостылено под лв.
C++:
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;

    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;

    auto combined_damage_modifier = 0.16f;
    auto combined_penetration_modifier = (enter_penetration_modifier + exit_penetration_modifier) * 0.5f;

    if (enter_material == CHAR_TEX_GLASS || enter_material == CHAR_TEX_GRATE)
    {
        combined_penetration_modifier = 3.0f;
        combined_damage_modifier = 0.05f;
    }
    else if (contents_grate || surf_nodraw)
        combined_penetration_modifier = 1.0f;
    else if (enter_material == CHAR_TEX_FLESH && ((player_t*)enterTrace.hit_entity)->m_iTeamNum() == g_ctx.local()->m_iTeamNum() && !ff_damage_reduction_bullets)
    {
        if (!ff_damage_bullet_penetration) //-V550
            return false;

        combined_penetration_modifier = ff_damage_bullet_penetration;
        combined_damage_modifier = 0.16f;
    }

    if (enter_material == exit_material)
    {
        if (exit_material == CHAR_TEX_WOOD || exit_material == CHAR_TEX_CARDBOARD)
            combined_penetration_modifier = 3.0f;
        else if (exit_material == CHAR_TEX_PLASTIC)
            combined_penetration_modifier = 2.0f;
    }

    auto penetration_modifier = std::fmaxf(0.0f, 1.0f / combined_penetration_modifier);
    auto penetration_distance = (exit_trace.endpos - enterTrace.endpos).Length();

    penetration_distance = penetration_distance * penetration_distance * penetration_modifier * 0.041666668f;

    auto damage_modifier = max(0.0f, 3.0f / weaponData->flPenetration * 1.25f) * penetration_modifier * 3.0f + currentDamage * combined_damage_modifier + penetration_distance;
    auto damage_lost = max(0.0f, damage_modifier);

    if (damage_lost > currentDamage)
        return false;

    currentDamage -= damage_lost;

    if (currentDamage < 1.0f)
        return false;

    eyePosition = exit_trace.endpos;
    --possibleHitsRemaining;

    return true;
}
 
mindset studio — yougame.biz/threads/284270
Дизайнер
Статус
Оффлайн
Регистрация
26 Дек 2018
Сообщения
280
Реакции[?]
266
Поинты[?]
86K
Последнее редактирование:
мой нос как останкинская башня
Забаненный
Статус
Оффлайн
Регистрация
24 Апр 2020
Сообщения
483
Реакции[?]
60
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
B.O.M.J
Эксперт
Статус
Оффлайн
Регистрация
19 Май 2017
Сообщения
2,400
Реакции[?]
897
Поинты[?]
3K
Этот код даже не с Nothing.
C++:
bool C_AutoWall::HandleBulletPenetration( )
{
    bool bSolidSurf = ( ( m_PenetrationData.m_EnterTrace.contents >> 3 ) & CONTENTS_SOLID );
    bool bLightSurf = ( m_PenetrationData.m_EnterTrace.surface.flags >> 7 ) & SURF_LIGHT;
    
    int32_t nEnterMaterial = g_Globals.m_Interfaces.m_PropPhysics->GetSurfaceData( m_PenetrationData.m_EnterTrace.surface.surfaceProps )->game.material;
    if ( !m_PenetrationData.m_PenetrationCount && !bLightSurf && !bSolidSurf && nEnterMaterial != 9 )
    {
        if ( nEnterMaterial != 71 )
            return false;
    }

    Vector vecEnd;
    if ( m_PenetrationData.m_PenetrationCount <= 0 || m_PenetrationData.m_flPenetrationPower <= 0.0f )
        return false;

    CGameTrace pExitTrace;
    if ( !TraceToExit( m_PenetrationData.m_EnterTrace.endpos, vecEnd, &m_PenetrationData.m_EnterTrace, &pExitTrace ) )
    {
        if ( !( g_Globals.m_Interfaces.m_EngineTrace->GetPointContents( vecEnd, 0x600400B ) & 0x600400B ) )
        {
            m_PenetrationData.m_flCurrentDamage = 0.0f;
            m_PenetrationData.m_PenetrationCount = 0;

            return false;
        }
    }

    surfacedata_t* pEnterSurfaceData = g_Globals.m_Interfaces.m_PropPhysics->GetSurfaceData(m_PenetrationData.m_EnterTrace.surface.surfaceProps);
    unsigned short pEnterMaterial = pEnterSurfaceData->game.material;
    float_t flEnterSurfacePenetrationModifier = pEnterSurfaceData->game.flPenetrationModifier;

    surfacedata_t* pExitSurfaceData = g_Globals.m_Interfaces.m_PropPhysics->GetSurfaceData( pExitTrace.surface.surfaceProps );
    unsigned short pExitMaterial = pExitSurfaceData->game.material;

    float_t flExitSurfacePenetration = pExitSurfaceData->game.flPenetrationModifier;
    float_t flExitSurfaceModifier = pExitSurfaceData->game.flDamageModifier;

    float flFinalDamageModifier = 0.16f;
    float flCombinedPenetrationModifier = 0.0f;

    if ( pEnterMaterial == CHAR_TEX_GRATE || pEnterMaterial == CHAR_TEX_GLASS )
    {
        flCombinedPenetrationModifier = 3.f;
        flFinalDamageModifier = 0.05f;
    }
    else if ( bSolidSurf || bLightSurf )
    {
        flCombinedPenetrationModifier = 1.f;
        flFinalDamageModifier = 0.16f;
    }
    else if ( pEnterMaterial == CHAR_TEX_FLESH )
    {
        flCombinedPenetrationModifier = g_Globals.m_ConVars.m_DamageBulletPenetration->GetFloat( );
        flFinalDamageModifier = 0.16f;
    }
    else
    {
        flCombinedPenetrationModifier = ( flEnterSurfacePenetrationModifier + flExitSurfacePenetration ) / 2.f;
        flFinalDamageModifier = 0.16f;
    }
 
    //Do our materials line up?
    if ( pEnterMaterial == pExitMaterial )
    {
        if ( pExitMaterial == CHAR_TEX_CARDBOARD || pExitMaterial == CHAR_TEX_WOOD )
            flCombinedPenetrationModifier = 3.f;
        else if ( pExitMaterial == CHAR_TEX_PLASTIC )
            flCombinedPenetrationModifier = 2.f;
    }

    float flModifier = fmaxf( 0.0f, 1.0f / flCombinedPenetrationModifier );
    float flThickness = ( pExitTrace.endpos - m_PenetrationData.m_EnterTrace.endpos ).LengthSqr( );
    float flLostDamage = fmaxf(
            ( ( flModifier * flThickness ) / 24.f )
            + ( ( m_PenetrationData.m_flCurrentDamage * flFinalDamageModifier )
                + ( fmaxf( 3.75f / m_PenetrationData.m_flPenetrationPower, 0.f ) * 3.f * flModifier ) ), 0.f );

    if ( flLostDamage > m_PenetrationData.m_flCurrentDamage )
        return false;

    if ( flLostDamage > 0.0f )
        m_PenetrationData.m_flCurrentDamage -= flLostDamage;

    if ( m_PenetrationData.m_flCurrentDamage < 1.0f )
        return false;

    m_PenetrationData.m_vecShootPosition = pExitTrace.endpos;
    m_PenetrationData.m_PenetrationCount--;

    return true;
}
 
Участник
Статус
Оффлайн
Регистрация
19 Апр 2020
Сообщения
1,178
Реакции[?]
314
Поинты[?]
152K
Как я понял это с nothing взято и перекостылено под лв.
C++:
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;

    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;

    auto combined_damage_modifier = 0.16f;
    auto combined_penetration_modifier = (enter_penetration_modifier + exit_penetration_modifier) * 0.5f;

    if (enter_material == CHAR_TEX_GLASS || enter_material == CHAR_TEX_GRATE)
    {
        combined_penetration_modifier = 3.0f;
        combined_damage_modifier = 0.05f;
    }
    else if (contents_grate || surf_nodraw)
        combined_penetration_modifier = 1.0f;
    else if (enter_material == CHAR_TEX_FLESH && ((player_t*)enterTrace.hit_entity)->m_iTeamNum() == g_ctx.local()->m_iTeamNum() && !ff_damage_reduction_bullets)
    {
        if (!ff_damage_bullet_penetration) //-V550
            return false;

        combined_penetration_modifier = ff_damage_bullet_penetration;
        combined_damage_modifier = 0.16f;
    }

    if (enter_material == exit_material)
    {
        if (exit_material == CHAR_TEX_WOOD || exit_material == CHAR_TEX_CARDBOARD)
            combined_penetration_modifier = 3.0f;
        else if (exit_material == CHAR_TEX_PLASTIC)
            combined_penetration_modifier = 2.0f;
    }

    auto penetration_modifier = std::fmaxf(0.0f, 1.0f / combined_penetration_modifier);
    auto penetration_distance = (exit_trace.endpos - enterTrace.endpos).Length();

    penetration_distance = penetration_distance * penetration_distance * penetration_modifier * 0.041666668f;

    auto damage_modifier = max(0.0f, 3.0f / weaponData->flPenetration * 1.25f) * penetration_modifier * 3.0f + currentDamage * combined_damage_modifier + penetration_distance;
    auto damage_lost = max(0.0f, damage_modifier);

    if (damage_lost > currentDamage)
        return false;

    currentDamage -= damage_lost;

    if (currentDamage < 1.0f)
        return false;

    eyePosition = exit_trace.endpos;
    --possibleHitsRemaining;

    return true;
}
перепиши фулл авто волл с nothing)
 
Сверху Снизу