-
Автор темы
- #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)
{
CGameTrace trace_exit;
surfacedata_t* enter_surface_data = m_physsurface()->GetSurfaceData(enterTrace.surface.surfaceProps);
int enter_material = enter_surface_data->game.material;
float enter_surf_penetration_modifier = enter_surface_data->game.flPenetrationModifier;
float final_damage_modifier = 0.18f;
float compined_penetration_modifier = 0.f;
bool solid_surf = ((enterTrace.contents >> 3) & CONTENTS_SOLID);
bool light_surf = ((enterTrace.surface.flags >> 7) & SURF_LIGHT);
if
(
possibleHitsRemaining <= 0
|| (!possibleHitsRemaining && !light_surf && !solid_surf && enter_material != CHAR_TEX_GLASS && enter_material != CHAR_TEX_GRATE)
|| weaponData->flPenetration <= 0.f
|| !trace_to_exit(enterTrace, trace_exit, enterTrace.endpos, direction)
&& !(m_trace()->GetPointContents(enterTrace.endpos, MASK_SHOT_HULL | CONTENTS_HITBOX, NULL) & (MASK_SHOT_HULL | CONTENTS_HITBOX))
)
{
return false;
}
surfacedata_t* exit_surface_data = m_physsurface()->GetSurfaceData(trace_exit.surface.surfaceProps);
int exit_material = exit_surface_data->game.material;
float exit_surf_penetration_modifier = exit_surface_data->game.flPenetrationModifier;
if (enter_material == CHAR_TEX_GLASS || enter_material == CHAR_TEX_GRATE) {
compined_penetration_modifier = 3.f;
final_damage_modifier = 0.08f;
}
else if (light_surf || solid_surf)
{
compined_penetration_modifier = 1.f;
final_damage_modifier = 0.18f;
}
else {
compined_penetration_modifier = (enter_surf_penetration_modifier + exit_surf_penetration_modifier) * 0.5f;
final_damage_modifier = 0.18f;
}
if (enter_material == exit_material)
{
if (exit_material == CHAR_TEX_CARDBOARD || exit_material == CHAR_TEX_WOOD)
compined_penetration_modifier = 3.f;
else if (exit_material == CHAR_TEX_PLASTIC)
compined_penetration_modifier = 2.0f;
}
float thickness = (trace_exit.endpos - enterTrace.endpos).LengthSqr();
float modifier = max(0.f, 1.f / compined_penetration_modifier);
float lost_damage = fmax(((modifier * thickness) / 24.f) + ((currentDamage * final_damage_modifier) + (fmax(3.75f / weaponData->flPenetration, 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 = trace_exit.endpos;
possibleHitsRemaining--;
return true;
}