diff --git a/BigBaseV2/src/services/gta_data/gta_data_service.cpp b/BigBaseV2/src/services/gta_data/gta_data_service.cpp index ba14ce11..7b5ecdde 100644 --- a/BigBaseV2/src/services/gta_data/gta_data_service.cpp +++ b/BigBaseV2/src/services/gta_data/gta_data_service.cpp @@ -3,30 +3,38 @@ #include "thread_pool.hpp" #include "gta_data_service.hpp" +#define EXIST_IN_ARRAY(arr, val) (std::find(std::begin(arr), std::end(arr), val) != std::end(arr)) + namespace big { - gta_data_service::gta_data_service() : - m_vehicle_file(g_file_manager->get_project_file("./lib/vehicles.json")), - m_vehicle_file_etag(g_file_manager->get_project_file("./lib/vehicles_etag.txt")), - m_ped_file(g_file_manager->get_project_file("./lib/peds.json")), - m_ped_file_etag(g_file_manager->get_project_file("./lib/peds_etag.txt")) + gta_data_service::gta_data_service() { + const std::string url_prefix = "http://github-proxy.damon.sh/DurtyFree/gta-v-data-dumps/master/"; + load_from_file( - m_vehicle_file, - m_vehicle_file_etag, - "http://github-proxy.damon.sh/DurtyFree/gta-v-data-dumps/master/vehicles.json", + "./lib/vehicles.json", + "./lib/vehicles_etag.txt", + url_prefix + "vehicles.json", >a_data_service::load_vehicles, "Vehicle" ); load_from_file( - m_ped_file, - m_ped_file_etag, - "http://github-proxy.damon.sh/DurtyFree/gta-v-data-dumps/master/peds.json", - >a_data_service::load_ped, + "./lib/peds.json", + "./lib/peds_etag.txt", + url_prefix + "peds.json", + >a_data_service::load_peds, "Ped" ); + load_from_file( + "./lib/weapons.json", + "./lib/weapons_etag.txt", + url_prefix + "weapons.json", + >a_data_service::load_weapons, + "Weapon" + ); + g_gta_data_service = this; } @@ -49,18 +57,16 @@ namespace big { return empty_vehicle_item; } - else - { - return m_vehicle_item_arr[idx]; - } + + return m_vehicle_item_arr[idx]; } - std::vector& gta_data_service::get_vehicle_class_arr() + const std::vector& gta_data_service::get_vehicle_class_arr() { return m_vehicle_class_arr; } - std::vector& gta_data_service::get_vehicle_arr() + const std::vector& gta_data_service::get_vehicle_arr() { return m_vehicle_item_arr; } @@ -79,33 +85,63 @@ namespace big { return empty_ped_item; } - else - { - return m_ped_item_arr[idx]; - } + + return m_ped_item_arr[idx]; } - std::vector& gta_data_service::get_ped_type_arr() + const std::vector& gta_data_service::get_ped_type_arr() { return m_ped_type_arr; } - std::vector& gta_data_service::get_ped_arr() + const std::vector& gta_data_service::get_ped_arr() { return m_ped_item_arr; } - - void gta_data_service::load_from_file(file file_to_load, file file_etag, std::string url, void(gta_data_service::* load_func)(), std::string data_name) + const weapon_item& gta_data_service::find_weapon_by_hash(Hash hash) { + int idx = -1; + + if (m_weapon_hash_idx_map.count(hash)) + { + idx = m_weapon_hash_idx_map[hash]; + } + + if (idx == -1) + { + return empty_weapon_item; + } + + return m_weapon_item_arr[idx]; + } + + const std::vector& gta_data_service::get_weapon_type_arr() + { + return m_weapon_type_arr; + } + + const std::vector& gta_data_service::get_weapon_arr() + { + return m_weapon_item_arr; + } + + + void gta_data_service::load_from_file(std::string file_path, std::string etag_path, std::string url, void(gta_data_service::* load_func)(file), std::string data_name) + { + file file_to_load(g_file_manager->get_project_file(file_path)); + if (file_to_load.exists()) { - (this->*load_func)(); + (this->*load_func)(file_to_load); LOG(INFO) << "Data loaded: " + data_name; } - g_thread_pool->push([this, file_to_load, file_etag, url, load_func, data_name]() { + g_thread_pool->push([this, file_path, etag_path, url, load_func, data_name]() { + file file_to_load(g_file_manager->get_project_file(file_path)); + file file_etag(g_file_manager->get_project_file(etag_path)); + for (int retry = 0; retry < 2; retry++) { bool ret = remote::update_binary( @@ -116,11 +152,11 @@ namespace big if (ret) { - (this->*load_func)(); + (this->*load_func)(file_to_load); LOG(INFO) << "Data updated: " + data_name; break; } - else if (!m_vehicle_file.exists()) + else if (!file_to_load.exists()) { LOG(WARNING) << "Failed to download data: " + data_name; } @@ -128,13 +164,13 @@ namespace big }); } - void gta_data_service::load_vehicles() + void gta_data_service::load_vehicles(file file_to_load) { m_vehicle_class_arr.clear(); m_vehicle_hash_idx_map.clear(); m_vehicle_item_arr.clear(); - std::ifstream file(m_vehicle_file.get_path()); + std::ifstream file(file_to_load.get_path()); nlohmann::json all_vehicles; try @@ -154,8 +190,7 @@ namespace big item_json["Name"].is_null() || !item_json["Bones"].is_array() || item_json["Bones"][0] == "stub" - ) - { + ) { continue; } @@ -175,13 +210,13 @@ namespace big } - void gta_data_service::load_ped() + void gta_data_service::load_peds(file file_to_load) { m_ped_type_arr.clear(); m_ped_hash_idx_map.clear(); m_ped_item_arr.clear(); - std::ifstream file(m_ped_file.get_path()); + std::ifstream file(file_to_load.get_path()); nlohmann::json all_peds; try @@ -198,8 +233,7 @@ namespace big if ( item_json["Hash"].is_null() || item_json["Name"].is_null() - ) - { + ) { continue; } @@ -217,4 +251,71 @@ namespace big std::sort(m_ped_type_arr.begin(), m_ped_type_arr.end()); } } + + + void gta_data_service::load_weapons(file file_to_load) + { + m_weapon_type_arr.clear(); + m_weapon_hash_idx_map.clear(); + m_weapon_item_arr.clear(); + + std::ifstream file(file_to_load.get_path()); + nlohmann::json all_weapons; + + try + { + file >> all_weapons; + } + catch (const std::exception& ex) + { + LOG(WARNING) << "Failed to load weapons.json:\n" << ex.what(); + } + + constexpr Hash hash_blacklist_arr[] = { + RAGE_JOAAT("WEAPON_BIRD_CRAP"), + RAGE_JOAAT("WEAPON_DIGISCANNER"), + RAGE_JOAAT("WEAPON_GARBAGEBAG"), + RAGE_JOAAT("WEAPON_GRENADELAUNCHER_SMOKE"), + RAGE_JOAAT("WEAPON_HANDCUFFS"), + RAGE_JOAAT("WEAPON_METALDETECTOR"), + RAGE_JOAAT("GADGET_NIGHTVISION"), + RAGE_JOAAT("GADGET_PARACHUTE"), + RAGE_JOAAT("WEAPON_TRANQUILIZER"), + RAGE_JOAAT("WEAPON_STINGER") + }; + + for (auto& item_json : all_weapons) + { + if ( + item_json["Hash"].is_null() || + item_json["Name"].is_null() || + item_json["IsVehicleWeapon"] + ) { + continue; + } + + if (EXIST_IN_ARRAY(hash_blacklist_arr, item_json["Hash"])) + { + continue; + } + + auto item = weapon_item(item_json); + + if (item.name == "Invalid" || item.name == "Unarmed" || item.weapon_type == "NULL") + { + continue; + } + + m_weapon_hash_idx_map[item_json["Hash"]] = (int)m_weapon_item_arr.size(); + + m_weapon_item_arr.push_back(item); + + if (std::find(m_weapon_type_arr.begin(), m_weapon_type_arr.end(), item.weapon_type) == m_weapon_type_arr.end()) + { + m_weapon_type_arr.push_back(item.weapon_type); + } + + std::sort(m_weapon_type_arr.begin(), m_weapon_type_arr.end()); + } + } } diff --git a/BigBaseV2/src/services/gta_data/gta_data_service.hpp b/BigBaseV2/src/services/gta_data/gta_data_service.hpp index 93ce4eab..13c208d9 100644 --- a/BigBaseV2/src/services/gta_data/gta_data_service.hpp +++ b/BigBaseV2/src/services/gta_data/gta_data_service.hpp @@ -2,17 +2,13 @@ #include "file_manager/file.hpp" #include "vehicle_item.hpp" #include "ped_item.hpp" +#include "weapon_item.hpp" +#include "gta/joaat.hpp" namespace big { class gta_data_service { - file m_vehicle_file; - file m_vehicle_file_etag; - - file m_ped_file; - file m_ped_file_etag; - std::vector m_vehicle_class_arr; std::map m_vehicle_hash_idx_map; std::vector m_vehicle_item_arr; @@ -23,23 +19,33 @@ namespace big std::vector m_ped_item_arr; const ped_item empty_ped_item = ped_item(); + std::vector m_weapon_type_arr; + std::map m_weapon_hash_idx_map; + std::vector m_weapon_item_arr; + const weapon_item empty_weapon_item = weapon_item(); + public: gta_data_service(); ~gta_data_service(); const vehicle_item& find_vehicle_by_hash(Hash hash); - std::vector& get_vehicle_class_arr(); - std::vector& get_vehicle_arr(); + const std::vector& get_vehicle_class_arr(); + const std::vector& get_vehicle_arr(); const ped_item& find_ped_by_hash(Hash hash); - std::vector& get_ped_type_arr(); - std::vector& get_ped_arr(); + const std::vector& get_ped_type_arr(); + const std::vector& get_ped_arr(); + + const weapon_item& find_weapon_by_hash(Hash hash); + const std::vector& get_weapon_type_arr(); + const std::vector& get_weapon_arr(); private: - void load_from_file(file file_to_load, file file_etag, std::string url, void(gta_data_service::* load_func)(), std::string data_name); + void load_from_file(std::string file_path, std::string etag_path, std::string url, void(gta_data_service::* load_func)(file), std::string data_name); - void load_vehicles(); - void load_ped(); + void load_vehicles(file file_to_load); + void load_peds(file file_to_load); + void load_weapons(file file_to_load); }; inline gta_data_service* g_gta_data_service{}; diff --git a/BigBaseV2/src/services/gta_data/weapon_item.cpp b/BigBaseV2/src/services/gta_data/weapon_item.cpp new file mode 100644 index 00000000..18649d6a --- /dev/null +++ b/BigBaseV2/src/services/gta_data/weapon_item.cpp @@ -0,0 +1,75 @@ +#include "weapon_item.hpp" +#include "gta/joaat.hpp" + +namespace big +{ + weapon_item::weapon_item() + { + this->name = ""; + this->throwable = false; + this->weapon_type = ""; + + this->hash = 0; + this->reward_hash = 0; + this->reward_ammo_hash = 0; + } + weapon_item::weapon_item(nlohmann::json& item_json) + { + this->name = item_json["Name"]; + this->throwable = false; + this->weapon_type = "NULL"; + + if ( + item_json.contains("TranslatedLabel") && + item_json["TranslatedLabel"].contains("English") && + !item_json["TranslatedLabel"]["English"].is_null() + ) { + this->name = item_json["TranslatedLabel"]["English"]; + } + + if (!item_json["Category"].is_null()) + { + this->weapon_type = item_json["Category"]; + } + + this->hash = item_json["Hash"]; + this->reward_hash = 0; + this->reward_ammo_hash = 0; + + const std::string reward_prefix = "REWARD_"; + bool is_gun = false; + bool is_recharge = false; + + if (item_json.contains("Flags")) + { + auto flags = item_json["Flags"]; + + for (auto& flag : flags) + { + if (flag == "Gun") + { + is_gun = true; + } + else if (flag == "DisplayRechargeTimeHUD") + { + is_recharge = true; + } + else if (flag == "Thrown") + { + this->throwable = true; + } + } + } + + if (this->weapon_type == "GROUP_MELEE" || this->weapon_type == "GROUP_UNARMED" || is_gun) + { + this->reward_hash = rage::joaat((reward_prefix + std::string(item_json["Name"])).c_str()); + + if (is_gun && !is_recharge) + { + std::string weapon_id = std::string(item_json["Name"]).substr(7); + this->reward_ammo_hash = rage::joaat((reward_prefix + "AMMO_" + weapon_id).c_str()); + } + } + } +} diff --git a/BigBaseV2/src/services/gta_data/weapon_item.hpp b/BigBaseV2/src/services/gta_data/weapon_item.hpp new file mode 100644 index 00000000..db4d9247 --- /dev/null +++ b/BigBaseV2/src/services/gta_data/weapon_item.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "file_manager/file.hpp" + +namespace big +{ + class weapon_item { + public: + weapon_item(); + weapon_item(nlohmann::json& item_json); + + std::string name; + bool throwable; + std::string weapon_type; + + Hash hash; + Hash reward_hash; + Hash reward_ammo_hash; + }; +} diff --git a/BigBaseV2/src/services/pickups/pickup_helper.hpp b/BigBaseV2/src/services/pickups/pickup_helper.hpp deleted file mode 100644 index 9aa6a664..00000000 --- a/BigBaseV2/src/services/pickups/pickup_helper.hpp +++ /dev/null @@ -1,173 +0,0 @@ -#pragma once -#include "gta\joaat.hpp" - -namespace big -{ - struct rewards - { - using pickup_map = std::map; - - inline static const pickup_map misc = { - { "ARMOUR", RAGE_JOAAT("REWARD_ARMOUR") }, - { "HEALTH", RAGE_JOAAT("REWARD_HEALTH") }, - { "HEALTH_ENTER_VEHICLE", RAGE_JOAAT("REWARD_HEALTH_ENTER_VEHICLE") }, - { "HEALTH_VARIABLE", RAGE_JOAAT("REWARD_HEALTH_VARIABLE") }, - { "MONEY_VARIABLE", RAGE_JOAAT("REWARD_MONEY_VARIABLE") }, - { "PARACHUTE", RAGE_JOAAT("REWARD_PARACHUTE") }, - { "STAT_HEALTH", RAGE_JOAAT("REWARD_STAT_HEALTH") }, - { "STAT_HEALTH_VARIABLE", RAGE_JOAAT("REWARD_STAT_HEALTH_VARIABLE") }, - { "STAT_WEAPON", RAGE_JOAAT("REWARD_STAT_WEAPON") }, - { "VEHICLE_FIX", RAGE_JOAAT("REWARD_VEHICLE_FIX") } - }; - - inline static const pickup_map ammo = - { - { "ADVANCEDRIFLE", RAGE_JOAAT("REWARD_AMMO_ADVANCEDRIFLE") }, - { "APPISTOL", RAGE_JOAAT("REWARD_AMMO_APPISTOL") }, - { "ASSAULTRIFLE", RAGE_JOAAT("REWARD_AMMO_ASSAULTRIFLE") }, - { "ASSAULTSHOTGUN", RAGE_JOAAT("REWARD_AMMO_ASSAULTSHOTGUN") }, - { "ASSAULTSMG", RAGE_JOAAT("REWARD_AMMO_ASSAULTSMG") }, - { "AUTOSHOTGUN", RAGE_JOAAT("REWARD_AMMO_AUTOSHOTGUN") }, - { "BULLET_MP", RAGE_JOAAT("REWARD_AMMO_BULLET_MP") }, - { "BULLPUPRIFLE", RAGE_JOAAT("REWARD_AMMO_BULLPUPRIFLE") }, - { "BULLPUPSHOTGUN", RAGE_JOAAT("REWARD_AMMO_BULLPUPSHOTGUN") }, - { "CARBINERIFLE", RAGE_JOAAT("REWARD_AMMO_CARBINERIFLE") }, - { "COMBATMG", RAGE_JOAAT("REWARD_AMMO_COMBATMG") }, - { "COMBATPDW", RAGE_JOAAT("REWARD_AMMO_COMBATPDW") }, - { "COMBATPISTOL", RAGE_JOAAT("REWARD_AMMO_COMBATPISTOL") }, - { "COMPACTLAUNCHER", RAGE_JOAAT("REWARD_AMMO_COMPACTLAUNCHER") }, - { "COMPACTRIFLE", RAGE_JOAAT("REWARD_AMMO_COMPACTRIFLE") }, - { "DBSHOTGUN", RAGE_JOAAT("REWARD_AMMO_DBSHOTGUN") }, - { "DOUBLEACTION", RAGE_JOAAT("REWARD_AMMO_DOUBLEACTION") }, - { "FIREWORK", RAGE_JOAAT("REWARD_AMMO_FIREWORK") }, - { "FIREWORK_MP", RAGE_JOAAT("REWARD_AMMO_FIREWORK_MP") }, - { "FLAREGUN", RAGE_JOAAT("REWARD_AMMO_FLAREGUN") }, - { "GRENADE", RAGE_JOAAT("REWARD_AMMO_GRENADE") }, - { "GRENADELAUNCHER", RAGE_JOAAT("REWARD_AMMO_GRENADELAUNCHER") }, - { "GRENADELAUNCHER_MP", RAGE_JOAAT("REWARD_AMMO_GRENADELAUNCHER_MP") }, - { "GUSENBERG", RAGE_JOAAT("REWARD_AMMO_GUSENBERG") }, - { "HEAVYPISTOL", RAGE_JOAAT("REWARD_AMMO_HEAVYPISTOL") }, - { "HEAVYSHOTGUN", RAGE_JOAAT("REWARD_AMMO_HEAVYSHOTGUN") }, - { "HEAVYSNIPER", RAGE_JOAAT("REWARD_AMMO_HEAVYSNIPER") }, - { "HOMINGLAUNCHER", RAGE_JOAAT("REWARD_AMMO_HOMINGLAUNCHER") }, - { "MACHINEPISTOL", RAGE_JOAAT("REWARD_AMMO_MACHINEPISTOL") }, - { "MARKSMANPISTOL", RAGE_JOAAT("REWARD_AMMO_MARKSMANPISTOL") }, - { "MARKSMANRIFLE", RAGE_JOAAT("REWARD_AMMO_MARKSMANRIFLE") }, - { "MG", RAGE_JOAAT("REWARD_AMMO_MG") }, - { "MICROSMG", RAGE_JOAAT("REWARD_AMMO_MICROSMG") }, - { "MINIGUN", RAGE_JOAAT("REWARD_AMMO_MINIGUN") }, - { "MINISMG", RAGE_JOAAT("REWARD_AMMO_MINISMG") }, - { "MISSILE_MP", RAGE_JOAAT("REWARD_AMMO_MISSILE_MP") }, - { "MOLOTOV", RAGE_JOAAT("REWARD_AMMO_MOLOTOV") }, - { "MUSKET", RAGE_JOAAT("REWARD_AMMO_MUSKET") }, - { "PETROLCAN", RAGE_JOAAT("REWARD_AMMO_PETROLCAN") }, - { "PIPEBOMB", RAGE_JOAAT("REWARD_AMMO_PIPEBOMB") }, - { "PISTOL", RAGE_JOAAT("REWARD_AMMO_PISTOL") }, - { "PISTOL50", RAGE_JOAAT("REWARD_AMMO_PISTOL50") }, - { "PROXMINE", RAGE_JOAAT("REWARD_AMMO_PROXMINE") }, - { "PUMPSHOTGUN", RAGE_JOAAT("REWARD_AMMO_PUMPSHOTGUN") }, - { "PUMPSHOTGUN_ENTER_VEHICLE", RAGE_JOAAT("REWARD_AMMO_PUMPSHOTGUN_ENTER_VEHICLE") }, - { "RAILGUN", RAGE_JOAAT("REWARD_AMMO_RAILGUN") }, - { "RAYPISTOL", RAGE_JOAAT("REWARD_AMMO_RAYPISTOL") }, - { "REVOLVER", RAGE_JOAAT("REWARD_AMMO_REVOLVER") }, - { "RPG", RAGE_JOAAT("REWARD_AMMO_RPG") }, - { "SAWNOFFSHOTGUN", RAGE_JOAAT("REWARD_AMMO_SAWNOFFSHOTGUN") }, - { "SMG", RAGE_JOAAT("REWARD_AMMO_SMG") }, - { "SMOKEGRENADE", RAGE_JOAAT("REWARD_AMMO_SMOKEGRENADE") }, - { "SNIPERRIFLE", RAGE_JOAAT("REWARD_AMMO_SNIPERRIFLE") }, - { "SNSPISTOL", RAGE_JOAAT("REWARD_AMMO_SNSPISTOL") }, - { "SPECIALCARBINE", RAGE_JOAAT("REWARD_AMMO_SPECIALCARBINE") }, - { "STICKYBOMB", RAGE_JOAAT("REWARD_AMMO_STICKYBOMB") }, - { "STUNGUN", RAGE_JOAAT("REWARD_AMMO_STUNGUN") }, - { "VINTAGEPISTOL", RAGE_JOAAT("REWARD_AMMO_VINTAGEPISTOL") } - }; - - inline static const pickup_map weapons = - { - { "ADVANCEDRIFLE", RAGE_JOAAT("REWARD_WEAPON_ADVANCEDRIFLE") }, - { "APPISTOL", RAGE_JOAAT("REWARD_WEAPON_APPISTOL") }, - { "ASSAULTRIFLE", RAGE_JOAAT("REWARD_WEAPON_ASSAULTRIFLE") }, - { "ASSAULTRIFLE_MK2", RAGE_JOAAT("REWARD_WEAPON_ASSAULTRIFLE_MK2") }, - { "ASSAULTSHOTGUN", RAGE_JOAAT("REWARD_WEAPON_ASSAULTSHOTGUN") }, - { "ASSAULTSMG", RAGE_JOAAT("REWARD_WEAPON_ASSAULTSMG") }, - { "AUTOSHOTGUN", RAGE_JOAAT("REWARD_WEAPON_AUTOSHOTGUN") }, - { "BAT", RAGE_JOAAT("REWARD_WEAPON_BAT") }, - { "BATTLEAXE", RAGE_JOAAT("REWARD_WEAPON_BATTLEAXE") }, - { "BOTTLE", RAGE_JOAAT("REWARD_WEAPON_BOTTLE") }, - { "BULLPUPRIFLE", RAGE_JOAAT("REWARD_WEAPON_BULLPUPRIFLE") }, - { "BULLPUPRIFLE_MK2", RAGE_JOAAT("REWARD_WEAPON_BULLPUPRIFLE_MK2") }, - { "BULLPUPSHOTGUN", RAGE_JOAAT("REWARD_WEAPON_BULLPUPSHOTGUN") }, - { "CARBINERIFLE", RAGE_JOAAT("REWARD_WEAPON_CARBINERIFLE") }, - { "CARBINERIFLE_MK2", RAGE_JOAAT("REWARD_WEAPON_CARBINERIFLE_MK2") }, - { "COMBATMG", RAGE_JOAAT("REWARD_WEAPON_COMBATMG") }, - { "COMBATMG_MK2", RAGE_JOAAT("REWARD_WEAPON_COMBATMG_MK2") }, - { "COMBATPDW", RAGE_JOAAT("REWARD_WEAPON_COMBATPDW") }, - { "COMBATPISTOL", RAGE_JOAAT("REWARD_WEAPON_COMBATPISTOL") }, - { "COMPACTLAUNCHER", RAGE_JOAAT("REWARD_WEAPON_COMPACTLAUNCHER") }, - { "COMPACTRIFLE", RAGE_JOAAT("REWARD_WEAPON_COMPACTRIFLE") }, - { "CROWBAR", RAGE_JOAAT("REWARD_WEAPON_CROWBAR") }, - { "DAGGER", RAGE_JOAAT("REWARD_WEAPON_DAGGER") }, - { "DBSHOTGUN", RAGE_JOAAT("REWARD_WEAPON_DBSHOTGUN") }, - { "DOUBLEACTION", RAGE_JOAAT("REWARD_WEAPON_DOUBLEACTION") }, - { "FIREWORK", RAGE_JOAAT("REWARD_WEAPON_FIREWORK") }, - { "FLAREGUN", RAGE_JOAAT("REWARD_WEAPON_FLAREGUN") }, - { "FLASHLIGHT", RAGE_JOAAT("REWARD_WEAPON_FLASHLIGHT") }, - { "GOLFCLUB", RAGE_JOAAT("REWARD_WEAPON_GOLFCLUB") }, - { "GRENADE", RAGE_JOAAT("REWARD_WEAPON_GRENADE") }, - { "GRENADELAUNCHER", RAGE_JOAAT("REWARD_WEAPON_GRENADELAUNCHER") }, - { "GUSENBERG", RAGE_JOAAT("REWARD_WEAPON_GUSENBERG") }, - { "HAMMER", RAGE_JOAAT("REWARD_WEAPON_HAMMER") }, - { "HATCHET", RAGE_JOAAT("REWARD_WEAPON_HATCHET") }, - { "HEAVYPISTOL", RAGE_JOAAT("REWARD_WEAPON_HEAVYPISTOL") }, - { "HEAVYSHOTGUN", RAGE_JOAAT("REWARD_WEAPON_HEAVYSHOTGUN") }, - { "HEAVYSNIPER", RAGE_JOAAT("REWARD_WEAPON_HEAVYSNIPER") }, - { "HEAVYSNIPER_MK2", RAGE_JOAAT("REWARD_WEAPON_HEAVYSNIPER_MK2") }, - { "HOMINGLAUNCHER", RAGE_JOAAT("REWARD_WEAPON_HOMINGLAUNCHER") }, - { "KNIFE", RAGE_JOAAT("REWARD_WEAPON_KNIFE") }, - { "KNUCKLE", RAGE_JOAAT("REWARD_WEAPON_KNUCKLE") }, - { "MACHETE", RAGE_JOAAT("REWARD_WEAPON_MACHETE") }, - { "MACHINEPISTOL", RAGE_JOAAT("REWARD_WEAPON_MACHINEPISTOL") }, - { "MARKSMANPISTOL", RAGE_JOAAT("REWARD_WEAPON_MARKSMANPISTOL") }, - { "MARKSMANRIFLE", RAGE_JOAAT("REWARD_WEAPON_MARKSMANRIFLE") }, - { "MARKSMANRIFLE_MK2", RAGE_JOAAT("REWARD_WEAPON_MARKSMANRIFLE_MK2") }, - { "MG", RAGE_JOAAT("REWARD_WEAPON_MG") }, - { "MICROSMG", RAGE_JOAAT("REWARD_WEAPON_MICROSMG") }, - { "MINIGUN", RAGE_JOAAT("REWARD_WEAPON_MINIGUN") }, - { "MINISMG", RAGE_JOAAT("REWARD_WEAPON_MINISMG") }, - { "MOLOTOV", RAGE_JOAAT("REWARD_WEAPON_MOLOTOV") }, - { "MUSKET", RAGE_JOAAT("REWARD_WEAPON_MUSKET") }, - { "NIGHTSTICK", RAGE_JOAAT("REWARD_WEAPON_NIGHTSTICK") }, - { "PETROLCAN", RAGE_JOAAT("REWARD_WEAPON_PETROLCAN") }, - { "PIPEBOMB", RAGE_JOAAT("REWARD_WEAPON_PIPEBOMB") }, - { "PISTOL", RAGE_JOAAT("REWARD_WEAPON_PISTOL") }, - { "PISTOL50", RAGE_JOAAT("REWARD_WEAPON_PISTOL50") }, - { "PISTOL_MK2", RAGE_JOAAT("REWARD_WEAPON_PISTOL_MK2") }, - { "POOLCUE", RAGE_JOAAT("REWARD_WEAPON_POOLCUE") }, - { "PROXMINE", RAGE_JOAAT("REWARD_WEAPON_PROXMINE") }, - { "PUMPSHOTGUN", RAGE_JOAAT("REWARD_WEAPON_PUMPSHOTGUN") }, - { "PUMPSHOTGUN_MK2", RAGE_JOAAT("REWARD_WEAPON_PUMPSHOTGUN_MK2") }, - { "RAILGUN", RAGE_JOAAT("REWARD_WEAPON_RAILGUN") }, - { "RAYCARBINE", RAGE_JOAAT("REWARD_WEAPON_RAYCARBINE") }, - { "RAYMINIGUN", RAGE_JOAAT("REWARD_WEAPON_RAYMINIGUN") }, - { "RAYPISTOL", RAGE_JOAAT("REWARD_WEAPON_RAYPISTOL") }, - { "REVOLVER", RAGE_JOAAT("REWARD_WEAPON_REVOLVER") }, - { "REVOLVER_MK2", RAGE_JOAAT("REWARD_WEAPON_REVOLVER_MK2") }, - { "RPG", RAGE_JOAAT("REWARD_WEAPON_RPG") }, - { "SAWNOFFSHOTGUN", RAGE_JOAAT("REWARD_WEAPON_SAWNOFFSHOTGUN") }, - { "SMG", RAGE_JOAAT("REWARD_WEAPON_SMG") }, - { "SMG_MK2", RAGE_JOAAT("REWARD_WEAPON_SMG_MK2") }, - { "SMOKEGRENADE", RAGE_JOAAT("REWARD_WEAPON_SMOKEGRENADE") }, - { "SNIPERRIFLE", RAGE_JOAAT("REWARD_WEAPON_SNIPERRIFLE") }, - { "SNSPISTOL", RAGE_JOAAT("REWARD_WEAPON_SNSPISTOL") }, - { "SNSPISTOL_MK2", RAGE_JOAAT("REWARD_WEAPON_SNSPISTOL_MK2") }, - { "SPECIALCARBINE", RAGE_JOAAT("REWARD_WEAPON_SPECIALCARBINE") }, - { "SPECIALCARBINE_MK2", RAGE_JOAAT("REWARD_WEAPON_SPECIALCARBINE_MK2") }, - { "STICKYBOMB", RAGE_JOAAT("REWARD_WEAPON_STICKYBOMB") }, - { "STONE_HATCHET", RAGE_JOAAT("REWARD_WEAPON_STONE_HATCHET") }, - { "STUNGUN", RAGE_JOAAT("REWARD_WEAPON_STUNGUN") }, - { "SWITCHBLADE", RAGE_JOAAT("REWARD_WEAPON_SWITCHBLADE") }, - { "VINTAGEPISTOL", RAGE_JOAAT("REWARD_WEAPON_VINTAGEPISTOL") }, - { "WRENCH", RAGE_JOAAT("REWARD_WEAPON_WRENCH") } - }; - }; -} diff --git a/BigBaseV2/src/services/pickups/pickup_service.cpp b/BigBaseV2/src/services/pickups/pickup_service.cpp index 6708e70a..10d82fbb 100644 --- a/BigBaseV2/src/services/pickups/pickup_service.cpp +++ b/BigBaseV2/src/services/pickups/pickup_service.cpp @@ -1,7 +1,7 @@ #include "pickup_service.hpp" -#include "pickup_helper.hpp" #include "pointers.hpp" #include "script.hpp" +#include "services/gta_data/gta_data_service.hpp" namespace big { @@ -37,31 +37,42 @@ namespace big void pickup_service::give_ammo(const int targets) const { - for (const auto& [_, hash] : rewards::ammo) + for (const auto& weapon : g_gta_data_service->get_weapon_arr()) { - g_pointers->m_give_pickup_rewards(targets, hash); - - script::get_current()->yield(20ms); + if (weapon.reward_ammo_hash != 0 || weapon.throwable) + { + g_pointers->m_give_pickup_rewards(targets, weapon.reward_ammo_hash); + script::get_current()->yield(20ms); + } } } void pickup_service::give_armour(const int targets) const { - g_pointers->m_give_pickup_rewards(targets, rewards::misc.at("ARMOUR")); + g_pointers->m_give_pickup_rewards(targets, RAGE_JOAAT("REWARD_ARMOUR")); + script::get_current()->yield(20ms); } void pickup_service::give_health(const int targets) const { - g_pointers->m_give_pickup_rewards(targets, rewards::misc.at("HEALTH")); + g_pointers->m_give_pickup_rewards(targets, RAGE_JOAAT("REWARD_HEALTH")); + script::get_current()->yield(20ms); + g_pointers->m_give_pickup_rewards(targets, RAGE_JOAAT("REWARD_HEALTH")); + script::get_current()->yield(20ms); } void pickup_service::give_weapons(const int targets) const { - for (const auto& [_, hash] : rewards::weapons) + for (const auto& weapon : g_gta_data_service->get_weapon_arr()) { - g_pointers->m_give_pickup_rewards(targets, hash); - - script::get_current()->yield(20ms); + if (weapon.reward_hash != 0) + { + g_pointers->m_give_pickup_rewards(targets, weapon.reward_hash); + script::get_current()->yield(20ms); + } } + + g_pointers->m_give_pickup_rewards(targets, RAGE_JOAAT("REWARD_PARACHUTE")); + script::get_current()->yield(20ms); } } diff --git a/BigBaseV2/src/views/self/view_weapons.cpp b/BigBaseV2/src/views/self/view_weapons.cpp index 95c774d4..80ef8b35 100644 --- a/BigBaseV2/src/views/self/view_weapons.cpp +++ b/BigBaseV2/src/views/self/view_weapons.cpp @@ -1,9 +1,10 @@ #include "core/data/custom_weapons.hpp" #include "fiber_pool.hpp" #include "natives.hpp" -#include "gta/Weapons.h" #include "core/data/special_ammo_types.hpp" #include "core/data/bullet_impact_types.hpp" +#include "services/gta_data/gta_data_service.hpp" +#include "gta/joaat.hpp" #include "views/view.hpp" namespace big @@ -26,10 +27,14 @@ namespace big for (const auto& special_ammo : SPECIAL_AMMOS) { if (ImGui::Selectable(special_ammo.name, special_ammo.type == selected_ammo)) + { g->weapons.ammo_special.type = special_ammo.type; + } if (special_ammo.type == selected_ammo) + { ImGui::SetItemDefaultFocus(); + } } ImGui::EndCombo(); @@ -40,10 +45,14 @@ namespace big for (const auto& [type, name] : BULLET_IMPACTS) { if (ImGui::Selectable(name, type == selected_impact)) + { g->weapons.ammo_special.impactType = type; + } if (type == selected_impact) + { ImGui::SetItemDefaultFocus(); + } } ImGui::EndCombo(); @@ -64,16 +73,20 @@ namespace big ImGui::Checkbox("No Spread", &g->weapons.no_spread); components::button("Get All Weapons", [] { - for (auto const& weapon : weapon_list) { - WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, weapon, 9999, false); + for (auto const& weapon : g_gta_data_service->get_weapon_arr()) + { + WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, weapon.hash, 9999, false); } - WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, -72657034, 0, true); + + constexpr auto parachute_hash = RAGE_JOAAT("GADGET_PARACHUTE"); + WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, parachute_hash, 0, true); }); ImGui::SameLine(); components::button("Remove Current Weapon", [] { Hash weaponHash; WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weaponHash, 1); - if (weaponHash != RAGE_JOAAT("WEAPON_UNARMED")) { + if (weaponHash != RAGE_JOAAT("WEAPON_UNARMED")) + { WEAPON::REMOVE_WEAPON_FROM_PED(self::ped, weaponHash); } }); @@ -96,7 +109,9 @@ namespace big } if (weapon.id == selected) + { ImGui::SetItemDefaultFocus(); + } } ImGui::EndCombo(); @@ -108,7 +123,8 @@ namespace big components::input_text_with_hint( "Shooting Model", "Name of the vehicle model", - g->weapons.vehicle_gun_model, sizeof(g->weapons.vehicle_gun_model)); + g->weapons.vehicle_gun_model, sizeof(g->weapons.vehicle_gun_model) + ); break; }