5 ночей на aim_ag_texture2
-
Автор темы
- #1
Код:
void RageBot::UTIL_TraceLine(const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask, C_BasePlayer* ignore, trace_t* ptr)
{
Ray_t ray;
ray.Init(vecAbsStart, vecAbsEnd);
CTraceFilter filter;
filter.pSkip = ignore;
g_pEngineTrace->TraceRay(ray, mask, &filter, ptr);
}
float RageBot::DistanceToRay(const Vector &pos, const Vector &rayStart, const Vector &rayEnd, float *along, Vector *pointOnRay)
{
Vector to = pos - rayStart;
Vector dir = rayEnd - rayStart;
float length = dir.NormalizeInPlace();
float rangeAlong = dir.Dot(to);
if (along)
{
*along = rangeAlong;
}
float range;
if (rangeAlong < 0.0f)
{
// off start point
range = -(pos - rayStart).Length();
if (pointOnRay)
{
*pointOnRay = rayStart;
}
}
else if (rangeAlong > length)
{
// off end point
range = -(pos - rayEnd).Length();
if (pointOnRay)
{
*pointOnRay = rayEnd;
}
}
else // within ray bounds
{
Vector onRay = rayStart + (dir.operator*(rangeAlong));
range = (pos - onRay).Length();
if (pointOnRay)
{
*pointOnRay = onRay;
}
}
return range;
}
void RageBot::UTIL_ClipTraceToPlayers(Vector& vecAbsStart, Vector& vecAbsEnd, unsigned int mask, ITraceFilter* filter, trace_t* tr)
{
trace_t playerTrace;
Ray_t ray;
float smallestFraction = tr->fraction;
const float maxRange = 60.0f;
ray.Init(vecAbsStart, vecAbsEnd);
for (int k = 1; k <= g_pGlobals->maxClients; ++k)
{
auto *player = (C_BasePlayer*)g_pEntityList->GetClientEntity(k);
if (!player || !player->IsAlive())
continue;
if (player->IsDormant())
continue;
if (filter && filter->ShouldHitEntity((IHandleEntity*)player, mask) == false)
continue;
float range = DistanceToRay(player->WorldSpaceCenter(), vecAbsStart, vecAbsEnd);
if (range < 0.0f || range > maxRange)
continue;
g_pEngineTrace->ClipRayToEntity(ray, mask | CONTENTS_HITBOX, (IHandleEntity*)player, &playerTrace);
if (playerTrace.fraction < smallestFraction)
{
// we shortened the ray - save off the trace
tr = &playerTrace;
smallestFraction = playerTrace.fraction;
}
}
}
float RageBot::GetHitgroupDamageMultiplier(int iHitgroup)
{
switch (iHitgroup)
{
case HITGROUP_HEAD:
return 4.0f;
case HITGROUP_CHEST:
case HITGROUP_LEFTARM:
case HITGROUP_RIGHTARM:
return 1.0f;
case HITGROUP_STOMACH:
return 1.25f;
case HITGROUP_LEFTLEG:
case HITGROUP_RIGHTLEG:
return 0.75f;
default:
return 1.0f;
}
}
void RageBot::ScaleDamage(int hitgroup, C_BasePlayer *enemy, float weapon_armor_ratio, float ¤t_damage)
{
current_damage *= GetHitgroupDamageMultiplier(hitgroup);
if (enemy->m_ArmorValue() > 0)
{
if (hitgroup == HITGROUP_HEAD)
{
if (enemy->m_bHasHelmet())
current_damage *= weapon_armor_ratio * 0.5f;
}
else
current_damage *= weapon_armor_ratio * 0.5f;
}
}
bool RageBot::TraceToExit(Vector &end, trace_t *enter_trace, float x, float y, float z, float x2, float y2, float z2, trace_t *exit_trace)
{
typedef bool(__fastcall* TraceToExitFn)(Vector&, trace_t&, float, float, float, float, float, float, trace_t*);
static TraceToExitFn TraceToExit = (TraceToExitFn)Utils::PatternScan(GetModuleHandleW(L"client.dll"), "55 8B EC 83 EC 30 F3 0F 10 75");
if (!TraceToExit)
return false;
_asm
{
push exit_trace
push z2
push y2
push x2
push z
push y
push x
mov edx, enter_trace
mov ecx, end
call TraceToExit
add esp, 0x1C
}
}
bool RageBot::HandleBulletPenetration(CCSWeaponInfo* weaponInfo, FireBulletData &data)
{
surfacedata_t *enter_surface_data = g_pPhysSurface->GetSurfaceData(data.enter_trace.surface.surfaceProps);
int enter_material = enter_surface_data->game.material;
float enter_surf_penetration_mod = *(float*)((uint8_t*)enter_surface_data + 88);
data.trace_length += data.enter_trace.fraction * data.trace_length_remaining;
data.current_damage *= powf(weaponInfo->flRangeModifier, data.trace_length * 0.002f);
if (data.trace_length > 3000.f || enter_surf_penetration_mod < 0.1f)
data.penetrate_count = 0;
if (data.penetrate_count <= 0)
return false;
Vector dummy;
trace_t trace_exit;
if (!TraceToExit(dummy, &data.enter_trace, data.enter_trace.endpos.x, data.enter_trace.endpos.y, data.enter_trace.endpos.z, data.direction.x, data.direction.y, data.direction.z, &trace_exit)) //if (!TraceToExit(dummy, &data.enter_trace, data.enter_trace.endpos, data.direction, &trace_exit))
return false;
surfacedata_t *exit_surface_data = g_pPhysSurface->GetSurfaceData(trace_exit.surface.surfaceProps);
int exit_material = exit_surface_data->game.material;
float exit_surf_penetration_mod = *(float*)((uint8_t*)exit_surface_data + 88);
float final_damage_modifier = 0.16f;
float combined_penetration_modifier = 0.0f;
if ((data.enter_trace.contents & CONTENTS_GRATE) != 0 || enter_material == 89 || enter_material == 71)
{
combined_penetration_modifier = 3.0f;
final_damage_modifier = 0.05f;
}
else
combined_penetration_modifier = (enter_surf_penetration_mod + exit_surf_penetration_mod) * 0.5f;
if (enter_material == exit_material)
{
if (exit_material == 87 || exit_material == 85)
combined_penetration_modifier = 3.0f;
else if (exit_material == 76)
combined_penetration_modifier = 2.0f;
}
float v34 = fmaxf(0.f, 1.0f / combined_penetration_modifier);
float v35 = (data.current_damage * final_damage_modifier) + v34 * 3.0f * fmaxf(0.0f, (3.0f / weaponInfo->flPenetration) * 1.25f);
float thickness = (trace_exit.endpos - data.enter_trace.endpos).Length();
thickness *= thickness;
thickness *= v34;
thickness /= 24.0f;
float lost_damage = fmaxf(0.0f, v35 + thickness);
if (lost_damage > data.current_damage)
return false;
if (lost_damage >= 0.0f)
data.current_damage -= lost_damage;
if (data.current_damage < 1.0f)
return false;
data.src = trace_exit.endpos;
data.penetrate_count--;
return true;
}
bool RageBot::SimulateFireBullet(C_BaseCombatWeapon* pWeapon, FireBulletData &data)
{
CCSWeaponInfo* weaponInfo = pWeapon->GetCSWeaponData();
data.penetrate_count = 4;
data.trace_length = 0.0f;
data.current_damage = (float)weaponInfo->iDamage;
while (data.penetrate_count > 0 && data.current_damage >= 1.0f)
{
data.trace_length_remaining = weaponInfo->flRange - data.trace_length;
Vector end = data.src + data.direction * data.trace_length_remaining;
// data.enter_trace
UTIL_TraceLine(data.src, end, MASK_SHOT, pLocal, &data.enter_trace);
UTIL_ClipTraceToPlayers(data.src, end * 40.f, 0x4600400B, &data.filter, &data.enter_trace);
if (data.enter_trace.fraction == 1.0f)
break;
if (data.enter_trace.hitgroup <= HITGROUP_RIGHTLEG && data.enter_trace.hitgroup > HITGROUP_GENERIC)
{
data.trace_length += data.enter_trace.fraction * data.trace_length_remaining;
data.current_damage *= powf(weaponInfo->flRangeModifier, data.trace_length * 0.002f);
auto* player = (C_BasePlayer*)data.enter_trace.hit_entity;//data.enter_trace.m_pEnt;
if (player->m_iTeamNum() == pLocal->m_iTeamNum())
return false;
ScaleDamage(data.enter_trace.hitgroup, player, weaponInfo->flArmorRatio, data.current_damage);
return true;
}
if (!HandleBulletPenetration(weaponInfo, data))
break;
}
return false;
}
float RageBot::GetDamage(const Vector& point)
{
float damage = 30.0f;
Vector dst = point;
FireBulletData data(pLocal->GetEyePos());
data.filter.pSkip = pLocal;
QAngle angles;
Math::CalcAngle(data.src, dst, angles);//Utilities::CalcAngle(data.src, dst);
Math::AngleVectors(angles, &data.direction);
float dir = data.direction.NormalizeInPlace();
C_BaseCombatWeapon* pWeapon = (C_BaseCombatWeapon*)g_pEntityList->GetClientEntityFromHandle(pLocal->m_hActiveWeapon());
if (!pWeapon)
return 0.f;
if (SimulateFireBullet(pWeapon, data)) {
damage = data.current_damage;
}
return damage;
}
даТы обновил под ласт апдейт аутоволл?
Последнее редактирование: