Трахов
-
Автор темы
- #1
C++:
float inline GetHitgroupDamageMultiplier(int iHitGroup)
{
switch (iHitGroup)
{
case HITGROUP_HEAD:
{
return 4.0f;
}
case HITGROUP_STOMACH:
{
return 1.25f;
}
case HITGROUP_LEFTLEG:
{
return 0.75f;
}
}
return 1.0f;
}
bool autowall::EntityHasArmor(player_t* e, int hitgroup)
{
if (e->m_ArmorValue() > 0)
{
if ((hitgroup == HITGROUP_HEAD && e->m_bHasHelmet()) || (hitgroup >= HITGROUP_CHEST && hitgroup <= HITGROUP_RIGHTARM))
return true;
}
return false;
}
void autowall::scale_damage(player_t* e, CGameTrace& enterTrace, weapon_info_t* weaponData, float& currentDamage)
{
auto bHasHeavyArmor = e->m_bHasHeavyArmor();
auto hitgroup = enterTrace.hitgroup;
switch (hitgroup)
{
case HITGROUP_HEAD:
if (!bHasHeavyArmor)
currentDamage *= 4.0f;
else
currentDamage = (currentDamage * 4.0f) * 0.5f;
break;
case HITGROUP_STOMACH:
currentDamage *= 1.25f;
break;
case HITGROUP_LEFTLEG:
currentDamage *= 0.75f;
break;
}
if (e && EntityHasArmor(e, hitgroup))
{
float flHeavyRatio = 1.0f;
float flBonusRatio = 0.5f;
float flRatio = weaponData->flArmorRatio * 0.5f;
float flNewDamage;
if (!bHasHeavyArmor)
{
flNewDamage = currentDamage * flRatio;
}
else
{
flBonusRatio = 0.33f;
flRatio = weaponData->flArmorRatio * 0.25f;
flHeavyRatio = 0.33f;
flNewDamage = (currentDamage * flRatio) * 0.85f;
}
int iArmor = e->m_ArmorValue();
if (((currentDamage - flNewDamage) * (flHeavyRatio * flBonusRatio)) > iArmor)
flNewDamage = currentDamage - (iArmor / flBonusRatio);
currentDamage = flNewDamage;
}
currentDamage = floorf(currentDamage);
}
bool autowall::trace_to_exit(Vector startPosition, const Vector& direction, CGameTrace& enterTrace, CGameTrace& exit_trace)
{
auto enter_point_contents = 0;
auto point_contents = 0;
auto is_window = 0;
auto flag = 0;
auto fDistance = 0.0f;
Vector start, end;
do
{
fDistance += 4.0f;
end = startPosition + direction * fDistance;
start = end - direction * 4.0f;
if (!enter_point_contents)
{
enter_point_contents = m_trace()->GetPointContents(end, 0x4600400B);
point_contents = enter_point_contents;
}
else
point_contents = m_trace()->GetPointContents(end, 0x4600400B);
if (point_contents & MASK_SHOT_HULL && (!(point_contents & CONTENTS_HITBOX) || enter_point_contents == point_contents))
continue;
static auto trace_filter_simple = util::FindSignature(crypt_str("client.dll"), crypt_str("55 8B EC 83 E4 F0 83 EC 7C 56 52")) + 0x3D;
uint32_t filter_[4] =
{
*(uint32_t*)(trace_filter_simple),
(uint32_t)g_ctx.local(),
0,
0
};
util::trace_line(end, start, MASK_SHOT_HULL | CONTENTS_HITBOX, (CTraceFilter*)filter_, &exit_trace); //-V641
if (exit_trace && exit_trace.surface.flags & SURF_HITBOX)
{
CTraceFilter filter;
filter.pSkip = exit_trace.hit_entity;
filter_[1] = (uint32_t)exit_trace.hit_entity;
util::trace_line(end, startPosition, MASK_SHOT_HULL, (CTraceFilter*)filter_, &exit_trace); //-V641
if (exit_trace.DidHit() && !exit_trace.startsolid)
return true;
continue;
}
auto name = (int*)enterTrace.surface.name; //-V206
if (name)
{
if (*name == 1936744813 && name[1] == 1601397551 && name[2] == 1768318575 && name[3] == 1731159395 && name[4] == 1936941420 && name[5] == 1651668271 && name[6] == 1734307425 && name[7] == 1936941420)
is_window = 1;
else
{
is_window = 0;
if (*name != 1936744813)
goto LABEL_34;
}
if (name[1] == 1600480303 && name[2] == 1701536108 && name[3] == 1634494255 && name[4] == 1731162995 && name[5] == 1936941420)
{
flag = 1;
LABEL_35:
if (is_window || flag)
{
exit_trace = enterTrace;
exit_trace.endpos = end + direction;
return true;
}
goto LABEL_37;
}
LABEL_34:
flag = 0;
goto LABEL_35;
}
LABEL_37:
if (!exit_trace.DidHit() || exit_trace.startsolid)
{
if (enterTrace.hit_entity && enterTrace.hit_entity->EntIndex() && is_breakable_entity(enterTrace.hit_entity))
{
exit_trace = enterTrace;
exit_trace.endpos = startPosition + direction;
return true;
}
continue;
}
if (exit_trace.surface.flags & SURF_NODRAW)
{
if (is_breakable_entity(exit_trace.hit_entity) && is_breakable_entity(enterTrace.hit_entity))
return true;
if (!(enterTrace.surface.flags & SURF_NODRAW))
continue;
}
if (exit_trace.plane.normal.Dot(direction) <= 1.0)
return true;
} while (fDistance <= 90.0f);
return false;
}
bool autowall::handle_bullet_penetration(weapon_info_t* weaponData, CGameTrace& enterTrace, Vector& eyePosition, const Vector& direction, int& possibleHitsRemaining, float& currentDamage, float penetrationPower, float entry_surface_damage_modifier, float ff_damage_reduction_bullets, float ff_damage_bullet_penetration, bool draw_impact)
{
auto enterSurfaceData = m_physsurface()->GetSurfaceData(enterTrace.surface.surfaceProps);
int enter_material = enterSurfaceData->game.material;
bool contents_grate = enterTrace.contents & CONTENTS_GRATE;
int is_nodraw = (enterTrace.surface.flags) & SURF_NODRAW;
float entry_penetration_modifier = enterSurfaceData->game.flPenetrationModifier;
auto isPlayer = ((player_t*)enterTrace.hit_entity)->is_player();
auto isEnemy = ((player_t*)enterTrace.hit_entity)->m_iTeamNum() != g_ctx.local()->m_iTeamNum();
bool cannotpenetrate = false;
trace_t exit_trace;
if (!possibleHitsRemaining)
{
if (!is_nodraw && !contents_grate)
{
if (enter_material != CHAR_TEX_GLASS)
cannotpenetrate = enter_material != CHAR_TEX_GRATE;
}
}
if (penetrationPower <= 0.0f || possibleHitsRemaining <= 0)
cannotpenetrate = true;
if (!trace_to_exit(enterTrace.endpos, direction, enterTrace, exit_trace)
&& !(m_trace()->GetPointContents(enterTrace.endpos, MASK_SHOT_HULL, 0) & MASK_SHOT_HULL)
|| cannotpenetrate)
{
return false;
}
auto exit_surface_data = m_physsurface()->GetSurfaceData(exit_trace.surface.surfaceProps);
bool use_new_penetration_system = m_cvar()->FindVar("sv_penetration_type") ? m_cvar()->FindVar("sv_penetration_type")->GetBool() : true;
float damage_modifier;
float average_penetration_modifier;
unsigned short exit_material = exit_surface_data->game.material;
const float reduction_bullets = m_cvar()->FindVar("ff_damage_reduction_bullets") != nullptr ? m_cvar()->FindVar("ff_damage_reduction_bullets")->GetFloat() : 0.1f;
const float damage_bullet_pen = m_cvar()->FindVar("ff_damage_bullet_penetration") != nullptr ? m_cvar()->FindVar("ff_damage_bullet_penetration")->GetFloat() : 0.f;
if (!use_new_penetration_system)
{
if (contents_grate || is_nodraw)
{
average_penetration_modifier = 1.0f;
damage_modifier = 0.99f;
}
else
{
average_penetration_modifier = fminf(exit_surface_data->game.flPenetrationModifier, entry_penetration_modifier);
damage_modifier = fminf(entry_surface_damage_modifier, exit_surface_data->game.flDamageModifier);
}
if (enter_material == exit_material && (exit_material == CHAR_TEX_METAL || exit_material == CHAR_TEX_WOOD))
average_penetration_modifier += average_penetration_modifier;
float thickness = (exit_trace.endpos - enterTrace.endpos).Length();
if (sqrt(thickness) <= average_penetration_modifier * penetrationPower)
{
ff_damage_bullet_penetration *= damage_modifier;
//if (bDoEffects) //note: not on windows version, is it inlined into the function?
//ImpactTrace(exit_trace, weaponmask);
eyePosition = exit_trace.endpos;
--possibleHitsRemaining;
return false;
}
return true;
}
else
{
damage_modifier = 0.16f;
if (!contents_grate && !is_nodraw)
{
if (enter_material == CHAR_TEX_GLASS)
goto LABEL_51;
if (enter_material != CHAR_TEX_GRATE)
{
if (enterTrace.hit_entity)
{
if (isPlayer)
{
goto LABEL_45;
}
}
if (enter_material != CHAR_TEX_FLESH
|| reduction_bullets != 0.0f
|| !enterTrace.hit_entity
|| !isPlayer
|| isEnemy)
{
average_penetration_modifier = (exit_surface_data->game.flPenetrationModifier + entry_penetration_modifier) * 0.5f;
goto LABEL_46;
}
if (damage_bullet_pen == 0.0f)
return false;
entry_penetration_modifier = damage_bullet_pen;
LABEL_45:
average_penetration_modifier = entry_penetration_modifier;
LABEL_46:
damage_modifier = 0.16f;
goto LABEL_52;
}
}
if (enter_material != CHAR_TEX_GRATE && enter_material != CHAR_TEX_GLASS)
{
average_penetration_modifier = 1.0f;
goto LABEL_52;
}
LABEL_51:
damage_modifier = 0.05f;
average_penetration_modifier = 3.0f;
}
LABEL_52:
if (enter_material == exit_material)
{
if (exit_material == CHAR_TEX_WOOD || exit_material == CHAR_TEX_CARDBOARD)
average_penetration_modifier = 3.0f;
else if (exit_material == CHAR_TEX_PLASTIC)
average_penetration_modifier = 2.0f;
}
float penetration_length = (exit_trace.endpos - enterTrace.endpos).Length();
float modifier = fmaxf(1.0f / average_penetration_modifier, 0.0f);
float taken_first = (fmaxf(((3.0f / penetrationPower) * 1.25f), 0.0f) * (modifier * 3.0f) + (currentDamage * damage_modifier));
float taken_damage = (((penetration_length * penetration_length) * modifier) / 24.0f) + taken_first;
currentDamage -= fmaxf(0.0f, taken_damage);
if (currentDamage < 1.0f)
return false;
//if (bDoEffects) //note: not on windows version, is it inlined into the function?
//ImpactTrace(exit_trace, weaponmask);
eyePosition = exit_trace.endpos;
--possibleHitsRemaining;
return true;
}
по причине того что сгорела пятая точка от сообщений людей в мой адрес, по поводу того что я просто пащю все что вижу и откуда вижу а также что я "вырезаю половину нужных функций от недопастеров" и конвертирую через одно место.
Правда не важно что именно этот Автоволл полностью такой-же как в оригинале без каких либо изменений т.е from mutiny to LW.
azazinc иди дальше конвертируй свой rifk7 awall через кривые ручки и говори что это хуже дефа лв и я не правильно что-то сделал, не важно что мутини автоволл это самый лучший паблик аволл который есть на данный момент.
анти-паста легчайшая просто убрал 3 слова в коде.
Последнее редактирование: