-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
header
Code:
namespace SDK{
class tickrecord_t {
public:
float _lowerbody_yaw;
float _yaw;
float _simulation_time;
int _tickbase;
int _flags;
float _pitch;
Vector _velocity;
tickrecord_t() {}
tickrecord_t(CBaseEntity* entity) {
_lowerbody_yaw = entity->GetLowerBodyYaw();
_yaw = entity->angles().y;
_simulation_time = entity->GetSimTime();
_tickbase = entity->GetTickBase();
_flags = entity->GetFlags();
_velocity = entity->GetVelocity();
_pitch = entity->angles().x;
}
tickrecord_t(CBaseEntity* entity, float yaw) {
_lowerbody_yaw = entity->GetLowerBodyYaw();
_yaw = yaw;
_simulation_time = entity->GetSimTime();
_tickbase = entity->GetTickBase();
_flags = entity->GetFlags();
_velocity = entity->GetVelocity();
_pitch = entity->angles().x;
}
};
}
#include <array>
class CResolver
{
public:
std::array<std::list<SDK::tickrecord_t>, 64> records;
std::array<std::list<SDK::tickrecord_t>, 64> moving_records;
std::array<float, 64> suspected_real;
std::array<std::list<float>, 64> suspected_real_lbys;
std::array<SDK::tickrecord_t, 64> last_backtrackable_tick;
void cap() {
for (int i = 0; i <= 64; i++) {
while (suspected_real_lbys[i].size() > 5) {
suspected_real_lbys[i].pop_back();
}
}
}
void resolve(CBaseEntity*);
void store(CBaseEntity*, float);
float random(float a, float b) {
float _return = (float)rand() / (float)RAND_MAX;
float delta = a - b;
return ((_return * delta) + a);
}
bool similar(float a, float b, float c = 17) {
return (abs(a - b) <= c);
}
bool can_backtrack(CBaseEntity*);
bool lby_updated(tickrecord_t, tickrecord_t, CBaseEntity*);
bool moving_lby_check(CBaseEntity*);
void lby_update_checks(CBaseEntity*, tickrecord_t, tickrecord_t);
float moving_lby(CBaseEntity*);
bool similar_moving_lby_delta(CBaseEntity*);
float average_lby_delta_moving(CBaseEntity*);
bool breaking_lby(CBaseEntity*);
void perform_delta_checks(CBaseEntity*, SDK::tickrecord_t, SDK::tickrecord_t);
float get_yaw_while_breaking(CBaseEntity*);
float lby_delta(CBaseEntity*);
bool lby_delta_found(CBaseEntity*);
void reset(int idx) {
moving_records[idx].clear();
records[idx].clear();
backtrack[idx] = false;
unresolved[idx] = false;
using_fake_angles[idx] = false;
}
};
extern CResolver* resolver;
now for the p100 resolving
Code:
bool CResolver::lby_updated(SDK::tickrecord_t a, SDK::tickrecord_t b, CBaseEntity* entity) {
if (a._lowerbody_yaw != b._lowerbody_yaw) return true;
if ((last_backtrackable_tick[entity->GetIndex()]._simulation_time + 1.1f + INTERFACES::Globals->interval_per_tick) < entity->GetSimTime()) return true;
bool set = true;
CAnimationLayer _previous;
for (int i = 0; i < 13; i++)
{
CAnimationLayer layer = entity->GetAnimOverlay(i);
if (set) {
_previous = layer;
set = false;
}
const int activity = entity->GetSequenceActivity(layer.m_nSequence);
const int previous_act = entity->GetSequenceActivity(_previous.m_nSequence);
if (activity == 979 && previous_act == 979) {
if ((_previous.m_flCycle != layer.m_flCycle) || layer.m_flWeight == 1.f)
{
float
flAnimTime = layer.m_flCycle,
flSimTime = entity->GetSimTime();
if (flAnimTime < 0.01f && _previous.m_flCycle > 0.01f)
{
return true;
}
}
}
_previous = layer;
}
return false;
}
void CResolver::lby_update_checks(CBaseEntity* entity, SDK::tickrecord_t a, SDK::tickrecord_t b) {
float ave_moving_lby = moving_lby(entity);
float _delta_a = abs(suspected_real[entity->GetIndex()] - ave_moving_lby);
float _delta_b = abs(a._lowerbody_yaw - ave_moving_lby);
float _delta_c = abs(b._lowerbody_yaw - ave_moving_lby);
if (_delta_a <= _delta_b && _delta_a <= _delta_c && _delta_a <= 20) {
return;
}
if (similar(b._lowerbody_yaw, ave_moving_lby, 20) && similar(a._lowerbody_yaw, ave_moving_lby, 20)) {
float ave = b._lowerbody_yaw + a._lowerbody_yaw;
if (ave != 0) ave /= 2;
suspected_real[entity->GetIndex()] = ave;
return;
}
if (_delta_b < _delta_c && _delta_b <= 20) {
suspected_real[entity->GetIndex()] = b._lowerbody_yaw;
return;
}
if (_delta_c < _delta_b && _delta_c <= 20) {
suspected_real[entity->GetIndex()] = a._lowerbody_yaw;
return;
}
suspected_real[entity->GetIndex()] = entity->angles().y;
}
bool CResolver::similar_moving_lby_delta(CBaseEntity* entity) {
std::list<float> deltas;
float average = 0;
for (auto v : moving_records[entity->GetIndex()]) {
for (auto p : deltas) {
if (!similar(p, v._lowerbody_yaw - v._yaw, 45)) return false;
}
deltas.push_front(v._lowerbody_yaw - v._yaw);
average += v._lowerbody_yaw - v._yaw;
}
if (average != 0) average /= deltas.size();
average += entity->angles().x;
if (similar(average, entity->GetLowerBodyYaw(), 20)) {
return true;
}
return false;
}
bool CResolver::can_backtrack(CBaseEntity* entity) {
float lby_update_time = last_backtrackable_tick[entity->GetIndex()]._simulation_time;
float current_time = INTERFACES::Globals->curtime;
return ((current_time - lby_update_time) <= 0.2f);
}
void CResolver::store(CBaseEntity* entity, float yaw)
{
records[entity->GetIndex()].push_front(SDK::tickrecord_t(entity, yaw));
if (entity->GetVelocity().Length2D() > 40.f && entity->GetFlags() & FL_ONGROUND) {
moving_records[entity->GetIndex()].push_front(SDK::tickrecord_t(entity, yaw));
}
if (records[entity->GetIndex()].size() > 5) records[entity->GetIndex()].pop_back();
if (moving_records[entity->GetIndex()].size() > 10) moving_records[entity->GetIndex()].pop_back();
}
bool CResolver::breaking_lby(CBaseEntity* entity) {
bool set = true;
CAnimationLayer previous;
for (int i = 0; i < 13; i++)
{
CAnimationLayer layer = entity->GetAnimOverlay(i);
if (set) {
set = false;
previous = layer;
}
if ((previous.m_flCycle != layer.m_flCycle) || layer.m_flWeight == 1.f)
{
const int activity = entity->GetSequenceActivity(layer.m_nSequence);
int _previous = entity->GetSequenceActivity(previous.m_nSequence);
if (activity == 979 && _previous == 979) return true;
}
previous = layer;
}
return false;
}
bool CResolver::moving_lby_check(CBaseEntity* entity)
{
std::list<float> yaws;
for (auto v : moving_records[entity->GetIndex()]) {
for (auto p : yaws) {
if (!similar(p, v._lowerbody_yaw, 45)) return false;
}
yaws.push_front(v._lowerbody_yaw);
}
return true;
}
float CResolver::moving_lby(CBaseEntity* entity) {
float average = 0;
for (auto v : moving_records[entity->GetIndex()]) {
average += v._lowerbody_yaw;
}
if (average != 0) average /= moving_records[entity->GetIndex()].size();
if (similar(average, entity->GetLowerBodyYaw(), 20)) return entity->GetLowerBodyYaw();
return average;
}
float CResolver::get_yaw_while_breaking(CBaseEntity* entity) {
float yaw = entity->angles_ptr()->yaw;
if (similar(yaw, entity->GetLowerBodyYaw())) yaw -= 180;
else yaw = (entity->GetLowerBodyYaw() - 180);
return yaw;
}
float CResolver::average_lby_delta_moving(CBaseEntity* entity) {
float average = 0;
for (auto v : moving_records[entity->GetIndex()]){
average += v._lowerbody_yaw - v._yaw;
}
if (average != 0) average /= moving_records[entity->GetIndex()].size();
if (similar(average + entity->angles().x, entity->GetLowerBodyYaw(), 10)) {
return entity->GetLowerBodyYaw();
}
return average + entity->angles().x;
}
float CResolver::lby_delta(CBaseEntity* entity) {
float average = 0;
for (auto v : suspected_real_lbys[entity->GetIndex()]) {
average += v;
}
if (average != 0) average /= suspected_real_lbys[entity->GetIndex()].size();
return entity->GetLowerBodyYaw() + average;
}
bool CResolver::lby_delta_found(CBaseEntity* entity) {
if (suspected_real_lbys[entity->GetIndex()].size() < 1) return false;
float average = abs(lby_delta(entity) - entity->GetLowerBodyYaw());
if (average > 20 && average <= 119) {
return true;
}
return false;
}
std::array<bool, 64> already_checked;
void CResolver::perform_delta_checks(CBaseEntity* entity, SDK::tickrecord_t _previous, SDK::tickrecord_t _current) {
float moving = moving_lby(entity);
auto real = lby_delta(entity) - entity->GetLowerBodyYaw();
if (!similar(_current._lowerbody_yaw, moving, 40)) already_checked[entity->GetIndex()] = true;
if (!similar(_current._lowerbody_yaw, moving, 20) && !similar(_previous._lowerbody_yaw, _current._lowerbody_yaw, 20) && similar(_previous._lowerbody_yaw, moving, 20))
{
if (!similar(real, moving - entity->GetLowerBodyYaw(), 20)) suspected_real_lbys[entity->GetIndex()].clear();
suspected_real_lbys[entity->GetIndex()].push_front(moving - entity->GetLowerBodyYaw());
}
else if (similar(_current._lowerbody_yaw, moving, 20) && !similar(_previous._lowerbody_yaw, moving, 20)) {
if (similar(_current._lowerbody_yaw, moving, 10)) {
if (!similar(real, _current._lowerbody_yaw - _previous._lowerbody_yaw, 20)) suspected_real_lbys[entity->GetIndex()].clear();
suspected_real_lbys[entity->GetIndex()].push_front(_current._lowerbody_yaw - _previous._lowerbody_yaw);
}
else {
if (!similar(real, moving - _previous._lowerbody_yaw, 20)) suspected_real_lbys[entity->GetIndex()].clear();
suspected_real_lbys[entity->GetIndex()].push_front(moving - _previous._lowerbody_yaw);
}
}
}
std::array<bool, 64> faking_angles = { false };
void CResolver::resolve(CBaseEntity* entity)
{
backtrack[entity->GetIndex()] = false;
unresolved[entity->GetIndex()] = false;
if (records[entity->GetIndex()].size() < 2) return;
auto _current = SDK::tickrecord_t(entity);
auto _previous = records[entity->GetIndex()].front();
if (_previous._simulation_time != _current._simulation_time) {
faking_angles[entity->GetIndex()] = ((_current._simulation_time - _previous._simulation_time) != INTERFACES::Globals->interval_per_tick);
}
using_fake_angles[entity->GetIndex()] = faking_angles[entity->GetIndex()];
if (!faking_angles[entity->GetIndex()]) return;
std::string method = "estimating";
if (_previous._lowerbody_yaw != _current._lowerbody_yaw && _current._velocity.Length2D() < 40 && _current._flags & FL_ONGROUND && _previous._velocity.Length2D() < 40 && _previous._flags & FL_ONGROUND) {
lby_update_checks(entity, _previous, _current);
if (!already_checked[entity->GetIndex()]) perform_delta_checks(entity, _previous, _current);
}
float yaw = entity->angles().y;
if (entity->GetVelocity().Length() > 40.f) already_checked[entity->GetIndex()] = false;
if (entity->GetVelocity().Length2D() > 40.f && entity->GetFlags() & FL_ONGROUND) {
tick_to_back[entity->GetIndex()] = _current._simulation_time;
last_backtrackable_tick[entity->GetIndex()] = _current;
yaw = entity->GetLowerBodyYaw();
}
else if (lby_updated(_previous, _current, entity)) {
tick_to_back[entity->GetIndex()] = _current._simulation_time;
last_backtrackable_tick[entity->GetIndex()] = _current;
backtrack[entity->GetIndex()] = true;
yaw = entity->GetLowerBodyYaw();
}
else if (!(entity->GetFlags() & FL_ONGROUND)) {
nospread_resolve(entity, entity->GetIndex());
}
else {
unresolved[entity->GetIndex()] = true;
if (can_backtrack(entity)) {
unresolved[entity->GetIndex()] = false;
yaw = entity->GetLowerBodyYaw();
backtrack[entity->GetIndex()] = true;
tick_to_back[entity->GetIndex()] = last_backtrackable_tick[entity->GetIndex()]._simulation_time;
method = "backtracking";
}
else if (breaking_lby(entity)) {
unresolved[entity->GetIndex()] = false;
yaw = get_yaw_while_breaking(entity);
method = "triggering 979";
}
else if (lby_delta_found(entity)) {
yaw = lby_delta(entity);
method = "lby delta found";
}
else if (suspected_real[entity->GetIndex()] != entity->angles().y) {
yaw = suspected_real[entity->GetIndex()];
method = "suspected real";
}
else if (moving_lby_check(entity)) {
yaw = moving_lby(entity);
method = "moving check";
}
else if (similar_moving_lby_delta(entity)) {
yaw = average_lby_delta_moving(entity);
method = "moving delta check";
}
else {
method = "lowerbody";
yaw = entity->GetLowerBodyYaw();
}
float missed = shots_fired[entity->GetIndex()] - shots_hit[entity->GetIndex()];
if (unresolved[entity->GetIndex()] && missed > 1) {
yaw += ((missed - 1) * 45);
}
}
resolver_method[entity->GetIndex()] = method;
entity->angles_ptr()->yaw = yaw;
}
CResolver* resolver = new CResolver();