Escalation Project
-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Сразу поясню, вы можете вызывать это где угодно, хоть в крейтмуве.
Я вызываю это в ресольвере, ибо мне не жалко трейсить каждый кадр по 4 линии.
Посмотрев сурсы антифристенда большинства людей почему то все чекают дамаг, когда нужно чекать расстояние между трейсами.
Для дамага достаточно всего одной проверки и наоборот.
Предложу свой вариант сольва основанный на трейсе.
Я вызываю это в ресольвере, ибо мне не жалко трейсить каждый кадр по 4 линии.
Посмотрев сурсы антифристенда большинства людей почему то все чекают дамаг, когда нужно чекать расстояние между трейсами.
Для дамага достаточно всего одной проверки и наоборот.
Предложу свой вариант сольва основанный на трейсе.
C++:
float_t get_backward_side(player_t* player)
{
return math::calculate_angle(globals.local()->m_vecOrigin(), player->m_vecOrigin()).y;
}
Vector GetHitboxPos(player_t* player, matrix3x4_t* mat, int hitbox_id)
{
if (!player)
return Vector();
auto hdr = m_modelinfo()->GetStudioModel(player->GetModel());
if (!hdr)
return Vector();
auto hitbox_set = hdr->pHitboxSet(player->m_nHitboxSet());
if (!hitbox_set)
return Vector();
auto hitbox = hitbox_set->pHitbox(hitbox_id);
if (!hitbox)
return Vector();
Vector min, max;
math::vector_transform(hitbox->bbmin, mat[hitbox->bone], min);
math::vector_transform(hitbox->bbmax, mat[hitbox->bone], max);
return (min + max) * 0.5f;
}
static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
Vector delta = a - b;
float delta_length = delta.Length();
if (delta_length <= min_delta) {
Vector result;
if (-min_delta <= delta_length) {
return a;
}
else {
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b - ((delta * iradius) * min_delta);
}
}
else {
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b + ((delta * iradius) * min_delta);
}
};
float_t MaxYawModificator(player_t* enemy)
{
auto animstate = enemy->get_animation_state();
if (!animstate)
return 0.0f;
auto speedfactor = math::clamp(animstate->m_flFeetSpeedForwardsOrSideWays, 0.0f, 1.0f);
auto avg_speedfactor = (animstate->m_flStopToFullRunningFraction * -0.3f - 0.2f) * speedfactor + 1.0f;
auto duck_amount = animstate->m_fDuckAmount;
if (duck_amount)
{
auto max_velocity = math::clamp(animstate->m_flFeetSpeedUnknownForwardOrSideways, 0.0f, 1.0f);
auto duck_speed = duck_amount * max_velocity;
avg_speedfactor += duck_speed * (0.5f - avg_speedfactor);
}
return animstate->yaw_desync_adjustment() * avg_speedfactor;
}
float_t GetBackwardYaw(player_t* player) {
return math::calculate_angle(player->m_vecOrigin(), player->m_vecOrigin()).y;
}
void resolver::resolve_yaw()
{
player_info_t player_info;
if (!m_engine()->GetPlayerInfo(player->EntIndex(), &player_info))
return;
if (!globals.local()->is_alive() || player->m_iTeamNum() == globals.local()->m_iTeamNum())
return;
auto animstate = player->get_animation_state();
auto choked = abs(TIME_TO_TICKS(player->m_flSimulationTime() - player->m_flOldSimulationTime()) - 1);
if (!animstate && choked == 0 || !animstate, choked == 0)
return;
float new_body_yaw_pose = 0.0f;
auto m_flCurrentFeetYaw = player->get_animation_state()->m_flCurrentFeetYaw;
auto m_flGoalFeetYaw = player->get_animation_state()->m_flGoalFeetYaw;
auto m_flEyeYaw = player->get_animation_state()->m_flEyeYaw;
float flMaxYawModifier = MaxYawModificator(player);
float flMinYawModifier = player->get_animation_state()->pad10[512];
auto anglesy = math::normalize_yaw(player->m_angEyeAngles().y - original_goal_feet_yaw);
auto valid_lby = true;
auto speed = player->m_vecVelocity().Length2D();
float m_lby = player->m_flLowerBodyYawTarget() * 0.574f;
if (animstate->m_velocity > 0.1f || fabs(animstate->flUpVelocity) > 100.f)
valid_lby = animstate->m_flTimeSinceStartedMoving < 0.22f;
auto player_stand = player->m_vecVelocity().Length2D();
player_stand = 0.f;
///////////////////// [ FLIGHT-FIX ] /////////////////////
AnimationLayer layers[13];
if (player_record->flags & !FL_ONGROUND || player->m_fFlags() & !FL_ONGROUND)
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 0.f);
}
///////////////////// [ FLIGHT-FIX ] /////////////////////
float m_flLastClientSideAnimationUpdateTimeDelta = 0.0f;
auto trace = false;
AnimationLayer moveLayers[3][13];
adjust_data* previous_record;
memcpy(layers, player->get_animlayers(), sizeof(AnimationLayer) * 15);
if (animstate->m_flFeetSpeedForwardsOrSideWays >= 0.0)
animstate->m_flFeetSpeedForwardsOrSideWays = fminf(animstate->m_flFeetSpeedForwardsOrSideWays, 1.0);
else
animstate->m_flFeetSpeedForwardsOrSideWays = 0.0;
auto v54 = animstate->m_fDuckAmount;
auto v55 = ((((*(float*)((uintptr_t)animstate + 0x11C)) * -0.30000001) - 0.19999999) * animstate->m_flFeetSpeedForwardsOrSideWays) + 1.0f;
if (v54 > 0.0)
{
if (animstate->m_flFeetSpeedUnknownForwardOrSideways >= 0.0)
animstate->m_flFeetSpeedUnknownForwardOrSideways = fminf(animstate->m_flFeetSpeedUnknownForwardOrSideways, 1.0);
else
animstate->m_flFeetSpeedUnknownForwardOrSideways = 0.0;
v55 += ((animstate->m_flFeetSpeedUnknownForwardOrSideways * v54) * (0.5f - v55));
}
bool bWasMovingLastUpdate = false;
bool bJustStartedMovingLastUpdate = false;
if (player->m_vecVelocity().Length2D() <= 0.0f)
{
animstate->m_flTimeSinceStartedMoving = 0.0f;
bWasMovingLastUpdate = animstate->m_flTimeSinceStoppedMoving <= 0.0f;
animstate->m_flTimeSinceStoppedMoving += animstate->m_flLastClientSideAnimationUpdateTime;
}
else
{
animstate->m_flTimeSinceStoppedMoving = 0.0f;
bJustStartedMovingLastUpdate = animstate->m_flTimeSinceStartedMoving <= 0.0f;
animstate->m_flTimeSinceStartedMoving = animstate->m_flLastClientSideAnimationUpdateTime + animstate->m_flTimeSinceStartedMoving;
}
auto unknown_velocity = *(float*)(uintptr_t(animstate) + 0x2A4);
if (animstate->m_flFeetSpeedUnknownForwardOrSideways < 1.0f)
{
if (animstate->m_flFeetSpeedUnknownForwardOrSideways < 0.5f)
{
float velocity = unknown_velocity;
float delta = animstate->m_flLastClientSideAnimationUpdateTime * 60.0f;
float new_velocity;
if ((80.0f - velocity) <= delta)
{
if (-delta <= (80.0f - velocity))
new_velocity = 80.0f;
else
new_velocity = velocity - delta;
}
else
{
new_velocity = velocity + delta;
}
unknown_velocity = new_velocity;
}
}
float cycle = (layers->m_flPlaybackRate * animstate->m_flLastClientSideAnimationUpdateTime) + layers->m_flCycle;
cycle -= (float)(int)cycle;
if (cycle < 0.0f)
cycle += 1.0f;
if (cycle > 1.0f)
cycle -= 1.0f;
auto first_matrix = player_record->matrixes_data.first;
auto second_matrix = player_record->matrixes_data.second;
auto central_matrix = player_record->matrixes_data.zero;
auto leftPose = GetHitboxPos(player, first_matrix, HITBOX_HEAD);
auto rightPose = GetHitboxPos(player, second_matrix, HITBOX_HEAD);
auto centralPose = GetHitboxPos(player, central_matrix, HITBOX_HEAD);
auto fire_first = autowall::get().wall_penetration(globals.g.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first), player);
auto fire_second = autowall::get().wall_penetration(globals.g.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second), player);
auto fire_third = autowall::get().wall_penetration(globals.g.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.zero), player);
auto delta = math::AngleDiff(animstate->m_flGoalFeetYaw, animstate->m_flEyeYaw);
///////////////////// [ ANIMLAYERS ] /////////////////////
if (player_record->flags & FL_ONGROUND || player->m_fFlags() & FL_ONGROUND) {
int i = player->EntIndex();
auto m_MaxDesyncDelta = player->get_max_desync_delta(); \
const auto player_slowwalking = animstate->m_flFeetYawRate >= 0.01f && animstate->m_flFeetYawRate <= 0.8f; // weave (owness)
auto result = player_record->player->sequence_activity(player_record->layers[3].m_nSequence);
if (player->m_bDucked() || player->m_bDucking())
{
if (m_lby < 0.f)
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 45.f);
switch (globals.g.missed_shots[i] > 1)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - 45.f);
break;
}
}
else
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - 45.f);
switch (globals.g.missed_shots[i] > 1)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 45.f);
break;
}
}
}
else if (std::fabsf(layers[6].m_flWeight - layers[6].m_flWeight) < 0.01f)
{
if (layers[3].m_flWeight == 0.f && layers[3].m_flCycle == 0.f)
{
if (result == 979 || result != 979) {
if (speed < 0.1f)
{
int missed_player = player->EntIndex();
Vector src3D, dst3D, forward, right, up, src, dst;
float back_two, right_two, left_two;
Ray_t RayToLeft, RayToRight, RayRightLow, RayLeftLow;
float RightDistance, LeftDistance, RightLow, LeftLow;
Vector CurrentLocalPose;
CurrentLocalPose = globals.local()->get_shoot_position();
CGameTrace tr;
float Distance = std::floor(globals.local()->GetAbsOrigin().DistTo(player->GetAbsOrigin()));
Vector GetRight(player->m_angEyeAngles().x, player->m_angEyeAngles().y - 60.0, player->m_angEyeAngles().z);
Vector GetLeft(player->m_angEyeAngles().x, player->m_angEyeAngles().y + 60.0, player->m_angEyeAngles().z);
Vector GetLowRight(player->m_angEyeAngles().x, player->m_angEyeAngles().y - 30.f, player->m_angEyeAngles().z);
Vector GetLowLeft(player->m_angEyeAngles().x, player->m_angEyeAngles().y + 30.f, player->m_angEyeAngles().z);
CTraceFilter filter;
filter.pSkip = globals.local();
math::angle_vectors(Vector(0, get_backward_side(player), 0), &forward, &right, &up);
RayRightLow.Init(CurrentLocalPose, rightPose);
m_trace()->TraceRay(RayRightLow, MASK_SHOT, &filter, &tr);
RightLow = (tr.endpos - tr.startpos).Length();
RayLeftLow.Init(CurrentLocalPose, leftPose);
m_trace()->TraceRay(RayLeftLow, MASK_SHOT, &filter, &tr);
LeftLow = (tr.endpos - tr.startpos).Length();
auto abs_right = (abs(RightDistance - RightLow) > 25.f);
auto abs_left = (abs(LeftDistance - LeftLow) > 25.f);
RayToRight.Init(CurrentLocalPose, rightPose);
m_trace()->TraceRay(RayToRight, MASK_SHOT, &filter, &tr);
RightDistance = (tr.endpos - tr.startpos).Length();
RayToLeft.Init(CurrentLocalPose, leftPose);
m_trace()->TraceRay(RayToLeft, MASK_SHOT, &filter, &tr);
LeftDistance = (tr.endpos - tr.startpos).Length();
if (fire_first.damage > 0.0f && fire_second.damage > 0.0f)
{
if (RightDistance > Distance && RightDistance > RightLow || LeftDistance > Distance && LeftDistance > LeftLow)
{
if (RightLow > Distance && globals.g.missed_shots[missed_player] < 1)
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta + 30.f);
}
else
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta - 30.f);
switch (globals.g.missed_shots[missed_player] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = delta * flMinYawModifier;
break;
case 1:
animstate->m_flGoalFeetYaw = delta * flMaxYawModifier;
break;
}
}
}
else
{
if (RightDistance > Distance)
{
if (globals.g.missed_shots[missed_player] < 1)
{
animstate->m_flGoalFeetYaw = delta * flMinYawModifier;
}
else
{
animstate->m_flGoalFeetYaw = delta * flMaxYawModifier;
switch (globals.g.missed_shots[missed_player] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta + 30.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta - 30.f);
break;
}
}
}
else
{
if (globals.g.missed_shots[missed_player] < 1)
{
animstate->m_flGoalFeetYaw = delta * flMaxYawModifier;
}
else
{
animstate->m_flGoalFeetYaw = delta * flMinYawModifier;
switch (globals.g.missed_shots[missed_player] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta - 30.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta + 30.f);
break;
}
}
}
}
}
else
{
if (RightDistance > Distance && RightDistance > RightLow || LeftDistance > Distance && LeftDistance > LeftLow)
{
if (abs_right && globals.g.missed_shots[missed_player] < 1 || RightLow > Distance && globals.g.missed_shots[missed_player] < 1)
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta + 30.f);
}
else
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta - 30.f);
switch (globals.g.missed_shots[missed_player] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = delta * flMinYawModifier;
break;
case 1:
animstate->m_flGoalFeetYaw = delta * flMaxYawModifier;
break;
}
}
}
else
{
if (RightDistance > Distance)
{
if (globals.g.missed_shots[missed_player] < 1)
{
animstate->m_flGoalFeetYaw = delta * flMaxYawModifier;
}
else
{
animstate->m_flGoalFeetYaw = delta * flMinYawModifier;
switch (globals.g.missed_shots[missed_player] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta + 30.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta - 30.f);
break;
}
}
}
else
{
if (globals.g.missed_shots[missed_player] < 1)
{
animstate->m_flGoalFeetYaw = delta * flMinYawModifier;
}
else
{
animstate->m_flGoalFeetYaw = delta * flMaxYawModifier;
switch (globals.g.missed_shots[missed_player] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta - 30.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(delta + 30.f);
break;
}
}
}
}
}
}
}
}
}
else if (int(layers[6].m_flWeight * 1000.0 == (int(layers[6].m_flWeight * 1000.0))))
{
int i = player->EntIndex();
int m_way;
float first = fabs(layers[6].m_flPlaybackRate - moveLayers[0][6].m_flPlaybackRate);
float second = fabs(layers[6].m_flPlaybackRate - moveLayers[2][6].m_flPlaybackRate);
float third = fabs(layers[6].m_flPlaybackRate - moveLayers[1][6].m_flPlaybackRate);
if (int(first) <= int(second) || int(third) < int(second) || int(second * 1000.0f))
{
if (int(first) >= int(third) && int(second) > int(third) && !int(third * 1000.0f))
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flCurrentTorsoYaw + 58.f);
switch (globals.g.missed_shots[i] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flCurrentTorsoYaw + 30.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flCurrentTorsoYaw - 30.f);
break;
}
}
}
else
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flCurrentTorsoYaw - 58.f);
switch (globals.g.missed_shots[i] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flCurrentTorsoYaw - 30.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flCurrentTorsoYaw + 30.f);
break;
}
}
}
///////////////////// [ ANIMLAYERS ] /////////////////////
}
}