-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
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* m_pEnt;
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;
static auto dmg_reduction_bullets = m_cvar()->FindVar("ff_damage_reduction_bullets")->GetFloat();
static auto dmg_bullet_penetration = m_cvar()->FindVar("ff_damage_bullet_penetration")->GetFloat();
auto ent =reinterpret_cast<player_t*>(exit_trace.hit_entity);
if (enter_material == CHAR_TEX_GRATE || enter_material == CHAR_TEX_GLASS)
{
combined_penetration_modifier = 3.0f;
combined_damage_modifier = 0.05f;
}
else if (is_light_surf || is_solid_surf)
{
combined_penetration_modifier = 1.0f;
combined_damage_modifier = 0.16f;
}
else if (enter_material == CHAR_TEX_FLESH && ent->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !dmg_reduction_bullets)
{
if (!dmg_bullet_penetration)
return false;
combined_penetration_modifier = dmg_bullet_penetration;
combined_damage_modifier = 0.16f;
}
else
{
combined_penetration_modifier = (enter_penetration_modifier + exit_penetration_modifier) * 0.5f;
combined_damage_modifier = 0.16f;
}
if (enter_material == exit_material)
{
if (exit_material == CHAR_TEX_CARDBOARD || exit_material == CHAR_TEX_WOOD)
combined_damage_modifier = 3.f;
else if (exit_material == CHAR_TEX_PLASTIC)
combined_damage_modifier = 2.0f;
}
auto penetration_modifier = std::fmaxf(0.0f, 1.0f / combined_penetration_modifier);
auto penetration_distance = (exit_trace.endpos - enterTrace.endpos).LengthSqr();
float lost_damage = fmax(((penetration_modifier * penetration_distance) / 24.f) + ((currentDamage * combined_damage_modifier) + (fmax(3.75f / enter_penetration_modifier, 0.f) * 3.f * combined_damage_modifier)), 0.f);
if (lost_damage > currentDamage)
return false;
if (lost_damage > 0.f)
currentDamage -= lost_damage;
if (currentDamage < 1.0f)
return false;
eyePosition = exit_trace.endpos;
--possibleHitsRemaining;
return true;
}