diff --git a/BigBaseV2/src/pointers.cpp b/BigBaseV2/src/pointers.cpp index 660c55f0..d10d51fb 100644 --- a/BigBaseV2/src/pointers.cpp +++ b/BigBaseV2/src/pointers.cpp @@ -92,8 +92,14 @@ namespace big m_model_spawn_bypass = ptr.add(8).as(); }); + // World Model Spawn Bypass + main_batch.add("WMSB", "48 85 C0 0F 84 ? ? ? ? 8B 48 50", [this](memory::handle ptr) + { + m_world_model_spawn_bypass = ptr.as(); + }); + // New pointers - + // Native Return Spoofer main_batch.add("NRF", "FF E3", [this](memory::handle ptr) { @@ -119,7 +125,7 @@ namespace big }); // Received Event Signatures START - + // Received Event Hook main_batch.add("REH", "66 41 83 F9 ? 0F 83", [this](memory::handle ptr) { @@ -159,7 +165,7 @@ namespace big }); // Read Bitbuffer Array - main_batch.add("RBA", "48 89 5C 24 ? 57 48 83 EC 30 41 8B F8 4C", [this](memory::handle ptr) + main_batch.add("RBA", "48 89 5C 24 ? 57 48 83 EC 30 41 8B F8 4C", [this](memory::handle ptr) { m_read_bitbuf_array = ptr.as(); }); diff --git a/BigBaseV2/src/pointers.hpp b/BigBaseV2/src/pointers.hpp index 63183648..edcce5dc 100644 --- a/BigBaseV2/src/pointers.hpp +++ b/BigBaseV2/src/pointers.hpp @@ -45,6 +45,7 @@ namespace big PVOID m_blame_explode; PVOID m_model_spawn_bypass; + PVOID m_world_model_spawn_bypass; PVOID m_native_return; PVOID m_network_group_override; PUSHORT m_spectator_check; @@ -65,7 +66,7 @@ namespace big functions::get_gameplay_cam_coords m_get_gameplay_cam_coords; functions::give_pickup_rewards m_give_pickup_rewards{}; - + functions::trigger_script_event m_trigger_script_event{}; // Bitbuffer Read/Write START @@ -80,7 +81,7 @@ namespace big functions::write_bitbuf_bool m_write_bitbuf_bool{}; functions::write_bitbuf_array m_write_bitbuf_array{}; // Bitbuffer Read/Write END - + // Received Event Signatures START PVOID m_received_event{}; functions::send_event_ack m_send_event_ack{}; diff --git a/BigBaseV2/src/services/vehicle/persist_car_service.cpp b/BigBaseV2/src/services/vehicle/persist_car_service.cpp index 202b9b55..ef4a2b7e 100644 --- a/BigBaseV2/src/services/vehicle/persist_car_service.cpp +++ b/BigBaseV2/src/services/vehicle/persist_car_service.cpp @@ -1,5 +1,6 @@ #include "persist_car_service.hpp" #include "util/vehicle.hpp" +#include "util/world_model.hpp" #include "pointers.hpp" @@ -96,15 +97,16 @@ namespace big for (const auto& j : model_attachments) { const auto attachment = j.get(); - STREAMING::REQUEST_MODEL(attachment.model_hash); - const auto object = OBJECT::CREATE_OBJECT(attachment.model_hash, 0, 0, 0, true, false, false); - ENTITY::ATTACH_ENTITY_TO_ENTITY( - object, vehicle, - 0, - attachment.position.x, attachment.position.y, attachment.position.z, - attachment.rotation.x, attachment.rotation.y, attachment.rotation.z, - false, false, false, false, 0, true); - STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(attachment.model_hash); + const auto object = big::world_model::spawn(attachment.model_hash); + if (object) + { + ENTITY::ATTACH_ENTITY_TO_ENTITY( + object, vehicle, + 0, + attachment.position.x, attachment.position.y, attachment.position.z, + attachment.rotation.x, attachment.rotation.y, attachment.rotation.z, + false, false, false, false, 0, true); + } } std::vector vehicle_attachments = vehicle_json[vehicle_attachments_key]; diff --git a/BigBaseV2/src/util/world_model.hpp b/BigBaseV2/src/util/world_model.hpp new file mode 100644 index 00000000..69d081b9 --- /dev/null +++ b/BigBaseV2/src/util/world_model.hpp @@ -0,0 +1,40 @@ +#pragma once +#include "natives.hpp" +#include "script.hpp" +#include "pointers.hpp" + +namespace big::world_model +{ + constexpr size_t patch_size = 24; + static inline std::once_flag once_flag; + static inline std::array backup; + static inline void setup_backup() + { + memcpy(backup.data(), g_pointers->m_world_model_spawn_bypass, patch_size); + } + + inline Object spawn(Hash hash, Vector3 location = Vector3(), bool is_networked = true) + { + STREAMING::REQUEST_MODEL(hash); + for (int i = 0; i < 100 && !STREAMING::HAS_MODEL_LOADED(hash); i++) + { + script::get_current()->yield(); + } + if (!STREAMING::HAS_MODEL_LOADED(hash)) + { + LOG(WARNING) << "Failed to load model " << HEX_TO_UPPER(hash); + return 0; + } + + std::call_once(once_flag, setup_backup); + memset(g_pointers->m_world_model_spawn_bypass, 0x90, patch_size); + + const auto object = OBJECT::CREATE_OBJECT(hash, location.x, location.y, location.z, is_networked, false, false); + + memcpy(g_pointers->m_world_model_spawn_bypass, backup.data(), patch_size); + + STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash); + + return object; + } +}