• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Вопрос В чем может быть проблема с расчетом (траблы с математикой)?

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
10 Апр 2020
Сообщения
21
Реакции
1
/del
 
Последнее редактирование:
дай свой дс/тг под хайд плиз
я амеба в математике. Кто шарит, подскажите, почему под конец (15 +- патрон) на ак уводит влево, да и в целом, где я обосрался?
recoil.cpp:
Expand Collapse Copy
#include "include.h"

namespace recoil {
    const std::vector<std::vector<std::array<double, 2>>> recoil_table = {
    {
        {0.000, 0.000}
    },
    {
        {0.000000,-2.257792},{0.323242,-2.300758},{0.649593,-2.299759},{0.848786,-2.259034},
        {1.075408,-2.323947},{1.268491,-2.215956},{1.330963,-2.236556},{1.336833,-2.218203},
        {1.505516,-2.143454},{1.504423,-2.233091},{1.442116,-2.270194},{1.478543,-2.204318},
        {1.392874,-2.165817},{1.480824,-2.177887},{1.597069,-2.270915},{1.449996,-2.145893},
        {1.369179,-2.270450},{1.582363,-2.298334},{1.516872,-2.235066},{1.498249,-2.238401},
        {1.465769,-2.331642},{1.564812,-2.242621},{1.517519,-2.303052},{1.422433,-2.211946},
        {1.553195,-2.248043},{1.510463,-2.285327},{1.553878,-2.240047},{1.520380,-2.221839},
        {1.553878,-2.240047},{1.553195,-2.248043}
    },
    {
        {0.000000,-2.052616},{0.055584,-1.897695},{-0.247226,-1.863222},{-0.243871,-1.940010},
        {0.095727,-1.966751},{0.107707,-1.885520},{0.324888,-1.946722},{-0.181137,-1.880342},
        {0.162399,-1.820107},{-0.292076,-1.994940},{0.064575,-1.837156},{-0.126699,-1.887880},
        {-0.090568,-1.832799},{0.065338,-1.807480},{-0.197343,-1.705888},{-0.216561,-1.785949},
        {0.042567,-1.806371},{-0.065534,-1.757623},{0.086380,-1.904010},{-0.097326,-1.969296},
        {-0.213034,-1.850288},{-0.017790,-1.730867},{-0.045577,-1.783686},{-0.053309,-1.886260},
        {0.055072,-1.793076},{-0.091874,-1.921906},{-0.033719,-1.796160},{0.266464,-1.993952},
        {0.079090,-1.921165}
    },
    {
        {0.125361,-1.052446},{-0.099548,-0.931548},{0.027825,-0.954094},{-0.013715,-0.851504},
        {-0.007947,-1.070579},{0.096096,-1.018017},{-0.045937,-0.794216},{0.034316,-1.112618},
        {-0.003968,-0.930040},{-0.009403,-0.888503},{0.140813,-0.970807},{-0.015052,-1.046551},
        {0.095699,-0.860475},{-0.269643,-1.038896},{0.000285,-0.840478},{0.018413,-1.038126},
        {0.099191,-0.851701},{0.199659,-0.893041},{-0.082660,-1.069278},{0.006826,-0.881493},
        {0.091709,-1.150956},{-0.108677,-0.965513},{0.169612,-1.099499},{-0.038244,-1.120084},
        {-0.085513,-0.876956},{0.136279,-1.047589},{0.196392,-1.039977},{-0.152513,-1.209291},
        {-0.214510,-0.956648},{0.034276,-0.095177}
    },
    {
        {-0.114414,-0.680635},{0.008685,-0.676597},{0.010312,-0.682837},{0.064825,-0.691344},
        {0.104075,-0.655617},{-0.088118,-0.660429},{0.089906,-0.675183},{0.037071,-0.632623},
        {0.178466,-0.634737},{0.034653,-0.669444},{-0.082658,-0.664827},{0.025551,-0.636631},
        {0.082413,-0.647118},{-0.123305,-0.662104},{0.028164,-0.662354},{-0.117345,-0.693474},
        {-0.268777,-0.661122},{-0.053086,-0.677493},{0.004238,-0.647037},{0.014169,-0.551440},
        {-0.009907,-0.552079},{0.044076,-0.577694},{-0.043187,-0.549581}
    },
    {
        {-0.114413,-0.680635},{0.008686,-0.676598},{0.010312,-0.682837},{0.064825,-0.691345},
        {0.104075,-0.655618},{-0.088118,-0.660429},{0.089906,-0.675183},{0.037071,-0.632623},
        {0.178465,-0.634737},{0.034654,-0.669443},{-0.082658,-0.664826},{0.025550,-0.636631},
        {0.082414,-0.647118},{-0.123305,-0.662104},{0.028164,-0.662354},{-0.117346,-0.693475},
        {-0.268777,-0.661123},{-0.053086,-0.677493},{0.04238,-0.647038},{0.04238,-0.647038}
    }
    };

    const std::array<double, WEAPON_MAX> weapon_delays = {
        /* None */        0.0,
        /* AK-47 */        133.333333333,
        /* LR-300 */    120.0,
        /* MP5 */        100.0,
        /* Thompson */    130.0,
        /* Custom */    100.0
    };

    const std::vector<std::vector<double>> control_time = {
        { 0 },
        { {121.961516,92.633356,138.606013,113.378747,66.251547,66.295303,75.932732,85.055126,89.202546,86.680192,78.821495,70.045184,60.859441,59.516501,71.667596,86.740825,98.336474,104.341144,104.093287,97.587559,85.480627,70.488800,56.564358,47.386454,56.637950,91.593555,112.386841,111.393398,87.506773} },
        { {50.486527,63.409837,69.352231,69.019084,60.342866,50.279209,40.623896,30.626204,31.369554,40.533283,43.897277,38.230196,23.219868,9.947927,14.267603,20.268351,25.386810,29.051251,31.098685,31.469423,30.140472,27.108869,22.395387,16.088652,8.546886,27.487437,61.533720,72.697228,60.831257} },
        { {151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000,151.250000} },
        { {43.441909,58.669031,66.411108,71.385438,83.641583,79.398875,52.763157,21.615756,40.987258,52.649410,42.242421,15.073904,19.158961,29.407978,34.560589,33.587834,26.295315,12.769285,4.207833,10.980831,17.070518,21.744130,24.917849,26.570261,26.693439,25.283775,22.339392,17.859221,11.842602} },
        { {86.598887,78.347140,74.408310,73.568908,69.211680,57.652541,44.231602,43.172386,46.847870,43.832255,32.594771,25.597451,32.269315,36.054248,31.898137,20.621504,16.997289,22.046002,22.690070} },
        { {72.942129,66.636213,62.974812,61.750535,60.935042,57.200952,49.164097,38.976078,35.006739,37.638419,39.187920,36.075356,28.171659,21.234233,24.358432,28.987042,29.927871,26.070199,18.119360,13.438176,16.856357,19.274035,18.320346} },
    };

    const std::array<double, SCOPE_MAX> scope_multipliers = {
        1.0, //Silencer and muzzle brake stay the same
        0.8, //Silencer and muzzle brake stay the same
        1.2, //Silencer and muzzle brake stay the same
        3.83721, //Silencer becomes 1.0, Muzzle brake becomes 0.8
        7.65116 //Silencer becomes 1.0, Muzzle brake becomes 0.8
    };

    const std::array<std::pair<double, double>, BARREL_MAX> barrel_multipliers = {
        std::pair(1, 1),
        std::pair(0.8, 1),
    };
}

static bool Inited = false;
void recoil::Init() {

    if (Inited) {
        return;
    }

    for (int weapon_index = 1; weapon_index < WEAPON_MAX; weapon_index++)
    {
        weapon_info* weapon = &weapons[weapon_index];
        weapon->recoil_table = recoil::recoil_table[weapon_index];
        weapon->delay = weapon_delays[weapon_index];

        if (recoil::control_time.size() > weapon_index)
            weapon->control_time = control_time[weapon_index];
    }

    Inited = true;
}

bool recoil::IsHoldingLeft() noexcept {
    return GetAsyncKeyState(VK_LBUTTON) & 0x8000;
}

bool recoil::IsHoldingRight() noexcept {
    return GetAsyncKeyState(VK_RBUTTON) & 0x8000;
}

bool recoil::IsCrouching() noexcept {
    return GetAsyncKeyState(VK_CONTROL) & 0x8000;
}

bool recoil::IsValidWeapon() noexcept {
    return true;
}

bool recoil::Checks() {
    return recoil::IsHoldingLeft() && recoil::IsHoldingRight() && recoil::IsValidWeapon();
}

void recoil::Thread() noexcept {
    recoil::Init();
    while (true) {
        weapon_info current_weapon = recoil::weapons[recoil::CurrentWeapon];
        float current_scope_multiplier = recoil::scope_multipliers[recoil::CurrentScope];
        //std::pair<double, double> current_barrel_multiplier = barrel_multipliers[g_settings.barrel];
        for (int bullets_shot = 0; bullets_shot < current_weapon.recoil_table.size(); bullets_shot++)
        {
            //bool is_crouched = false;

            if (!recoil::Checks())
            {
                break;
            }
            double sens = recoil::IsCrouching() ? global::Sensitivity * 1.0 : global::Sensitivity * 0.715;
            double Fov_multiplier = (float)global::FOV / 90.0f;

            double table_x = current_weapon.recoil_table[bullets_shot][0];
            double table_y = current_weapon.recoil_table[bullets_shot][1];

            debug::AddLog("CURRENT SHOT: " + std::to_string(bullets_shot) + "| TABLE_X: " + std::to_string(table_x) + "| TABLE_Y: " + std::to_string(table_y));

            float mult = (-0.03f * (sens * sens) * 3.0f * (global::FOV / 100.0f));
            //float mult = -0.03f * (sens * 3.0f) / (global::FOV / 100.0f);

            //double scale = 1.0 / mult;
            //double recoil_x = (table_x * 1.4) * scale;
            //double recoil_x = (table_x * 1.8) * scale;
            //double recoil_y = table_y * scale;
            double scope = 1.0;
            double brake = 1.0;
         
            double recoil_x = (table_x * scope * brake) / mult;
            double recoil_y = (table_y * scope * brake) / mult;

            if (recoil::CurrentWeapon == 1){
                recoil_x += randomize::RandomFloat(-7.0, -7.5);
            }

            //humanize(recoil_x, recoil_y);

            double weapon_delay = current_weapon.delay;
            //weapon_delay *= current_barrel_multiplier.second;

            double control_time = recoil::CurrentWeapon == recoil::CurrentWeapon == WEAPON_THOMPSON || recoil::CurrentWeapon == WEAPON_CUSTOM ? weapon_delay : current_weapon.control_time.at(bullets_shot);
            debug::AddLog("X: " + std::to_string(recoil_x) + "| Y: " + std::to_string(recoil_y));
            //if (global::Humanize > 0)
            //{
                //mouse::RelativeMove(weapon_delay, control_time, recoil_x, recoil_y);
            //}
            //else
            //{
            mouse::RelativeMove(weapon_delay, weapon_delay, recoil_x, recoil_y);
            //}
        }
        SleepEx(1, false);
    }
}


Удали
// if (recoil::CurrentWeapon == 1){// recoil_x += randomize::RandomFloat(-7.0, -7.5);// }


и замени
float mult = (-0.03f * (sens * sens) * 3.0f * (global::FOV / 100.0f));

на
float mult = (-0.03f * sens * 3.0f * (global::FOV / 100.0f));
 
ты говоришь что у тебя ак уводит когда у тебя есть рандомизация для recoil_x


CurrentWeapon == 1{
recoil_x += randomize::RandomFloat(-7.0,7.5);
}
 
Последнее редактирование:
ты говоришь что у тебя ак уводит когда у тебя есть рандомизация для recoil_x


CurrentWeapon == 1{
recoil_x += randomize::RandomFloat(-7.0,7.5);
}
да не, без нее та же хуйня. С ней же - немного лучше. Уводит вправо -> положительный X, а не отрицательный
дай свой дс/тг под хайд плиз



Удали
// if (recoil::CurrentWeapon == 1){// recoil_x += randomize::RandomFloat(-7.0, -7.5);// }


и замени
float mult = (-0.03f * (sens * sens) * 3.0f * (global::FOV / 100.0f));

на
float mult = (-0.03f * sens * 3.0f * (global::FOV / 100.0f));

Пожалуйста, зарегистрируйтесь или авторизуйтесь, чтобы увидеть содержимое.

 
Назад
Сверху Снизу