mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-17 14:57:27 +08:00
Add world model spawning (#451)
This commit is contained in:
parent
3327be9772
commit
96cbfe3b70
@ -92,8 +92,14 @@ namespace big
|
||||
m_model_spawn_bypass = ptr.add(8).as<PVOID>();
|
||||
});
|
||||
|
||||
// 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<PVOID>();
|
||||
});
|
||||
|
||||
// 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<decltype(m_read_bitbuf_array)>();
|
||||
});
|
||||
|
@ -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{};
|
||||
|
@ -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<model_attachment>();
|
||||
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<nlohmann::json> vehicle_attachments = vehicle_json[vehicle_attachments_key];
|
||||
|
40
BigBaseV2/src/util/world_model.hpp
Normal file
40
BigBaseV2/src/util/world_model.hpp
Normal file
@ -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<byte, patch_size> 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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user