-
Автор темы
- #1
Как я понял это с 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;
}